#1217

MCP client hardcodes protocol version 2024-11-05; cannot connect to newer servers (repro: GitLab MCP)

OpenVictorLowtheropened 24d ago

Problem

The MCP client hardcodes protocol version 2024-11-05 in the initialize handshake (stdio, streamable-HTTP, and SSE transports). MCP servers implementing newer revisions (2025-03-26 / 2025-06-18 / 2025-11-25) reject the stale proposal outright, so those servers cannot connect at all.

Reproduced against the GitLab MCP provider: the streamable-HTTP endpoint answers our initialize with HTTP 400 and a JSON-RPC error whose data says Unsupported protocol version '2024-11-05'. Supported: 2026-07-28, 2025-11-25, 2025-06-18, 2025-03-26. Because the client also dropped the JSON-RPC error data member when rendering failures, the user only saw a bare "Invalid params" with no hint of what went wrong.

Two spec details made it worse than a version bump alone:

  • Newer revisions expect subsequent HTTP requests to carry the negotiated version in the MCP-Protocol-Version header (and to omit it on initialize itself).
  • The newest revision, 2026-07-28, retires the initialize handshake entirely, so it is not a version this handshake-based client can simply add to its proposal list.

Expected behavior

Protocol version negotiation per the spec: propose a current version, retry on version-shaped rejections using the versions the server lists, adopt a supported counter-offer, fail with an actionable error only when there is no overlap — and send the negotiated version in the MCP-Protocol-Version header afterward.

Fix

Fixed on main in 4c34126c (fix(mcp): negotiate the protocol version instead of hardcoding 2024-11-05):

  • New internal/mcp/negotiate.go: candidates 2025-11-25, 2025-06-18, 2025-03-26, 2024-11-05 (newest first); parses the server's supported list out of the rejection, retries with the newest mutually supported version, stops immediately when the server names only versions we don't speak; non-version failures (auth, bad params) are not retried.
  • rpcError now carries the JSON-RPC data member and it is appended to surfaced errors (that's where the rejection detail lives).
  • The streamable-HTTP client records the negotiated version and sends MCP-Protocol-Version on subsequent requests.
  • Regression tests include a GitLab-shaped HTTP 400 rejection round-trip (TestNetworkClientNegotiatesAfterHTTP400VersionRejection).

Environment

  • Tested against the GitLab MCP provider (streamable-HTTP transport), 2026-11.

Activity

3
Vasanthdev200424d ago

Thanks for the detailed report. Confirmed on current main: initialize sends a fixed "protocolVersion": "2024-11-05" from all three clients (internal/mcp/client.go:245 for stdio, internal/mcp/network_client.go:98 and :115 for the network transports). Nothing sends MCP-Protocol-Version afterwards; the only header the network client carries forward is Mcp-Session-Id. So any server that refuses 2024-11-05 cannot connect at all.

One note on the fix: 4c34126c is not in this repository, and GitHub cannot find it on your fork either, so I assume it is a local commit. CONTRIBUTING asks for the issue-approved label on the issue before a pull request is opened. I think this one should be approved and will flag it for @kevincodex1. Once the label is on, please open the PR against main with the negotiation tests you describe.

Vasanthdev200415d ago

Nine days without an objection, and I verified the report on main myself, so I am marking this bug and issue-approved. @VictorLowther please open the PR against main with the negotiation tests you described: propose a current version, retry with what the server lists, send the negotiated version in MCP-Protocol-Version on later requests, and keep the JSON-RPC error data in what the user sees.

gnanam19904d ago

Recording the compatibility change requested in the maintainer review, since it differs from the original fix sketch above.

#1246 makes one final 2024-11-05 proposal when a rejection supplies no usable advertised candidate, including bare Invalid params and empty/disjoint lists. This preserves servers that connect with main's old proposal. Explicit missing-field/authentication errors and HTTP 401/403 do not start that fallback. New untried version hints are followed; failed retries retain the first error.

Missing protocolVersion in a successful response accepts the proposal. An explicit unsupported counteroffer remains rejected.

These choices are documented in the PR and regression tests. Current head 2229cbb0 passes full CI and before/after proof. The PR is awaiting maintainer re-review.