From 753afb0d303f0da1be69f5f44062da3d955d135c Mon Sep 17 00:00:00 2001 From: Jeremiah Lowin <153965+jlowin@users.noreply.github.com> Date: Sat, 28 Jun 2025 21:51:32 -0400 Subject: [PATCH] Pass httpxerrors through --- src/fastmcp/client/client.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fastmcp/client/client.py b/src/fastmcp/client/client.py index 66d1099ce..96330f3bc 100644 --- a/src/fastmcp/client/client.py +++ b/src/fastmcp/client/client.py @@ -294,7 +294,9 @@ class Client(Generic[ClientTransportT]): and not self._session_task.cancelled() ): exception = self._session_task.exception() - if exception is not None: + if isinstance(exception, httpx.HTTPStatusError): + raise exception + elif exception is not None: raise RuntimeError( f"Client failed to connect: {exception}" ) from exception