Skip to content

feat: Add _meta field to classes across MCPSchema #368

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

pantanurag555
Copy link
Contributor

@pantanurag555 pantanurag555 commented Jul 2, 2025

Motivation and Context

_meta field was added to multiple classes in the schema to make it easy to pass metadata when communicating between an MCP client and server. Relevant spec PR: modelcontextprotocol/modelcontextprotocol#710

This PR adds _meta field across all relevant classes in MCPSchema. It also creates new interfaces for Result and Notifications to ensure that this field is added to any future classes created that implement these interfaces.

Currently MCPSchema in java SDK is missing classes for different list requests (ListResourcesRequest, ListToolsRequest etc-) opting to create the JSONRPCRequest and send it directly to the server instead. Similarly the class for RootsListChangedNotification is missing as well. Therefore, it is not possible to add _meta field to these exchanges between the server and client as of now. Relevant classes should be added to the java SDK in the future to maintain parity with the specification. This PR does not address this issue.

Resolves #344

How Has This Been Tested?

Added relevant unit tests for all classes.

Breaking Changes

None. Added relevant backward compatible constructors to ensure

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Add support for _meta across fields defined in MCPSchema
1 participant