From e1886a8229d4f6144f42596e2e178d8f7a348dcd Mon Sep 17 00:00:00 2001 From: thinhtpt-dev Date: Tue, 6 Jan 2026 14:00:13 +0700 Subject: [PATCH] fix: detect 401 errors from `StreamableHTTP` transport in client --- client/src/lib/hooks/useConnection.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/src/lib/hooks/useConnection.ts b/client/src/lib/hooks/useConnection.ts index eb782041..4a584336 100644 --- a/client/src/lib/hooks/useConnection.ts +++ b/client/src/lib/hooks/useConnection.ts @@ -7,6 +7,7 @@ import { import { StreamableHTTPClientTransport, StreamableHTTPClientTransportOptions, + StreamableHTTPError, } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; import { ClientNotification, @@ -358,6 +359,7 @@ export function useConnection({ const is401Error = (error: unknown): boolean => { return ( (error instanceof SseError && error.code === 401) || + (error instanceof StreamableHTTPError && error.code === 401) || (error instanceof Error && error.message.includes("401")) || (error instanceof Error && error.message.includes("Unauthorized")) );