فهرست منبع

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.
MuriloFP 11 ماه پیش
والد
کامیت
ef95562dfe
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      src/core/webview/ClineProvider.ts

+ 10 - 0
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() ?? [],
 		}
 	}