Skip to content

Commit bdd781d

Browse files
fix(server): ACP terminal MCP calls answer interleaved server requests
mcpToolSession collected a whole response stream and kept only its own reply, so a server request on that stream (such as a ping) went unanswered. It now replies to each server request as it arrives: an empty result for ping, method-not-found for anything else. Fixes #35794 Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 6da43f4 commit bdd781d

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

‎apps/server/src/mcp/AcpMcpStdioBridge.ts‎

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ function protocolVersionOf(entry: unknown): string | null {
5858
return typeof version === "string" && version.length > 0 ? version : null;
5959
}
6060

61+
function replyToServerRequest(envelope: JsonRpcEnvelope): unknown {
62+
return envelope.method === "ping"
63+
? { jsonrpc: "2.0", id: envelope.id, result: {} }
64+
: { jsonrpc: "2.0", id: envelope.id, error: { code: -32601, message: "Method not found" } };
65+
}
66+
6167
export interface McpToolSessionOptions {
6268
readonly endpoint: string;
6369
readonly authorization: string;
@@ -112,10 +118,16 @@ export const mcpToolSession = (
112118
message: `T3 Code MCP endpoint responded with HTTP ${response.status}.`,
113119
});
114120
}
115-
const payloads = yield* Stream.runCollect(responsePayloads(response, bridgeError));
116-
for (const payload of payloads) {
121+
const payloads: Array<unknown> = [];
122+
yield* Stream.runForEach(responsePayloads(response, bridgeError), (payload) => {
117123
protocolVersion = protocolVersionOf(payload) ?? protocolVersion;
118-
}
124+
const envelope = asEnvelope(payload);
125+
if (envelope?.id !== undefined && typeof envelope.method === "string") {
126+
return send(replyToServerRequest(envelope)).pipe(Effect.asVoid);
127+
}
128+
payloads.push(payload);
129+
return Effect.void;
130+
});
119131
return payloads;
120132
});
121133

0 commit comments

Comments
 (0)