feat(client): add _meta support to call_tool for tool calls\n\n- Adds…#1003
Closed
pyrotank41 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Closed
feat(client): add _meta support to call_tool for tool calls\n\n- Adds…#1003pyrotank41 wants to merge 1 commit intomodelcontextprotocol:mainfrom
pyrotank41 wants to merge 1 commit intomodelcontextprotocol:mainfrom
Conversation
… optional _meta parameter to ClientSession.call_tool and ClientSessionGroup.call_tool\n- Passes _meta as request metadata for tool calls, enabling user-supplied context or progress tokens\n- Backward compatible: does not affect existing usage\n- Adds/updates tests to verify _meta passthrough and correct request construction
This was referenced Jun 22, 2025
Contributor
|
Thank you for your contribution! One of the examples mentioned in PR is passing progress token. SDK handless it automatically, when the User context use case sounds more like an extension and should be handled outside of the SDK. Please re-open the PR in case there are concrete examples for passing _meta and I missed something. |
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.
Adds optional
_metaparameter support toClientSession.call_toolandClientSessionGroup.call_toolmethods, enabling users to pass request metadata (such as progress tokens or user context) in a clean, explicit, and backward-compatible way.Motivation and Context
Currently, users who need to pass metadata (like progress tokens or user context) to tool calls have to work around the SDK's limitations by either:
call_toolargumentsparameter (which is not semantically correct)This change provides a proper, first-class way to pass request metadata while maintaining full backward compatibility.
How Has This Been Tested?
ClientSession.call_toolandClientSessionGroup.call_toolwith_metaparameter_metadata is properly passed through to the underlying request structureBreaking Changes
No breaking changes. The
_metaparameter is optional and defaults toNone, so existing code will continue to work without modification.Types of changes
Checklist
Additional context
RequestParams.Metastructure that was already defined in the types_metaparameter is passed as the_metafield inCallToolRequestParams, which inherits fromRequestParams