tooluniverse.mcp_client_tool moduleΒΆ
MCP Client Tool for ToolUniverse
This module provides a tool that acts as a client to connect to an existing MCP server, supporting all MCP functionality including tools, resources, and prompts.
- class tooluniverse.mcp_client_tool.BaseMCPClient(server_url: str, transport: str = 'http', timeout: int = 30)[source]ΒΆ
Bases:
object
Base MCP client with common functionality shared between MCPClientTool and MCPAutoLoaderTool. Provides session management, request handling, and async cleanup patterns.
- async _initialize_mcp_session()[source]ΒΆ
Initialize MCP session if needed (for compatibility with different MCP servers)
- class tooluniverse.mcp_client_tool.MCPAutoLoaderTool(tool_config)[source]ΒΆ
Bases:
BaseTool
,BaseMCPClient
An advanced MCP tool that automatically discovers and loads all tools from an MCP server. It can register discovered tools as individual ToolUniverse tools for seamless usage.
- async auto_load_and_register(engine) Dict[str, Any] [source]ΒΆ
Automatically discover, load and register all MCP tools
- async call_tool(tool_name: str, arguments: Dict[str, Any]) Dict[str, Any] [source]ΒΆ
Directly call an MCP tool by name
- generate_proxy_tool_configs() List[Dict[str, Any]] [source]ΒΆ
Generate proxy tool configurations for discovered tools
- class tooluniverse.mcp_client_tool.MCPClientTool(tool_config)[source]ΒΆ
Bases:
BaseTool
,BaseMCPClient
A tool that acts as an MCP client to connect to existing MCP servers. Supports both HTTP and WebSocket transports.
- async call_tool(name: str, arguments: Dict[str, Any]) Dict[str, Any] [source]ΒΆ
Call a tool on the MCP server
- class tooluniverse.mcp_client_tool.MCPProxyTool(tool_config)[source]ΒΆ
Bases:
MCPClientTool
A proxy tool that automatically forwards tool calls to an MCP server. This creates individual tools for each tool available on the MCP server.
- class tooluniverse.mcp_client_tool.MCPServerDiscovery[source]ΒΆ
Bases:
object
Helper class to discover and create tool configurations for MCP servers.
- static create_mcp_tools_config(server_configs: List[Dict[str, str]]) List[Dict[str, Any]] [source]ΒΆ
Create tool configurations for multiple MCP servers.
- Parameters:
server_configs β List of server configurations, each containing: - server_url: URL of the MCP server - transport: βhttpβ or βwebsocketβ (optional, defaults to βhttpβ) - server_name: Name prefix for tools (optional)
- Returns:
List of tool configurations that can be loaded into ToolUniverse