Repository navigation
Conversation
…annotations headerSchemaProperty decoded every property's "type" as a string. JSON Schema allows an array there, and jsonschema.For emits ["null", T] for pointer fields. One such property made the remarshal of the whole inputSchema fail, so the tool was treated as having no x-mcp-header annotations at all: clients sent no Mcp-Param-* headers and servers skipped header validation for it. A boolean subschema had the same effect. Decode each property leniently. A non-string type is kept as its raw JSON text, so an annotated nullable property is still rejected by the primitive-type check. Fixes modelcontextprotocol#1406 Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com> Signed-off-by: jay23606 <4602056+jay23606@users.noreply.github.com>
This branch has not been deployed
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.
Fixes #1406
What was broken
headerSchemaPropertydecoded each property'stypeas a plain string. JSON Schema also allowstypeto be an array, andjsonschema.Foremits"type": ["null", "string"]for every pointer field. A boolean subschema ("extra": true) is also valid JSON Schema.When any property in a tool's
inputSchemahad one of these shapes, decoding the whole schema failed and the SDK silently treated the tool as having nox-mcp-headerannotations at all, including on properties that were correctly annotated. The visible effects:Mcp-Param-*headers for the tool, so a server that validates them rejects the call withHeaderMismatch.validateParamHeaders, so a request whoseMcp-Param-*header contradicted the body was accepted.numberproperty) were not reported byAddToolor the client'stools/listfilter.What changed
headerSchemaPropertynow has its ownUnmarshalJSON, so each property decodes independently:typeis kept as its raw JSON text. It therefore still fails the existing primitive-type check, so an annotated nullable property (["null", "string"]) is still rejected, as before.The change is confined to
mcp/streamable_headers.go. No exported API changes.How it was tested
TestExtractToolParamHeaders(an array-typed sibling and a boolean subschema must not hide an annotated property) and toTestValidateToolParamHeaders(an invalid annotation next to an array-typed or boolean sibling must be reported, and a nullable annotated property must be rejected). All five new cases fail on the unmodified code and pass with this change.go test ./mcp/...passes,go vet ./mcp/is clean, and the touched files are gofmt-clean.This patch was prepared with AI assistance (Claude Code). The failure mode and the test cases were checked by hand against the code paths listed above.
🤖 Generated with Claude Code