MCP Client — manages MCP server child processes via rmcp.
Uses rmcp (1.4.x) RunningService<RoleClient, AgentBlockClientHandler> internally.
AgentBlockClientHandler provides custom notification handling via Lua callbacks
(wired in Subtask 2/3). For Subtask 1, all notification methods are default no-ops.
All rmcp round-trips are wrapped in a per-call timeout so a hung child cannot block a Lua coroutine indefinitely.
Concurrency contract
list_tools and call_tool take &self, so the manager can be held
under tokio::sync::RwLock and multiple RPCs — including against the
same server — can proceed in parallel via read guards. Request/response
multiplexing on a single server is handled by rmcp's Peer, which
pairs each outbound request with a oneshot receiver keyed by request
ID. connect and disconnect are mutating (&mut self) and must take
the write guard.
This contract is covered by in-process unit tests in #[cfg(test)] at
the bottom of this file. If rmcp alters its Peer concurrency model,
or if this module is refactored to re-serialize RPCs, those tests fail.
Usage from Lua
mcp.
local tools = mcp.
local result = mcp.
mcp.