different-ai/openwork · error · ProbeFailure
MCP_VERSION
MCP_VERSION
Error message
Server selected an unexpected MCP protocol version
What it means
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.
Source
Thrown at packages/enterprise-mcp-mock-server/src/testing/probe.ts:765
const initializeEnvelope = await parseRpc(initializeResponse, "MCP_INITIALIZE")
if (initializeEnvelope.error) {
const versionEvidence = z.object({ supportedVersions: z.array(z.string()).min(1) }).safeParse(initializeEnvelope.error.data)
throw versionEvidence.success || initializeEnvelope.error.message === "Unsupported MCP protocol version"
? new ProbeFailure("MCP_VERSION", "mcp_version", initializeEnvelope.error.message)
: new ProbeFailure("MCP_INITIALIZE", "mcp_initialize", initializeEnvelope.error.message)
}
if (initializeEnvelope.id !== 1) {
throw new ProbeFailure("MCP_INITIALIZE", "mcp_initialize", "Initialize response JSON-RPC id did not match the request")
}
const initialize = parseAt(
initializeResultSchema,
initializeEnvelope.result,
"MCP_INITIALIZE",
"mcp_initialize",
"Initialize result did not match the required shape",
)
if (initialize.protocolVersion !== scenario.protocol.version) {
throw new ProbeFailure("MCP_VERSION", "mcp_version", "Server selected an unexpected MCP protocol version")
}
mutable.negotiatedProtocolVersion = initialize.protocolVersion
if (scenario.protocol.requireSession && !sessionId) {
throw new ProbeFailure("MCP_INITIALIZE", "mcp_initialize", "Initialize response omitted required MCP-Session-Id")
}
recordPassed(phases, "MCP_INITIALIZE", startedAt, "MCP version, capabilities, and session negotiated")
const sessionHeaders = {
...rpcHeaders,
"mcp-session-id": sessionId,
"mcp-protocol-version": initialize.protocolVersion,
}
startedAt = Date.now()
const initializedResponse = await fetchStep(mcpUrl, {
method: "POST",
headers: sessionHeaders,
body: JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" }),
}, "MCP_INITIALIZED", overallDeadline)View on GitHub (pinned to 2b7df46e8a)
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
Example fix
// before (server)
return { protocolVersion: "2024-11-05", ... }
// after (server)
return { protocolVersion: request.params.protocolVersion, ... } Defensive patterns
Strategy: validation
Validate before calling
if (initialize.protocolVersion !== scenario.protocol.version) throw new Error(`server negotiated ${initialize.protocolVersion}, expected ${scenario.protocol.version}`) Type guard
function supportsVersion(serverVersions: string[], wanted: string): boolean {
return serverVersions.includes(wanted)
} Try / catch
try {
await probeEnterpriseMcpMockServer(scenario)
} catch (e) {
if (e instanceof ProbeFailure && e.code === "MCP_VERSION") {
console.error("Protocol negotiation failed:", e.message)
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unsupported_protocol_version
- MCP_INITIALIZE
- MCP_UNSUPPORTED_VERSION
- invalid_mcp_token_payload
- invalid_mcp_connection_payload
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/f2363a4659ca7df3.
Report an issue: GitHub.