fix(server): handle POST body disconnects gracefully
Closed
LI
2mo ago+47+47+01234567890123456789-2-2-0123456789
Summary
- handle Starlette
ClientDisconnectwhile reading a Streamable HTTP POST body as a normal client-side event - return without attempting to send an HTTP 500 response to a client that has already disconnected
- keep the disconnect out of the internal session stream because no JSON-RPC message was parsed or dispatched
- add direct ASGI regression coverage for the partial-body disconnect path
Fixes #1648.
Verification
uv run --frozen pytest tests/server/test_streamable_http_router.py -q(4 passed)uv run --frozen ruff check src/mcp/server/streamable_http.py tests/server/test_streamable_http_router.pyuv run --frozen ruff format --check src/mcp/server/streamable_http.py tests/server/test_streamable_http_router.pyuv run --frozen pyright src/mcp/server/streamable_http.py tests/server/test_streamable_http_router.py(0 errors)
The full scripts/test -n 0 run collected 5,592 tests but could not complete on this Windows host because unrelated stdio interaction tests were unable to spawn child Python processes (PermissionError: [WinError 5]).
AI assistance was used during investigation and implementation. I reviewed the final diff and take responsibility for the change.