Honor preferred HTTP transport
Issue
HTTP and HTTPS MCP URLs ignored the caller's preferred HTTP transport when auto negotiation was enabled.
For HTTP URLs, McpClient::negotiateTransport() used URI path heuristics to choose between HTTP+SSE and Streamable HTTP. That meant a caller could configure preferred_transport = StreamableHttp or preferred_transport = HttpSse, but the client could still choose a different transport based only on the URL path.
This broke clients that needed to explicitly select Streamable HTTP or HTTP+SSE for a server whose endpoint path did not match the SDK heuristic.
How to reproduce
- Configure an MCP client with an HTTP or HTTPS server URL.
- Leave auto negotiation enabled.
- Set a preferred HTTP transport explicitly, for example:
preferred_transport = StreamableHttp
or
preferred_transport = HttpSse
- Use a URL path whose name points the old heuristic to the opposite transport. Examples:
with preferred_transport = StreamableHttp, or:
with preferred_transport = HttpSse.
Before the fix, the client chose transport from the path heuristic instead of honoring the explicit preferred transport. That could make the client open the wrong kind of HTTP MCP session and fail during initialization or request handling.
Expected fixed behavior
For http:// and https:// URLs:
- if auto negotiation is disabled, return
preferred_transport directly;
- if auto negotiation is enabled and
preferred_transport is StreamableHttp or HttpSse, use that explicit preference;
- otherwise fall back to the existing URL path heuristic.
This lets callers override the heuristic when they know which MCP HTTP transport the server expects.
Regression check
A regression test should cover HTTP and HTTPS URLs with:
auto_negotiate_transport = false, verifying the preferred transport is returned;
auto_negotiate_transport = true and preferred_transport = StreamableHttp, verifying Streamable HTTP wins even for an SSE-looking path;
auto_negotiate_transport = true and preferred_transport = HttpSse, verifying HTTP+SSE wins even for a generic path;
- no explicit HTTP preference, verifying the existing path heuristic still applies.
Honor preferred HTTP transport
Issue
HTTP and HTTPS MCP URLs ignored the caller's preferred HTTP transport when auto negotiation was enabled.
For HTTP URLs,
McpClient::negotiateTransport()used URI path heuristics to choose between HTTP+SSE and Streamable HTTP. That meant a caller could configurepreferred_transport = StreamableHttporpreferred_transport = HttpSse, but the client could still choose a different transport based only on the URL path.This broke clients that needed to explicitly select Streamable HTTP or HTTP+SSE for a server whose endpoint path did not match the SDK heuristic.
How to reproduce
or
with
preferred_transport = StreamableHttp, or:with
preferred_transport = HttpSse.Before the fix, the client chose transport from the path heuristic instead of honoring the explicit preferred transport. That could make the client open the wrong kind of HTTP MCP session and fail during initialization or request handling.
Expected fixed behavior
For
http://andhttps://URLs:preferred_transportdirectly;preferred_transportisStreamableHttporHttpSse, use that explicit preference;This lets callers override the heuristic when they know which MCP HTTP transport the server expects.
Regression check
A regression test should cover HTTP and HTTPS URLs with:
auto_negotiate_transport = false, verifying the preferred transport is returned;auto_negotiate_transport = trueandpreferred_transport = StreamableHttp, verifying Streamable HTTP wins even for an SSE-looking path;auto_negotiate_transport = trueandpreferred_transport = HttpSse, verifying HTTP+SSE wins even for a generic path;