-
fix(mcp): only fall back to legacy SSE transport on a 4xx Streamable HTTP error (#7154) · 62ae4f16
* fix(mcp): only fall back to legacy SSE transport on a 4xx Streamable HTTP error The MCP client caught any Streamable HTTP connection error and immediately retried with the legacy HTTP+SSE transport. For a Streamable-HTTP-only server, a failure unrelated to protocol support (network error, 5xx, or an error after a successful initialize) was masked by a misleading SSE error such as "Non-200 status code (405)", hiding the real root cause. Follow the MCP spec's backwards-compatibility flow: fall back to SSE only when the server rejects the Streamable HTTP request with a 4xx (e.g. 404/405), which signals it does not speak Streamable HTTP. Other errors now surface as-is, and when the SSE fallback also fails both errors are reported. * test(mcp): cover conditional SSE fallback behavior Update the fallback test to use a 4xx StreamableHTTPError and add cases for: non-HTTP errors and 5xx not triggering fallback, and both errors being surfaced when the SSE fallback also fails. * perf: code * perf: code --------- Co-authored-by: archer <545436317@qq.com>
Serhii Zghama committed
| Name |
Last commit
|
Last Update |
|---|---|---|
| .. | ||
| templates | Loading commit data... | |
| tool | Loading commit data... | |
| http.test.ts | Loading commit data... | |
| mcp.test.ts | Loading commit data... |