fix: return header mismatch for missing protocol header - #1083
Merged
DaleSeo merged 1 commit intoJul 29, 2026
Merged
Conversation
mrcs64
marked this pull request as ready for review
July 29, 2026 19:31
DaleSeo
approved these changes
Jul 29, 2026
Merged
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.
Return
HeaderMismatch(-32020) when request_metadeclares a protocol version but the requiredMCP-Protocol-Versionheader is absent. Add a stateless HTTP regression test covering the complete JSON-RPC error response.Motivation and Context
The 2026-07-28 per-request protocol mirrors request metadata into HTTP headers. Required headers that are missing, malformed, or disagree with the request body are header-validation failures.
The missing
MCP-Protocol-Versionbranch previously returnedInvalid Request(-32600), unlike the adjacent header/body mismatch branch, which correctly returnsHeaderMismatch(-32020).This change is intentionally limited to that modern per-request validation branch:
server/discoverremainsInvalid Params(-32602)initializeheader/body validation remainsInvalid Request(-32600)References:
How Has This Been Tested?
Added a stateless HTTP regression test that verifies:
-32020Ran:
Result: 28 passed, 0 failed.
cargo fmt --all -- --checkalso passes with the installed stable formatter. It reports the repository's existing warnings for nightly-only rustfmt settings.Breaking Changes
None. This corrects the error classification for an already-invalid request.
Types of changes
Checklist
Additional context
The regression request includes the required
Mcp-Methodheader so the only missing modern routing header isMCP-Protocol-Version. The assertion matches a stable message fragment rather than the full diagnostic text.