Expose RequestParams._meta in ClientSession.call_tool #1231
+7
−4
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
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 breakprogress_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 thanprogressToken
.Also
types.RequestParams.Meta
model is already configured to allow extra key-values.Types of changes
Checklist
Additional context
I decided to expose
meta
as a plain dict instead oftypes.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 withtool_call
for now, but would be happy to replicate it to the other interfaces.