{"record":{"id":"f2363a4659ca7df3","repo":"different-ai/openwork","slug":"mcp-version","errorCode":"MCP_VERSION","errorMessage":"Server selected an unexpected MCP protocol version","messagePattern":"Server selected an unexpected MCP protocol version","errorType":"exception","errorClass":"ProbeFailure","httpStatus":null,"severity":"error","filePath":"packages/enterprise-mcp-mock-server/src/testing/probe.ts","lineNumber":765,"sourceCode":"    const initializeEnvelope = await parseRpc(initializeResponse, \"MCP_INITIALIZE\")\n    if (initializeEnvelope.error) {\n      const versionEvidence = z.object({ supportedVersions: z.array(z.string()).min(1) }).safeParse(initializeEnvelope.error.data)\n      throw versionEvidence.success || initializeEnvelope.error.message === \"Unsupported MCP protocol version\"\n        ? new ProbeFailure(\"MCP_VERSION\", \"mcp_version\", initializeEnvelope.error.message)\n        : new ProbeFailure(\"MCP_INITIALIZE\", \"mcp_initialize\", initializeEnvelope.error.message)\n    }\n    if (initializeEnvelope.id !== 1) {\n      throw new ProbeFailure(\"MCP_INITIALIZE\", \"mcp_initialize\", \"Initialize response JSON-RPC id did not match the request\")\n    }\n    const initialize = parseAt(\n      initializeResultSchema,\n      initializeEnvelope.result,\n      \"MCP_INITIALIZE\",\n      \"mcp_initialize\",\n      \"Initialize result did not match the required shape\",\n    )\n    if (initialize.protocolVersion !== scenario.protocol.version) {\n      throw new ProbeFailure(\"MCP_VERSION\", \"mcp_version\", \"Server selected an unexpected MCP protocol version\")\n    }\n    mutable.negotiatedProtocolVersion = initialize.protocolVersion\n    if (scenario.protocol.requireSession && !sessionId) {\n      throw new ProbeFailure(\"MCP_INITIALIZE\", \"mcp_initialize\", \"Initialize response omitted required MCP-Session-Id\")\n    }\n    recordPassed(phases, \"MCP_INITIALIZE\", startedAt, \"MCP version, capabilities, and session negotiated\")\n\n    const sessionHeaders = {\n      ...rpcHeaders,\n      \"mcp-session-id\": sessionId,\n      \"mcp-protocol-version\": initialize.protocolVersion,\n    }\n    startedAt = Date.now()\n    const initializedResponse = await fetchStep(mcpUrl, {\n      method: \"POST\",\n      headers: sessionHeaders,\n      body: JSON.stringify({ jsonrpc: \"2.0\", method: \"notifications/initialized\" }),\n    }, \"MCP_INITIALIZED\", overallDeadline)","sourceCodeStart":747,"sourceCodeEnd":783,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/packages/enterprise-mcp-mock-server/src/testing/probe.ts#L747-L783","documentation":"Thrown when the server's initialize result selects a protocolVersion different from the version the probe requested in scenario.protocol.version. MCP requires the server to respond with the exact version the client requested if supported; any other value is treated as a failed negotiation and surfaces as an MCP_VERSION failure.","triggerScenarios":"The scenario is configured with scenario.protocol.version (e.g. \"2025-06-18\") but the server's initialize result returns a different protocolVersion string, such as an older date-versioned spec.","commonSituations":"Server SDK updated (or not updated) relative to the scenario's expected spec version; scenario config points at a newer protocol version than the mock/real server implements; server ignores the client's requested version and always returns its default.","solutions":["Update the server to echo the client's requested protocolVersion when it supports it","Align scenario.protocol.version in the probe scenario with a version the server actually implements","Pin or upgrade the server's MCP SDK so its supported versions include the scenario's version"],"exampleFix":"// before (server)\nreturn { protocolVersion: \"2024-11-05\", ... }\n// after (server)\nreturn { protocolVersion: request.params.protocolVersion, ... }","handlingStrategy":"validation","validationCode":"if (initialize.protocolVersion !== scenario.protocol.version) throw new Error(`server negotiated ${initialize.protocolVersion}, expected ${scenario.protocol.version}`)","typeGuard":"function supportsVersion(serverVersions: string[], wanted: string): boolean {\n  return serverVersions.includes(wanted)\n}","tryCatchPattern":"try {\n  await probeEnterpriseMcpMockServer(scenario)\n} catch (e) {\n  if (e instanceof ProbeFailure && e.code === \"MCP_VERSION\") {\n    console.error(\"Protocol negotiation failed:\", e.message)\n  }\n}","preventionTips":["Keep the server's MCP SDK and scenario protocol.version in sync","Prefer servers that echo the client's requested protocolVersion","Pin protocol versions in CI so upgrades are intentional"],"tags":["mcp","protocol-version","negotiation","initialize"],"backgroundTag":"protocol-version-mismatch","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}