From 75abb05b7d3eba574de137b8876a91f2ad5173cf Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Wed, 15 Oct 2025 11:42:11 +0200 Subject: [PATCH] Don't treat non-success HTTP codes as transport errors The spec states that: > If the server cannot accept the input, it MUST return an HTTP error > status code (e.g., 400 Bad Request). > The HTTP response body MAY comprise a JSON-RPC error response that has no id. But the rust-sdk treated any POST responses with non successful status as an error. Before this patch, trying to call list_resources on a server that does return HTTP 400 with JSON-RPC error: ``` TransportSend( DynamicTransportError { transport_name: "rmcp::transport::worker::WorkerTransport>", transport_type_id: TypeId(0xf7bacf3cf3889d471ead32d7a3cc8155), error: Client( reqwest::Error { kind: Status( 400, None, ), url: "http://localhost:4000/mcp", }, ), }, ) ``` After this patch: ``` McpError( ErrorData { code: ErrorCode( -32601, ), message: "Method not found", data: Some( Object { "name": String("resources/list"), }, ), }, ) ``` --- crates/rmcp/src/transport/common/reqwest/sse_client.rs | 1 - .../rmcp/src/transport/common/reqwest/streamable_http_client.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/crates/rmcp/src/transport/common/reqwest/sse_client.rs b/crates/rmcp/src/transport/common/reqwest/sse_client.rs index a5362d79..fca5b6c9 100644 --- a/crates/rmcp/src/transport/common/reqwest/sse_client.rs +++ b/crates/rmcp/src/transport/common/reqwest/sse_client.rs @@ -33,7 +33,6 @@ impl SseClient for reqwest::Client { request_builder .send() .await - .and_then(|resp| resp.error_for_status()) .map_err(SseTransportError::from) .map(drop) } diff --git a/crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs b/crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs index bea1a71f..00e96b6b 100644 --- a/crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs +++ b/crates/rmcp/src/transport/common/reqwest/streamable_http_client.rs @@ -118,7 +118,6 @@ impl StreamableHttpClient for reqwest::Client { })); } } - let response = response.error_for_status()?; if response.status() == reqwest::StatusCode::ACCEPTED { return Ok(StreamableHttpPostResponse::Accepted); }