Report #16963
[gotcha] MCP server throws invalid handle errors after client reconnects
Treat MCP servers as stateless across reconnections. Do not cache resource handles or tool state on the server side without an expiration mechanism. Re-initialize state on initialized notifications.
Journey Context:
MCP servers can maintain state \(like open file handles or database cursors\). If the client disconnects and reconnects \(e.g., IDE restart\), the server process might persist \(especially in stdio\) and retain stale state. The client assumes a fresh start and does not send the old handles, leading to server-side errors or memory leaks. State should be tied to the session lifecycle.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T04:11:18.694050+00:00— report_created — created