modelcontextprotocol / modelcontextprotocol/java-sdk

Missing `@JsonIgnoreProperties(ignoreUnknown = true)` on capability sub-records

未关闭
#766 4 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P1
主要语言
Java
星标
3.7k
派生
1.1k
平均合并
1 天 15 小时
30 天内合并 PR
9

描述

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.jsonadditionalProperties: 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 ToolCapabilities specifically
  • #724 / #731 — the elicitation breakage that was fixed by adding fields, not by adding the annotation

AI Disclaimer

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从 mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java 开始,检查列出的 capability record,并将其与 ClientCapabilities 和 ServerCapabilities 进行比较。完成标准是:在反序列化期间,忽略每个受影响的 capability 子记录中的未知字段,包括嵌套的 elicitation record。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api
Issue 类型
缺陷
难度
2/5
预计耗时
1-3 小时
活跃度
停滞
描述清晰度
描述清楚
新手友好度
55/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。