Skip to content

feat: add SEP-2575 meta helpers#942

Open
howardjohn wants to merge 1 commit into
modelcontextprotocol:mainfrom
howardjohn:john/sep-2575-meta-helpers
Open

feat: add SEP-2575 meta helpers#942
howardjohn wants to merge 1 commit into
modelcontextprotocol:mainfrom
howardjohn:john/sep-2575-meta-helpers

Conversation

@howardjohn

Copy link
Copy Markdown
Contributor

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional 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.

Fixes modelcontextprotocol#869
@howardjohn howardjohn requested a review from a team as a code owner June 29, 2026 16:12
@github-actions github-actions Bot added T-test Testing related changes T-core Core library changes T-model Model/data structure changes labels Jun 29, 2026

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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())

@DaleSeo

DaleSeo commented Jun 30, 2026

Copy link
Copy Markdown
Member

Wrapping the long commit body will help the CI job pass.

2026-06-30 at 10 44 46

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2026-07-28 T-core Core library changes T-model Model/data structure changes T-test Testing related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants