Expand description
MCP (Model Context Protocol) integration — JSON-RPC client, tool bridging, lazy loading.
Modules§
- descriptors
- Task 19 (Commit A) — safe local MCP descriptor cache and dormant deferred-tool integration (spec §7.4).
- lease
- Task 19 (Commit B) — session-scoped exact MCP runtime leases (spec §7.4).
Structs§
- McpConfig
- MCP config file format: { “mcpServers”: { “name”: { command, args, env } } }
- McpConnect
Tool - A tool that lazily connects to MCP servers on demand. Instead of spawning all servers at startup (burning tokens on 65 tool schemas), this registers ONE tool that the model calls to activate a specific server.
- McpLease
Capability - Typed per-session lease capability handed to tool contexts: the exact session identity plus the shared manager. Never widens to a server grant — every call re-validates the exact tool and fingerprint.
- McpRuntime
Manager - Session-scoped exact MCP runtime lease manager. See module docs.
- McpServer
Config - MCP server configuration — matches claude-code/gemini-cli format.
- McpSession
EndGuard - Durable last-owner session scope. The Runtime mints ONE of these per
tool session (wrapped in an
Arcshared by every runtime clone and in-flight stream); streams HOLD it, never construct or drop their own. Leases therefore survive across provider turns, and only the drop of the LAST owner — true session end — terminates the session’s leases. - McpTool
- A dynamic tool backed by an MCP server connection. The connection is shared (Arc<Mutex<>>) across all tools from the same server.
Constants§
- MCP_
CONFIG_ MAX_ ARGS - MCP_
CONFIG_ MAX_ ARG_ BYTES - MCP_
CONFIG_ MAX_ BYTES - Hard byte bound on
mcp.json. - MCP_
CONFIG_ MAX_ COMMAND_ BYTES - MCP_
CONFIG_ MAX_ ENV_ ENTRIES - MCP_
CONFIG_ MAX_ ENV_ KEY_ BYTES - MCP_
CONFIG_ MAX_ ENV_ VALUE_ BYTES - MCP_
CONFIG_ MAX_ SERVERS - Structural bounds on
mcp.json(Task 19 review): the 1 MiB byte cap alone leaves server/env counts and string shapes unbounded. Violations fail the WHOLE config closed with a static reason. - MCP_
CONFIG_ MAX_ SERVER_ NAME_ BYTES
Functions§
- connect_
mcp_ servers - Connect to all configured MCP servers and register their tools. Returns the number of tools registered.
- load_
mcp_ config - Load MCP config from ~/.synaps-cli/mcp.json (or profile variant).
- setup_
lazy_ mcp - Set up MCP loading at engine boot, before any session tool set exists.
- validate_
mcp_ config - Validate config structure before ANY use. Static reasons only — no config content is ever echoed.