mirror of
https://github.com/lWolvesl/claw-code.git
synced 2026-04-02 07:41:52 +08:00
The runtime crate already had typed MCP config parsing, bootstrap metadata, and stdio JSON-RPC transport primitives, but it lacked the stateful layer that owns configured subprocesses and routes discovered tools back to the right server. This change adds a thin lazy McpServerManager in mcp_stdio, keeps unsupported transports explicit, and locks the behavior with subprocess-backed discovery, routing, reuse, shutdown, and error tests. Constraint: Keep the change narrow to the runtime crate and stdio transport only Constraint: Reuse existing MCP config/bootstrap/process helpers instead of adding new dependencies Rejected: Eagerly spawn all configured servers at construction | unnecessary startup cost and failure coupling Rejected: Spawn a fresh process per request | defeats lifecycle management and tool routing cache Confidence: high Scope-risk: moderate Reversibility: clean Directive: Keep higher-level runtime/session integration separate until a caller needs this manager surface Tested: cargo fmt --all; cargo clippy -p runtime --all-targets -- -D warnings; cargo test -p runtime Not-tested: Integration into conversation/runtime flows outside direct manager APIs