create_client

View as MarkdownOpen in Claude

Create and start a new MCP client for the named service. The client spawns a sandboxed subprocess, initializes the MCP session via JSON-RPC, and retrieves the list of available tools. Raises ValueError if the service is unknown or disabled, and RuntimeError if the MCP process fails to start.

Parameters

service_name
strRequired

Name of the service to create a client for. Must match a key in the services section of the configuration.

Returns

MCPClient — A started MCP client connected to the service.

Example

from signalwire.mcp_gateway import MCPManager
config = {
"services": {
"todo": {"command": ["python3", "todo_mcp.py"], "description": "Todo list", "enabled": True}
}
}
manager = MCPManager(config)
client = manager.create_client("todo")
tools = client.get_tools()
print(f"Available tools: {[t['name'] for t in tools]}")
client.stop()