From e00a43901fa2b4fd7d582e1de57277be88233007 Mon Sep 17 00:00:00 2001 From: czp Date: Fri, 27 Mar 2026 19:24:47 +0800 Subject: [PATCH] fix: Add explicit type checks for MCP servers (http/sse) (#487) As mentioned in https://github.com/agentclientprotocol/claude-agent-acp/issues/468#issuecomment-4141841845 IDEA always explicitly passes the MCP server type; for example, even if the type is `stdio`, IDEA will still pass `type: 'stdio'`. This causes the following code to enter the http or sse branch due to the presence of the 'type' field Image As part of defensive programming, change this line to a more robust check: `if ("type" in server && (server.type === "http" || server.type === "sse"))` --- src/acp-agent.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/acp-agent.ts b/src/acp-agent.ts index b32f0362..abcfa358 100644 --- a/src/acp-agent.ts +++ b/src/acp-agent.ts @@ -1256,7 +1256,8 @@ export class ClaudeAcpAgent implements Agent { const mcpServers: Record = {}; if (Array.isArray(params.mcpServers)) { for (const server of params.mcpServers) { - if ("type" in server) { + if ("type" in server && (server.type === "http" || server.type === "sse")) { + // HTTP or SSE type MCP server mcpServers[server.name] = { type: server.type, url: server.url, @@ -1265,6 +1266,7 @@ export class ClaudeAcpAgent implements Agent { : undefined, }; } else { + // Stdio type MCP server (with or without explicit type field) mcpServers[server.name] = { type: "stdio", command: server.command,