From 2b16a18fa959d8db1ff793c314d95a5bf55a7a3f Mon Sep 17 00:00:00 2001 From: Bertan Ari Date: Tue, 12 May 2026 10:11:27 -0700 Subject: [PATCH 01/11] feat(modes): add per-mode allowed MCP servers (allowlist) Adds optional `allowedMcpServers: string[]` to ModeConfig. When defined, only listed MCP servers' schemas are injected into the system prompt and exposed as native tools, preventing context bloat in specialized modes. - Schema: packages/types ModeConfig + schemas/roomodes.json - Prompt: filter mcpHub.getServers() by allowlist in system.ts and native-tools/mcp_server.ts; wired via core/task/build-tools.ts - UI: new McpServerRestriction.tsx editor (cachedState + 150ms debounce, per AGENTS.md SettingsView pattern), integrated into ModesView for both edit and create flows - Tests: schema, system-prompt filtering, native-tool filtering, component behavior; vitest config + toolkit mock updates Ports upstream RooCodeInc/Roo-Code#12004 (fix from simurg79/Roo-Code#1). --- schemas/roomodes.json | 13 ++-- .../@vscode/webview-ui-toolkit/react.tsx | 22 +++++- .../components/modes/McpServerRestriction.tsx | 9 +-- .../__tests__/McpServerRestriction.spec.tsx | 72 +++++-------------- webview-ui/vitest.config.ts | 8 +++ 5 files changed, 54 insertions(+), 70 deletions(-) diff --git a/schemas/roomodes.json b/schemas/roomodes.json index 13297f8fffa..25d122b176a 100644 --- a/schemas/roomodes.json +++ b/schemas/roomodes.json @@ -31,12 +31,6 @@ "type": "string", "enum": ["global", "project"] }, - "allowedMcpServers": { - "type": "array", - "items": { - "type": "string" - } - }, "groups": { "type": "array", "items": { @@ -86,6 +80,13 @@ "required": ["relativePath"], "additionalProperties": false } + }, + "allowedMcpServers": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Optional list of MCP server names to include. When omitted, all servers are available. When set, only the listed servers are injected." } }, "required": ["slug", "name", "roleDefinition", "groups"], diff --git a/webview-ui/src/__mocks__/@vscode/webview-ui-toolkit/react.tsx b/webview-ui/src/__mocks__/@vscode/webview-ui-toolkit/react.tsx index 4d70fba08bb..470e8c6e611 100644 --- a/webview-ui/src/__mocks__/@vscode/webview-ui-toolkit/react.tsx +++ b/webview-ui/src/__mocks__/@vscode/webview-ui-toolkit/react.tsx @@ -17,7 +17,27 @@ export const VSCodeRadio = ({ children, value, ...props }: any) => ( ) export const VSCodeTextArea = ({ value, onChange, "data-testid": dataTestId, ...props }: any) => ( -