Expand description
MCP server lifecycle management.
This module provides McpServerManager, which handles spawning MCP
servers (stdio or HTTP+SSE), discovering their tools, and registering
them into the agent’s ToolRegistry. Each MCP tool is wrapped in a
thin adapter that delegates execution to the corresponding server.
§Architecture
┌─────────────────────────────────────────────┐
│ McpServerManager │
│ ┌──────────┐ ┌──────────┐ ┌──────────┐ │
│ │ Server A │ │ Server B │ │ Server C │ │
│ │ (stdio) │ │ (SSE) │ │ (stdio) │ │
│ └────┬─────┘ └────┬─────┘ └────┬─────┘ │
│ │ │ │ │
│ ┌────▼──────────────▼──────────────▼────┐ │
│ │ ToolRegistry │ │
│ │ mcp__A__tool1 mcp__B__tool2 ... │ │
│ └───────────────────────────────────────┘ │
└─────────────────────────────────────────────┘Structs§
- Json
RpcError - A JSON-RPC 2.0 error object.
- Json
RpcRequest - A JSON-RPC 2.0 request.
- Json
RpcResponse - A JSON-RPC 2.0 response.
- McpServer
Manager - Manages the lifecycle of one or more MCP servers and their tools.
- McpServer
Runner - Runs the MCP server stdio loop: reads JSON-RPC from stdin, dispatches, and writes responses to stdout.
Functions§
- dispatch_
request - Dispatch a parsed JSON-RPC request and return a response.
Returns
Nonefor notifications (no response needed).