modelcontextprotocol / modelcontextprotocol/java-sdk
Missing `@JsonIgnoreProperties(ignoreUnknown = true)` on capability sub-records
Personne n'a encore pris cette issue.
- Langage dominant
- Java
- Étoiles
- 3.7k
- Forks
- 1.1k
- Merge moyen
- 1 j 15 h
- PR mergées (30 j)
- 9
Description
Bug description
The top-level ClientCapabilities and ServerCapabilities records have @JsonIgnoreProperties(ignoreUnknown = true), but their nested sub-records do not. Since the ObjectMapper is constructed with default settings (FAIL_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 form and url fields (#724, fixed in #731), but the systemic issue remains — the next spec addition to any capability sub-object will break older SDK versions again.
Affected records
In McpSchema.java:
| Record | Line | Has annotation? |
|---|---|---|
ClientCapabilities |
383 | Yes |
RootCapabilities |
397 | Yes |
Sampling |
410 | No |
Elicitation |
437 | No |
Elicitation.Form |
443 | No |
Elicitation.Url |
450 | No |
ServerCapabilities |
535 | Yes |
CompletionCapabilities |
548 | No |
LoggingCapabilities |
555 | No |
PromptCapabilities |
565 | No |
ResourceCapabilities |
576 | No |
ToolCapabilities |
587 | No |
Spec reference
The spec schema explicitly states capabilities are not a closed set:
"Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities."
ClientCapabilities in schema.json — additionalProperties: false is never set on any capability object or sub-object. Several sub-capabilities (sampling, elicitation, completions, logging) explicitly set additionalProperties: true.
Expected behavior
Unknown fields on capability sub-objects should be silently ignored, matching the behavior of the top-level ClientCapabilities and ServerCapabilities records.
Related
- #734 — reports the same issue for
ToolCapabilitiesspecifically - #724 / #731 — the elicitation breakage that was fixed by adding fields, not by adding the annotation
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez dans mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java et examinez les capability records listés en les comparant à ClientCapabilities et ServerCapabilities. C’est terminé lorsque les champs inconnus de chaque sous-enregistrement de capability concerné sont ignorés lors de la désérialisation, y compris les elicitation records imbriqués.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- java
- Domaine
- api
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 55/100