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

1from signalwire.mcp_gateway import MCPManager
2
3config = {
4 "services": {
5 "todo": {"command": ["python3", "todo_mcp.py"], "description": "Todo list", "enabled": True}
6 }
7}
8
9manager = MCPManager(config)
10client = manager.create_client("todo")
11tools = client.get_tools()
12print(f"Available tools: {[t['name'] for t in tools]}")
13client.stop()