mcp: send the proposed protocol version in the initialize header - #1165
Open
gwyszynski-sa wants to merge 1 commit into
Open
mcp: send the proposed protocol version in the initialize header#1165gwyszynski-sa wants to merge 1 commit into
gwyszynski-sa wants to merge 1 commit into
Conversation
The legacy initialize handshake pins params.protocolVersion but sends no Mcp-Protocol-Version header of its own: setMCPHeaders finds c.initializedResult still nil, since it is assigned a few lines later, and the message carries no _meta.protocolVersion, so the header falls to the request context. For a standalone client that context is empty and the header is absent; for a process that is both a server and a client it holds that process's inbound version, which then contradicts the body it accompanies. This is the client-side mirror of modelcontextprotocol#963. Declares the proposed version on the context of the initialize send, the same way the server/discover probe immediately above already does, so the header always states what the body proposes. The fake server asserted wantProtocolVersion for other methods but for none of its sixteen initialize cases, so neither an absent nor a contradicting header was covered. Asserts header/body agreement centrally instead, since it holds for every initialize unconditionally. Fixes modelcontextprotocol#1164
gwyszynski-sa
force-pushed
the
fix/initialize-protocol-version-header
branch
from
August 13, 2026 12:19
9017736 to
babfbb3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The legacy initialize handshake pins params.protocolVersion but sends no
Mcp-Protocol-Version header of its own: setMCPHeaders finds c.initializedResult
still nil, since it is assigned a few lines later, and the message carries no
_meta.protocolVersion, so the header falls to the request context. For a
standalone client that context is empty and the header is absent; for a process
that is both a server and a client it holds that process's inbound version,
which then contradicts the body it accompanies. This is the client-side mirror
of #963.
Declares the proposed version on the context of the initialize send, the same
way the server/discover probe immediately above already does, so the header
always states what the body proposes.
The fake server asserted wantProtocolVersion for other methods but for none of
its sixteen initialize cases, so neither an absent nor a contradicting header
was covered. Asserts header/body agreement centrally instead, since it holds
for every initialize unconditionally.
Fixes #1164