from ai_infra.mcp import MCPClientMCP Client for connecting to one or more MCP servers. Production-ready features: - Multi-server support with automatic discovery - All transports: stdio, sse, streamable_http - Auto-reconnect with configurable retry - Health checks - Timeout handling - Graceful shutdown via async context manager
# Simple usage
mcp = MCPClient([
{"command": "npx", "args": ["-y", "@anthropic/mcp-server-filesystem", "/tmp"]},
])
await mcp.discover()
tools = await mcp.list_tools()
# With async context manager
async with MCPClient(configs) as mcp:
tools = await mcp.list_tools()
# Automatic cleanup on exit