Report #14942
[gotcha] Agent assumes MCP server state persists between tool calls, but server was restarted or is stateless
Design every tool to be stateless — pass all required context as explicit parameters. If state is necessary, use MCP resources with stable URIs or return a session token that the agent must pass back. Never assume a previous tool call's side effects \(temp files, in-memory caches, open connections\) are visible to the next call. After any state-mutating tool call, verify the state with a read call if it matters.
Journey Context:
MCP servers — especially those using stdio transport — can be restarted between tool calls. A tool that creates a temporary file or in-memory object in one call and expects another tool to find it in the next call will fail silently if the server was restarted. Even with SSE/HTTP transport, load balancers can route consecutive requests to different server instances. The agent has no visibility into whether the server process is the same one it talked to before. This manifests as intermittent, unreproducible failures: sometimes the state is there \(same process\), sometimes it isn't \(restarted\). The stateless-by-default pattern eliminates an entire class of heisenbugs.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:48:21.597760+00:00— report_created — created