GitHub advisory · PyPI
Model Context Protocol Python SDK: HTTP client transports followed cross-origin redirects carrying custom headers and bodies
Description
In affected versions, the SDK's Streamable HTTP and SSE client transports followed HTTP redirects to any host. If the configured MCP endpoint answered with a redirect to a different origin:
X-API-Key credential) were sent to that origin, and307 or 308 redirect the request body was re-sent there too.The SDK's OAuth client providers followed redirects on their own discovery, registration and token requests in the same way.
A lone Authorization bearer header was not exposed; the HTTP library already drops it on cross-origin redirects.
Anyone able to make an endpoint you trust redirect elsewhere (a stale redirect to a lapsed domain, a misrouted proxy rule, redirect logic an attacker can influence) could capture that material. A server that is itself malicious gains nothing this way; it already receives your requests directly.
Yes, if your code uses the SDK as an MCP client over HTTP through any of:
streamable_http_client (on 2.x also Client given an http:// or https:// URL)streamablehttp_client or sse_clientClientSessionGroup with HTTP server parameterscreate_mcp_http_client helperThis includes an HTTP client you passed in yourself with follow_redirects=True.
Affected versions: 1.8.0 through 1.29.1, and 2.0.0 through 2.1.1.
Not affected:
follow_redirects left at its default of FalseUpgrade to mcp 1.30.0 (1.x) or 2.2.0 (2.x) or later; no code changes are needed.
The transports, and the OAuth providers' own requests, now follow a redirect only when it stays on the endpoint's origin (same scheme, host and port, or an http to https upgrade on the same host) and keeps the request method. Any other redirect is not followed and the request fails with an error naming the target (MCPError on 2.x, httpx.HTTPStatusError on 1.x), whichever HTTP…
Manual fix · PyPI
pip install --upgrade "mcp>=1.30.0"Sources