Skip to content

fix(client): surface streamable HTTP 401 as JSON-RPC error - #3051

Closed
Sehlani042 wants to merge 1 commit into
modelcontextprotocol:mainfrom
Sehlani042:codex/streamable-http-401-jsonrpc-error
Closed

fix(client): surface streamable HTTP 401 as JSON-RPC error#3051
Sehlani042 wants to merge 1 commit into
modelcontextprotocol:mainfrom
Sehlani042:codex/streamable-http-401-jsonrpc-error

Conversation

@Sehlani042

Copy link
Copy Markdown

Summary

  • map bare Streamable HTTP 401 POST responses for JSON-RPC requests to a correlated JSON-RPC error instead of the generic fallback
  • keep existing JSON-RPC error bodies, 404 pre-session, and session-terminated handling unchanged
  • add a regression test for operation-specific authorization failures

Fixes #1295.

Verification

  • RED: PATH=/tmp/codex-uv-0.9.5/bin:$PATH uv run pytest tests/client/test_streamable_http.py::test_bare_401_request_maps_to_unauthorized_jsonrpc_error -q failed with Server returned an error response vs Unauthorized
  • GREEN: PATH=/tmp/codex-uv-0.9.5/bin:$PATH uv run pytest tests/client/test_streamable_http.py::test_bare_401_request_maps_to_unauthorized_jsonrpc_error tests/client/test_streamable_http.py -q
  • PATH=/tmp/codex-uv-0.9.5/bin:$PATH uv run ruff check src/mcp/client/streamable_http.py tests/client/test_streamable_http.py
  • PATH=/tmp/codex-uv-0.9.5/bin:$PATH uv run ruff format --check src/mcp/client/streamable_http.py tests/client/test_streamable_http.py
  • PATH=/tmp/codex-uv-0.9.5/bin:$PATH uv run pyright src/mcp/client/streamable_http.py tests/client/test_streamable_http.py
  • git diff --check

Note: the local Homebrew uv is 0.9.4 while this repo requires >=0.9.5, so verification used an isolated /tmp/codex-uv-0.9.5 binary.

@Sehlani042
Sehlani042 marked this pull request as ready for review July 2, 2026 08:37

@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

@Sehlani042
Sehlani042 force-pushed the codex/streamable-http-401-jsonrpc-error branch from a6b5613 to 115bb4c Compare July 2, 2026 19:01
@maxisbey

Copy link
Copy Markdown
Contributor

Thanks for the PR. This has since landed via #2047. Closing this as part of a wider backlog cleanup following the v2 launch. If it's still relevant, feel free to reopen.

AI Disclaimer

@maxisbey maxisbey closed this Jul 29, 2026
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.

401 in Streamable HTTP should be handled gracefully

2 participants