Merge pull request #999 from thinhtpt-dev/main

fix: detect 401 errors from `StreamableHTTP` transport in client
This commit is contained in:
Cliff Hall 2026-01-07 16:19:45 -05:00 • committed by GitHub
commit fc8066efe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -7,6 +7,7 @@ import {
import {
StreamableHTTPClientTransport,
StreamableHTTPClientTransportOptions,
StreamableHTTPError,
} from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import {
ClientNotification,
@ -358,8 +359,11 @@ 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"))
(error instanceof Error && error.message.includes("Unauthorized")) ||
(error instanceof Error &&
error.message.includes("Missing Authorization header"))
);
};