Skip to content

feat(transport): expose body-free HTTP status errors - #1386

Merged
DaleSeo merged 4 commits into
modelcontextprotocol:mainfrom
theamodhshetty:fix/http-status-metadata
Oct 23, 2026
Merged

DaleSeo merged 4 commits into
modelcontextprotocol:mainfrom
theamodhshetty:fix/http-status-metadata

Conversation

@theamodhshetty

@theamodhshetty theamodhshetty commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

HTTP 429 and 5xx failures currently lose Retry-After metadata. This implements the narrow metadata proposal in #1356 (thanks @dux-web for the report and scope).

Adds non-exhaustive HttpStatusError through StreamableHttpError::HttpStatus, carrying status and the first valid UTF-8 Retry-After value of at most 128 bytes. A public constructor lets custom backends report the same metadata.

GET failures, all HTTP 429 POST responses, and non-JSON POST 5xx failures are classified without reading the body. JSON POST 5xx responses keep the existing JSON-RPC error forwarding, preserving the server's code, message and request id; malformed or non-error JSON falls back to typed HTTP metadata. The metadata retains no body, URL, credentials or other headers. Auth challenges, session expiration, GET 405 and other statuses keep their existing paths. No automatic retries, DELETE changes or client-trait changes.

Remaining body-reader limitation: JSON 5xx error responses must finish before their JSON-RPC error can be recognized. This retains the existing behavior; response-size/time bounds remain related to #1246.

Review follow-up: added the custom-backend constructor, preserved JSON-RPC errors on 5xx, removed the handwritten generated-changelog entry, converted header cases to rstest, grouped imports and removed PR-scope wording from rustdoc.

Validation on macOS arm64 with Rust 1.96.1:

  • The 500/503 JSON-RPC preservation regressions fail on the original PR head and pass after the fix. Two new JSON 429 regressions (complete and unfinished bodies) fail on 2e8420c and pass on cf40e5b.
  • 387 library tests and 39 integration tests across eight related HTTP targets pass, including external construction, JSON-RPC forwarding, fallback metadata, unfinished non-JSON bodies, auth/session handling and discovery.
  • Strict Clippy for the library/new integration target, nightly workspace formatting and git diff --check pass.

Previous head 2e8420c passed upstream CI, conformance and CodeQL. New head cf40e5b addresses the follow-up about JSON 429 responses; hosted checks for that revision are pending.

AI assistance: Codex assisted investigation, implementation and local validation.

Fixes #1356.

@theamodhshetty
theamodhshetty requested a review from a team as a code owner October 22, 2026 19:27
@github-actions github-actions Bot added T-documentation Documentation improvements T-test Testing related changes T-config Configuration file changes T-core Core library changes T-transport Transport layer changes labels Oct 22, 2026
@github-actions
github-actions Bot requested a review from DaleSeo October 22, 2026 19:27
@github-actions

Copy link
Copy Markdown
Contributor

@DaleSeo (assignment failed) is on triage rotation this week and is the reviewer for this one.

Labels come from the PR labeler. Please review the change.

Automated triage. Labels are a first pass and the assigned maintainer has the final say.

Comment thread crates/rmcp/src/transport/streamable_http_client.rs
Comment thread crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs Outdated
Comment thread crates/rmcp/CHANGELOG.md Outdated
Comment thread crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs Outdated
Comment thread crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs
Comment thread crates/rmcp/src/transport/streamable_http_client.rs Outdated
@github-actions github-actions Bot removed the T-documentation Documentation improvements label Oct 22, 2026
Comment thread crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs Outdated
DaleSeo
DaleSeo previously approved these changes Oct 22, 2026

@DaleSeo DaleSeo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for addressing my feedback, @theamodhshetty! Approved with one additional comment. Nothing is blocking.

Comment thread crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs Outdated
@DaleSeo
DaleSeo merged commit 2a401c4 into modelcontextprotocol:main Oct 23, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-config Configuration file changes T-core Core library changes T-test Testing related changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose body-free HTTP status and Retry-After metadata

2 participants