diff --git a/src/agentscope/mcp/_client_base.py b/src/agentscope/mcp/_client_base.py index 368887034c..ee1dc6f2cb 100644 --- a/src/agentscope/mcp/_client_base.py +++ b/src/agentscope/mcp/_client_base.py @@ -33,6 +33,7 @@ async def get_callable_function( self, func_name: str, wrap_tool_result: bool = True, + execution_timeout: float | None = None, ) -> Callable: """Get a tool function by its name.""" diff --git a/src/agentscope/tool/_toolkit.py b/src/agentscope/tool/_toolkit.py index d17257f65c..d640437403 100644 --- a/src/agentscope/tool/_toolkit.py +++ b/src/agentscope/tool/_toolkit.py @@ -1056,6 +1056,7 @@ async def register_mcp_client( "raise", "rename", ] = "raise", + execution_timeout: float | None = None, ) -> None: """Register tool functions from an MCP client. @@ -1092,6 +1093,9 @@ async def register_mcp_client( - 'skip': skip the registration of the new tool function. - 'rename': rename the new tool function by appending a random suffix to make it unique. + execution_timeout (`float | None`, optional): + The preset timeout in seconds for calling the tool function. + If `None`, no timeout will be applied. """ if ( isinstance(mcp_client, StatefulClientBase) @@ -1151,6 +1155,7 @@ async def register_mcp_client( func_obj = await mcp_client.get_callable_function( func_name=mcp_tool.name, wrap_tool_result=True, + execution_timeout=execution_timeout, ) # Prepare preset kwargs