Add @JsonIgnoreProperties(ignoreUnknown = true) to capability sub-records#852
Open
rameshreddy-adutla wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
…ords The top-level ClientCapabilities and ServerCapabilities records have @JsonIgnoreProperties(ignoreUnknown = true) but their nested sub-records do not. Since ObjectMapper defaults to FAIL_ON_UNKNOWN_PROPERTIES = true, unknown fields on sub-objects cause deserialization failures. This already caused a real breakage when elicitation gained form/url fields (modelcontextprotocol#724). The MCP spec explicitly does not close capability objects (additionalProperties is never set to false), so SDKs must tolerate unknown fields for forward compatibility. Add the annotation to: - ClientCapabilities.Sampling - ClientCapabilities.Elicitation, Elicitation.Form, Elicitation.Url - ServerCapabilities.CompletionCapabilities - ServerCapabilities.LoggingCapabilities - ServerCapabilities.PromptCapabilities - ServerCapabilities.ResourceCapabilities - ServerCapabilities.ToolCapabilities Fixes modelcontextprotocol#766 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Summary
Add
@JsonIgnoreProperties(ignoreUnknown = true)to all capability sub-records that are missing the annotation, ensuring forward compatibility when the MCP spec adds new fields.Problem
The top-level
ClientCapabilitiesandServerCapabilitiesrecords have@JsonIgnoreProperties(ignoreUnknown = true), but their nested sub-records do not. Since theObjectMapperdefaults toFAIL_ON_UNKNOWN_PROPERTIES = true, any unknown field on a capability sub-object causes a deserialization failure.This already caused a real breakage when the elicitation capability gained
formandurlfields (#724, fixed in #731). The systemic issue remains — the next spec addition to any capability sub-object will break older SDK versions.The MCP spec schema explicitly does not close capability objects (
additionalProperties: falseis never set). Several sub-capabilities (sampling,elicitation,completions,logging) explicitly setadditionalProperties: true.Fix
Add
@JsonIgnoreProperties(ignoreUnknown = true)to:ClientCapabilities.SamplingClientCapabilities.ElicitationClientCapabilities.Elicitation.FormClientCapabilities.Elicitation.UrlServerCapabilities.CompletionCapabilitiesServerCapabilities.LoggingCapabilitiesServerCapabilities.PromptCapabilitiesServerCapabilities.ResourceCapabilitiesServerCapabilities.ToolCapabilitiesTesting
Added 9 targeted tests in
McpSchemaTeststhat verify each sub-record correctly ignores unknown fields during deserialization. All existing tests continue to pass.Fixes #766
Related: #734