Report #90542
[gotcha] Client sends requests before MCP server initialization handshake completes, getting cryptic 'Server not initialized' errors
Always await the full initialization handshake \(send initialize request, receive result with capabilities, send initialized notification\) before submitting any other requests. Implement a state machine that blocks request submission until the connection is in 'initialized' state. Treat the handshake as an atomic barrier, not a background task.
Journey Context:
The MCP lifecycle requires a specific 3-step handshake: client sends \`initialize\` request, server responds with its capabilities, client sends \`initialized\` notification. Only AFTER this sequence is the server ready. The spec says servers MUST return error code -32002 for requests before initialization. But in practice, clients that eagerly queue requests \(e.g., listing tools immediately after connect\) hit this race. The error message varies by server implementation and is rarely helpful. Some server implementations silently drop the request instead of returning an error, making it even harder to diagnose. The temptation is to add a small sleep after connect, but the correct approach is a proper state machine that gates on the handshake completion event.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T10:34:17.403986+00:00— report_created — created