Skip to content

Commit e76a774

Browse files
committed
feat: enhance ClientSessionGroup.call_tool method to support full ClientSession.callback
1 parent de2289d commit e76a774

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/mcp/client/session_group.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from mcp.client.stdio import StdioServerParameters
2626
from mcp.client.streamable_http import streamablehttp_client
2727
from mcp.shared.exceptions import McpError
28+
from mcp.shared.session import ProgressFnT
2829

2930

3031
class SseServerParameters(BaseModel):
@@ -172,11 +173,25 @@ def tools(self) -> dict[str, types.Tool]:
172173
"""Returns the tools as a dictionary of names to tools."""
173174
return self._tools
174175

175-
async def call_tool(self, name: str, args: dict[str, Any]) -> types.CallToolResult:
176+
async def call_tool(
177+
self,
178+
name: str,
179+
args: dict[str, Any],
180+
read_timeout_seconds: timedelta | None = None,
181+
progress_callback: ProgressFnT | None = None,
182+
*,
183+
meta: dict[str, Any] | None = None,
184+
) -> types.CallToolResult:
176185
"""Executes a tool given its name and arguments."""
177186
session = self._tool_to_session[name]
178187
session_tool_name = self.tools[name].name
179-
return await session.call_tool(session_tool_name, args)
188+
return await session.call_tool(
189+
session_tool_name,
190+
args,
191+
read_timeout_seconds=read_timeout_seconds,
192+
progress_callback=progress_callback,
193+
meta=meta,
194+
)
180195

181196
async def disconnect_from_server(self, session: mcp.ClientSession) -> None:
182197
"""Disconnects from a single MCP server."""

0 commit comments

Comments
 (0)