From 8fae227e8d53b962f8b7db3abff51906fad1d181 Mon Sep 17 00:00:00 2001 From: Harold Mciver Date: Wed, 13 Aug 2025 19:31:24 +0000 Subject: fix: Prevent duplicate or inactive tools/prompts after server refresh (#5850) --- packages/core/src/tools/tool-registry.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'packages/core/src/tools') diff --git a/packages/core/src/tools/tool-registry.ts b/packages/core/src/tools/tool-registry.ts index 02f77727..b3625285 100644 --- a/packages/core/src/tools/tool-registry.ts +++ b/packages/core/src/tools/tool-registry.ts @@ -158,6 +158,18 @@ export class ToolRegistry { } } + /** + * Removes all tools from a specific MCP server. + * @param serverName The name of the server to remove tools from. + */ + removeMcpToolsByServer(serverName: string): void { + for (const [name, tool] of this.tools.entries()) { + if (tool instanceof DiscoveredMCPTool && tool.serverName === serverName) { + this.tools.delete(name); + } + } + } + /** * Discovers tools from project (if available and configured). * Can be called multiple times to update discovered tools. -- cgit v1.2.3