Skip to content

fix: drain terminal streamable HTTP responses#2725

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/drain-sse-response-on-completion
Open

fix: drain terminal streamable HTTP responses#2725
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/drain-sse-response-on-completion

Conversation

@he-yufeng
Copy link
Copy Markdown

Summary

  • stop closing terminal Streamable HTTP SSE responses immediately after the matching JSON-RPC response
  • keep draining the POST, GET resumption, and standalone GET SSE streams to EOF so HTTP keepalive connections stay reusable
  • add regression coverage for both normal response handling and reconnection after a terminal event

Fixes #2707.

To verify

  • uv run pytest tests/shared/test_streamable_http.py -q
  • uv run ruff check src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py
  • uv run pyright src/mcp/client/streamable_http.py tests/shared/test_streamable_http.py
  • git diff --check

@he-yufeng he-yufeng force-pushed the fix/drain-sse-response-on-completion branch 2 times, most recently from e8cb12c to e89af5b Compare May 30, 2026 03:07
@he-yufeng he-yufeng force-pushed the fix/drain-sse-response-on-completion branch from e89af5b to a043f86 Compare May 30, 2026 03:16
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.

streamable_http: early response.aclose() poisons keepalive connection, causes ~260ms latency on every subsequent tool call

1 participant