mcp: disk-cache tool schemas + connect-on-first-call (#206 Phase 2)
Infrastructure for advertising MCP tools at spawn without blocking on connection, so the agent is reachable immediately AND there is no prompt-cache miss (the previous fix accepted one intentional miss). - schema_cache: new `~/.jcode/mcp-schema-cache.json`. Caches each server's `tools/list` schemas keyed by a fingerprint of its launch config (command + args + sorted env + shared). A config change changes the fingerprint and invalidates the stale entry, so we never advertise tools for a reconfigured server. The cache is a hint; live connections reconcile it. Full unit tests (fingerprint stability/sensitivity, env order-independence, fingerprint-gated reads, change detection, pruning, load/save round-trip). - protocol: derive `Serialize` on `McpToolDef` so schemas can be cached. - manager: `call_tool` now connects-on-first-call — if a server is configured but not yet connected (because we advertised cached tools early), it connects first, bounded by a 30s timeout, then retries. Clean, server-named tool errors on connect failure/timeout; never hangs startup. Added `ensure_server_connected(timeout)`. Tests cover unconfigured-server errors and bounded failure for a broken server. - tool: `create_mcp_tools_from_cached()` builds proxy tools from cached schemas without a live connection (they connect on first call). This is the reusable layer; the registration wiring lands next.
J
jeremy committed
573e9b1c007b922948ccff226d5638c7d2736705
Parent: 1c1d18e