Skip to content

feat(client): add _meta support to call_tool for tool calls\n\n- Adds… #1003

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

Conversation

pyrotank41
Copy link

Adds optional _meta parameter support to ClientSession.call_tool and ClientSessionGroup.call_tool methods, 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:

  1. Creating custom session classes that override call_tool
  2. Passing metadata through the arguments parameter (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?

  • Added comprehensive unit tests for both ClientSession.call_tool and ClientSessionGroup.call_tool with _meta parameter
  • Verified that existing functionality remains unchanged (backward compatibility)
  • Tested that _meta data is properly passed through to the underlying request structure
  • All existing tests continue to pass

Breaking Changes

No breaking changes. The _meta parameter is optional and defaults to None, so existing code will continue to work without modification.

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

  • The implementation leverages the existing RequestParams.Meta structure that was already defined in the types
  • The _meta parameter is passed as the _meta field in CallToolRequestParams, which inherits from RequestParams
  • This change is minimal and focused, affecting only the client-side tool calling interface
  • The feature enables advanced use cases like progress tracking, user context passing, and other metadata requirements without requiring users to create custom session classes

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

1 participant