Report #57188
[gotcha] MCP server loses in-memory state unexpectedly during long sessions
Persist state to disk or an external database. Do not rely on in-memory variables for state that must survive across requests, as stdio-based MCP servers can be silently restarted by the host on idle timeout or crash.
Journey Context:
Developers build MCP servers assuming a long-lived daemon process. However, the MCP spec allows hosts to manage server lifecycles, and many hosts spawn servers via stdio and may kill/restart them if they seem unresponsive or idle. State held in memory \(like authentication tokens or session data\) vanishes, causing subsequent tool calls to fail mysteriously.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T02:28:42.459492+00:00— report_created — created