outputSchema is generated for the deserialize contract; tool results are serialised
Maintainer thường phản hồi trong vòng 2 ngày
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Problem
schema_for_output::<T>() builds a tool's outputSchema through schema_for_type, which uses SchemaSettings::draft2020_12(), i.e. schemars' default Contract::Deserialize (crates/rmcp/src/handler/server/common.rs, still the case on main at ad5a284). A tool result is a value the server serialises, so its schema should describe what Serialize writes. Under the deserialize contract the advertised schema is wrong for common shapes:
- an
Option<T>field withoutskip_serializing_ifis always written (asnull), but is advertised as optional; - a
#[serde(default)]field is always written, but is advertised as optional; - a type that accepts several forms and writes one (e.g.
rust_decimal::Decimal: string or number in, string out) is advertised with every accepted form.
A client or model reading outputSchema is told a field may be absent when the server always sends it, or may be a number when the server sends a string.
Repro
#[derive(serde::Serialize, schemars::JsonSchema)]
struct Out {
always: Option<i32>,
#[serde(skip_serializing_if = "Option::is_none")]
sometimes: Option<i32>,
}
// schema_for_output::<Out>()["required"] is absent; it should be ["always"].
Proposed fix
schema_for_output generates with SchemaSettings::draft2020_12().for_serialize(). Inputs (schema_for_type) stay on the deserialize contract. There is no public API change. For types whose two forms are equal, the output schema is byte-identical.
I have a patch against main with two tests (an always-written Option is required in an output schema; an input Option stays optional). cargo test -p rmcp --features server,client,macros,schemars,transport-io passes. I'm happy to open the PR if this direction is welcome.
- Ngôn ngữ chính
- Rust
- Star
- 4k
- Fork
- 688
- Merge trung bình
- 3 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 36
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của modelcontextprotocol/rust-sdk
-
Streamable HTTP client: a 401 or 403 with a JSON-RPC error body and no WWW-Authenticate loses its HTTP statusCó thể đã có người làm @aton-of-data đã nhận 8 ngày trước. Đang mởbug P2 ready for work T-security T-transport
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
modelcontextprotocol/rust-sdk#1339 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
auth: refresh_token() requests offline_access that was never granted, so refreshes fail with invalid_scopeCó thể đã có người làm @jstar0 đã nhận 10 ngày trước. Đang mởbug P1 ready for work T-security T-transport
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
modelcontextprotocol/rust-sdk#1330 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
P3 question Stale T-documentation T-enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
modelcontextprotocol/rust-sdk#1155 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Streamable HTTP client: update the stored endpoint URI after a 308Có thể đã có người làm @connor4312 đã nhận 2 ngày trước. Đang mởenhancement P3 T-transport
modelcontextprotocol/rust-sdk#1373 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Expose OAuth discovery and registration results for application-owned flowsCó thể đã có người làm @connor4312 đã nhận 3 ngày trước. Đang mởenhancement P2 ready for work T-security
modelcontextprotocol/rust-sdk#1371 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của modelcontextprotocol/rust-sdk
Issue tương tự
-
ci: SHA pin 3rd party actionsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 64/100
Maintainer thường phản hồi trong vòng 3 ngày
-
Zellij doesn't validate hex colors correctly and crashesCó thể đã có người làm @ymcx đã nhận hôm nay. Đang mởsuspected bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
zellij-org/zellij#5732 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug rust
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
jonathanong/no-mistakes#2267 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BASEPRI needs an ISBĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
rust-embedded/cortex-m#702 · 1 bình luận ·
-
Make major, minor, and makedev safe on solarish targetsCó thể đã có người làm @xtqqczze đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày