Skip to content

add progress_callback to mcp call_tool #1494

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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/google/adk/tools/mcp_tool/mcp_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from google.genai.types import FunctionDeclaration
from typing_extensions import override

from mcp.shared.session import ProgressFnT

from .._gemini_schema_util import _to_gemini_schema
from .mcp_session_manager import MCPSessionManager
from .mcp_session_manager import retry_on_closed_resource
Expand Down Expand Up @@ -106,7 +108,7 @@ def _get_declaration(self) -> FunctionDeclaration:
return function_decl

@retry_on_closed_resource("_mcp_session_manager")
async def run_async(self, *, args, tool_context: ToolContext):
async def run_async(self, *, args, tool_context: ToolContext, progress_callback: ProgressFnT | None = None):
"""Runs the tool asynchronously.

Args:
Expand All @@ -119,5 +121,5 @@ async def run_async(self, *, args, tool_context: ToolContext):
# Get the session from the session manager
session = await self._mcp_session_manager.create_session()

response = await session.call_tool(self.name, arguments=args)
response = await session.call_tool(self.name, arguments=args, progress_callback)
return response