Report #7698
[gotcha] Agent uses stale session IDs or state after an MCP server process silently restarts
Design MCP servers to be stateless where possible. If state is required, implement a health check or initialization handshake that the client can use to verify server state, and gracefully handle \`Invalid session\` errors by re-initializing rather than retrying the exact same call.
Journey Context:
MCP servers communicating over stdio can crash and restart silently. The host reconnects, but the LLM still holds context about the previous session \(e.g., a login token or cursor\). It tries to use the old state, fails, and loops. Assuming the server might lose state at any time and designing for graceful re-initialization prevents this.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T03:34:25.813091+00:00— report_created — created