Repository navigation
[Docs][Server] Document and test that initialize negotiates from th… - #739
Merged
chr-hertel merged 2 commits intoNov 16, 2026
Conversation
…e body, not the version header The MCP-Protocol-Version header sent with `initialize` plays no part in negotiation and is not compared with `params.protocolVersion`. Closes modelcontextprotocol#309
nbullorini
requested review from
CodeWithKyrian,
Nyholm,
chr-hertel and
soyuka
as code owners
November 11, 2026 16:26
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the documentation and regression-coverage changes for initialization version negotiation.
No open issues 🎉
What changed in this PR
Documents and adds regression coverage for body-driven initialize version negotiation, addressing issue #309 without changing runtime behavior.
Changes:
- Clarifies that the header does not participate in handshake negotiation, while separate header validation still applies.
- Tests older, newer, and missing headers with and without sessions, checking the response and stored session version.
- Corrects the middleware docblock to say clients may omit the header on
initialize.
| File | Description |
|---|---|
tests/Unit/Server/Transport/StreamableHttpTransportTest.php |
Adds six negotiation cases and an initialization request helper. |
src/Server/Transport/Http/Middleware/ProtocolVersionMiddleware.php |
Corrects the comment about optional initialization headers. |
docs/run/http.md |
Explains body-driven negotiation, version pinning, and modern-header rejection. |
Review effort: Balanced
chr-hertel
approved these changes
Nov 16, 2026
chr-hertel
left a comment
Member
There was a problem hiding this comment.
Thanks @nbullorini - made some minor stylistic abjustments in 36a8eb6 before merging.
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.
On
initializethe body is authoritative: theMCP-Protocol-Versionheader plays no part in negotiation and is not compared withparams.protocolVersion. This corrects the "Protocol Version Validation" section indocs/run/http.mdand adds transport tests for both mismatch directions and a missing header, with and without sessions.Closes #309
Motivation and Context
As agreed in #309: the docs said the header check happens after the handshake, and nothing pinned down that the header has no effect on
initialize, so it could quietly regress to the originally reported behaviour.How Has This Been Tested?
New transport-level test in
StreamableHttpTransportTestcovering an older header, a newer header and no header, each with and without sessions, asserting the negotiated version in both the response and the stored session.Breaking Changes
None. No runtime behaviour changes.
Types of changes
Checklist
Additional context
The
ProtocolVersionMiddlewaredocblock repeated the same inaccurate claim thatinitializedoesn't carry the header, so it's corrected too.