-
Notifications
You must be signed in to change notification settings - Fork 443
feat(rmcp): add optional _meta to CallToolResult, EmbeddedResource, and ResourceContents #386
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
feat(rmcp): add optional _meta to CallToolResult, EmbeddedResource, and ResourceContents #386
Conversation
Kvadratni
left a comment
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.
LGTM
|
i need to clean up the test fixtures. not quite ready for final review. |
e327541 to
6cd9273
Compare
6cd9273 to
4c88e25
Compare
…ntents - Add optional _meta to RawEmbeddedResource and ResourceContents (text/blob) - Update constructors/usages to set meta: None by default - Add tests to lock behavior (embedded text/blob + CallToolResult) - Update JSON Schemas to include optional _meta fields
4c88e25 to
d9d26ba
Compare
Kvadratni
left a comment
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.
LGTM!
alexhancock
left a comment
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.
Let's follow up to make sure we're not missing it on any other required types but this LGTM for these types!
sounds good, doing an analysis now |
…nd ResourceContents (modelcontextprotocol#386) * feat(rmcp): support optional _meta on EmbeddedResource and ResourceContents - Add optional _meta to RawEmbeddedResource and ResourceContents (text/blob) - Update constructors/usages to set meta: None by default - Add tests to lock behavior (embedded text/blob + CallToolResult) - Update JSON Schemas to include optional _meta fields * style(rmcp): rustfmt after _meta changes and tests
Summary
Support the optional
_metafield across core MCP results and resources so protocol-level metadata can be exchanged and properly serialized/deserialized per the MCP spec.Problem
The MCP spec allows an optional
_metafield on results and certain content forms. The Rust SDK only partially supported this, limiting interoperability (e.g., clients expecting_metacould not round-trip metadata).Changes
_meta(serde rename to"_meta", skip whenNone)"_meta"_meta(serde rename to"_meta")_meta(serde rename to"_meta")PartialEqandschemars::JsonSchemafor testing and schema generationTests
crates/rmcp/tests/test_tool_result_meta.rs: serialize/deserialize CallToolResult with and without_metacrates/rmcp/tests/test_embedded_resource_meta.rs: serialize/deserialize EmbeddedResource and inner Text/Blob contents with and without_metatests/test_message_schema/client_json_rpc_message_schema.jsontests/test_message_schema/server_json_rpc_message_schema.jsonBackward compatibility
No breaking changes: all new fields are optional and omitted when
None.Examples
CallToolResult:
{ "content": [{"type":"text","text":"ok"}], "_meta": {"foo":"bar"} }EmbeddedResource with Text contents:
{ "type": "resource", "_meta": {"top": 1}, "resource": { "uri": "str://example", "mimeType": "text/plain", "text": "hello", "_meta": {"inner": 2} } }Notes
success_with_meta()/error_with_meta()helpers (not included).