Skip to content

Expose RequestParams._meta in ClientSession.call_tool #1231

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 4 commits into
base: main
Choose a base branch
from

Conversation

samchenatti
Copy link

Motivation and Context

This change allow clients to send metadata through the _meta field as specified by the protocol.

It is important to expose _meta since there might be some metadata required by the server to control how the tool works (such as client preferences, its localization and so on). In some cases we also don't want the Agent/LLM to be aware of such data; it should be known by the MCP Host and Server only; therefore it cannot be exposed as tool usual arguments.

This feature has already been requested by me and another user - so it might benefit another people as well.

I also started a discussion about _meta being exposed by FastMCP Client, but they will wait until its implemented in here.

How Has This Been Tested?

I tested it on my local environment using a self-made MCP Server.

Since _meta is currently being used for progress report tokens, I also ensured this feature doesn't break progress_callback.

I'd be happy to implement the required unit-tests if someone can point the best test-file for it.

Breaking Changes

There are no breaking changes. The python-sdk already considers that _meta can carry data other than progressToken.

Also types.RequestParams.Meta model is already configured to allow extra key-values.

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

I decided to expose meta as a plain dict instead of types.RequestParams.Meta since, from my understanding, mcp.types shouldn't be exposed to final users.

Metadata could be exposed by another interfaces as well, such as list_tools, list_prompts and etc. I'm sticking with tool_call for now, but would be happy to replicate it to the other interfaces.

@samchenatti samchenatti requested a review from a team as a code owner August 3, 2025 18:43
@samchenatti samchenatti requested a review from ihrpr August 3, 2025 18:43
Copy link
Member

@dsp-ant dsp-ant left a comment

Choose a reason for hiding this comment

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

I am okay with this change, but I think we should make the ordering such that it's BC compatbile, and create a follow up for the SDK version 2.0 to reconsider the ordering and force named arguments.

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.

2 participants