Skip to content

mcp: send the proposed protocol version in the initialize header - #1165

Open
gwyszynski-sa wants to merge 1 commit into
modelcontextprotocol:mainfrom
gwyszynski-sa:fix/initialize-protocol-version-header
Open

mcp: send the proposed protocol version in the initialize header#1165
gwyszynski-sa wants to merge 1 commit into
modelcontextprotocol:mainfrom
gwyszynski-sa:fix/initialize-protocol-version-header

Conversation

@gwyszynski-sa

@gwyszynski-sa gwyszynski-sa commented Aug 13, 2026

Copy link
Copy Markdown

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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

initialize sends no Mcp-Protocol-Version of its own, so the header can contradict params.protocolVersion

1 participant