Symptom
When app.run() raises inside a stateful Streamable HTTP session, the client gets JSON-RPC -32603 with message Error handling POST request: (empty after the colon). The real exception is only in a separate Session <id> crashed log.
Evidence what you'll see
- The client body is
{"jsonrpc":"2.0","id":"server-error","error":{"code":-32603,"message":"Error handling POST request: "}}with HTTP 500. - The server log shows
Session <id> crashedthenRuntimeError: BOOM-distinctive-root-cause, and separatelyError handling POST request/anyio.ClosedResourceError. - The reporter's live trigger was
OSError: [Errno 24] inotify instance limit reached; every later request 500'd with an opaqueClosedResourceError.
Why it happens
_handle_stateful_request starts run_server (app.run() on the session streams) and concurrently calls http_transport.handle_request(). If app.run() raises, connect() tears down the streams. _handle_post_request then raises ClosedResourceError at writer.send(session_message), builds the 500 with f"Error handling POST request: {err}", and str(ClosedResourceError()) is empty.
Affected versions
Python 3.14, mcp 1.27.2 (also observed on 1.27.1), anyio 4.13, starlette 1.2.1. Stateful Streamable HTTP (stateless_http=False).
Fix steps
0 of 2 done
Your check marks stay in this browser only.
How to check it worked
- The JSON-RPC error for that initialize names
BOOM-distinctive-root-cause(orRuntimeError), notError handling POST request:with an empty suffix.
If it still fails
- The linked issue does not name an SDK release that puts the session crash cause on the client error.
- This path is the remaining diagnosability gap after the process-crash work in 1.10.0. Closed pull request 2742 was described as sending the real cause to the client; it did not merge.
Sources and credit
Summarized in our own words from these public reports. Credit goes to their authors.
Provided as is, without warranty. Try changes in a non-production environment and back up first. Security-related steps: verify against the official docs. Terms · Request removal or attribution change
Hit an error we don't cover? Submit it