mcp_pool
mcp_pool
¶
Shared MCP server pool manager for the conductor.
The conductor-side MCP pool starts one process per configured MCP server and, for stdio servers, exposes that process through a multiplexed Unix socket bridge. Multiple MCP clients can connect through the proxy shim; request IDs are rewritten upstream and restored on the way back to the originating client.
Lifecycle:
- start_all() — starts all configured servers on daemon startup
- stop_all() — terminates all servers on daemon shutdown
- health_check(name) — verifies a server process is alive
- get_socket_path(name) — returns the socket path for agent access
The manager owns the stdio-to-socket bridge for transport: stdio entries.
Native socket/http transports can still use their configured socket/path as a
future extension.
Classes¶
McpServerState
¶
Bases: str, Enum
State of a managed MCP server process.
McpPoolManager
¶
Manages MCP server process lifecycle for the conductor.
Reads McpPoolConfig and starts/stops server processes. Tracks state per server and provides socket path lookups for agent sandboxes.
Usage::
manager = McpPoolManager(config.mcp_pool)
await manager.start_all()
# During operation
if await manager.health_check("github"):
path = manager.get_socket_path("github")
# Bind-mount path into agent sandbox
# On shutdown
await manager.stop_all()
Source code in src/marianne/daemon/mcp_pool.py
Methods:¶
server_names
¶
is_running
¶
Check if a server is currently running.
Reconciles the recorded state against the live process/bridge: a handle recorded as RUNNING whose process has exited (or whose bridge is dead) is transitioned to FAILED as a side effect, so config generation and status inventories exclude the dead server immediately.
Source code in src/marianne/daemon/mcp_pool.py
get_status
¶
Get the state of all servers.
get_socket_path
¶
Get the Unix socket path for a server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Server name. |
required |
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to the Unix socket, or None if the server is not configured. |
Source code in src/marianne/daemon/mcp_pool.py
get_all_socket_paths
¶
Get socket paths for all configured servers.
start_all
async
¶
Start the pool once and supervise it until stop_all().
Source code in src/marianne/daemon/mcp_pool.py
stop_all
async
¶
health_check
async
¶
Check if a server process is alive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Server name. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the server process is running, False otherwise. |
Source code in src/marianne/daemon/mcp_pool.py
generate_mcp_config_file
¶
Generate an MCP config JSON file for MCP-native CLI instruments.
Produces a file compatible with claude-code's --mcp-config flag,
pointing each server at the proxy shim which bridges to the pool's
Unix sockets.
The config file is written atomically (write-to-temp + rename) to prevent partial reads by concurrent processes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace
|
Path
|
Directory where the config file is written. |
required |
server_names
|
list[str] | None
|
Optional subset of servers to include. If None, all running servers are included. |
None
|
Returns:
| Type | Description |
|---|---|
Path | None
|
Path to the generated config file, or None if no servers are |
Path | None
|
running. |