Open
Conversation
MCPToolset now extends AsyncToolset and gains an `async_mode=True` flag. When set, MCP tools are built with an `AsyncRunContext` parameter that forwards MCP progress notifications via `ctx.update`, so the agent can narrate progress while a slow MCP tool runs in the background instead of blocking the reply loop. `AsyncToolset` no longer stores `get_running_tasks` / `cancel_task` in `_tools`; they're exposed through a `tools` property override that subclasses can condition. `MCPToolset` overrides it to expose the helpers only when `async_mode=True`, so the legacy MCP UX is unchanged when the flag is off. `MCPServer.list_tools` now caches per `async_mode`, and the example MCP server gains a long-running `book_flight` tool that emits progress updates.
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
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.
Summary
MCPToolsetnow extendsAsyncToolsetand gains a keyword-onlyasync_modeflag. When enabled, MCP tools are built with anAsyncRunContextparameter and the MCP server's progress notifications are forwarded viactx.update, so the agent can narrate progress while a slow MCP tool runs in the background.Example
examples/voice_agents/mcp/server.pynow ships a fastget_weather(sync, no progress) and a long-runningbook_flightthat emitsctx.report_progressupdates over ~70s.mcp-agent.pyusesasync_mode=Trueand bumpsclient_session_timeout_seconds=120since the per-request timeout otherwise fires beforebook_flightreturns.