From 0bcecffc4c52c52e0502e53b59715ebaba88f998 Mon Sep 17 00:00:00 2001 From: ihrpr Date: Thu, 12 Jun 2025 09:09:13 +0100 Subject: [PATCH] set timeout for sse in httpx_client_factory (#943) --- src/mcp/client/sse.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mcp/client/sse.py b/src/mcp/client/sse.py index 1ce6a6d..0c05c6d 100644 --- a/src/mcp/client/sse.py +++ b/src/mcp/client/sse.py @@ -54,12 +54,13 @@ async def sse_client( async with anyio.create_task_group() as tg: try: logger.debug(f"Connecting to SSE endpoint: {remove_request_params(url)}") - async with httpx_client_factory(headers=headers, auth=auth) as client: + async with httpx_client_factory( + headers=headers, auth=auth, timeout=httpx.Timeout(timeout, read=sse_read_timeout) + ) as client: async with aconnect_sse( client, "GET", url, - timeout=httpx.Timeout(timeout, read=sse_read_timeout), ) as event_source: event_source.response.raise_for_status() logger.debug("SSE connection established")