tooluniverse.mcp_tool_registry module¶
MCP Tool Registration System for ToolUniverse
This module provides functionality to register local tools as MCP tools and enables automatic loading of these tools on remote servers via ToolUniverse integration.
Usage¶
Server Side (Tool Provider): .. code-block:: python
- from tooluniverse.mcp_tool_registry import (
register_mcp_tool, start_mcp_server
)
- @register_mcp_tool(
tool_type_name=”my_analysis_tool”, config={
“description”: “Performs custom data analysis”
}, mcp_config={
“server_name”: “Custom Analysis Server”,
“host”: “0.0.0.0”, “port”: 8001
}
) class MyAnalysisTool:
- def run(self, arguments):
return {“result”: “analysis complete”}
# Start MCP server with registered tools start_mcp_server() ```
Client Side (Tool Consumer): ```python from tooluniverse import ToolUniverse
# Auto-discover and load MCP tools from remote servers tu = ToolUniverse() tu.load_mcp_tools(server_urls=[”http://localhost:8001”])
# Use the remote tool result = tu.run_tool(“my_analysis_tool”, {“data”: “input”}) ```
- tooluniverse.mcp_tool_registry.register_mcp_tool(tool_type_name=None, config=None, mcp_config=None)[source]¶
Decorator to register a tool class for MCP server exposure.
This decorator registers tools both globally (via register_tool) and for MCP server management. The global registration allows ToolUniverse to properly instantiate tools, while MCP registration controls server exposure. The parameters and behavior are identical to register_tool, with an optional mcp_config parameter for server configuration.
- Parameters:
tool_type_name (
str, optional) – Custom name for the tool type. Same as register_tool.config (
dict, optional) – Tool configuration dictionary. Same as register_tool.mcp_config (
dict, optional) – Additional MCP server configuration. Can include: - server_name: Name of the MCP server - host: Server host (default: “localhost”) - port: Server port (default: 8000) - transport: “http” or “stdio” (default: “http”) - auto_start: Whether to auto-start server when tool is registered
- Returns:
Decorator function that registers the tool class for MCP server only.
- Return type:
function
- tooluniverse.mcp_tool_registry.register_mcp_tool_from_config(tool_class, config)[source]¶
Register an existing tool class as MCP tool using configuration.
This function provides a programmatic way to register tools as MCP tools without using decorators, useful for dynamic tool registration. Just like register_mcp_tool decorator, this registers tools for MCP exposure only.
- tooluniverse.mcp_tool_registry.get_mcp_tool_configs()[source]¶
Get the MCP tool configurations for ToolUniverse.
- tooluniverse.mcp_tool_registry.get_registered_tools()[source]¶
Get a list of all registered MCP tools with their information.
- Returns
List of dictionaries containing tool information including name, description, and port.
- tooluniverse.mcp_tool_registry.get_mcp_server_configs()[source]¶
Get the current MCP server configurations grouped by port.
- tooluniverse.mcp_tool_registry.start_mcp_server(port=None, **kwargs)[source]¶
Start MCP server(s) for registered tools.
- Parameters:
port (
int, optional) – Specific port to start server for. If None, starts servers for all registered tools.**kwargs – Additional arguments passed to SMCP server
- tooluniverse.mcp_tool_registry.start_mcp_server_for_tool(tool_name)[source]¶
Start MCP server for a specific tool.
- tooluniverse.mcp_tool_registry.stop_mcp_server(port=None)[source]¶
Stop MCP server(s).
- Parameters:
port (
int, optional) – Specific port to stop server for. If None, stops all servers.
- tooluniverse.mcp_tool_registry.list_mcp_tools()[source]¶
List all registered MCP tools with their configurations.
- tooluniverse.mcp_tool_registry.get_mcp_tool_urls()[source]¶
Get list of MCP server URLs for all registered tools.