feat: add SEP-2575 meta helpers#942
Open
howardjohn wants to merge 1 commit into
Open
Conversation
Expose typed accessors for the per-request protocol version, client info, client capabilities, and log level entries carried in _meta without making those fields required for older peers. Fixes modelcontextprotocol#869
DaleSeo
reviewed
Jun 30, 2026
DaleSeo
left a comment
Member
There was a problem hiding this comment.
Thanks for adding this, @howardjohn! I have a few comments.
Comment on lines
+205
to
+212
| /// `_meta` key carrying the MCP protocol version for this request. | ||
| pub const META_KEY_PROTOCOL_VERSION: &str = "io.modelcontextprotocol/protocolVersion"; | ||
| /// `_meta` key carrying the client implementation identity for this request. | ||
| pub const META_KEY_CLIENT_INFO: &str = "io.modelcontextprotocol/clientInfo"; | ||
| /// `_meta` key carrying the client capabilities for this request. | ||
| pub const META_KEY_CLIENT_CAPABILITIES: &str = "io.modelcontextprotocol/clientCapabilities"; | ||
| /// `_meta` key carrying the requested per-request log level. | ||
| pub const META_KEY_LOG_LEVEL: &str = "io.modelcontextprotocol/logLevel"; |
Member
There was a problem hiding this comment.
Do these constants need to be part of the public API? It seems like the getters and setters below should be sufficient for consumers. How about we keep them internal until there's a clear need for them downstream?
Member
There was a problem hiding this comment.
I would also consider making these private associated constants on Meta instead of module-level constants. The raw keys are only used by the Meta helpers, so keeping them under impl Meta makes the ownership clearer.
| { | ||
| self.0 | ||
| .get(key) | ||
| .and_then(|value| serde_json::from_value(value.clone()).ok()) |
Member
There was a problem hiding this comment.
Serde can deserialize directly from &Value instead of cloning Value every time.
Suggested change
| .and_then(|value| serde_json::from_value(value.clone()).ok()) | |
| .and_then(|value| T::deserialize(value).ok()) |
Member
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.

Motivation and Context
Expose typed accessors for the per-request protocol version, client info, client capabilities, and log level entries carried in _meta without making those fields required for older peers.
This is needed for part of SEP-2575 which requires reading/writing these fields. Obviously its possible to set these manually today but given these are first class fields it seems nice to have typed APIs for them.
For #869
How Has This Been Tested?
Testing in Agentgateway (unmerged)
Breaking Changes
No
Types of changes
Checklist
Additional context