Skip to main content

Module mcp_pool

Module mcp_pool 

Source
Expand description

The shared, lazily-connected MCP pool.

Per-agent [[mcp_servers]] let a blueprint carry its own MCP tool dependencies. Rather than spawn a connection per agent, all agents share one leviath_mcp::ToolExecutor (the client store) fronted by this pool: a server is connected on first use, deduped by its config signature, and its tools reused by every agent that declares it. Connection is async and is driven from every spawn path: the spawn preprocessor for top-level and sub-agent spawns (both run in the serve loop), McpPool::warm_recovered for runs reloaded on daemon restart, and a detached warm task for fan-out workers. So the pool is warm by the time an agent’s tools are advertised.

Structs§

McpPool
A shared MCP connection pool over one executor, caching each connected server’s advertised tool defs by config signature.

Constants§

DEFAULT_MCP_IDLE_DISCONNECT_SECS
Default for how long a per-agent MCP server may sit with zero leasing runs before its connection is torn down. Long enough that back-to-back runs of the same blueprint reuse the warm connection (and never re-trigger an OAuth flow between them); short enough that a one-off run’s servers do not hold child processes and buffers for the daemon’s remaining life.

Functions§

parse_blueprint_mcp_servers
Parse a blueprint manifest’s [[mcp_servers]] array. Parsed CLI-side because leviath-core cannot depend on leviath-mcp (that crate already depends on core - a cycle). Returns an empty vec when the section is absent or malformed; a malformed entry is skipped with a warning.