MCPcopy
hub / github.com/continuedev/continue / createServerForOAuth

Function createServerForOAuth

core/context/mcp/MCPOauth.ts:33–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

31let serverInstance: http.Server | null = null;
32
33const createServerForOAuth = () =>
34 http.createServer((req, res) => {
35 try {
36 if (!req.url) {
37 throw new Error("no url found");
38 }
39
40 const parsedUrl = url.parse(req.url, true);
41 if (!parsedUrl.query["code"]) {
42 throw new Error("no query params found");
43 }
44
45 const code = parsedUrl.query["code"] as string;
46 const state = parsedUrl.query["state"] as string | undefined;
47
48 void handleMCPOauthCode(code, state);
49
50 const html = `
51<!DOCTYPE html>
52<html>
53<head><title>Authentication Complete</title></head>
54<body>Authentication Complete. You can close this page now.</body>
55</html>`;
56
57 res.writeHead(200, {
58 "Content-Type": "text/html",
59 });
60 res.end(html);
61 } catch (error) {
62 res.writeHead(400, { "Content-Type": "text/plain" });
63 res.end(`Unexpected redirect error: ${(error as Error).message}`);
64 }
65 });
66
67type MCPOauthStorage = GlobalContextType["mcpOauthStorage"][string];
68type MCPOauthStorageKey = keyof MCPOauthStorage;

Callers 1

Calls 1

handleMCPOauthCodeFunction · 0.85

Tested by

no test coverage detected