From ef95562dfe5166b2c66c5c55a4fe264e12e57ffd Mon Sep 17 00:00:00 2001 From: MuriloFP Date: Fri, 7 Feb 2025 16:57:21 -0300 Subject: [PATCH] fix: ensure MCP server list appears in settings when server starts first When the MCP server was initialized before opening RooCode, the server list would not appear in the settings. This was fixed by: 1. Adding proper server list initialization in ClineProvider.ts when the webview launches, checking if mcpHub exists and sending its current servers to the webview: ```typescript if (this.mcpHub) { this.postMessageToWebview({ type: "mcpServers", mcpServers: this.mcpHub.getServers() }) } ``` 2. Using the public getServers() method from McpHub instead of relying on internal state updates, ensuring consistent server list state across the application. The fix maintains clean separation of concerns and follows existing patterns for state management between the extension and webview. --- src/core/webview/ClineProvider.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/webview/ClineProvider.ts b/src/core/webview/ClineProvider.ts index 7b4d4b2047..23346d945c 100644 --- a/src/core/webview/ClineProvider.ts +++ b/src/core/webview/ClineProvider.ts @@ -613,6 +613,15 @@ export class ClineProvider implements vscode.WebviewViewProvider { this.postMessageToWebview({ type: "openRouterModels", openRouterModels }) } }) + + // If MCP Hub is already initialized, update the webview with current server list + if (this.mcpHub) { + this.postMessageToWebview({ + type: "mcpServers", + mcpServers: this.mcpHub.getServers(), + }) + } + // gui relies on model info to be up-to-date to provide the most accurate pricing, so we need to fetch the latest details on launch. // we do this for all users since many users switch between api providers and if they were to switch back to openrouter it would be showing outdated model info if we hadn't retrieved the latest at this point // (see normalizeApiConfiguration > openrouter) @@ -2115,6 +2124,7 @@ export class ClineProvider implements vscode.WebviewViewProvider { autoApprovalEnabled: autoApprovalEnabled ?? false, customModes: await this.customModesManager.getCustomModes(), experiments: experiments ?? experimentDefault, + mcpServers: this.mcpHub?.getServers() ?? [], } }