Skip to content

Commit f676f6c

Browse files
zhangch-sszhangchuanhuifelixweinberger
authored
fix: catch and rethrow SSEError during SSE connection establishment (#975)
Co-authored-by: zhangchuanhui <[email protected]> Co-authored-by: Felix Weinberger <[email protected]>
1 parent d648a31 commit f676f6c

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/mcp/client/sse.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from anyio.abc import TaskStatus
99
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
1010
from httpx_sse import aconnect_sse
11+
from httpx_sse._exceptions import SSEError
1112

1213
import mcp.types as types
1314
from mcp.shared._httpx_utils import McpHttpClientFactory, create_mcp_http_client
@@ -105,6 +106,9 @@ async def sse_reader(
105106
await read_stream_writer.send(session_message)
106107
case _:
107108
logger.warning(f"Unknown SSE event: {sse.event}")
109+
except SSEError as sse_exc:
110+
logger.exception("Encountered SSE exception")
111+
raise sse_exc
108112
except Exception as exc:
109113
logger.exception("Error in sse_reader")
110114
await read_stream_writer.send(exc)

0 commit comments

Comments
 (0)