agentscope.service.mcp_manager module
This module manages MCP (ModelContextProtocal) sessions and tool execution within an asynchronous context. It includes functionality to create, manage, and close sessions, as well as execute various tools provided by an MCP server.
- class MCPSessionHandler(name: str, config: dict[str, Any], sync: bool = True)[源代码]
基类:
object
Handles MCP session connections and tool execution.
- async execute_tool(tool_name: str, **kwargs: Any) ServiceResponse [源代码]
Execute a tool and return ServiceResponse
- sync_exec(func: Callable, *args: Any, **kwargs: Any) Any [源代码]
Execute a function synchronously.
- 参数:
func (Callable) -- The asynchronous function to execute.
*args (Any) -- Positional arguments to pass to the function.
**kwargs (Any) -- Keyword arguments to pass to the function.
- 返回:
The result of the function execution.
- 返回类型:
Any