@mcp-use/inspector 20.0.0-beta.15 → 20.0.0-beta.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/cdn/inspector.js +395 -344
- package/dist/cli.js +1 -1
- package/dist/server/cdn-shell.js +2 -2
- package/dist/server/{chunk-WNQGHIZ3.js → chunk-FHC5ZGMM.js} +1 -1
- package/dist/server/{chunk-ZPGABKXL.js → chunk-QXOCY5ZE.js} +1 -1
- package/dist/server/{chunk-XKCUJ6ZJ.js → chunk-R5ZEVRE5.js} +1 -1
- package/dist/server/cli.js +2 -2
- package/dist/server/index.js +3 -3
- package/dist/server/middleware.js +3 -3
- package/dist/server/version.js +1 -1
- package/dist/web/assets/{index-Bqfsh_Rp.js → index-BgHcVJO3.js} +22 -22
- package/dist/web/index.html +2 -2
- package/package.json +4 -4
package/dist/cdn/inspector.js
CHANGED
|
@@ -37672,7 +37672,7 @@ function YE() {
|
|
|
37672
37672
|
let e = window.__INSPECTOR_VERSION__;
|
|
37673
37673
|
if (e !== void 0 && e !== "") return e;
|
|
37674
37674
|
}
|
|
37675
|
-
return "20.0.0-beta.
|
|
37675
|
+
return "20.0.0-beta.15";
|
|
37676
37676
|
} catch {
|
|
37677
37677
|
return "0.0.0";
|
|
37678
37678
|
}
|
|
@@ -49208,8 +49208,7 @@ var aV = class {
|
|
|
49208
49208
|
}
|
|
49209
49209
|
}
|
|
49210
49210
|
getProxyFetch(e) {
|
|
49211
|
-
|
|
49212
|
-
let t = e ?? globalThis.fetch.bind(globalThis), n = this.oauthProxyUrl, r = /* @__PURE__ */ new Set(), i = !1;
|
|
49211
|
+
let t = e ?? globalThis.fetch.bind(globalThis), n = this.proxyOAuthRequests && this.oauthProxyUrl ? this.oauthProxyUrl : void 0, r = /* @__PURE__ */ new Set(), i = !1;
|
|
49213
49212
|
return async (e, a) => {
|
|
49214
49213
|
let o = typeof e == "string" ? e : e instanceof URL ? e.toString() : e.url, s = this.reanchorWellKnownUrl(o), c;
|
|
49215
49214
|
try {
|
|
@@ -49218,6 +49217,10 @@ var aV = class {
|
|
|
49218
49217
|
return await t(e, a);
|
|
49219
49218
|
}
|
|
49220
49219
|
let l = c.includes("/.well-known/");
|
|
49220
|
+
if (!n) return await t(l ? s : e, l ? {
|
|
49221
|
+
...a,
|
|
49222
|
+
cache: "no-store"
|
|
49223
|
+
} : a);
|
|
49221
49224
|
if (!i) {
|
|
49222
49225
|
i = !0;
|
|
49223
49226
|
let e = (await this.discoveryState())?.authorizationServerMetadata;
|
|
@@ -49238,7 +49241,8 @@ var aV = class {
|
|
|
49238
49241
|
if (l) {
|
|
49239
49242
|
let e = await t(d, {
|
|
49240
49243
|
...a,
|
|
49241
|
-
method: "GET"
|
|
49244
|
+
method: "GET",
|
|
49245
|
+
cache: "no-store"
|
|
49242
49246
|
});
|
|
49243
49247
|
try {
|
|
49244
49248
|
let t = await e.clone().json();
|
|
@@ -49285,7 +49289,9 @@ var aV = class {
|
|
|
49285
49289
|
return this.staticClientInfo ? this.staticClientInfo : this.session.clientInformation(e);
|
|
49286
49290
|
}
|
|
49287
49291
|
async saveClientInformation(e, t) {
|
|
49288
|
-
if (
|
|
49292
|
+
if (this.staticClientInfo) return;
|
|
49293
|
+
let { client_secret: n, ...r } = e;
|
|
49294
|
+
return n && console.info(`[${this.storageKeyPrefix}] Discarded client_secret returned for a public browser OAuth client.`), this.session.saveClientInformation(r, t);
|
|
49289
49295
|
}
|
|
49290
49296
|
codeVerifier() {
|
|
49291
49297
|
return this.session.codeVerifier();
|
|
@@ -52879,8 +52885,7 @@ var KH = class {
|
|
|
52879
52885
|
}
|
|
52880
52886
|
}
|
|
52881
52887
|
getProxyFetch(e) {
|
|
52882
|
-
|
|
52883
|
-
let t = e ?? globalThis.fetch.bind(globalThis), n = this.oauthProxyUrl, r = /* @__PURE__ */ new Set(), i = !1;
|
|
52888
|
+
let t = e ?? globalThis.fetch.bind(globalThis), n = this.proxyOAuthRequests && this.oauthProxyUrl ? this.oauthProxyUrl : void 0, r = /* @__PURE__ */ new Set(), i = !1;
|
|
52884
52889
|
return async (e, a) => {
|
|
52885
52890
|
let o = typeof e == "string" ? e : e instanceof URL ? e.toString() : e.url, s = this.reanchorWellKnownUrl(o), c;
|
|
52886
52891
|
try {
|
|
@@ -52889,6 +52894,10 @@ var KH = class {
|
|
|
52889
52894
|
return await t(e, a);
|
|
52890
52895
|
}
|
|
52891
52896
|
let l = c.includes("/.well-known/");
|
|
52897
|
+
if (!n) return await t(l ? s : e, l ? {
|
|
52898
|
+
...a,
|
|
52899
|
+
cache: "no-store"
|
|
52900
|
+
} : a);
|
|
52892
52901
|
if (!i) {
|
|
52893
52902
|
i = !0;
|
|
52894
52903
|
let e = (await this.discoveryState())?.authorizationServerMetadata;
|
|
@@ -52909,7 +52918,8 @@ var KH = class {
|
|
|
52909
52918
|
if (l) {
|
|
52910
52919
|
let e = await t(d, {
|
|
52911
52920
|
...a,
|
|
52912
|
-
method: "GET"
|
|
52921
|
+
method: "GET",
|
|
52922
|
+
cache: "no-store"
|
|
52913
52923
|
});
|
|
52914
52924
|
try {
|
|
52915
52925
|
let t = await e.clone().json();
|
|
@@ -52956,7 +52966,9 @@ var KH = class {
|
|
|
52956
52966
|
return this.staticClientInfo ? this.staticClientInfo : this.session.clientInformation(e);
|
|
52957
52967
|
}
|
|
52958
52968
|
async saveClientInformation(e, t) {
|
|
52959
|
-
if (
|
|
52969
|
+
if (this.staticClientInfo) return;
|
|
52970
|
+
let { client_secret: n, ...r } = e;
|
|
52971
|
+
return n && console.info(`[${this.storageKeyPrefix}] Discarded client_secret returned for a public browser OAuth client.`), this.session.saveClientInformation(r, t);
|
|
52960
52972
|
}
|
|
52961
52973
|
codeVerifier() {
|
|
52962
52974
|
return this.session.codeVerifier();
|
|
@@ -53948,225 +53960,242 @@ function Ice(e) {
|
|
|
53948
53960
|
}
|
|
53949
53961
|
var sU = 3e3, Lce = 5e3;
|
|
53950
53962
|
function Rce(e) {
|
|
53951
|
-
let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? GH(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c,
|
|
53963
|
+
let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? GH(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c, connectionMode: l, autoProxyFallback: u = !1, logLevel: d = "silent", autoRetry: f = !1, autoReconnect: p = !0, reconnectionOptions: m, preventAutoAuth: h = !0, useRedirectFlow: g = !1, onPopupWindow: _, timeout: v = 3e4, wrapTransport: y, serverId: b, fetch: x, clientOptions: S, protocolNegotiation: C, onNotification: w, onSampling: T, onElicitation: E, oauth: D } = e, O = "http", k = s?.proxyAddress, A = D?.clientId?.trim() || void 0, j = D?.clientMetadataUrl?.trim() || void 0, N = D?.scope?.trim() || void 0, P = (0, M.useMemo)(() => A ? { client_id: A } : void 0, [A]), F = (0, M.useMemo)(() => {
|
|
53952
53964
|
let e = `useMcp:${t || "no-url"}`, n = OH.get(e);
|
|
53953
|
-
return
|
|
53954
|
-
}, [t,
|
|
53965
|
+
return d && (n.level = d), n;
|
|
53966
|
+
}, [t, d]), I = o ?? {}, L = (0, M.useMemo)(() => Kse(S), [S]), R = T, z = E, B = (0, M.useMemo)(() => ({
|
|
53955
53967
|
name: "mcp-use",
|
|
53956
53968
|
title: "mcp-use",
|
|
53957
53969
|
version: WH(),
|
|
53958
53970
|
description: "mcp-use is a complete TypeScript framework for building and using MCP",
|
|
53959
53971
|
icons: [{ src: "https://mcp-use.com/logo.png" }],
|
|
53960
53972
|
websiteUrl: "https://mcp-use.com"
|
|
53961
|
-
}), []),
|
|
53962
|
-
...
|
|
53973
|
+
}), []), V = (0, M.useMemo)(() => e.clientInfo ? {
|
|
53974
|
+
...B,
|
|
53963
53975
|
...e.clientInfo
|
|
53964
|
-
} :
|
|
53965
|
-
if (!
|
|
53976
|
+
} : B, [e.clientInfo, B]), H = (0, M.useMemo)(() => Mce(V), [V]), U = (0, M.useMemo)(() => {
|
|
53977
|
+
if (l === "direct" || l === "proxy" || !u) return {
|
|
53966
53978
|
enabled: !1,
|
|
53967
53979
|
proxyAddress: void 0
|
|
53968
53980
|
};
|
|
53969
|
-
if (typeof
|
|
53981
|
+
if (typeof u == "boolean") {
|
|
53970
53982
|
let e = s?.proxyAddress;
|
|
53971
53983
|
return {
|
|
53972
|
-
enabled:
|
|
53984
|
+
enabled: u && !!e,
|
|
53973
53985
|
proxyAddress: e
|
|
53974
53986
|
};
|
|
53975
53987
|
}
|
|
53976
|
-
let e =
|
|
53988
|
+
let e = u.proxyAddress ?? s?.proxyAddress;
|
|
53977
53989
|
return {
|
|
53978
|
-
enabled:
|
|
53990
|
+
enabled: u.enabled !== !1 && !!e,
|
|
53979
53991
|
proxyAddress: e
|
|
53980
53992
|
};
|
|
53981
|
-
}, [
|
|
53993
|
+
}, [
|
|
53994
|
+
u,
|
|
53995
|
+
l,
|
|
53996
|
+
s
|
|
53997
|
+
]), W = (0, M.useMemo)(() => p === !1 ? {
|
|
53982
53998
|
enabled: !1,
|
|
53983
53999
|
initialDelay: 0,
|
|
53984
54000
|
healthCheckInterval: !1,
|
|
53985
54001
|
healthCheckTimeout: 3e4
|
|
53986
|
-
} :
|
|
54002
|
+
} : p === !0 ? {
|
|
53987
54003
|
enabled: !0,
|
|
53988
54004
|
initialDelay: sU,
|
|
53989
54005
|
healthCheckInterval: 1e4,
|
|
53990
54006
|
healthCheckTimeout: 3e4
|
|
53991
|
-
} : typeof
|
|
54007
|
+
} : typeof p == "number" ? {
|
|
53992
54008
|
enabled: !0,
|
|
53993
|
-
initialDelay:
|
|
54009
|
+
initialDelay: p,
|
|
53994
54010
|
healthCheckInterval: 1e4,
|
|
53995
54011
|
healthCheckTimeout: 3e4
|
|
53996
54012
|
} : {
|
|
53997
|
-
enabled:
|
|
53998
|
-
initialDelay:
|
|
53999
|
-
healthCheckInterval:
|
|
54000
|
-
healthCheckTimeout:
|
|
54001
|
-
}, [
|
|
54013
|
+
enabled: p.enabled !== !1,
|
|
54014
|
+
initialDelay: p.initialDelay ?? sU,
|
|
54015
|
+
healthCheckInterval: p.healthCheckInterval ?? 1e4,
|
|
54016
|
+
healthCheckTimeout: p.healthCheckTimeout ?? 3e4
|
|
54017
|
+
}, [p]), [G, ee] = (0, M.useState)(void 0);
|
|
54002
54018
|
(0, M.useEffect)(() => {
|
|
54003
|
-
|
|
54004
|
-
}, [
|
|
54005
|
-
|
|
54006
|
-
|
|
54007
|
-
|
|
54008
|
-
|
|
54009
|
-
|
|
54010
|
-
|
|
54011
|
-
|
|
54012
|
-
|
|
54013
|
-
|
|
54014
|
-
|
|
54015
|
-
|
|
54016
|
-
|
|
54017
|
-
|
|
54018
|
-
|
|
54019
|
-
|
|
54020
|
-
|
|
54021
|
-
|
|
54019
|
+
ee(void 0);
|
|
54020
|
+
}, [
|
|
54021
|
+
t,
|
|
54022
|
+
k,
|
|
54023
|
+
l,
|
|
54024
|
+
U.proxyAddress
|
|
54025
|
+
]);
|
|
54026
|
+
let te = (0, M.useMemo)(() => {
|
|
54027
|
+
if (U.enabled && G?.proxyAddress === U.proxyAddress && G) {
|
|
54028
|
+
let e = s?.headers ?? {};
|
|
54029
|
+
return {
|
|
54030
|
+
...G,
|
|
54031
|
+
headers: {
|
|
54032
|
+
...e,
|
|
54033
|
+
...G.headers ?? {}
|
|
54034
|
+
}
|
|
54035
|
+
};
|
|
54036
|
+
}
|
|
54037
|
+
return l === "auto" || l === "direct" || l === void 0 && U.enabled ? void 0 : s;
|
|
54038
|
+
}, [
|
|
54039
|
+
G,
|
|
54040
|
+
s,
|
|
54041
|
+
l,
|
|
54042
|
+
U.enabled,
|
|
54043
|
+
U.proxyAddress
|
|
54044
|
+
]), ne = te?.proxyAddress, re = te?.headers ?? {}, ie = (0, M.useMemo)(() => t || "", [t]), K = (0, M.useMemo)(() => ({
|
|
54045
|
+
...re,
|
|
54046
|
+
...I
|
|
54047
|
+
}), [re, I]), [ae, oe] = (0, M.useState)("discovering"), [se, ce] = (0, M.useState)([]), [q, le] = (0, M.useState)([]), [ue, de] = (0, M.useState)([]), [fe, pe] = (0, M.useState)([]), [me, he] = (0, M.useState)(e._initialServerInfo?.name ? e._initialServerInfo : void 0), [ge, _e] = (0, M.useState)(), [ve, ye] = (0, M.useState)(void 0), [be, xe] = (0, M.useState)(void 0), [Se, Ce] = (0, M.useState)(), [we, Te] = (0, M.useState)({}), [Ee, De] = (0, M.useState)(void 0), [Oe, ke] = (0, M.useState)([]), [Ae, je] = (0, M.useState)(void 0), [Me, Ne] = (0, M.useState)(void 0), Pe = (0, M.useRef)(null), Fe = (0, M.useRef)(null), Ie = (0, M.useRef)(a ?? null), Le = (0, M.useRef)(null), Re = (0, M.useRef)(!1), ze = (0, M.useRef)(!0), Be = (0, M.useRef)(0), Ve = (0, M.useRef)(0), He = (0, M.useRef)(null), Ue = (0, M.useRef)(!1), We = (0, M.useRef)(!1), Ge = (0, M.useRef)(ae), Ke = (0, M.useRef)(p), qe = (0, M.useRef)(null), Je = (0, M.useRef)(null), Ye = (0, M.useRef)(null), Xe = (0, M.useRef)(R), Ze = (0, M.useRef)(z), Qe = (0, M.useRef)(R !== void 0), $e = (0, M.useRef)(z !== void 0), et = (0, M.useRef)(w);
|
|
54048
|
+
R !== void 0 && (Xe.current = R), z !== void 0 && (Ze.current = z), Qe.current = R !== void 0, $e.current = z !== void 0, et.current = w;
|
|
54049
|
+
let tt = (0, M.useCallback)(async (e) => Xe.current(e), []), nt = (0, M.useCallback)(async (e) => Ze.current(e), []), rt = (0, M.useCallback)((e) => {
|
|
54050
|
+
et.current?.(e);
|
|
54022
54051
|
}, []);
|
|
54023
54052
|
(0, M.useEffect)(() => {
|
|
54024
|
-
|
|
54025
|
-
}, [
|
|
54026
|
-
|
|
54053
|
+
Ge.current = ae, Ke.current = p;
|
|
54054
|
+
}, [ae, p]), (0, M.useEffect)(() => {
|
|
54055
|
+
Ie.current = a ?? null;
|
|
54027
54056
|
}, [a]);
|
|
54028
|
-
let
|
|
54057
|
+
let it = (0, M.useCallback)((e, t, ...n) => {
|
|
54029
54058
|
let r = n.length > 0 ? `${t} ${n.map((e) => JSON.stringify(e)).join(" ")}` : t, i = `[useMcp] ${r}`;
|
|
54030
54059
|
switch (e) {
|
|
54031
54060
|
case "error":
|
|
54032
|
-
|
|
54061
|
+
F.error(i);
|
|
54033
54062
|
break;
|
|
54034
54063
|
case "warn":
|
|
54035
|
-
|
|
54064
|
+
F.warn(i);
|
|
54036
54065
|
break;
|
|
54037
54066
|
case "info":
|
|
54038
|
-
|
|
54067
|
+
F.info(i);
|
|
54039
54068
|
break;
|
|
54040
54069
|
case "debug":
|
|
54041
|
-
|
|
54070
|
+
F.debug(i);
|
|
54042
54071
|
break;
|
|
54043
|
-
default:
|
|
54072
|
+
default: F.info(i);
|
|
54044
54073
|
}
|
|
54045
|
-
|
|
54074
|
+
ze.current && ke((t) => [...t.slice(-100), {
|
|
54046
54075
|
level: e,
|
|
54047
54076
|
message: r,
|
|
54048
54077
|
timestamp: Date.now()
|
|
54049
54078
|
}]);
|
|
54050
|
-
}, [
|
|
54051
|
-
stateRef:
|
|
54052
|
-
connectionRef:
|
|
54053
|
-
hasClient: () =>
|
|
54054
|
-
isMounted: () =>
|
|
54055
|
-
setTools:
|
|
54056
|
-
setResources:
|
|
54057
|
-
setResourceTemplates:
|
|
54058
|
-
setPrompts:
|
|
54059
|
-
addLog:
|
|
54060
|
-
}),
|
|
54061
|
-
e ||
|
|
54062
|
-
let t =
|
|
54079
|
+
}, [F]), at = Ice({
|
|
54080
|
+
stateRef: Ge,
|
|
54081
|
+
connectionRef: Fe,
|
|
54082
|
+
hasClient: () => Pe.current !== null,
|
|
54083
|
+
isMounted: () => ze.current,
|
|
54084
|
+
setTools: ce,
|
|
54085
|
+
setResources: le,
|
|
54086
|
+
setResourceTemplates: de,
|
|
54087
|
+
setPrompts: pe,
|
|
54088
|
+
addLog: it
|
|
54089
|
+
}), ot = (0, M.useCallback)(async (e = !1) => {
|
|
54090
|
+
e || it("info", "Disconnecting..."), Re.current = !1, He.current && clearTimeout(He.current), He.current = null;
|
|
54091
|
+
let t = Ve.current, n = Pe.current;
|
|
54063
54092
|
if (n) try {
|
|
54064
|
-
let e = rU, t = n ===
|
|
54093
|
+
let e = rU, t = n === Pe.current ? Fe.current : null;
|
|
54065
54094
|
t && t._healthCheckCleanup && (t._healthCheckCleanup(), t._healthCheckCleanup = null), t && await n.closeSession(e);
|
|
54066
54095
|
} catch (t) {
|
|
54067
|
-
e ||
|
|
54068
|
-
}
|
|
54069
|
-
let r =
|
|
54070
|
-
|
|
54071
|
-
}, [
|
|
54072
|
-
|
|
54073
|
-
let r = n && "code" in n ? n.code : void 0, i =
|
|
54074
|
-
if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return
|
|
54075
|
-
|
|
54096
|
+
e || it("warn", "Error closing connection:", t);
|
|
54097
|
+
}
|
|
54098
|
+
let r = Ve.current !== t;
|
|
54099
|
+
Pe.current === n && !r && (Pe.current = null, Fe.current = null), ze.current && !e && !r && (oe("discovering"), ce([]), le([]), de([]), pe([]), De(void 0), je(void 0), Ne(void 0), he(void 0), _e(void 0), ye(void 0), xe(void 0), Ce(void 0), Te({}));
|
|
54100
|
+
}, [it]), st = (0, M.useCallback)((e, n) => {
|
|
54101
|
+
it("error", e, n ?? "");
|
|
54102
|
+
let r = n && "code" in n ? n.code : void 0, i = U.enabled && !te?.proxyAddress, o = e.includes("CORS") || e.includes("blocked by CORS policy") || e.includes("Failed to fetch"), s = r === 400;
|
|
54103
|
+
if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return it("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), Pe.current = null, a || (Ie.current = null), it("debug", "Cleared client and auth provider for proxy fallback"), ee({ proxyAddress: U.proxyAddress }), ze.current && oe("discovering"), setTimeout(() => {
|
|
54104
|
+
ze.current && Je.current?.();
|
|
54076
54105
|
}, 1e3), !0;
|
|
54077
|
-
if (
|
|
54078
|
-
|
|
54079
|
-
let t =
|
|
54080
|
-
t && (
|
|
54106
|
+
if (ze.current) {
|
|
54107
|
+
it("info", "Setting state to FAILED:", e), oe("failed"), De(e);
|
|
54108
|
+
let t = Ie.current?.getLastAttemptedAuthUrl?.();
|
|
54109
|
+
t && (je(t), it("info", "Manual authentication URL may be available.", t));
|
|
54081
54110
|
}
|
|
54082
|
-
return
|
|
54111
|
+
return Re.current = !1, t && eU.getInstance().trackUseMcpConnection({
|
|
54083
54112
|
url: t,
|
|
54084
|
-
transportType:
|
|
54113
|
+
transportType: O,
|
|
54085
54114
|
success: !1,
|
|
54086
54115
|
errorType: n?.name || "UnknownError",
|
|
54087
|
-
hasOAuth: !!
|
|
54088
|
-
hasSampling:
|
|
54089
|
-
hasElicitation:
|
|
54116
|
+
hasOAuth: !!Ie.current,
|
|
54117
|
+
hasSampling: Qe.current,
|
|
54118
|
+
hasElicitation: $e.current
|
|
54090
54119
|
}).catch(() => {}), !1;
|
|
54091
54120
|
}, [
|
|
54092
|
-
|
|
54121
|
+
it,
|
|
54093
54122
|
t,
|
|
54094
|
-
|
|
54095
|
-
|
|
54096
|
-
|
|
54123
|
+
O,
|
|
54124
|
+
U,
|
|
54125
|
+
te,
|
|
54097
54126
|
a
|
|
54098
|
-
]),
|
|
54127
|
+
]), ct = (0, M.useCallback)(async () => {
|
|
54099
54128
|
if (!n || !t) {
|
|
54100
|
-
|
|
54129
|
+
it("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag.");
|
|
54101
54130
|
return;
|
|
54102
54131
|
}
|
|
54103
|
-
if (
|
|
54104
|
-
|
|
54132
|
+
if (Re.current) {
|
|
54133
|
+
it("debug", "Connection attempt already in progress.");
|
|
54105
54134
|
return;
|
|
54106
54135
|
}
|
|
54107
|
-
if (!
|
|
54108
|
-
|
|
54136
|
+
if (!ze.current) {
|
|
54137
|
+
it("debug", "Connect called after unmount, aborting.");
|
|
54109
54138
|
return;
|
|
54110
54139
|
}
|
|
54111
|
-
if (
|
|
54140
|
+
if (Re.current = !0, Ve.current += 1, Be.current += 1, De(void 0), je(void 0), qe.current = null, oe("discovering"), ce([]), le([]), de([]), pe([]), he(void 0), _e(void 0), ye(void 0), xe(void 0), Ce(void 0), Te({}), it("info", `Connecting attempt #${Be.current} to ${t}...`), !Ie.current) {
|
|
54112
54141
|
let { provider: e, oauthProxyUrl: t } = aU({
|
|
54113
|
-
effectiveOAuthUrl:
|
|
54142
|
+
effectiveOAuthUrl: ie,
|
|
54114
54143
|
storageKeyPrefix: i,
|
|
54115
|
-
oauthClientConfig:
|
|
54144
|
+
oauthClientConfig: H,
|
|
54116
54145
|
callbackUrl: r,
|
|
54117
|
-
preventAutoAuth:
|
|
54118
|
-
useRedirectFlow:
|
|
54119
|
-
gatewayUrl:
|
|
54146
|
+
preventAutoAuth: h,
|
|
54147
|
+
useRedirectFlow: g,
|
|
54148
|
+
gatewayUrl: ne,
|
|
54120
54149
|
oauthProxyUrl: c,
|
|
54121
|
-
onPopupWindow:
|
|
54150
|
+
onPopupWindow: _,
|
|
54122
54151
|
proxyOAuthRequests: !0,
|
|
54123
|
-
staticClientInfo:
|
|
54124
|
-
clientMetadataUrl:
|
|
54125
|
-
scope:
|
|
54152
|
+
staticClientInfo: P,
|
|
54153
|
+
clientMetadataUrl: j,
|
|
54154
|
+
scope: N
|
|
54126
54155
|
});
|
|
54127
|
-
|
|
54156
|
+
Ie.current = e, t && it("debug", `OAuth BFF enabled: ${t}`), it("debug", `BrowserOAuthClientProvider initialized with URL: ${ie}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${ne ? "enabled" : "disabled"}`);
|
|
54128
54157
|
}
|
|
54129
|
-
|
|
54158
|
+
Pe.current ? it("debug", "BrowserMCPClient already exists, reusing.") : (Pe.current = new Sce(), it("debug", "BrowserMCPClient initialized in connect."));
|
|
54130
54159
|
let e = async (n) => {
|
|
54131
|
-
if (!
|
|
54132
|
-
|
|
54160
|
+
if (!ze.current) return it("debug", "Connection attempt aborted - component unmounted"), "failed";
|
|
54161
|
+
it("info", `Attempting connection with transport: ${n}`), it("debug", `Client ref status at start of tryConnectWithTransport: ${Pe.current ? "initialized" : "NULL"}`);
|
|
54133
54162
|
try {
|
|
54134
54163
|
let e = rU, r = {
|
|
54135
54164
|
url: t,
|
|
54136
|
-
timeout:
|
|
54137
|
-
clientInfo:
|
|
54165
|
+
timeout: v,
|
|
54166
|
+
clientInfo: V,
|
|
54138
54167
|
...(() => {
|
|
54139
|
-
let e =
|
|
54168
|
+
let e = Ie.current?.getProxyFetch?.(x) ?? x;
|
|
54140
54169
|
return e ? { fetch: e } : {};
|
|
54141
54170
|
})(),
|
|
54142
|
-
...
|
|
54143
|
-
...
|
|
54144
|
-
...
|
|
54171
|
+
...L && { clientOptions: L },
|
|
54172
|
+
...C !== void 0 && { protocolNegotiation: C },
|
|
54173
|
+
...m ? { reconnectionOptions: m } : p === !1 ? { reconnectionOptions: { maxRetries: 0 } } : {}
|
|
54145
54174
|
};
|
|
54146
|
-
if (
|
|
54147
|
-
if (!
|
|
54175
|
+
if (ne && (r.gatewayUrl = ne, it("debug", `Using proxy gateway: ${ne} for target: ${t}`)), K && Object.keys(K).length > 0 && (r.headers = K), !Pe.current) {
|
|
54176
|
+
if (!ze.current) return it("debug", "Connection aborted - component unmounted, client cleaned up"), "failed";
|
|
54148
54177
|
let e = /* @__PURE__ */ Error("Client not initialized - this is a bug in the connection flow");
|
|
54149
|
-
throw
|
|
54178
|
+
throw it("error", "Client ref is null in tryConnectWithTransport but component is still mounted"), e;
|
|
54150
54179
|
}
|
|
54151
|
-
|
|
54180
|
+
Pe.current.addServer(e, {
|
|
54152
54181
|
...r,
|
|
54153
|
-
authProvider:
|
|
54154
|
-
onSampling:
|
|
54155
|
-
onElicitation:
|
|
54182
|
+
authProvider: Ie.current,
|
|
54183
|
+
onSampling: Qe.current ? tt : void 0,
|
|
54184
|
+
onElicitation: $e.current ? nt : void 0,
|
|
54156
54185
|
onNotification: (e) => {
|
|
54157
|
-
|
|
54186
|
+
it("debug", "Notification received:", e.method, e), rt(e), e.method === "notifications/tools/list_changed" ? (it("info", "Tools list changed, auto-refreshing..."), at.refreshTools().catch((e) => it("warn", "Auto-refresh tools failed:", e))) : e.method === "notifications/resources/list_changed" ? (it("info", "Resources list changed, auto-refreshing..."), at.refreshResources().catch((e) => it("warn", "Auto-refresh resources failed:", e))) : e.method === "notifications/prompts/list_changed" && (it("info", "Prompts list changed, auto-refreshing..."), at.refreshPrompts().catch((e) => it("warn", "Auto-refresh prompts failed:", e)));
|
|
54158
54187
|
},
|
|
54159
|
-
wrapTransport:
|
|
54188
|
+
wrapTransport: y ? (n) => (it("debug", "Applying transport wrapper for server:", e, "url:", t), y(n, b ?? t)) : void 0
|
|
54160
54189
|
});
|
|
54161
|
-
let i = await
|
|
54162
|
-
if (
|
|
54163
|
-
|
|
54164
|
-
gatewayUrl:
|
|
54190
|
+
let i = await Pe.current.connect(e);
|
|
54191
|
+
if (Fe.current = i, !ze.current) return it("debug", "Connection aborted after connection creation - component unmounted"), "failed";
|
|
54192
|
+
it("info", "✅ Successfully connected to MCP server"), it("info", "Server info:", i.info.server), it("info", "Server capabilities:", i.info.capabilities), W.enabled && W.healthCheckInterval !== !1 && (i._healthCheckCleanup = Fce({
|
|
54193
|
+
gatewayUrl: ne,
|
|
54165
54194
|
url: t,
|
|
54166
|
-
allHeaders:
|
|
54195
|
+
allHeaders: K,
|
|
54167
54196
|
getAuthHeaders: async () => {
|
|
54168
54197
|
try {
|
|
54169
|
-
let e = await
|
|
54198
|
+
let e = await Ie.current?.tokens?.();
|
|
54170
54199
|
if (e?.access_token) {
|
|
54171
54200
|
let t = e.token_type || "bearer";
|
|
54172
54201
|
return { Authorization: `${t.charAt(0).toUpperCase() + t.slice(1)} ${e.access_token}` };
|
|
@@ -54174,67 +54203,67 @@ function Rce(e) {
|
|
|
54174
54203
|
} catch {}
|
|
54175
54204
|
return {};
|
|
54176
54205
|
},
|
|
54177
|
-
isMountedRef:
|
|
54178
|
-
stateRef:
|
|
54179
|
-
autoReconnectRef:
|
|
54180
|
-
setState:
|
|
54181
|
-
addLog:
|
|
54182
|
-
connect:
|
|
54183
|
-
defaultReconnectDelay:
|
|
54184
|
-
healthCheckIntervalMs:
|
|
54185
|
-
healthCheckTimeoutMs:
|
|
54206
|
+
isMountedRef: ze,
|
|
54207
|
+
stateRef: Ge,
|
|
54208
|
+
autoReconnectRef: Ke,
|
|
54209
|
+
setState: oe,
|
|
54210
|
+
addLog: it,
|
|
54211
|
+
connect: ct,
|
|
54212
|
+
defaultReconnectDelay: W.initialDelay,
|
|
54213
|
+
healthCheckIntervalMs: W.healthCheckInterval,
|
|
54214
|
+
healthCheckTimeoutMs: W.healthCheckTimeout
|
|
54186
54215
|
})), eU.getInstance().trackUseMcpConnection({
|
|
54187
54216
|
url: t,
|
|
54188
54217
|
transportType: n,
|
|
54189
54218
|
success: !0,
|
|
54190
|
-
hasOAuth: !!
|
|
54191
|
-
hasSampling:
|
|
54192
|
-
hasElicitation:
|
|
54193
|
-
}).catch(() => {}),
|
|
54219
|
+
hasOAuth: !!Ie.current,
|
|
54220
|
+
hasSampling: Qe.current,
|
|
54221
|
+
hasElicitation: $e.current
|
|
54222
|
+
}).catch(() => {}), ce(i.tools || []);
|
|
54194
54223
|
let [a, o, s] = await Promise.all([
|
|
54195
54224
|
i.listAllResources(),
|
|
54196
54225
|
i.listPrompts(),
|
|
54197
54226
|
i.supports("resources") ? i.listResourceTemplates() : Promise.resolve({ resourceTemplates: [] })
|
|
54198
54227
|
]);
|
|
54199
|
-
if (!
|
|
54200
|
-
|
|
54201
|
-
let { server: c, capabilities: l, protocolEra: u, protocolVersion: d, instructions:
|
|
54202
|
-
if (
|
|
54203
|
-
if (
|
|
54204
|
-
|
|
54228
|
+
if (!ze.current) return it("debug", "Connection aborted after discovery - component unmounted"), "failed";
|
|
54229
|
+
le(a.resources || []), pe(o.prompts || []), de(s.resourceTemplates || []);
|
|
54230
|
+
let { server: c, capabilities: l, protocolEra: u, protocolVersion: d, instructions: f, extensions: h } = i.info;
|
|
54231
|
+
if (ze.current && (ye(u), xe(d), Ce(f), Te(h)), c) {
|
|
54232
|
+
if (it("debug", "Server info:", c), !ze.current) return it("debug", "Skipping state update - component unmounted"), "failed";
|
|
54233
|
+
he(c), Le.current = Ace({
|
|
54205
54234
|
serverInfo: c,
|
|
54206
54235
|
url: t,
|
|
54207
|
-
isMounted: () =>
|
|
54208
|
-
setServerInfo:
|
|
54209
|
-
addLog:
|
|
54236
|
+
isMounted: () => ze.current,
|
|
54237
|
+
setServerInfo: he,
|
|
54238
|
+
addLog: it
|
|
54210
54239
|
});
|
|
54211
54240
|
}
|
|
54212
54241
|
if (l) {
|
|
54213
|
-
if (
|
|
54214
|
-
|
|
54242
|
+
if (it("debug", "Server capabilities:", l), !ze.current) return it("debug", "Skipping state update - component unmounted"), "failed";
|
|
54243
|
+
_e(l);
|
|
54215
54244
|
}
|
|
54216
|
-
if (
|
|
54217
|
-
let e = await
|
|
54218
|
-
if (!
|
|
54245
|
+
if (Ie.current) {
|
|
54246
|
+
let e = await Ie.current.tokens?.();
|
|
54247
|
+
if (!ze.current) return it("debug", "Connection aborted after token fetch for auth tokens - component unmounted"), "failed";
|
|
54219
54248
|
if (e?.access_token) {
|
|
54220
54249
|
let t = e.expires_in ? Date.now() + e.expires_in * 1e3 : void 0, n = null, r = null, i = null;
|
|
54221
54250
|
try {
|
|
54222
|
-
n = await
|
|
54251
|
+
n = await Ie.current.getTokenEndpoint?.() ?? null;
|
|
54223
54252
|
} catch {
|
|
54224
54253
|
n = null;
|
|
54225
54254
|
}
|
|
54226
54255
|
try {
|
|
54227
|
-
r = await
|
|
54256
|
+
r = await Ie.current.getResource?.() ?? null;
|
|
54228
54257
|
} catch {
|
|
54229
54258
|
r = null;
|
|
54230
54259
|
}
|
|
54231
54260
|
try {
|
|
54232
|
-
i = await
|
|
54261
|
+
i = await Ie.current.getClientCredentials?.() ?? null;
|
|
54233
54262
|
} catch {
|
|
54234
54263
|
i = null;
|
|
54235
54264
|
}
|
|
54236
|
-
if (!
|
|
54237
|
-
|
|
54265
|
+
if (!ze.current) return it("debug", "Skipping state update - component unmounted"), "failed";
|
|
54266
|
+
Ne({
|
|
54238
54267
|
access_token: e.access_token,
|
|
54239
54268
|
token_type: e.token_type || "Bearer",
|
|
54240
54269
|
expires_at: t,
|
|
@@ -54247,145 +54276,145 @@ function Rce(e) {
|
|
|
54247
54276
|
});
|
|
54248
54277
|
}
|
|
54249
54278
|
}
|
|
54250
|
-
return
|
|
54279
|
+
return qe.current = n, oe("ready"), "success";
|
|
54251
54280
|
} catch (r) {
|
|
54252
|
-
let i = r, a = i?.message || String(r), o =
|
|
54253
|
-
if (o &&
|
|
54281
|
+
let i = r, a = i?.message || String(r), o = Ie.current?.getLastAttemptedAuthUrl?.();
|
|
54282
|
+
if (o && Ie.current && h) return it("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), ze.current && (oe("pending_auth"), je(o)), Re.current = !1, "auth_redirect";
|
|
54254
54283
|
let s = Nce(r), c = tU(r);
|
|
54255
|
-
if (s &&
|
|
54256
|
-
if (s && (!
|
|
54284
|
+
if (s && I && Object.keys(I).length > 0) return st("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."), "failed";
|
|
54285
|
+
if (s && (!I || Object.keys(I).length === 0)) return st("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
|
|
54257
54286
|
if (c) {
|
|
54258
|
-
if (s) return
|
|
54259
|
-
if (
|
|
54260
|
-
if (
|
|
54261
|
-
|
|
54262
|
-
let e =
|
|
54263
|
-
e && (
|
|
54287
|
+
if (s) return st("Authentication required (HTTP 401). Server does not support OAuth. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed";
|
|
54288
|
+
if (Ie.current) if (it("info", "Authentication required. OAuth provider available."), h) {
|
|
54289
|
+
if (it("info", "Waiting for user to initiate authentication flow..."), ze.current) {
|
|
54290
|
+
oe("pending_auth");
|
|
54291
|
+
let e = Ie.current?.getLastAttemptedAuthUrl?.();
|
|
54292
|
+
e && (je(e), it("info", "Retrieved stored auth URL for manual authentication"));
|
|
54264
54293
|
}
|
|
54265
|
-
return
|
|
54294
|
+
return Re.current = !1, "auth_redirect";
|
|
54266
54295
|
} else {
|
|
54267
|
-
|
|
54296
|
+
it("info", "Triggering automatic OAuth authentication flow...");
|
|
54268
54297
|
try {
|
|
54269
|
-
if (await _B(
|
|
54298
|
+
if (await _B(Ie.current, {
|
|
54270
54299
|
serverUrl: t,
|
|
54271
|
-
fetchFn:
|
|
54300
|
+
fetchFn: Ie.current.getProxyFetch?.()
|
|
54272
54301
|
}) === "REDIRECT") {
|
|
54273
|
-
let e = await
|
|
54302
|
+
let e = await Ie.current.getAuthorizationCode?.();
|
|
54274
54303
|
if (!e) throw Error("Authorization code not captured by headless provider");
|
|
54275
|
-
await _B(
|
|
54304
|
+
await _B(Ie.current, {
|
|
54276
54305
|
serverUrl: t,
|
|
54277
54306
|
authorizationCode: e,
|
|
54278
|
-
fetchFn:
|
|
54307
|
+
fetchFn: Ie.current.getProxyFetch?.()
|
|
54279
54308
|
});
|
|
54280
54309
|
}
|
|
54281
|
-
return
|
|
54310
|
+
return it("info", "OAuth flow completed, reconnecting..."), await e(n);
|
|
54282
54311
|
} catch (e) {
|
|
54283
|
-
return
|
|
54312
|
+
return st(`Automatic OAuth authentication failed: ${e instanceof Error ? e.message : String(e)}`, e instanceof Error ? e : Error(String(e))), "failed";
|
|
54284
54313
|
}
|
|
54285
54314
|
}
|
|
54286
|
-
return
|
|
54315
|
+
return I && Object.keys(I).length > 0 ? (st("Authentication failed: Server returned 401 Unauthorized. Check your Authorization header value is correct."), "failed") : (st("Authentication required: Server returned 401 Unauthorized. Add an Authorization header in the Custom Headers section (e.g., Authorization: Bearer YOUR_API_KEY)."), "failed");
|
|
54287
54316
|
}
|
|
54288
|
-
return
|
|
54317
|
+
return st(a, i instanceof Error ? i : Error(String(i))) ? "auth_redirect" : "failed";
|
|
54289
54318
|
}
|
|
54290
54319
|
}, a = "failed";
|
|
54291
|
-
|
|
54320
|
+
it("debug", "Connecting via streamable HTTP"), a = await e("http"), (a === "success" || a === "failed" || a === "auth_redirect") && (Re.current = !1), it("debug", `Connection sequence finished with status: ${a}`);
|
|
54292
54321
|
}, [
|
|
54293
|
-
nt,
|
|
54294
|
-
at,
|
|
54295
54322
|
it,
|
|
54323
|
+
st,
|
|
54324
|
+
ot,
|
|
54296
54325
|
t,
|
|
54297
54326
|
i,
|
|
54298
54327
|
r,
|
|
54299
|
-
|
|
54300
|
-
|
|
54301
|
-
|
|
54302
|
-
|
|
54303
|
-
j,
|
|
54304
|
-
k,
|
|
54305
|
-
A,
|
|
54328
|
+
H.name,
|
|
54329
|
+
H.version,
|
|
54330
|
+
H.uri,
|
|
54331
|
+
H.logo_uri,
|
|
54306
54332
|
P,
|
|
54307
|
-
|
|
54308
|
-
|
|
54333
|
+
j,
|
|
54334
|
+
N,
|
|
54335
|
+
I,
|
|
54336
|
+
O,
|
|
54309
54337
|
h,
|
|
54310
54338
|
g,
|
|
54311
|
-
n,
|
|
54312
54339
|
_,
|
|
54313
|
-
|
|
54314
|
-
|
|
54315
|
-
|
|
54316
|
-
|
|
54317
|
-
|
|
54318
|
-
re,
|
|
54340
|
+
n,
|
|
54341
|
+
v,
|
|
54342
|
+
V,
|
|
54343
|
+
L,
|
|
54344
|
+
C,
|
|
54319
54345
|
ne,
|
|
54320
|
-
|
|
54321
|
-
|
|
54322
|
-
|
|
54346
|
+
c,
|
|
54347
|
+
K,
|
|
54348
|
+
ie,
|
|
54349
|
+
tt,
|
|
54350
|
+
nt,
|
|
54351
|
+
rt
|
|
54323
54352
|
]);
|
|
54324
54353
|
(0, M.useEffect)(() => {
|
|
54325
|
-
|
|
54326
|
-
}, [
|
|
54327
|
-
let
|
|
54328
|
-
|
|
54329
|
-
}, [
|
|
54330
|
-
|
|
54331
|
-
let e =
|
|
54332
|
-
if (e === "failed")
|
|
54354
|
+
Je.current = ct, Ye.current = st;
|
|
54355
|
+
}, [ct, st]);
|
|
54356
|
+
let lt = (0, M.useCallback)(() => {
|
|
54357
|
+
Ge.current === "failed" ? (it("info", "Retry requested..."), Je.current?.()) : it("warn", `Retry called but state is not 'failed' (state: ${Ge.current}). Ignoring.`);
|
|
54358
|
+
}, [it]), ut = (0, M.useCallback)(async () => {
|
|
54359
|
+
it("info", "Manual authentication requested...");
|
|
54360
|
+
let e = Ge.current;
|
|
54361
|
+
if (e === "failed") it("info", "Attempting to reconnect and authenticate via retry..."), lt();
|
|
54333
54362
|
else if (e === "pending_auth") {
|
|
54334
|
-
|
|
54363
|
+
it("info", "Proceeding with authentication from pending state...");
|
|
54335
54364
|
try {
|
|
54336
|
-
if (iU(
|
|
54337
|
-
|
|
54365
|
+
if (iU(Ie.current, "Auth Provider not available for manual auth"), iU(t, "Server URL is required for authentication"), a) {
|
|
54366
|
+
it("info", "Using provided authProvider for manual authentication");
|
|
54338
54367
|
let e = new URL(t), n = e.origin + e.pathname.replace(/\/+$/, "");
|
|
54339
|
-
await _B(
|
|
54368
|
+
await _B(Ie.current, {
|
|
54340
54369
|
serverUrl: n,
|
|
54341
|
-
fetchFn:
|
|
54342
|
-
}),
|
|
54370
|
+
fetchFn: Ie.current.getProxyFetch?.()
|
|
54371
|
+
}), Je.current?.();
|
|
54343
54372
|
return;
|
|
54344
54373
|
}
|
|
54345
|
-
|
|
54374
|
+
it("info", `Cleared ${Ie.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`), oe("authenticating");
|
|
54346
54375
|
let e = null, n = null, { provider: o, oauthProxyUrl: s } = aU({
|
|
54347
|
-
effectiveOAuthUrl:
|
|
54376
|
+
effectiveOAuthUrl: ie,
|
|
54348
54377
|
storageKeyPrefix: i,
|
|
54349
|
-
oauthClientConfig:
|
|
54378
|
+
oauthClientConfig: H,
|
|
54350
54379
|
callbackUrl: r,
|
|
54351
54380
|
preventAutoAuth: !1,
|
|
54352
|
-
useRedirectFlow:
|
|
54353
|
-
gatewayUrl:
|
|
54381
|
+
useRedirectFlow: g,
|
|
54382
|
+
gatewayUrl: ne,
|
|
54354
54383
|
oauthProxyUrl: c,
|
|
54355
54384
|
onPopupWindow: (t, r, i) => {
|
|
54356
54385
|
e = i;
|
|
54357
54386
|
try {
|
|
54358
54387
|
n = new URL(t).searchParams.get("state");
|
|
54359
54388
|
} catch {}
|
|
54360
|
-
|
|
54389
|
+
_?.(t, r, i);
|
|
54361
54390
|
},
|
|
54362
54391
|
proxyOAuthRequests: !0,
|
|
54363
|
-
staticClientInfo:
|
|
54364
|
-
clientMetadataUrl:
|
|
54365
|
-
scope:
|
|
54392
|
+
staticClientInfo: P,
|
|
54393
|
+
clientMetadataUrl: j,
|
|
54394
|
+
scope: N
|
|
54366
54395
|
});
|
|
54367
|
-
s &&
|
|
54396
|
+
s && it("info", "Scoped OAuth proxy fetch enabled for manual auth"), Ie.current = o, it("info", "Triggering fresh OAuth authorization...");
|
|
54368
54397
|
let l = new URL(t), u = await _B(o, {
|
|
54369
54398
|
serverUrl: l.origin + l.pathname.replace(/\/+$/, ""),
|
|
54370
54399
|
fetchFn: o.getProxyFetch?.()
|
|
54371
54400
|
});
|
|
54372
54401
|
if (u === "AUTHORIZED") {
|
|
54373
|
-
|
|
54402
|
+
it("info", "OAuth flow completed (tokens obtained)"), Re.current = !1, Je.current?.();
|
|
54374
54403
|
return;
|
|
54375
54404
|
}
|
|
54376
54405
|
if (u !== "REDIRECT") throw Error(`Unexpected OAuth auth() result: ${u}`);
|
|
54377
|
-
|
|
54406
|
+
it("info", "OAuth authorization redirect initiated");
|
|
54378
54407
|
let d = o.getLastAttemptedAuthUrl?.();
|
|
54379
|
-
if (d && (
|
|
54408
|
+
if (d && (je(d), it("info", "Updated auth URL for fallback:", d), !n)) try {
|
|
54380
54409
|
n = new URL(d).searchParams.get("state");
|
|
54381
54410
|
} catch {}
|
|
54382
|
-
if (
|
|
54411
|
+
if (g) return;
|
|
54383
54412
|
let f = o.getKey?.("tokens");
|
|
54384
54413
|
if (!f) {
|
|
54385
|
-
|
|
54414
|
+
it("warn", "Could not derive tokens storage key; relying on callback listener.");
|
|
54386
54415
|
return;
|
|
54387
54416
|
}
|
|
54388
|
-
|
|
54417
|
+
We.current = !0;
|
|
54389
54418
|
let p;
|
|
54390
54419
|
try {
|
|
54391
54420
|
p = await HH({
|
|
@@ -54394,189 +54423,190 @@ function Rce(e) {
|
|
|
54394
54423
|
tokensKey: f
|
|
54395
54424
|
});
|
|
54396
54425
|
} finally {
|
|
54397
|
-
|
|
54426
|
+
We.current = !1;
|
|
54398
54427
|
}
|
|
54399
|
-
if (!
|
|
54428
|
+
if (!ze.current) return;
|
|
54400
54429
|
switch (p.kind) {
|
|
54401
54430
|
case "success":
|
|
54402
|
-
|
|
54431
|
+
it("info", "Authentication succeeded; reconnecting to MCP server..."), Re.current = !1, Je.current?.();
|
|
54403
54432
|
break;
|
|
54404
54433
|
case "cancelled":
|
|
54405
|
-
|
|
54434
|
+
it("warn", "Authentication popup was closed before completing. Returning to pending_auth."), oe("pending_auth");
|
|
54406
54435
|
break;
|
|
54407
54436
|
case "timeout":
|
|
54408
|
-
|
|
54437
|
+
it("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."), oe("pending_auth");
|
|
54409
54438
|
break;
|
|
54410
54439
|
case "error":
|
|
54411
|
-
|
|
54440
|
+
st(`Authentication failed: ${p.error}`);
|
|
54412
54441
|
break;
|
|
54413
54442
|
default: break;
|
|
54414
54443
|
}
|
|
54415
54444
|
} catch (e) {
|
|
54416
|
-
if (!
|
|
54445
|
+
if (!ze.current) return;
|
|
54417
54446
|
let t = e instanceof Error ? e : Error(String(e));
|
|
54418
|
-
|
|
54447
|
+
st(`Manual authentication failed: ${t.message}`, t);
|
|
54419
54448
|
}
|
|
54420
54449
|
} else if (e === "authenticating") {
|
|
54421
|
-
|
|
54422
|
-
let e =
|
|
54423
|
-
e && !
|
|
54424
|
-
} else
|
|
54450
|
+
it("warn", "Already attempting authentication. Check for blocked popups or wait for timeout.");
|
|
54451
|
+
let e = Ie.current?.getLastAttemptedAuthUrl?.();
|
|
54452
|
+
e && !Ae && (je(e), it("info", "Manual authentication URL retrieved:", e));
|
|
54453
|
+
} else it("info", `Client not in a state requiring manual authentication trigger (state: ${e}). If needed, try disconnecting and reconnecting.`);
|
|
54425
54454
|
}, [
|
|
54426
|
-
|
|
54455
|
+
it,
|
|
54456
|
+
lt,
|
|
54427
54457
|
st,
|
|
54428
|
-
|
|
54429
|
-
Oe,
|
|
54458
|
+
Ae,
|
|
54430
54459
|
t,
|
|
54431
|
-
h,
|
|
54432
54460
|
g,
|
|
54461
|
+
_,
|
|
54433
54462
|
i,
|
|
54434
|
-
|
|
54435
|
-
|
|
54436
|
-
|
|
54463
|
+
H.name,
|
|
54464
|
+
H.uri,
|
|
54465
|
+
H.logo_uri,
|
|
54466
|
+
P,
|
|
54437
54467
|
j,
|
|
54438
|
-
|
|
54439
|
-
A,
|
|
54468
|
+
N,
|
|
54440
54469
|
r,
|
|
54441
|
-
|
|
54470
|
+
V,
|
|
54442
54471
|
a
|
|
54443
|
-
]),
|
|
54444
|
-
|
|
54472
|
+
]), dt = (0, M.useCallback)(() => {
|
|
54473
|
+
Ie.current?.clearStorage ? (it("info", `Cleared ${Ie.current.clearStorage()} item(s) from localStorage for ${t}.`), je(void 0), ot()) : it("warn", "Auth provider not initialized, cannot clear storage.");
|
|
54445
54474
|
}, [
|
|
54446
54475
|
t,
|
|
54447
|
-
|
|
54448
|
-
|
|
54476
|
+
it,
|
|
54477
|
+
ot
|
|
54449
54478
|
]);
|
|
54450
54479
|
(0, M.useEffect)(() => {
|
|
54451
54480
|
if (typeof window > "u") return;
|
|
54452
54481
|
let e = (e, t) => {
|
|
54453
|
-
if (
|
|
54454
|
-
|
|
54482
|
+
if (We.current) {
|
|
54483
|
+
it("debug", `Ignoring auth callback via ${t}; manual popup flow owns this result.`);
|
|
54455
54484
|
return;
|
|
54456
54485
|
}
|
|
54457
|
-
let n =
|
|
54486
|
+
let n = Ie.current?.serverUrlHash;
|
|
54458
54487
|
if (e?.serverUrlHash && n && e.serverUrlHash !== n) {
|
|
54459
|
-
|
|
54488
|
+
it("debug", `Ignoring auth callback via ${t} for a different server.`);
|
|
54460
54489
|
return;
|
|
54461
54490
|
}
|
|
54462
|
-
if (
|
|
54463
|
-
|
|
54491
|
+
if (it("info", `Received auth callback via ${t}.`, e), He.current && clearTimeout(He.current), He.current = null, e?.success) it("info", "Authentication successful via popup. Reconnecting client..."), Re.current && it("debug", "Connection attempt already in progress, resetting flag to allow reconnection."), Re.current = !1, setTimeout(() => {
|
|
54492
|
+
ze.current && (it("debug", "Initiating reconnection after successful auth callback."), Je.current?.());
|
|
54464
54493
|
}, 100);
|
|
54465
54494
|
else {
|
|
54466
|
-
if (
|
|
54467
|
-
|
|
54495
|
+
if (Ge.current !== "authenticating" && Ge.current !== "pending_auth") {
|
|
54496
|
+
it("debug", `Ignoring stale auth failure callback (state=${Ge.current}).`);
|
|
54468
54497
|
return;
|
|
54469
54498
|
}
|
|
54470
|
-
|
|
54499
|
+
Ye.current?.(`Authentication failed in callback: ${e?.error || "Unknown reason."}`);
|
|
54471
54500
|
}
|
|
54472
54501
|
}, t = (t) => {
|
|
54473
54502
|
t.origin === window.location.origin && t.data?.type === BH && e(t.data, "postMessage");
|
|
54474
54503
|
};
|
|
54475
|
-
window.addEventListener("message", t),
|
|
54504
|
+
window.addEventListener("message", t), it("debug", "Auth callback message listener added.");
|
|
54476
54505
|
let n = null, r = (t) => {
|
|
54477
54506
|
t.data?.type === BH && e(t.data, "BroadcastChannel");
|
|
54478
54507
|
};
|
|
54479
54508
|
if (typeof BroadcastChannel < "u") try {
|
|
54480
|
-
n = new BroadcastChannel(zH), n.addEventListener("message", r),
|
|
54509
|
+
n = new BroadcastChannel(zH), n.addEventListener("message", r), it("debug", "Auth callback BroadcastChannel listener added.");
|
|
54481
54510
|
} catch (e) {
|
|
54482
|
-
|
|
54511
|
+
it("warn", "Failed to open auth callback BroadcastChannel; lost-opener popups will not reach this client.", e), n = null;
|
|
54483
54512
|
}
|
|
54484
54513
|
return () => {
|
|
54485
|
-
if (window.removeEventListener("message", t),
|
|
54514
|
+
if (window.removeEventListener("message", t), it("debug", "Auth callback message listener removed."), n) {
|
|
54486
54515
|
try {
|
|
54487
54516
|
n.removeEventListener("message", r), n.close();
|
|
54488
54517
|
} catch {}
|
|
54489
|
-
|
|
54518
|
+
it("debug", "Auth callback BroadcastChannel listener removed.");
|
|
54490
54519
|
}
|
|
54491
|
-
|
|
54520
|
+
He.current && clearTimeout(He.current);
|
|
54492
54521
|
};
|
|
54493
|
-
}, [
|
|
54494
|
-
if (
|
|
54495
|
-
|
|
54522
|
+
}, [it]), (0, M.useEffect)(() => {
|
|
54523
|
+
if (ze.current = !0, !n || !t) return it("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."), oe("discovering"), () => {
|
|
54524
|
+
ze.current = !1;
|
|
54496
54525
|
};
|
|
54497
|
-
if (
|
|
54498
|
-
else if (!
|
|
54526
|
+
if (it("debug", "useMcp mounted, initiating connection."), Be.current = 0, a) Ie.current = a, it("debug", "Using externally provided authProvider");
|
|
54527
|
+
else if (!Ie.current || Ie.current.serverUrl !== ie) {
|
|
54499
54528
|
let { provider: e, oauthProxyUrl: t } = aU({
|
|
54500
|
-
effectiveOAuthUrl:
|
|
54529
|
+
effectiveOAuthUrl: ie,
|
|
54501
54530
|
storageKeyPrefix: i,
|
|
54502
|
-
oauthClientConfig:
|
|
54531
|
+
oauthClientConfig: H,
|
|
54503
54532
|
callbackUrl: r,
|
|
54504
|
-
preventAutoAuth:
|
|
54505
|
-
useRedirectFlow:
|
|
54506
|
-
gatewayUrl:
|
|
54533
|
+
preventAutoAuth: h,
|
|
54534
|
+
useRedirectFlow: g,
|
|
54535
|
+
gatewayUrl: ne,
|
|
54507
54536
|
oauthProxyUrl: c,
|
|
54508
|
-
onPopupWindow:
|
|
54537
|
+
onPopupWindow: _,
|
|
54509
54538
|
proxyOAuthRequests: !0,
|
|
54510
|
-
staticClientInfo:
|
|
54511
|
-
clientMetadataUrl:
|
|
54512
|
-
scope:
|
|
54539
|
+
staticClientInfo: P,
|
|
54540
|
+
clientMetadataUrl: j,
|
|
54541
|
+
scope: N
|
|
54513
54542
|
});
|
|
54514
|
-
|
|
54543
|
+
Ie.current = e, t && it("debug", `OAuth proxy URL in effect: ${t}`), it("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${ie}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${ne ? "enabled" : "disabled"}`);
|
|
54515
54544
|
}
|
|
54516
|
-
return
|
|
54517
|
-
|
|
54545
|
+
return ct(), () => {
|
|
54546
|
+
ze.current = !1, it("debug", "useMcp unmounting, disconnecting."), ot(!0);
|
|
54518
54547
|
};
|
|
54519
54548
|
}, [
|
|
54520
54549
|
t,
|
|
54521
54550
|
n,
|
|
54522
54551
|
i,
|
|
54523
54552
|
r,
|
|
54524
|
-
|
|
54525
|
-
|
|
54526
|
-
|
|
54527
|
-
|
|
54553
|
+
H.name,
|
|
54554
|
+
H.version,
|
|
54555
|
+
H.uri,
|
|
54556
|
+
H.logo_uri,
|
|
54557
|
+
P,
|
|
54528
54558
|
j,
|
|
54529
|
-
|
|
54530
|
-
|
|
54531
|
-
|
|
54532
|
-
|
|
54533
|
-
ne,
|
|
54559
|
+
N,
|
|
54560
|
+
g,
|
|
54561
|
+
V,
|
|
54562
|
+
ie,
|
|
54534
54563
|
s,
|
|
54564
|
+
U.proxyAddress,
|
|
54535
54565
|
a
|
|
54536
54566
|
]);
|
|
54537
|
-
let
|
|
54567
|
+
let ft = (0, M.useRef)(lt), pt = (0, M.useRef)(it);
|
|
54538
54568
|
(0, M.useEffect)(() => {
|
|
54539
|
-
|
|
54540
|
-
}, [
|
|
54569
|
+
ft.current = lt, pt.current = it;
|
|
54570
|
+
}, [lt, it]), (0, M.useEffect)(() => {
|
|
54541
54571
|
let e = null;
|
|
54542
|
-
if (
|
|
54543
|
-
if (!
|
|
54544
|
-
|
|
54545
|
-
let t = typeof
|
|
54546
|
-
|
|
54547
|
-
|
|
54572
|
+
if (ae === "failed" && f && Be.current > 0) {
|
|
54573
|
+
if (!Ue.current) {
|
|
54574
|
+
Ue.current = !0;
|
|
54575
|
+
let t = typeof f == "number" ? f : Lce;
|
|
54576
|
+
pt.current("info", `Connection failed, auto-retrying in ${t}ms...`), e = setTimeout(() => {
|
|
54577
|
+
Ue.current = !1, ze.current && Ge.current === "failed" && ft.current();
|
|
54548
54578
|
}, t);
|
|
54549
54579
|
}
|
|
54550
|
-
} else
|
|
54580
|
+
} else ae !== "failed" && (Ue.current = !1);
|
|
54551
54581
|
return () => {
|
|
54552
|
-
e && (clearTimeout(e),
|
|
54582
|
+
e && (clearTimeout(e), Ue.current = !1);
|
|
54553
54583
|
};
|
|
54554
|
-
}, [
|
|
54555
|
-
let
|
|
54584
|
+
}, [ae, f]);
|
|
54585
|
+
let mt = (0, M.useCallback)(async () => Ge.current === "ready" ? me?.icon ? me.icon : Le.current ? (it("debug", "Waiting for icon to finish loading..."), await Le.current) : (it("debug", "No icon available and no loading in progress"), null) : (it("warn", "Cannot ensure icon loaded - not connected"), null), [me, it]);
|
|
54556
54586
|
return {
|
|
54557
|
-
state:
|
|
54558
|
-
name:
|
|
54559
|
-
tools:
|
|
54560
|
-
resources:
|
|
54561
|
-
resourceTemplates:
|
|
54562
|
-
prompts:
|
|
54563
|
-
serverInfo:
|
|
54564
|
-
capabilities:
|
|
54565
|
-
protocolEra:
|
|
54566
|
-
protocolVersion:
|
|
54567
|
-
instructions:
|
|
54568
|
-
extensions:
|
|
54569
|
-
error:
|
|
54570
|
-
log:
|
|
54571
|
-
authUrl:
|
|
54572
|
-
authTokens:
|
|
54573
|
-
client:
|
|
54574
|
-
...
|
|
54575
|
-
retry:
|
|
54576
|
-
disconnect:
|
|
54577
|
-
authenticate:
|
|
54578
|
-
clearStorage:
|
|
54579
|
-
ensureIconLoaded:
|
|
54587
|
+
state: ae,
|
|
54588
|
+
name: me?.name || t || "",
|
|
54589
|
+
tools: se,
|
|
54590
|
+
resources: q,
|
|
54591
|
+
resourceTemplates: ue,
|
|
54592
|
+
prompts: fe,
|
|
54593
|
+
serverInfo: me,
|
|
54594
|
+
capabilities: ge,
|
|
54595
|
+
protocolEra: ve,
|
|
54596
|
+
protocolVersion: be,
|
|
54597
|
+
instructions: Se,
|
|
54598
|
+
extensions: we,
|
|
54599
|
+
error: Ee,
|
|
54600
|
+
log: Oe,
|
|
54601
|
+
authUrl: Ae,
|
|
54602
|
+
authTokens: Me,
|
|
54603
|
+
client: Pe.current,
|
|
54604
|
+
...at,
|
|
54605
|
+
retry: lt,
|
|
54606
|
+
disconnect: ot,
|
|
54607
|
+
authenticate: ut,
|
|
54608
|
+
clearStorage: dt,
|
|
54609
|
+
ensureIconLoaded: mt
|
|
54580
54610
|
};
|
|
54581
54611
|
}
|
|
54582
54612
|
var cU = null;
|
|
@@ -55927,6 +55957,9 @@ function jW(e) {
|
|
|
55927
55957
|
displayName: e.name?.trim() || e.url,
|
|
55928
55958
|
connectionMode: r,
|
|
55929
55959
|
protocolNegotiation: e.protocolNegotiation ?? "auto",
|
|
55960
|
+
proxyConfig: void 0,
|
|
55961
|
+
headers: void 0,
|
|
55962
|
+
autoProxyFallback: !1,
|
|
55930
55963
|
...e.oauth ? { oauth: e.oauth } : {}
|
|
55931
55964
|
};
|
|
55932
55965
|
return r === "proxy" && n ? i.proxyConfig = {
|
|
@@ -61725,6 +61758,24 @@ function eZ() {
|
|
|
61725
61758
|
variant: "outline",
|
|
61726
61759
|
disabled: !0,
|
|
61727
61760
|
children: [/* @__PURE__ */ (0, k.jsx)(ip, { className: "mr-2 h-4 w-4 animate-spin" }), "Authenticating..."]
|
|
61761
|
+
}) : e.authenticate ? /* @__PURE__ */ (0, k.jsx)(Y, {
|
|
61762
|
+
"data-testid": "server-tile-authenticate",
|
|
61763
|
+
size: "sm",
|
|
61764
|
+
className: "bg-yellow-500/20 border-0 dark:bg-yellow-400/10 text-yellow-800 dark:text-yellow-500",
|
|
61765
|
+
variant: "outline",
|
|
61766
|
+
onClick: (t) => {
|
|
61767
|
+
t.stopPropagation();
|
|
61768
|
+
try {
|
|
61769
|
+
sessionStorage.setItem("__mcpUseInspectorReconnect", JSON.stringify({
|
|
61770
|
+
url: e.url,
|
|
61771
|
+
name: e.name || "Auto-connected Server",
|
|
61772
|
+
transportType: e.transportType || "http",
|
|
61773
|
+
connectionMode: "auto"
|
|
61774
|
+
}));
|
|
61775
|
+
} catch {}
|
|
61776
|
+
e.authenticate();
|
|
61777
|
+
},
|
|
61778
|
+
children: "Authenticate"
|
|
61728
61779
|
}) : e.authUrl ? /* @__PURE__ */ (0, k.jsx)(Y, {
|
|
61729
61780
|
"data-testid": "server-tile-authenticate",
|
|
61730
61781
|
size: "sm",
|