Skip to content

Simplified client progress_callback support #632

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

Conversation

davemssavage
Copy link

@davemssavage davemssavage commented May 5, 2025

Add support for an optional callback to be called during tool execution to inform of progress

Motivation and Context

Tracking progress on the client is useful for long running tasks, the low level primitives are available via the protocol however they're a little complex to setup. This patch adds an optional calllback to to the call_tool request and does the heavy lifting for the caller so they don't have to do this.

The soluiton is implemented on the BaseSession object so the approach can be used for both client->server and server->client requests. Currently the only top level method that supports this is clientsession.call_tool which seems like the most common use case. If there are other are other use cases they can be added easilly.

How Has This Been Tested?

Unit testing only

Breaking Changes

None expected

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

If this looks useful I can add documentation to the patch

@davemssavage davemssavage changed the title Client progress Simplified client progress_callback support May 5, 2025
progress_id = None
send_request = None

if progress_callback is not None:
Copy link
Author

Choose a reason for hiding this comment

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

Nasty if/else branching, ugly but functional main challenge is how to inject meta into params when the type of the request is unknown. Open to ideas on how to make this cleaner

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