[Schema] Refuse an invalid x-mcp-header annotation at definition time - #441
Merged
chr-hertel merged 5 commits intoAug 18, 2026
Merged
Conversation
SEP-2243 calls a tool definition invalid when its x-mcp-header annotation is empty, is not an HTTP field name, collides case-insensitively with another, or sits on a number, array or object property - none of which can be mirrored onto a header. Nothing said so. The earliest place to is where the tool is defined, rather than on the request that trips over it.
chr-hertel
requested review from
CodeWithKyrian,
Nyholm and
soyuka
as code owners
August 18, 2026 06:59
Contributor
There was a problem hiding this comment.
Pull request overview
Adds definition-time validation for the x-mcp-header tool-argument annotation (SEP-2243) so invalid header annotations are rejected when a Tool is constructed, rather than failing later during request/header comparisons.
Changes:
- Validate
x-mcp-headerannotations inToolinput schemas (empty/invalid field-name, case-insensitive collisions, and disallowed schema types). - Add unit coverage for valid/invalid annotations, including nesting and “unreachable” annotations under
items. - Document the behavior in the changelog for the upcoming release.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/Unit/Schema/ToolHeaderAnnotationTest.php | Adds unit tests covering accepted, refused, and intentionally-ignored x-mcp-header placements/values. |
| src/Schema/Tool.php | Implements definition-time x-mcp-header validation for annotations reachable via properties. |
| CHANGELOG.md | Notes the new definition-time refusal behavior for invalid x-mcp-header annotations. |
Suppressed comments (1)
src/Schema/Tool.php:138
checkHeaderAnnotations()claims it validates everyx-mcp-headerannotation in the input schema, but the implementation only considers annotations reachable viaproperties(seeheaderAnnotations()). Tighten the docblock to match the actual validation scope.
* Validates every `x-mcp-header` annotation in an input schema (SEP-2243).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
chr-hertel
commented
Aug 18, 2026
This was referenced Aug 18, 2026
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 calls a tool definition invalid when its
x-mcp-headerannotation is empty, is not an HTTP field name (CR/LF injection included), collides case-insensitively with another, or sits on anumber, array or object property — none of which can be mirrored onto a header.Nothing said so. The earliest place to say it is where the tool is defined, rather than on the request that trips over it.
This is the definition-time half of
x-mcp-header; the request-time half (walking nested properties when comparingMcp-Param-*against the body) is part of the 2026-07-28 lifecycle work and will follow separately.