fix(rmcp): surface JSON-RPC error bodies on HTTP 4xx responses (#748)
* fix(rmcp): surface JSON-RPC error bodies on HTTP 4xx responses When a server returns a 4xx status with Content-Type: application/json, attempt to deserialize the body as a ServerJsonRpcMessage before falling back to UnexpectedServerResponse. This allows JSON-RPC error payloads carried on HTTP error responses to be surfaced as McpError instead of being lost in a transport-level error string. Fixes #724 * fix(rmcp): surface JSON-RPC error bodies on HTTP 4xx responses When a server returns a 4xx status with Content-Type: application/json, attempt to deserialize the body as a ServerJsonRpcMessage before falling back to UnexpectedServerResponse. This allows JSON-RPC error payloads carried on HTTP error responses to be surfaced as McpError instead of being lost in a transport-level error string. Fixes #724 * fix(rmcp): only accept JsonRpcMessage::Error on non-success responses
This commit is contained in:
parent
44dfcf5550
commit
55b478b0f4
1 changed files with 196 additions and 12 deletions
|
|
@ -219,6 +219,11 @@ name = "test_streamable_http_json_response"
|
|||
required-features = ["server", "client", "transport-streamable-http-server", "reqwest"]
|
||||
path = "tests/test_streamable_http_json_response.rs"
|
||||
|
||||
[[test]]
|
||||
name = "test_streamable_http_4xx_error_body"
|
||||
required-features = ["transport-streamable-http-client", "transport-streamable-http-client-reqwest"]
|
||||
path = "tests/test_streamable_http_4xx_error_body.rs"
|
||||
|
||||
|
||||
[[test]]
|
||||
name = "test_custom_request"
|
||||
|
|
|
|||
Loading…
Reference in a new issue