From 58f1aa6ceb53df94cc5bba77dc787950be340cb9 Mon Sep 17 00:00:00 2001 From: christine betts Date: Tue, 15 Jul 2025 20:45:24 +0000 Subject: Add support for allowed/excluded MCP server names in settings (#4135) Co-authored-by: Scott Densmore --- packages/cli/src/config/config.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'packages/cli/src/config/config.ts') diff --git a/packages/cli/src/config/config.ts b/packages/cli/src/config/config.ts index d116bc67..bf76fa4c 100644 --- a/packages/cli/src/config/config.ts +++ b/packages/cli/src/config/config.ts @@ -274,6 +274,26 @@ export async function loadCliConfig( let mcpServers = mergeMcpServers(settings, activeExtensions); const excludeTools = mergeExcludeTools(settings, activeExtensions); + if (!argv.allowedMcpServerNames) { + if (settings.allowMCPServers) { + const allowedNames = new Set(settings.allowMCPServers.filter(Boolean)); + if (allowedNames.size > 0) { + mcpServers = Object.fromEntries( + Object.entries(mcpServers).filter(([key]) => allowedNames.has(key)), + ); + } + } + + if (settings.excludeMCPServers) { + const excludedNames = new Set(settings.excludeMCPServers.filter(Boolean)); + if (excludedNames.size > 0) { + mcpServers = Object.fromEntries( + Object.entries(mcpServers).filter(([key]) => !excludedNames.has(key)), + ); + } + } + } + if (argv.allowedMcpServerNames) { const allowedNames = new Set(argv.allowedMcpServerNames.filter(Boolean)); if (allowedNames.size > 0) { -- cgit v1.2.3