fix: detect 401 errors from StreamableHTTP transport in client
This commit is contained in:
parent
fe393e514a
commit
e1886a8229
1 changed files with 2 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ import {
|
||||||
import {
|
import {
|
||||||
StreamableHTTPClientTransport,
|
StreamableHTTPClientTransport,
|
||||||
StreamableHTTPClientTransportOptions,
|
StreamableHTTPClientTransportOptions,
|
||||||
|
StreamableHTTPError,
|
||||||
} from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
} from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
||||||
import {
|
import {
|
||||||
ClientNotification,
|
ClientNotification,
|
||||||
|
|
@ -358,6 +359,7 @@ export function useConnection({
|
||||||
const is401Error = (error: unknown): boolean => {
|
const is401Error = (error: unknown): boolean => {
|
||||||
return (
|
return (
|
||||||
(error instanceof SseError && error.code === 401) ||
|
(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("401")) ||
|
||||||
(error instanceof Error && error.message.includes("Unauthorized"))
|
(error instanceof Error && error.message.includes("Unauthorized"))
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue