From 355fb4ac676820ebcca76c985284798dc40ed653 Mon Sep 17 00:00:00 2001 From: Jordan Demeulenaere Date: Mon, 7 Jul 2025 18:34:26 +0200 Subject: Add excludeTools and includeTools to mcpServers config (#2976) --- packages/core/src/tools/mcp-client.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'packages/core/src/tools/mcp-client.ts') diff --git a/packages/core/src/tools/mcp-client.ts b/packages/core/src/tools/mcp-client.ts index bb92ab05..6dca8cea 100644 --- a/packages/core/src/tools/mcp-client.ts +++ b/packages/core/src/tools/mcp-client.ts @@ -305,6 +305,26 @@ async function connectAndDiscover( continue; } + const { includeTools, excludeTools } = mcpServerConfig; + const toolName = funcDecl.name; + + let isEnabled = false; + if (includeTools === undefined) { + isEnabled = true; + } else { + isEnabled = includeTools.some( + (tool) => tool === toolName || tool.startsWith(`${toolName}(`), + ); + } + + if (excludeTools?.includes(toolName)) { + isEnabled = false; + } + + if (!isEnabled) { + continue; + } + let toolNameForModel = funcDecl.name; // Replace invalid characters (based on 400 error message from Gemini API) with underscores -- cgit v1.2.3