Report #78697
[gotcha] Agent reconnects to MCP servers on every turn, causing latency spikes and losing server-side state
Maintain persistent MCP server connections across the full agent session. Initialize once at session start, cache the tool list and server capabilities, and reuse the connection. Implement health checks \(e.g., ping on idle\) and reconnect only on detected failure. Never tear down and rebuild MCP connections between conversation turns.
Journey Context:
Some agent frameworks treat MCP connections as stateless request-response channels, connecting and disconnecting on each turn. The MCP initialization handshake \(capability negotiation, tool discovery, resource listing\) is expensive — it can add 1-5 seconds per turn. More critically, server-side state is lost on disconnect: authenticated sessions, cached data, open file handles, and in-progress operations. MCP is explicitly designed for persistent, stateful connections. The spec's lifecycle model is initialize-once, use-many. Reconnecting every turn is like re-authenticating to a database before every query — technically possible but catastrophically wasteful.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T14:41:07.355251+00:00— report_created — created