Skip to content

Commit 6b60cb7

Browse files
author
zhangchuanhui
committed
fix: catch and rethrow SSEError during SSE connection establishment
1 parent d0443a1 commit 6b60cb7

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.error(f"SSE error: {sse_exc}")
111+
raise sse_exc
108112
except Exception as exc:
109113
logger.error(f"Error in sse_reader: {exc}")
110114
await read_stream_writer.send(exc)

0 commit comments

Comments
 (0)