Skip to content

fix(client): catch httpx transport errors in streamable HTTP post_writer#3025

Open
devansh-dek wants to merge 1 commit into
modelcontextprotocol:mainfrom
devansh-dek:fix/915-streamable-http-unreachable-server
Open

fix(client): catch httpx transport errors in streamable HTTP post_writer#3025
devansh-dek wants to merge 1 commit into
modelcontextprotocol:mainfrom
devansh-dek:fix/915-streamable-http-unreachable-server

Conversation

@devansh-dek

@devansh-dek devansh-dek commented Jun 30, 2026

Copy link
Copy Markdown

Summary

  • Catch httpx.HTTPError inside streamable HTTP post_writer request tasks and reply with a JSON-RPC error on the read stream instead of letting the exception escape into the outer transport task group.
  • Fixes the uncatchable RuntimeError: Attempted to exit cancel scope in a different task than it was entered in when ClientSessionGroup.connect_to_server() targets an unreachable streamable HTTP server (Exception in ClientSessionGroup if streamable_http MCP server is not available #915).
  • Adds a regression test in tests/issues/test_915_streamable_http_unreachable.py.

Test plan

  • uv run pytest tests/issues/test_915_streamable_http_unreachable.py -v
  • uv run ruff check src/mcp/client/streamable_http.py tests/issues/test_915_streamable_http_unreachable.py

Fixes #915

When an unreachable streamable HTTP server causes httpx.HTTPError inside a
request task, complete the pending JSON-RPC waiter with an error response
instead of letting the exception crash the outer transport task group.

Fixes modelcontextprotocol#915

@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

Tip: cubic could auto-approve low-risk PRs like this, if it thinks it's safe to merge. Learn more

Re-trigger cubic

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.

Exception in ClientSessionGroup if streamable_http MCP server is not available

1 participant