Skip to main content

Crate agent_block_mcp

Crate agent_block_mcp 

Source
Expand description

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.connect("outline", "outline-mcp", {})
local tools = mcp.list_tools("outline")
local result = mcp.call("outline", "shelf", {})
mcp.disconnect("outline")

Re-exports§

pub use handler::AgentBlockClientHandler;

Modules§

handler
AgentBlockClientHandler — custom ClientHandler for agent-block MCP clients.
lua_json
Lua ↔ JSON value bridge.

Structs§

McpManager

Constants§

DEFAULT_RPC_TIMEOUT
Default RPC round-trip timeout when no explicit value is provided.