Skip to content

fix(streamable-http): fail request when resumable SSE stream can't complete#2732

Open
Epochex wants to merge 9 commits into
modelcontextprotocol:mainfrom
Epochex:fix/1577-streamable-http-disconnect-error
Open

fix(streamable-http): fail request when resumable SSE stream can't complete#2732
Epochex wants to merge 9 commits into
modelcontextprotocol:mainfrom
Epochex:fix/1577-streamable-http-disconnect-error

Conversation

@Epochex

@Epochex Epochex commented May 30, 2026

Copy link
Copy Markdown

Fixes #1577.

When a POST responds with ext/event-stream and the stream disconnects before a terminal JSON-RPC response/error arrives, the client transport tries to resume via GET + Last-Event-ID. If the server is gone (session 404s) or resumption otherwise can't succeed, the current code returns silently after exhausting retries.

Because ClientSession defaults to
ead_timeout_seconds=None, the original send_request() waits forever on the missing response.

Changes:

  • If an SSE response stream ends without completion and we have no resumable event id, send a CONNECTION_CLOSED JSON-RPC error for the original request id.
  • If resumption retries are exhausted, send the same request-scoped error (includes the last event id in data).

Tests:

  • Adds an interaction regression test that closes a call's SSE stream and deletes the server-side session on the first reconnect GET, asserting the call fails (no hang).

@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.

2 issues found across 3 files

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread src/mcp/client/streamable_http.py
Comment thread tests/client/test_streamable_http.py Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client tool call hangs forever if server crashes or connection dies when using streamable-http

1 participant