From 583c86b1ecc577011a7b6f8b9288e6e10240aabf Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 22 Jul 2025 23:05:08 +0000 Subject: [PATCH] fix: prevent disabled MCP servers from starting processes and show correct status - Added disabled state checks in updateServerConnections() to prevent disabled servers from being connected - Updated frontend getStatusColor() to show grey for disabled servers - Modified UI rendering to show minimal interface for disabled servers without error messages or retry buttons - Added translation for disabled server status Fixes #6036 --- src/services/mcp/McpHub.ts | 10 +++++++-- webview-ui/src/components/mcp/McpView.tsx | 27 +++++++++++++++++++---- webview-ui/src/i18n/locales/en/mcp.json | 3 ++- 3 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 10a74712ef..fda834247e 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -976,7 +976,10 @@ export class McpHub { // New server try { this.setupFileWatcher(name, validatedConfig, source) - await this.connectToServer(name, validatedConfig, source) + if (!validatedConfig.disabled) { + // Only connect if not disabled + await this.connectToServer(name, validatedConfig, source) + } } catch (error) { this.showErrorMessage(`Failed to connect to new MCP server ${name}`, error) } @@ -985,7 +988,10 @@ export class McpHub { try { this.setupFileWatcher(name, validatedConfig, source) await this.deleteConnection(name, source) - await this.connectToServer(name, validatedConfig, source) + if (!validatedConfig.disabled) { + // Only reconnect if not disabled + await this.connectToServer(name, validatedConfig, source) + } } catch (error) { this.showErrorMessage(`Failed to reconnect MCP server ${name}`, error) } diff --git a/webview-ui/src/components/mcp/McpView.tsx b/webview-ui/src/components/mcp/McpView.tsx index 0873bde195..a005e40c85 100644 --- a/webview-ui/src/components/mcp/McpView.tsx +++ b/webview-ui/src/components/mcp/McpView.tsx @@ -218,6 +218,11 @@ const ServerRow = ({ server, alwaysAllowMcp }: { server: McpServer; alwaysAllowM ] const getStatusColor = () => { + // Always show grey for disabled servers regardless of connection status + if (server.disabled) { + return "var(--vscode-descriptionForeground)" + } + switch (server.status) { case "connected": return "var(--vscode-testing-iconPassed)" @@ -229,7 +234,8 @@ const ServerRow = ({ server, alwaysAllowMcp }: { server: McpServer; alwaysAllowM } const handleRowClick = () => { - if (server.status === "connected") { + // Only allow expansion for connected servers that are not disabled + if (server.status === "connected" && !server.disabled) { setIsExpanded(!isExpanded) } } @@ -270,12 +276,12 @@ const ServerRow = ({ server, alwaysAllowMcp }: { server: McpServer; alwaysAllowM alignItems: "center", padding: "8px", background: "var(--vscode-textCodeBlock-background)", - cursor: server.status === "connected" ? "pointer" : "default", + cursor: server.status === "connected" && !server.disabled ? "pointer" : "default", borderRadius: isExpanded || server.status === "connected" ? "4px" : "4px 4px 0 0", opacity: server.disabled ? 0.6 : 1, }} onClick={handleRowClick}> - {server.status === "connected" && ( + {server.status === "connected" && !server.disabled && ( - {server.status === "connected" ? ( + {server.disabled ? ( + // Minimal UI for disabled servers - no error messages or retry buttons +
+ {t("mcp:serverStatus.disabled")} +
+ ) : server.status === "connected" ? ( isExpanded && (