[ide-mode] Create an IDE manager class to handle connecting to and exposing methods from the IDE server (#4797)

This commit is contained in:
christine betts
2025-07-25 17:46:55 +00:00
committed by GitHub
parent 3c16429fc4
commit 1b8ba5ca6b
14 changed files with 178 additions and 256 deletions

View File

@@ -24,11 +24,6 @@ import { ToolRegistry } from './tool-registry.js';
import { MCPOAuthProvider } from '../mcp/oauth-provider.js';
import { OAuthUtils } from '../mcp/oauth-utils.js';
import { MCPOAuthTokenStorage } from '../mcp/oauth-token-storage.js';
import {
OpenFilesNotificationSchema,
IDE_SERVER_NAME,
ideContext,
} from '../services/ideContext.js';
import { getErrorMessage } from '../utils/errors.js';
export const MCP_DEFAULT_TIMEOUT_MSEC = 10 * 60 * 1000; // default to 10 minutes
@@ -379,24 +374,11 @@ export async function connectAndDiscover(
);
try {
updateMCPServerStatus(mcpServerName, MCPServerStatus.CONNECTED);
mcpClient.onerror = (error) => {
console.error(`MCP ERROR (${mcpServerName}):`, error.toString());
updateMCPServerStatus(mcpServerName, MCPServerStatus.DISCONNECTED);
if (mcpServerName === IDE_SERVER_NAME) {
ideContext.clearOpenFilesContext();
}
};
if (mcpServerName === IDE_SERVER_NAME) {
mcpClient.setNotificationHandler(
OpenFilesNotificationSchema,
(notification) => {
ideContext.setOpenFilesContext(notification.params);
},
);
}
const tools = await discoverTools(
mcpServerName,
mcpServerConfig,