Skip to content

Commit fc8066e

Browse files
authored
Merge pull request modelcontextprotocol#999 from thinhtpt-dev/main
fix: detect 401 errors from `StreamableHTTP` transport in client
2 parents 82067f3 + f7bf100 commit fc8066e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

client/src/lib/hooks/useConnection.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
import {
88
StreamableHTTPClientTransport,
99
StreamableHTTPClientTransportOptions,
10+
StreamableHTTPError,
1011
} from "@modelcontextprotocol/sdk/client/streamableHttp.js";
1112
import {
1213
ClientNotification,
@@ -358,8 +359,11 @@ export function useConnection({
358359
const is401Error = (error: unknown): boolean => {
359360
return (
360361
(error instanceof SseError && error.code === 401) ||
362+
(error instanceof StreamableHTTPError && error.code === 401) ||
361363
(error instanceof Error && error.message.includes("401")) ||
362-
(error instanceof Error && error.message.includes("Unauthorized"))
364+
(error instanceof Error && error.message.includes("Unauthorized")) ||
365+
(error instanceof Error &&
366+
error.message.includes("Missing Authorization header"))
363367
);
364368
};
365369

0 commit comments

Comments
 (0)