feat: support progress_callback propagation in ClientSession (issue #1248) #1249
+3
−1
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.
closes #1248
Motivation and Context
This change introduces support for injecting a default
progress_handler
intoClientSession
. It solves the issue where downstream libraries (e.g., LangChain's MCP adapter) access the rawclient.session
and make tool calls that bypass the top-levelfastmcp.Client
’sprogress_handler
, leading to missing progress reports. With this enhancement, consistent progress reporting is ensured whether tools are called through the high-level client or the lower-level session.How Has This Been Tested?
This feature has been tested within an async environment using:
ClientSession.call_tool(...)
to ensure the default handler is triggered.progress_callback
to ensure override behavior works correctly.langchain_mcp_adapters
to confirm downstream compatibility and improved reporting.Breaking Changes
No breaking changes. This enhancement is backward-compatible. Existing users who do not pass a
progress_handler
will see no change in behavior. Users who want consistent progress reporting can optionally provide a handler toClientSession
.Types of changes
Checklist
Additional context
This feature enables clean integration with ecosystem libraries like LangChain without requiring redundant progress callback plumbing at every call site.