Add support for allowed/excluded MCP server names in settings (#4135)

Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
christine betts
2025-07-15 20:45:24 +00:00
committed by GitHub
parent 03b3917f62
commit 58f1aa6ceb
5 changed files with 97 additions and 0 deletions

View File

@@ -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) {