Upgrade 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 client the transport uses. The internal create_mcp_http_client helper no longer turns redirect following on, so code calling it directly now receives the redirect response instead.
If your client currently reaches its server through a redirect to another host, including a server that needs no credentials, it will stop connecting after the upgrade: set the endpoint URL to the redirect's target.
Until you can upgrade, supply your own HTTP client with follow_redirects left at False (http_client= on streamable_http_client; httpx_client_factory= on sse_client and streamablehttp_client; ClientSessionGroup has no such parameter). If a client may already have followed a redirect to a host you do not control, rotate the credentials it carried.
This restores what this advisory fixes: redirects to any host are followed again, carrying your custom headers and, on 307/308, the request body, OAuth token requests included. Prefer setting the endpoint URL to the redirect's target. If you cannot, and you accept forwarding credentials to the redirect target, give the transport an HTTP client that follows redirects regardless of what the SDK asks for:
import httpx2 # on 1.x: import httpx and subclass httpx.AsyncClient instead
class FollowRedirectsAnyway(httpx2.AsyncClient):
"""Follows redirects to ANY origin. Deliberately gives up the SDK's same-origin protection."""
async def send(self, request, *, follow_redirects=False, **kwargs):
return await super().send(request, follow_redirects=True, **kwargs)
http_client = FollowRedirectsAnyway(timeout=httpx2.Timeout(30, read=300))
# streamable_http_client(url, http_client=http_client)
# sse_client / streamablehttp_client take a factory instead:
def client_factory(headers=None, timeout=None, auth=None):
return FollowRedirectsAnyway(headers=headers, auth=auth,
timeout=timeout if timeout is not None else httpx2.Timeout(30, read=300))
# sse_client(url, httpx_client_factory=client_factory)
The redirect handling is then the HTTP library's own, as before the fix: a lone Authorization header is still dropped on cross-origin hops and 301/302/303 become GET. It is not something the SDK supports or tests.