feat(rmcp): add optional _meta to CallToolResult, EmbeddedResource, and ResourceContents#386
Merged
alexhancock merged 2 commits intomodelcontextprotocol:mainfrom Sep 2, 2025
Conversation
Contributor
Author
|
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
alexhancock
approved these changes
Sep 2, 2025
Contributor
alexhancock
left a comment
There was a problem hiding this comment.
Let's follow up to make sure we're not missing it on any other required types but this LGTM for these types!
Merged
Contributor
Author
sounds good, doing an analysis now |
This was referenced Sep 3, 2025
takumi-earth
pushed a commit
to earthlings-dev/rmcp
that referenced
this pull request
Jan 27, 2026
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).