-
Notifications
You must be signed in to change notification settings - Fork 408
Added _meta field to prompts, resources and paginated results #558
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
| pub struct CounterAnalysisArgs { | ||
| /// The target value you're trying to reach | ||
| pub goal: i32, | ||
| pub goal: String, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed type to String, because in standard arguments are strings https://modelcontextprotocol.io/specification/2025-06-18/schema#prompts/get
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds _meta field support to Prompts, Resources, and paginated list results to align with the MCP specification. The changes enable servers to attach arbitrary metadata to these entities, which was previously only available for Tools.
Key changes:
- Added
meta: Option<Meta>field toPrompt,Resource, and all paginated result types (ListPromptsResult,ListResourcesResult,ListResourceTemplatesResult,ListToolsResult) - Extended
#[prompt],#[tool_handler], and#[prompt_handler]macros to acceptmetaparameter - Updated the Counter example to demonstrate meta usage in prompts and handlers
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/rmcp/src/model/resource.rs | Added meta field to RawResource struct with proper serde annotations |
| crates/rmcp/src/model/prompt.rs | Added meta field to Prompt struct and imported Meta type |
| crates/rmcp/src/model/content.rs | Updated test to initialize meta: None for resource content |
| crates/rmcp/src/model.rs | Updated paginated_result! macro to include meta field in generated structs |
| crates/rmcp/src/handler/server/router.rs | Replaced explicit struct initialization with ..Default::default() for cleaner code |
| crates/rmcp-macros/src/tool_handler.rs | Added meta parameter support to #[tool_handler] macro |
| crates/rmcp-macros/src/prompt_handler.rs | Added meta parameter support to #[prompt_handler] macro |
| crates/rmcp-macros/src/prompt.rs | Added meta parameter support to #[prompt] macro |
| examples/servers/src/common/counter.rs | Demonstrated meta usage in prompts and handlers; changed goal type from i32 to String with validation |
| crates/rmcp/tests/test_message_schema/*.json | Updated JSON schemas to reflect new _meta fields in all affected types |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[serde(rename = "_meta", skip_serializing_if = "Option::is_none")] | ||
| pub meta: Option<Meta>, |
Copilot
AI
Nov 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Field ordering inconsistency: The meta field is placed first in paginated result structs, but in entity structs like Tool, Resource, and Prompt, the meta field is placed last (after icons). For consistency, consider placing meta last in this macro as well, after next_cursor and the items field. This would match the convention used in other structs throughout the codebase.
Co-authored-by: Copilot <[email protected]>
|
LGTM. if there is a requirement to update associated tests or documentation I would encourage doing so but this appears to address my ticket here: #557 |
Motivation and Context
MCP specifies _meta field for requested entities. Currently
_metafield implemeted for tool, but missing for others.This PR:
_metafield for Prompt, Resource_metafield for PaginatedResult: ListToolsResult, ListPromptsResult, ListResourceTemplatesResult, ListPromptsResult.metaattribute to tool_handler and prompt_handler macrosFormat of meta attribute is the same as existed for tool.
rust-sdk/crates/rmcp-macros/src/tool.rs
Lines 127 to 131 in 2b60f8a
In this case you need to provide Meta object, but we can update to something like
and use with item definition only with json, for instance
How Has This Been Tested?
Breaking Changes
No
Closes #557
Types of changes
Checklist
Additional context