start and stop during mcp server oauth process

This commit is contained in:
uinstinct 2025-07-29 13:02:00 +05:30
parent c401c2cda4
commit bc3089ad6c
2 changed files with 6 additions and 10 deletions

View file

@ -51,13 +51,6 @@ const server = http.createServer((req, res) => {
}
});
// TODO: start the server only when mcp oauth process starts and kill when done
server.listen(PORT, () => {
console.log(
`Server running for MCP Oauth process at http://localhost:${PORT}/`,
);
});
type MCPOauthStorage = GlobalContextType["mcpOauthStorage"][string];
type MCPOauthStorageKey = keyof MCPOauthStorage;
@ -166,6 +159,11 @@ class MCPConnectionOauthProvider implements OAuthClientProvider {
}
async redirectToAuthorization(authorizationUrl: URL) {
server.listen(PORT, () => {
console.debug(
`Server started for MCP Oauth process at http://localhost:${PORT}/`,
);
});
this.ide.openUrl(authorizationUrl.toString());
}
}
@ -210,7 +208,7 @@ export async function handleMCPOauthCode(authorizationCode: string) {
ide.showToast("error", `No MCP authorization code found for ${serverUrl}`);
return;
}
server.close(() => console.debug("Server for MCP Oauth process was closed"));
const authProvider = new MCPConnectionOauthProvider(serverUrl, ide);
const authStatus = await auth(authProvider, {
serverUrl,

View file

@ -232,8 +232,6 @@ function MCPSection() {
}));
}, [servers, selectedProfile]);
console.log("debug1 servers->", servers);
return (
<div className="flex flex-col gap-1">
<div className="flex max-h-[170px] flex-col gap-1 overflow-y-auto overflow-x-hidden pr-2">