`#[tool(description = …)]` accepts only a bare literal, while `#[doc]` and `#[schemars]` on the same items accept `include_str!` and `const` paths
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 62/100
Hướng nghiên cứu
Báo cáo không nêu tệp triển khai hoặc kiểm thử nào; hãy bắt đầu bằng cách tìm parser của thuộc tính #[tool] và phần xác thực của nó đối với description. Bổ sung coverage cho một đường dẫn const của &'static str và concat!, giữ nguyên hành vi của literal, đồng thời xác minh rằng description được sinh ra cũng như hành vi được ghi lại hoặc hành vi lỗi khớp với yêu cầu.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
description in #[tool] accepts only a bare string literal. Two attributes that sit on the very same items are more permissive: #[doc] on the function accepts include_str! and that value does reach the published description, and #[schemars(extend(…))] on the argument struct accepts const paths.
So a server can already source a tool's published text from outside the attribute — through #[doc], or through a literal handed in by a wrapper macro — just not through description, which is the field that names it. Accepting a const path and concat! there would remove the inconsistency.
This is an enhancement request, not a blocker: the workarounds below all work.
Version
rmcp 3.1.2, rustc 1.96.1, edition 2024.
What was measured
| form | result |
|---|---|
#[tool(description = "…")] |
works |
#[tool(description = my_crate::caps::TEXT)] |
error: Unexpected type \path`` |
#[tool(description = concat!("a", "b"))] |
error: Unexpected type \macro`` |
/// doc comment + #[tool] |
works — becomes the description |
#[doc = include_str!("text.md")] + #[tool] |
works — becomes the description |
#[schemars(extend("maximum" = MOST_STARTS_AT_ONCE))] on the args struct |
works — a const path, in the same attribute stack |
doc comment and description together |
description wins (no surprise here) |
macro_rules! wrapping the whole #[tool_router] impl |
works |
macro_rules! wrapping only the fn inside the impl |
compiles, registers nothing — filed separately |
The schemars row is the one that makes this feel like an oversight rather than a decision: a const is already acceptable one attribute away, for a value that is likewise baked into the published schema.
Why it matters on a larger surface
On a server with many tools the published text is an interface, and it usefully has two halves: a short one broadcast in tools/list before the first call, and a longer one fetched on demand. Ours measures 82 953 B of description across 66 tools, against a 13 590 B fetchable handbook — so keeping the split is worth real bytes, and it is far easier to keep the two halves honest when both can be declared together and the short one referenced from the attribute:
// what one would like to write
const GET_OR_CREATE_PROJECT: Capability = Capability {
broadcast: "…what prevents a wrong call…",
taught: "…the full explanation, fetched on demand…",
};
#[tool(description = GET_OR_CREATE_PROJECT.broadcast)]
Today that requires either moving the text into a file and using #[doc = include_str!(…)], or keeping a second copy plus a test comparing it to the literal.
Suggested change
Accept in description what neighbouring attributes already accept: a path to a const &'static str, and concat!. The generated code stores a &'static str either way.
If the literal is required because the value is needed during macro expansion, a line saying so in the docs — and an error message reading "only a string literal is accepted here" rather than naming the token type — would save the next person the experiment.
What this report does not establish
It does not claim the current behaviour is wrong, only that it is inconsistent with #[doc] and #[schemars] on the same items. name was not tested against a non-literal; only description was.
- Ngôn ngữ chính
- Rust
- Star
- 4k
- Fork
- 654
- Merge trung bình
- 4 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 40
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
-
P3 question 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 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
LocalSessionManager session workers don't cancel in-flight tool calls on client disconnect (follow-up to #857)Có thể đã có người làm @kkkhs đã nhận 1 ngày trước. Đang mởbug P1 ready for work T-transport
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 55/100
modelcontextprotocol/rust-sdk#1325 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
streamable-http server: client responses to server-initiated requests (sampling/elicitation/roots) are 202-accepted and silently discarded under the 2026-07-28 protocol — the pending request hangs foreverCó thể đã có người làm @DaleSeo đã nhận 1 ngày trước. Đang mởbug P1 ready for work T-transport
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
modelcontextprotocol/rust-sdk#1321 · 1 reaction · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Bound pre-lifecycle bootstrap attempts in server initializationCó thể đã có người làm @DaleSeo đã nhận 5 ngày trước. Đang mởenhancement P2 T-service T-transport
modelcontextprotocol/rust-sdk#1315 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 3 ngày
-
ProgressDispatcher: a slow progress subscriber blocks subscribe() and delivery for other tokensCó thể đã có người làm @monody0007 đã nhận 9 ngày trước. Đang mởbug P1 ready for work T-handler
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
modelcontextprotocol/rust-sdk#1312 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của modelcontextprotocol/rust-sdk
Issue tương tự
-
documentation enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
adorsys/status-list-server#619 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
batch-backport only backports the first 30 matching PRsCó thể đã có người làm @DvirDukhan đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 5 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
equinor/septic-config-generator#481 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày