8000 Validate Mcp-Param headers against tool call arguments by pushpak1300 · Pull Request #406 · laravel/mcp · GitHub
[go: up one dir, main page]

Skip to content

Validate Mcp-Param headers against tool call arguments - #406

Merged
pushpak1300 merged 3 commits into
mainfrom
os-110-mcp-param-header-validation-sep-2243
Nov 17, 2026
Merged

pushpak1300 merged 3 commits into
mainfrom
os-110-mcp-param-header-validation-sep-2243

Conversation

@pushpak1300
@pushpak1300 pushpak1300 commented Nov 17, 2026 •
Copy link
Copy Markdown
Member

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 ValidateMcpHeaders middleware, because only the tool schema says which arguments carry x-mcp-header. Stdio servers have no headers, so they skip the check.

Note

Over HTTP, a call to a tool with x-mcp-header annotations now fails with 400 and error -32020 when a mirrored header is missing, unexpected, or different from the body. Base64 header values without padding no longer decode. This also applies to Mcp-Name.

@pushpak1300
pushpak1300 marked this pull request as ready for review November 17, 2026 16:34
@pushpak1300
pushpak1300 merged commit a8057f2 into main Nov 17, 2026
17 checks passed
@pushpak1300
pushpak1300 deleted the os-110-mcp-param-header-validation-sep-2243 branch November 17, 2026 16:36
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.
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.

1 participant

0