Skip to content

fix(server): handle POST body disconnects gracefully - #3249

Closed
Linxiushen wants to merge 1 commit into
modelcontextprotocol:mainfrom
Linxiushen:fix/client-disconnect-post
Closed

fix(server): handle POST body disconnects gracefully#3249
Linxiushen wants to merge 1 commit into
modelcontextprotocol:mainfrom
Linxiushen:fix/client-disconnect-post

Conversation

@Linxiushen

Copy link
Copy Markdown

Summary

  • handle Starlette ClientDisconnect while 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.py
  • uv run --frozen ruff format --check src/mcp/server/streamable_http.py tests/server/test_streamable_http_router.py
  • uv 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Re-trigger cubic

@github-actions github-actions Bot added the missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md) label Aug 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for the contribution. This repository only keeps pull requests open when they're linked to an issue that a maintainer has assigned to the author — CONTRIBUTING.md explains why and how we work. This PR has been closed for now because you aren't currently assigned to #1648.

If a maintainer would like this change as a PR from you, they'll assign you to #1648 and this PR will reopen automatically — there's nothing more you need to do. (If you opened the issue, this PR already shows up on its timeline.)

There's no need to open a new PR — this one will be reopened. While it's closed, please push any updates as new commits rather than force-pushing, since GitHub can't reopen a PR whose branch has been rewritten.

Maintainers: reopening this PR, removing the missing-issue-link label, or adding bypass-issue-check bypasses the check.

@github-actions github-actions Bot closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-issue-link Auto-closed: PR needs a linked issue assigned to its author (see CONTRIBUTING.md)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ClientDisconnect returns HTTP 500

1 participant