tooluniverse.mcp_integration moduleΒΆ

ToolUniverse MCP Integration Extensions

This module extends ToolUniverse with methods to automatically discover and load MCP tools from remote servers, providing seamless integration between local tools and remote MCP services.

tooluniverse.mcp_integration.load_mcp_tools(self, server_urls=None, **kwargs)[source]ΒΆ

Load MCP tools from remote servers into this ToolUniverse instance.

This method automatically discovers tools from MCP servers and registers them as ToolUniverse tools, enabling seamless usage of remote capabilities.

Parameters:
  • server_urls (list of str, optional) –

    List of MCP server URLs to load tools from. Examples:

    If None, attempts to discover from local MCP tool registry.

  • **kwargs –

    Additional configuration options:

    • tool_prefix (str): Prefix for loaded tool names (default: β€œmcp_”)

    • timeout (int): Connection timeout in seconds (default: 30)

    • auto_register (bool): Whether to auto-register discovered tools (default: True)

    • selected_tools (list): Specific tools to load from each server

    • categories (list): Tool categories to filter by

Returns:

Summary of loaded tools with counts and any errors encountered.

Return type:

dict

Examples

Load from specific servers:

tu = ToolUniverse()

# Load tools from multiple MCP servers
result = tu.load_mcp_tools([
    "http://localhost:8001",  # Local analysis server
    "http://ml-server:8002",  # Remote ML server
    "ws://realtime:9000"      # WebSocket server
])

print(f"Loaded {result['total_tools']} tools from {result['servers_connected']} servers")

Load with custom configuration:

tu.load_mcp_tools(
server_urls=["http://localhost:8001"],
tool_prefix="analysis\_",
timeout=60,
selected_tools=["protein_analysis", "drug_interaction"]

Auto-discovery from local registry: `python # If you have registered MCP tools locally, auto-discover their servers tu.load_mcp_tools()  # Uses servers from mcp_tool_registry `

tooluniverse.mcp_integration.discover_mcp_tools(self, server_urls=None, **kwargs)[source]ΒΆ

Discover available tools from MCP servers without loading them.

This method connects to MCP servers to discover what tools are available without actually registering them in ToolUniverse. Useful for exploration and selective tool loading.

Parameters:
  • server_urls (list of str, optional) – List of MCP server URLs to discover from

  • **kwargs – Additional options: - timeout (int): Connection timeout (default: 30) - include_schemas (bool): Include tool parameter schemas (default: True)

Returns:

Discovery results with tools organized by server

Return type:

dict

Examples

tu = ToolUniverse()

# Discover what's available
discovery = tu.discover_mcp_tools([
    "http://localhost:8001",
    "http://ml-server:8002"
])

# Show available tools
for server, info in discovery["servers"].items():
    print(f"\n{server}:")
    for tool in info.get("tools", []):
        print(f"  - {tool['name']}: {tool['description']}")
tooluniverse.mcp_integration.list_mcp_connections(self)[source]ΒΆ

List all active MCP connections and loaded tools.

Returns:

Information about MCP connections, auto-loaders, and loaded tools

Return type:

dict

Examples

tu = ToolUniverse()
tu.load_mcp_tools(["http://localhost:8001"])

connections = tu.list_mcp_connections()
print(f"Active MCP connections: {len(connections['connections'])}")