Repository navigation
Validate Mcp-Param headers against tool call arguments - #406
Merged
Merged
Conversation
pushpak1300
marked this pull request as ready for review
November 17, 2026 16:34
albertcht
pushed a commit
to hypervel/mcp
that referenced
this pull request
Dec 3, 2026
Legacy protocol requests previously received modern result fields (resultType, cache hints, and _meta.serverInfo), and HTTP tool calls did not validate mirrored Mcp-Param headers against tool call arguments. Guard modern result fields in Server::send() with ! $request->isLegacy(), pass HTTP headers into ServerContext, and validate Mcp-Param headers against tool arguments in CallTool, ValidateMcpHeaders, MirroredParameter, and HeaderValue. Update ReadAppResourceTest to send a modern resource request when asserting ttlMs cache hints. Upstream: laravel/mcp#398, laravel/mcp#406 (bfbfa672d19c376123e80760fe846eb01f1bcc63). Validation: MCP suite, server conformance (http-custom-header-server-validation), PHPStan, and php-cs-fixer pass.
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.
SEP-2243 requires the server to check each
Mcp-Param-{Name}header against the tool argument that it mirrors. Without this check, a gateway can route on one value while the tool runs with another.The check runs when the tool is called, not in the
ValidateMcpHeadersmiddleware, because only the tool schema says which arguments carryx-mcp-header. Stdio servers have no headers, so they skip the check.Note
Over HTTP, a call to a tool with
x-mcp-headerannotations now fails with400and error-32020when a mirrored header is missing, unexpected, or different from the body. Base64 header values without padding no longer decode. This also applies toMcp-Name.