Skip to content

Commit 06d1f1e

Browse files
committed
docs: document SSRF redirect protection gap for user-provided clients
Add docstring note on the http_client parameter of streamable_http_client() clarifying that user-provided clients do not receive SSRF redirect protection. Also emit a logger.debug when a user-provided client is used. Github-Issue: #2106
1 parent 6fc1bc7 commit 06d1f1e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/mcp/client/streamable_http.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,9 @@ async def streamable_http_client(
523523
http_client: Optional pre-configured httpx.AsyncClient. If None, a default
524524
client with recommended MCP timeouts will be created. To configure headers,
525525
authentication, or other HTTP settings, create an httpx.AsyncClient and pass it here.
526+
Note: User-provided clients do not receive SSRF redirect protection.
527+
If redirect validation is required, use ``create_mcp_http_client()``
528+
or configure redirect hooks manually.
526529
terminate_on_close: If True, send a DELETE request to terminate the session when the context exits.
527530
528531
Yields:
@@ -543,6 +546,8 @@ async def streamable_http_client(
543546
if client is None:
544547
# Create default client with recommended MCP timeouts
545548
client = create_mcp_http_client()
549+
else:
550+
logger.debug("Using user-provided HTTP client; SSRF redirect protection is not applied")
546551

547552
transport = StreamableHTTPTransport(url)
548553

0 commit comments

Comments
 (0)