modelcontextprotocol / modelcontextprotocol/java-sdk

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

Đang mở
#766 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

bug P1
Ngôn ngữ chính
Java
Star
3.7k
Fork
1.1k
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
9

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu tại mcp-core/src/main/java/io/modelcontextprotocol/spec/McpSchema.java và xem xét các capability record được liệt kê, so sánh chúng với ClientCapabilities và ServerCapabilities. Hoàn thành có nghĩa là các trường không xác định trong mọi capability sub-record bị ảnh hưởng đều được bỏ qua trong quá trình giải tuần tự, bao gồm cả các elicitation record lồng nhau.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
java
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
55/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.