From 9e05f745a5c5634b82242596ab4753e5058dff4c Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Fri, 2 May 2025 09:34:12 -0400 Subject: [PATCH] MCPConnection: avoid accidentally mutating options.transport.env The code that added the PATH to the stdio transport environment was mutating the original options.transport.env object, which can lead to an infinite loop of reloading the continue config since MCPMananagerSingletone.setConnections() compares the old and new options and forces a refresh if any existing server changed transport options. This triggers a config reload because in core.ts we have: MCPManagerSingleton.getInstance().onConnectionsRefreshed = async () => { await this.configHandler.reloadConfig(); }; Which thens calls setConnections() and so forth... --- core/context/mcp/MCPConnection.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/context/mcp/MCPConnection.ts b/core/context/mcp/MCPConnection.ts index 489d53ccf..6db095de4 100644 --- a/core/context/mcp/MCPConnection.ts +++ b/core/context/mcp/MCPConnection.ts @@ -55,7 +55,9 @@ class MCPConnection { private constructTransport(options: MCPOptions): Transport { switch (options.transport.type) { case "stdio": - const env: Record = options.transport.env || {}; + const env: Record = options.transport.env + ? { ...options.transport.env } + : {}; if (process.env.PATH !== undefined) { env.PATH = process.env.PATH; }