From 3dbe77c4da86845d91238c2427fb86bff08ee570 Mon Sep 17 00:00:00 2001 From: Todd <2976910352@qq.com> Date: Tue, 23 Jun 2026 12:42:07 +0800 Subject: [PATCH] chore: remove no-op protocol-version negotiation in MCP initialize --- workers/mcp-services/src/mcp.ts | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/workers/mcp-services/src/mcp.ts b/workers/mcp-services/src/mcp.ts index e9fe24d3..5fc67708 100644 --- a/workers/mcp-services/src/mcp.ts +++ b/workers/mcp-services/src/mcp.ts @@ -207,10 +207,7 @@ async function handleMessage( switch (request.method) { case "initialize": - return jsonRpcResult( - request.id ?? null, - initializeResult(request.params), - ); + return jsonRpcResult(request.id ?? null, initializeResult()); case "notifications/initialized": return undefined; case "ping": @@ -727,21 +724,12 @@ function isRecord(value: unknown): value is JsonObject { return typeof value === "object" && value !== null && !Array.isArray(value); } -function initializeResult(params: unknown) { - const requested = - typeof params === "object" && params !== null - ? (params as { protocolVersion?: unknown }).protocolVersion - : undefined; - const protocolVersion = - typeof requested === "string" && requested.length > 0 - ? requested - : PROTOCOL_VERSION; - +function initializeResult() { + // This server supports exactly one protocol version, so the response always + // advertises PROTOCOL_VERSION. Per the MCP spec this is the correct reply + // whether or not the client requested that same version. return { - protocolVersion: - protocolVersion === PROTOCOL_VERSION - ? PROTOCOL_VERSION - : PROTOCOL_VERSION, + protocolVersion: PROTOCOL_VERSION, capabilities: { tools: {}, },