@mcp-use/inspector 20.0.0-beta.8 → 20.0.0-beta.9
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 -18
- package/dist/cdn/{ChatTab-C-Ysv6Zf.js → ChatTab-CU-Gf-GY.js} +6 -6
- package/dist/cdn/{ConnectionSettingsForm-CNuMa6jp.js → ConnectionSettingsForm-C4fEbp4v.js} +1 -1
- package/dist/cdn/{ConnectionSettingsTab-qSVQ1aIF.js → ConnectionSettingsTab-DXUrhGfL.js} +1 -1
- package/dist/cdn/{MCPAppsDebugControls-BpP-Ifap.js → MCPAppsDebugControls-Dp_o3k-P.js} +2 -2
- package/dist/cdn/{MarkdownRenderer-CK_6n3T9.js → MarkdownRenderer-COhmp4fm.js} +1 -1
- package/dist/cdn/{McpAppsViewPanel-jlsYQ7uS.js → McpAppsViewPanel-CMQZ28xs.js} +2 -2
- package/dist/cdn/{OAuthCallback--NZdLoWx.js → OAuthCallback-ClEnwZ9o.js} +1 -1
- package/dist/cdn/{PromptsTab-DSGYL32k.js → PromptsTab-DPjWr6W0.js} +1 -1
- package/dist/cdn/{ResourcesTab-d3wxN7xC.js → ResourcesTab-D8hOTjDs.js} +5 -5
- package/dist/cdn/{SamplingTab-DETdWNJk.js → SamplingTab-e1G8Qx1k.js} +3 -3
- package/dist/cdn/{ToolsTab-BMcnfEWg.js → ToolsTab-jNn6Cz6A.js} +4 -4
- package/dist/cdn/{ViewPreview-CBhrVdwx.js → ViewPreview-BpQYOKES.js} +2 -2
- package/dist/cdn/{dist-SxRsB1iS.js → dist-8Z7HZAGn.js} +2 -2
- package/dist/cdn/{index-browser-Dm3R1Mfe.js → index-browser-nWAQnCTk.js} +112 -200
- package/dist/cdn/inspector.js +5 -5
- package/dist/cdn/{react-Bl-hSkvn.js → react-8UPT_kVF.js} +521 -607
- package/dist/cdn/{telemetry-DjQn_Xm9.js → telemetry-X2tRdL3U.js} +37 -69
- package/dist/cdn/{useConfig-B_adtnP1.js → useConfig-BMqxaGDa.js} +2 -2
- package/dist/cdn/{useViewHostProps-CDOm2w6u.js → useViewHostProps-DMArgRGs.js} +1 -1
- package/dist/cli.js +1 -1
- package/dist/client/index.js +1 -6
- package/dist/client/telemetry/init.d.ts.map +1 -1
- package/dist/server/cdn-shell.js +2 -2
- package/dist/server/{chunk-BD3ROXCC.js → chunk-3WVGQOQX.js} +1 -1
- package/dist/server/{chunk-XTVIGRTB.js → chunk-BIKA6WIX.js} +1 -1
- package/dist/server/{chunk-BPXKTFQ5.js → chunk-KB6CHWZ4.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/{ChatTab-DxD-KLW_.js → ChatTab-fclW7HPg.js} +1 -1
- package/dist/web/assets/{ConnectionSettingsTab-pO6p0U0f.js → ConnectionSettingsTab-DNl63AkH.js} +1 -1
- package/dist/web/assets/{ElicitationTab-o5_z6gqe.js → ElicitationTab-B73XazTU.js} +1 -1
- package/dist/web/assets/{MCPAppsDebugControls-CZW1uZdH.js → MCPAppsDebugControls-BYLu5GRy.js} +1 -1
- package/dist/web/assets/{ManufactOAuthCallback-BnWhf5bW.js → ManufactOAuthCallback-Dp3icsBc.js} +1 -1
- package/dist/web/assets/{MarkdownRenderer-gUUHRIm1.js → MarkdownRenderer-CcvZ7qUS.js} +1 -1
- package/dist/web/assets/{McpAppsViewPanel-CDJDb4t-.js → McpAppsViewPanel-KD_ZnjfO.js} +1 -1
- package/dist/web/assets/{NotificationsTab-CkJ5E_sR.js → NotificationsTab-CV9kw9j-.js} +1 -1
- package/dist/web/assets/{OAuthCallback-Dv_mFcua.js → OAuthCallback-C9J2xEkV.js} +1 -1
- package/dist/web/assets/{PromptsTab-CLwWFf6d.js → PromptsTab-irNacYfj.js} +1 -1
- package/dist/web/assets/{ResourcesTab-B8cnuq-m.js → ResourcesTab-C-4Fd-HY.js} +1 -1
- package/dist/web/assets/{SamplingTab-BjYHYRHX.js → SamplingTab-B7bM9cnF.js} +1 -1
- package/dist/web/assets/{ServerMetadataTab-CPlclbb7.js → ServerMetadataTab-CnGUw9uD.js} +1 -1
- package/dist/web/assets/{ToolsTab-BSSwvp4Q.js → ToolsTab-DBHJRY9V.js} +1 -1
- package/dist/web/assets/{ViewPreview-C_LJdgt9.js → ViewPreview-D7NNsxbe.js} +1 -1
- package/dist/web/assets/{checkbox-BuuDhnpk.js → checkbox-C9WZqT8k.js} +1 -1
- package/dist/web/assets/{dist-C39gcmyH.js → dist-ChWdPMRV.js} +3 -3
- package/dist/web/assets/{index-CyvvaDNR.js → index-B5OxiZlj.js} +13 -13
- package/dist/web/assets/{shared-Chk1rURG.js → shared-BWLzd0mh.js} +1 -1
- package/dist/web/assets/{tabs-subtle-CK4nucyB.js → tabs-subtle-DkVoZG5s.js} +1 -1
- package/dist/web/assets/{useConfig-CgQbKjVT.js → useConfig-CTtYs2lN.js} +1 -1
- package/dist/web/assets/{useViewHostProps-DFI7Ywo7.js → useViewHostProps-DOJOoXbY.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +4 -4
|
@@ -1,105 +1,105 @@
|
|
|
1
1
|
import { a as e, s as t, t as n } from "./react-BIs9pQ3H.js";
|
|
2
2
|
import { A as r, C as i, D as a, E as o, I as s, M as c, N as l, O as u, P as d, S as f, T as p, _ as m, a as h, b as g, c as _, d as v, f as ee, g as te, h as y, i as b, j as x, k as S, l as C, m as ne, n as w, o as re, p as T, r as E, s as ie, t as ae, v as D, w as O, x as oe, y as k } from "./cfWorker-Bxcs9rNe.js";
|
|
3
3
|
//#region ../../node_modules/.pnpm/@modelcontextprotocol+core@2.0.0-beta.4/node_modules/@modelcontextprotocol/core/dist/auth-DFgbUATV.mjs
|
|
4
|
-
var A = /* @__PURE__ */ t(n(), 1), se = "io.modelcontextprotocol/related-task",
|
|
4
|
+
var A = /* @__PURE__ */ t(n(), 1), se = "io.modelcontextprotocol/related-task", ce = "io.modelcontextprotocol/subscriptionId", j = oe(() => x([
|
|
5
5
|
r(),
|
|
6
6
|
p(),
|
|
7
7
|
D(),
|
|
8
8
|
ne(),
|
|
9
|
-
S(r(),
|
|
10
|
-
m(
|
|
11
|
-
])),
|
|
12
|
-
m(
|
|
13
|
-
var
|
|
14
|
-
progressToken:
|
|
15
|
-
[se]:
|
|
16
|
-
}),
|
|
9
|
+
S(r(), j),
|
|
10
|
+
m(j)
|
|
11
|
+
])), M = S(r(), j);
|
|
12
|
+
m(j);
|
|
13
|
+
var N = x([r(), p().int()]), le = r(), ue = o({ ttl: p().optional() }), de = o({ taskId: r() }), P = i({
|
|
14
|
+
progressToken: N.optional(),
|
|
15
|
+
[se]: de.optional()
|
|
16
|
+
}), F = o({ _meta: P.optional() }), fe = F.extend({ task: ue.optional() }), I = o({
|
|
17
17
|
method: r(),
|
|
18
|
-
params:
|
|
19
|
-
}),
|
|
18
|
+
params: F.loose().optional()
|
|
19
|
+
}), L = o({ _meta: P.optional() }), R = o({
|
|
20
20
|
method: r(),
|
|
21
|
-
params:
|
|
22
|
-
}),
|
|
21
|
+
params: L.loose().optional()
|
|
22
|
+
}), z = i({ _meta: P.optional() }), pe = x([r(), p().int()]), B = o({
|
|
23
23
|
jsonrpc: f("2.0"),
|
|
24
|
-
id:
|
|
25
|
-
...
|
|
26
|
-
}).strict(), pe = o({
|
|
27
|
-
jsonrpc: f("2.0"),
|
|
28
|
-
...z.shape
|
|
24
|
+
id: pe,
|
|
25
|
+
...I.shape
|
|
29
26
|
}).strict(), me = o({
|
|
30
27
|
jsonrpc: f("2.0"),
|
|
31
|
-
|
|
32
|
-
result: B
|
|
28
|
+
...R.shape
|
|
33
29
|
}).strict(), he = o({
|
|
34
30
|
jsonrpc: f("2.0"),
|
|
35
|
-
id:
|
|
31
|
+
id: pe,
|
|
32
|
+
result: z
|
|
33
|
+
}).strict(), ge = o({
|
|
34
|
+
jsonrpc: f("2.0"),
|
|
35
|
+
id: pe.optional(),
|
|
36
36
|
error: o({
|
|
37
37
|
code: p().int(),
|
|
38
38
|
message: r(),
|
|
39
39
|
data: c().optional()
|
|
40
40
|
})
|
|
41
|
-
}).strict(),
|
|
42
|
-
|
|
43
|
-
pe,
|
|
41
|
+
}).strict(), _e = x([
|
|
42
|
+
B,
|
|
44
43
|
me,
|
|
45
|
-
he
|
|
44
|
+
he,
|
|
45
|
+
ge
|
|
46
46
|
]);
|
|
47
|
-
x([
|
|
48
|
-
var
|
|
49
|
-
requestId:
|
|
47
|
+
x([he, ge]);
|
|
48
|
+
var ve = z.strict(), ye = L.extend({
|
|
49
|
+
requestId: pe.optional(),
|
|
50
50
|
reason: r().optional()
|
|
51
|
-
}),
|
|
51
|
+
}), be = R.extend({
|
|
52
52
|
method: f("notifications/cancelled"),
|
|
53
|
-
params:
|
|
54
|
-
}),
|
|
53
|
+
params: ye
|
|
54
|
+
}), xe = o({ icons: m(o({
|
|
55
55
|
src: r(),
|
|
56
56
|
mimeType: r().optional(),
|
|
57
57
|
sizes: m(r()).optional(),
|
|
58
58
|
theme: T(["light", "dark"]).optional()
|
|
59
|
-
})).optional() }),
|
|
59
|
+
})).optional() }), Se = o({
|
|
60
60
|
name: r(),
|
|
61
61
|
title: r().optional()
|
|
62
|
-
}),
|
|
62
|
+
}), V = Se.extend({
|
|
63
|
+
...Se.shape,
|
|
63
64
|
...xe.shape,
|
|
64
|
-
...be.shape,
|
|
65
65
|
version: r(),
|
|
66
66
|
websiteUrl: r().optional(),
|
|
67
67
|
description: r().optional()
|
|
68
68
|
}), Ce = u((e) => e && typeof e == "object" && !Array.isArray(e) && Object.keys(e).length === 0 ? { form: {} } : e, g(o({
|
|
69
|
-
form: g(o({ applyDefaults: D().optional() }),
|
|
70
|
-
url:
|
|
71
|
-
}),
|
|
72
|
-
list:
|
|
73
|
-
cancel:
|
|
69
|
+
form: g(o({ applyDefaults: D().optional() }), M).optional(),
|
|
70
|
+
url: M.optional()
|
|
71
|
+
}), M.optional())), we = i({
|
|
72
|
+
list: M.optional(),
|
|
73
|
+
cancel: M.optional(),
|
|
74
74
|
requests: i({
|
|
75
|
-
sampling: i({ createMessage:
|
|
76
|
-
elicitation: i({ create:
|
|
75
|
+
sampling: i({ createMessage: M.optional() }).optional(),
|
|
76
|
+
elicitation: i({ create: M.optional() }).optional()
|
|
77
77
|
}).optional()
|
|
78
78
|
}), Te = i({
|
|
79
|
-
list:
|
|
80
|
-
cancel:
|
|
81
|
-
requests: i({ tools: i({ call:
|
|
79
|
+
list: M.optional(),
|
|
80
|
+
cancel: M.optional(),
|
|
81
|
+
requests: i({ tools: i({ call: M.optional() }).optional() }).optional()
|
|
82
82
|
}), H = o({
|
|
83
|
-
experimental: S(r(),
|
|
83
|
+
experimental: S(r(), M).optional(),
|
|
84
84
|
sampling: o({
|
|
85
|
-
context:
|
|
86
|
-
tools:
|
|
85
|
+
context: M.optional(),
|
|
86
|
+
tools: M.optional()
|
|
87
87
|
}).optional(),
|
|
88
88
|
elicitation: Ce.optional(),
|
|
89
89
|
roots: o({ listChanged: D().optional() }).optional(),
|
|
90
90
|
tasks: we.optional(),
|
|
91
|
-
extensions: S(r(),
|
|
92
|
-
}), Ee =
|
|
91
|
+
extensions: S(r(), M).optional()
|
|
92
|
+
}), Ee = F.extend({
|
|
93
93
|
protocolVersion: r(),
|
|
94
94
|
capabilities: H,
|
|
95
|
-
clientInfo:
|
|
96
|
-
}), De =
|
|
95
|
+
clientInfo: V
|
|
96
|
+
}), De = I.extend({
|
|
97
97
|
method: f("initialize"),
|
|
98
98
|
params: Ee
|
|
99
99
|
}), Oe = o({
|
|
100
|
-
experimental: S(r(),
|
|
101
|
-
logging:
|
|
102
|
-
completions:
|
|
100
|
+
experimental: S(r(), M).optional(),
|
|
101
|
+
logging: M.optional(),
|
|
102
|
+
completions: M.optional(),
|
|
103
103
|
prompts: o({ listChanged: D().optional() }).optional(),
|
|
104
104
|
resources: o({
|
|
105
105
|
subscribe: D().optional(),
|
|
@@ -107,38 +107,38 @@ var _e = B.strict(), ve = R.extend({
|
|
|
107
107
|
}).optional(),
|
|
108
108
|
tools: o({ listChanged: D().optional() }).optional(),
|
|
109
109
|
tasks: Te.optional(),
|
|
110
|
-
extensions: S(r(),
|
|
111
|
-
}), ke =
|
|
110
|
+
extensions: S(r(), M).optional()
|
|
111
|
+
}), ke = z.extend({
|
|
112
112
|
protocolVersion: r(),
|
|
113
113
|
capabilities: Oe,
|
|
114
|
-
serverInfo:
|
|
114
|
+
serverInfo: V,
|
|
115
115
|
instructions: r().optional()
|
|
116
|
-
}), Ae =
|
|
116
|
+
}), Ae = R.extend({
|
|
117
117
|
method: f("notifications/initialized"),
|
|
118
|
-
params:
|
|
119
|
-
}), je =
|
|
118
|
+
params: L.optional()
|
|
119
|
+
}), je = I.extend({
|
|
120
120
|
method: f("server/discover"),
|
|
121
|
-
params:
|
|
122
|
-
}), Me =
|
|
121
|
+
params: F.optional()
|
|
122
|
+
}), Me = z.extend({
|
|
123
123
|
supportedVersions: m(r()),
|
|
124
124
|
capabilities: Oe,
|
|
125
|
-
serverInfo:
|
|
125
|
+
serverInfo: V,
|
|
126
126
|
instructions: r().optional()
|
|
127
|
-
}), Ne =
|
|
127
|
+
}), Ne = I.extend({
|
|
128
128
|
method: f("ping"),
|
|
129
|
-
params:
|
|
129
|
+
params: F.optional()
|
|
130
130
|
}), Pe = o({
|
|
131
131
|
progress: p(),
|
|
132
132
|
total: a(p()),
|
|
133
133
|
message: a(r())
|
|
134
134
|
}), U = o({
|
|
135
|
-
...
|
|
135
|
+
...L.shape,
|
|
136
136
|
...Pe.shape,
|
|
137
|
-
progressToken:
|
|
138
|
-
}), Fe =
|
|
137
|
+
progressToken: N
|
|
138
|
+
}), Fe = R.extend({
|
|
139
139
|
method: f("notifications/progress"),
|
|
140
140
|
params: U
|
|
141
|
-
}), Ie =
|
|
141
|
+
}), Ie = F.extend({ cursor: le.optional() }), W = I.extend({ params: Ie.optional() }), Le = z.extend({ nextCursor: le.optional() }), G = o({
|
|
142
142
|
uri: r(),
|
|
143
143
|
mimeType: a(r()),
|
|
144
144
|
_meta: S(r(), c()).optional()
|
|
@@ -153,8 +153,8 @@ var _e = B.strict(), ve = R.extend({
|
|
|
153
153
|
priority: p().min(0).max(1).optional(),
|
|
154
154
|
lastModified: d({ offset: !0 }).optional()
|
|
155
155
|
}), Ve = o({
|
|
156
|
+
...Se.shape,
|
|
156
157
|
...xe.shape,
|
|
157
|
-
...be.shape,
|
|
158
158
|
uri: r(),
|
|
159
159
|
description: a(r()),
|
|
160
160
|
mimeType: a(r()),
|
|
@@ -162,23 +162,23 @@ var _e = B.strict(), ve = R.extend({
|
|
|
162
162
|
annotations: Be.optional(),
|
|
163
163
|
_meta: a(i({}))
|
|
164
164
|
}), He = o({
|
|
165
|
+
...Se.shape,
|
|
165
166
|
...xe.shape,
|
|
166
|
-
...be.shape,
|
|
167
167
|
uriTemplate: r(),
|
|
168
168
|
description: a(r()),
|
|
169
169
|
mimeType: a(r()),
|
|
170
170
|
annotations: Be.optional(),
|
|
171
171
|
_meta: a(i({}))
|
|
172
|
-
}), Ue = W.extend({ method: f("resources/list") }), We = Le.extend({ resources: m(Ve) }), Ge = W.extend({ method: f("resources/templates/list") }), Ke = Le.extend({ resourceTemplates: m(He) }), qe =
|
|
172
|
+
}), Ue = W.extend({ method: f("resources/list") }), We = Le.extend({ resources: m(Ve) }), Ge = W.extend({ method: f("resources/templates/list") }), Ke = Le.extend({ resourceTemplates: m(He) }), qe = F.extend({ uri: r() }), Je = qe, Ye = I.extend({
|
|
173
173
|
method: f("resources/read"),
|
|
174
174
|
params: Je
|
|
175
|
-
}), Xe =
|
|
175
|
+
}), Xe = z.extend({ contents: m(x([Re, q])) }), Ze = R.extend({
|
|
176
176
|
method: f("notifications/resources/list_changed"),
|
|
177
|
-
params:
|
|
178
|
-
}), Qe = qe, $e =
|
|
177
|
+
params: L.optional()
|
|
178
|
+
}), Qe = qe, $e = I.extend({
|
|
179
179
|
method: f("resources/subscribe"),
|
|
180
180
|
params: Qe
|
|
181
|
-
}), et = qe, tt =
|
|
181
|
+
}), et = qe, tt = I.extend({
|
|
182
182
|
method: f("resources/unsubscribe"),
|
|
183
183
|
params: et
|
|
184
184
|
}), nt = o({
|
|
@@ -186,13 +186,13 @@ var _e = B.strict(), ve = R.extend({
|
|
|
186
186
|
promptsListChanged: D().optional(),
|
|
187
187
|
resourcesListChanged: D().optional(),
|
|
188
188
|
resourceSubscriptions: m(r()).optional()
|
|
189
|
-
}), J =
|
|
189
|
+
}), J = F.extend({ notifications: nt }), rt = I.extend({
|
|
190
190
|
method: f("subscriptions/listen"),
|
|
191
191
|
params: J
|
|
192
|
-
}), it =
|
|
192
|
+
}), it = L.extend({ notifications: nt }), Y = R.extend({
|
|
193
193
|
method: f("notifications/subscriptions/acknowledged"),
|
|
194
194
|
params: it
|
|
195
|
-
}), at = i({ [
|
|
195
|
+
}), at = i({ [ce]: pe }), ot = z.extend({ _meta: at }), st = L.extend({ uri: r() }), ct = R.extend({
|
|
196
196
|
method: f("notifications/resources/updated"),
|
|
197
197
|
params: st
|
|
198
198
|
}), lt = o({
|
|
@@ -200,15 +200,15 @@ var _e = B.strict(), ve = R.extend({
|
|
|
200
200
|
description: a(r()),
|
|
201
201
|
required: a(D())
|
|
202
202
|
}), ut = o({
|
|
203
|
+
...Se.shape,
|
|
203
204
|
...xe.shape,
|
|
204
|
-
...be.shape,
|
|
205
205
|
description: a(r()),
|
|
206
206
|
arguments: a(m(lt)),
|
|
207
207
|
_meta: a(i({}))
|
|
208
|
-
}), dt = W.extend({ method: f("prompts/list") }), ft = Le.extend({ prompts: m(ut) }), pt =
|
|
208
|
+
}), dt = W.extend({ method: f("prompts/list") }), ft = Le.extend({ prompts: m(ut) }), pt = F.extend({
|
|
209
209
|
name: r(),
|
|
210
210
|
arguments: S(r(), r()).optional()
|
|
211
|
-
}), mt =
|
|
211
|
+
}), mt = I.extend({
|
|
212
212
|
method: f("prompts/get"),
|
|
213
213
|
params: pt
|
|
214
214
|
}), ht = o({
|
|
@@ -248,12 +248,12 @@ var _e = B.strict(), ve = R.extend({
|
|
|
248
248
|
]), St = o({
|
|
249
249
|
role: ze,
|
|
250
250
|
content: xt
|
|
251
|
-
}), Ct =
|
|
251
|
+
}), Ct = z.extend({
|
|
252
252
|
description: r().optional(),
|
|
253
253
|
messages: m(St)
|
|
254
|
-
}), wt =
|
|
254
|
+
}), wt = R.extend({
|
|
255
255
|
method: f("notifications/prompts/list_changed"),
|
|
256
|
-
params:
|
|
256
|
+
params: L.optional()
|
|
257
257
|
}), Tt = o({
|
|
258
258
|
title: r().optional(),
|
|
259
259
|
readOnlyHint: D().optional(),
|
|
@@ -265,33 +265,33 @@ var _e = B.strict(), ve = R.extend({
|
|
|
265
265
|
"optional",
|
|
266
266
|
"forbidden"
|
|
267
267
|
]).optional() }), Dt = o({
|
|
268
|
+
...Se.shape,
|
|
268
269
|
...xe.shape,
|
|
269
|
-
...be.shape,
|
|
270
270
|
description: r().optional(),
|
|
271
271
|
inputSchema: o({
|
|
272
272
|
type: f("object"),
|
|
273
|
-
properties: S(r(),
|
|
273
|
+
properties: S(r(), j).optional(),
|
|
274
274
|
required: m(r()).optional()
|
|
275
275
|
}).catchall(c()),
|
|
276
276
|
outputSchema: i({ $schema: r().optional() }).optional(),
|
|
277
277
|
annotations: Tt.optional(),
|
|
278
278
|
execution: Et.optional(),
|
|
279
279
|
_meta: S(r(), c()).optional()
|
|
280
|
-
}), Ot = W.extend({ method: f("tools/list") }), kt = Le.extend({ tools: m(Dt) }), At =
|
|
280
|
+
}), Ot = W.extend({ method: f("tools/list") }), kt = Le.extend({ tools: m(Dt) }), At = z.extend({
|
|
281
281
|
content: m(xt).default([]),
|
|
282
282
|
structuredContent: c().optional(),
|
|
283
283
|
isError: D().optional()
|
|
284
284
|
});
|
|
285
|
-
At.or(
|
|
286
|
-
var jt =
|
|
285
|
+
At.or(z.extend({ toolResult: c() }));
|
|
286
|
+
var jt = fe.extend({
|
|
287
287
|
name: r(),
|
|
288
288
|
arguments: S(r(), c()).optional()
|
|
289
|
-
}), Mt =
|
|
289
|
+
}), Mt = I.extend({
|
|
290
290
|
method: f("tools/call"),
|
|
291
291
|
params: jt
|
|
292
|
-
}), Nt =
|
|
292
|
+
}), Nt = R.extend({
|
|
293
293
|
method: f("notifications/tools/list_changed"),
|
|
294
|
-
params:
|
|
294
|
+
params: L.optional()
|
|
295
295
|
});
|
|
296
296
|
o({
|
|
297
297
|
autoRefresh: D().default(!0),
|
|
@@ -306,14 +306,14 @@ var Pt = T([
|
|
|
306
306
|
"critical",
|
|
307
307
|
"alert",
|
|
308
308
|
"emergency"
|
|
309
|
-
]), Ft =
|
|
309
|
+
]), Ft = F.extend({ level: Pt }), It = I.extend({
|
|
310
310
|
method: f("logging/setLevel"),
|
|
311
311
|
params: Ft
|
|
312
|
-
}), Lt =
|
|
312
|
+
}), Lt = L.extend({
|
|
313
313
|
level: Pt,
|
|
314
314
|
logger: r().optional(),
|
|
315
315
|
data: c()
|
|
316
|
-
}), Rt =
|
|
316
|
+
}), Rt = R.extend({
|
|
317
317
|
method: f("notifications/message"),
|
|
318
318
|
params: Lt
|
|
319
319
|
}), zt = o({
|
|
@@ -346,7 +346,7 @@ var Pt = T([
|
|
|
346
346
|
role: ze,
|
|
347
347
|
content: x([Ut, m(Ut)]),
|
|
348
348
|
_meta: S(r(), c()).optional()
|
|
349
|
-
}), Gt =
|
|
349
|
+
}), Gt = fe.extend({
|
|
350
350
|
messages: m(Wt),
|
|
351
351
|
modelPreferences: zt.optional(),
|
|
352
352
|
systemPrompt: r().optional(),
|
|
@@ -358,13 +358,13 @@ var Pt = T([
|
|
|
358
358
|
temperature: p().optional(),
|
|
359
359
|
maxTokens: p().int(),
|
|
360
360
|
stopSequences: m(r()).optional(),
|
|
361
|
-
metadata:
|
|
361
|
+
metadata: M.optional(),
|
|
362
362
|
tools: m(Dt).optional(),
|
|
363
363
|
toolChoice: Bt.optional()
|
|
364
|
-
}), Kt =
|
|
364
|
+
}), Kt = I.extend({
|
|
365
365
|
method: f("sampling/createMessage"),
|
|
366
366
|
params: Gt
|
|
367
|
-
}), qt =
|
|
367
|
+
}), qt = z.extend({
|
|
368
368
|
model: r(),
|
|
369
369
|
stopReason: a(T([
|
|
370
370
|
"endTurn",
|
|
@@ -373,7 +373,7 @@ var Pt = T([
|
|
|
373
373
|
]).or(r())),
|
|
374
374
|
role: ze,
|
|
375
375
|
content: Ht
|
|
376
|
-
}), Jt =
|
|
376
|
+
}), Jt = z.extend({
|
|
377
377
|
model: r(),
|
|
378
378
|
stopReason: a(T([
|
|
379
379
|
"endTurn",
|
|
@@ -461,7 +461,7 @@ var Pt = T([
|
|
|
461
461
|
Yt,
|
|
462
462
|
Xt,
|
|
463
463
|
Zt
|
|
464
|
-
]), tn = x([
|
|
464
|
+
]), tn = x([fe.extend({
|
|
465
465
|
mode: f("form").optional(),
|
|
466
466
|
message: r(),
|
|
467
467
|
requestedSchema: o({
|
|
@@ -469,18 +469,18 @@ var Pt = T([
|
|
|
469
469
|
properties: S(r(), en),
|
|
470
470
|
required: m(r()).optional()
|
|
471
471
|
}).catchall(c())
|
|
472
|
-
}),
|
|
472
|
+
}), fe.extend({
|
|
473
473
|
mode: f("url"),
|
|
474
474
|
message: r(),
|
|
475
475
|
elicitationId: r(),
|
|
476
476
|
url: r().url()
|
|
477
|
-
})]), nn =
|
|
477
|
+
})]), nn = I.extend({
|
|
478
478
|
method: f("elicitation/create"),
|
|
479
479
|
params: tn
|
|
480
|
-
}), rn =
|
|
480
|
+
}), rn = L.extend({ elicitationId: r() }), an = R.extend({
|
|
481
481
|
method: f("notifications/elicitation/complete"),
|
|
482
482
|
params: rn
|
|
483
|
-
}), on =
|
|
483
|
+
}), on = z.extend({
|
|
484
484
|
action: T([
|
|
485
485
|
"accept",
|
|
486
486
|
"decline",
|
|
@@ -498,17 +498,17 @@ var Pt = T([
|
|
|
498
498
|
}), cn = o({
|
|
499
499
|
type: f("ref/prompt"),
|
|
500
500
|
name: r()
|
|
501
|
-
}), ln =
|
|
501
|
+
}), ln = F.extend({
|
|
502
502
|
ref: x([cn, sn]),
|
|
503
503
|
argument: o({
|
|
504
504
|
name: r(),
|
|
505
505
|
value: r()
|
|
506
506
|
}),
|
|
507
507
|
context: o({ arguments: S(r(), r()).optional() }).optional()
|
|
508
|
-
}), un =
|
|
508
|
+
}), un = I.extend({
|
|
509
509
|
method: f("completion/complete"),
|
|
510
510
|
params: ln
|
|
511
|
-
}), dn =
|
|
511
|
+
}), dn = z.extend({ completion: i({
|
|
512
512
|
values: m(r()).max(100),
|
|
513
513
|
total: a(p().int()),
|
|
514
514
|
hasMore: a(D())
|
|
@@ -516,12 +516,12 @@ var Pt = T([
|
|
|
516
516
|
uri: r().startsWith("file://"),
|
|
517
517
|
name: r().optional(),
|
|
518
518
|
_meta: S(r(), c()).optional()
|
|
519
|
-
}), pn =
|
|
519
|
+
}), pn = I.extend({
|
|
520
520
|
method: f("roots/list"),
|
|
521
|
-
params:
|
|
522
|
-
}), mn =
|
|
521
|
+
params: F.optional()
|
|
522
|
+
}), mn = z.extend({ roots: m(fn) }), hn = R.extend({
|
|
523
523
|
method: f("notifications/roots/list_changed"),
|
|
524
|
-
params:
|
|
524
|
+
params: L.optional()
|
|
525
525
|
});
|
|
526
526
|
i({
|
|
527
527
|
ttl: p().optional(),
|
|
@@ -542,21 +542,21 @@ var gn = T([
|
|
|
542
542
|
pollInterval: a(p()),
|
|
543
543
|
statusMessage: a(r())
|
|
544
544
|
});
|
|
545
|
-
|
|
546
|
-
var vn =
|
|
547
|
-
|
|
545
|
+
z.extend({ task: _n });
|
|
546
|
+
var vn = L.merge(_n);
|
|
547
|
+
R.extend({
|
|
548
548
|
method: f("notifications/tasks/status"),
|
|
549
549
|
params: vn
|
|
550
|
-
}),
|
|
550
|
+
}), I.extend({
|
|
551
551
|
method: f("tasks/get"),
|
|
552
|
-
params:
|
|
553
|
-
}),
|
|
552
|
+
params: F.extend({ taskId: r() })
|
|
553
|
+
}), z.merge(_n), I.extend({
|
|
554
554
|
method: f("tasks/result"),
|
|
555
|
-
params:
|
|
556
|
-
}),
|
|
555
|
+
params: F.extend({ taskId: r() })
|
|
556
|
+
}), z.loose(), W.extend({ method: f("tasks/list") }), Le.extend({ tasks: m(_n) }), I.extend({
|
|
557
557
|
method: f("tasks/cancel"),
|
|
558
|
-
params:
|
|
559
|
-
}),
|
|
558
|
+
params: F.extend({ taskId: r() })
|
|
559
|
+
}), z.merge(_n), x([
|
|
560
560
|
Ne,
|
|
561
561
|
De,
|
|
562
562
|
je,
|
|
@@ -573,12 +573,12 @@ z.extend({
|
|
|
573
573
|
Mt,
|
|
574
574
|
Ot
|
|
575
575
|
]), x([
|
|
576
|
-
|
|
576
|
+
be,
|
|
577
577
|
Fe,
|
|
578
578
|
Ae,
|
|
579
579
|
hn
|
|
580
580
|
]), x([
|
|
581
|
-
|
|
581
|
+
ve,
|
|
582
582
|
qt,
|
|
583
583
|
Jt,
|
|
584
584
|
on,
|
|
@@ -589,7 +589,7 @@ z.extend({
|
|
|
589
589
|
nn,
|
|
590
590
|
pn
|
|
591
591
|
]), x([
|
|
592
|
-
|
|
592
|
+
be,
|
|
593
593
|
Fe,
|
|
594
594
|
Rt,
|
|
595
595
|
ct,
|
|
@@ -599,7 +599,7 @@ z.extend({
|
|
|
599
599
|
Y,
|
|
600
600
|
an
|
|
601
601
|
]), x([
|
|
602
|
-
|
|
602
|
+
ve,
|
|
603
603
|
ke,
|
|
604
604
|
Me,
|
|
605
605
|
dn,
|
|
@@ -978,7 +978,7 @@ o({
|
|
|
978
978
|
});
|
|
979
979
|
var Yn = o({
|
|
980
980
|
toolInfo: o({
|
|
981
|
-
id:
|
|
981
|
+
id: pe.optional().describe("JSON-RPC id of the tools/call request."),
|
|
982
982
|
tool: Dt.describe("Tool definition including name, inputSchema, etc.")
|
|
983
983
|
}).optional().describe("Metadata of the tool call that instantiated this App."),
|
|
984
984
|
theme: Tn.optional().describe("Current color theme preference."),
|
|
@@ -1018,13 +1018,13 @@ var Xn = o({
|
|
|
1018
1018
|
}), Zn = o({
|
|
1019
1019
|
method: f("ui/initialize"),
|
|
1020
1020
|
params: o({
|
|
1021
|
-
appInfo:
|
|
1021
|
+
appInfo: V.describe("App identification (name and version)."),
|
|
1022
1022
|
appCapabilities: Hn.describe("Features and capabilities this app provides."),
|
|
1023
1023
|
protocolVersion: r().describe("Protocol version this app supports.")
|
|
1024
1024
|
})
|
|
1025
1025
|
}), Qn = o({
|
|
1026
1026
|
protocolVersion: r().describe("Negotiated protocol version string (e.g., \"2025-11-21\")."),
|
|
1027
|
-
hostInfo:
|
|
1027
|
+
hostInfo: V.describe("Host application identification and version."),
|
|
1028
1028
|
hostCapabilities: Vn.describe("Features and capabilities provided by the host."),
|
|
1029
1029
|
hostContext: Yn.describe("Rich context about the host environment.")
|
|
1030
1030
|
}).passthrough(), $n = class {
|
|
@@ -1037,7 +1037,7 @@ var Xn = o({
|
|
|
1037
1037
|
console.debug("Ignoring message from unknown source", e);
|
|
1038
1038
|
return;
|
|
1039
1039
|
}
|
|
1040
|
-
let n =
|
|
1040
|
+
let n = _e.safeParse(e.data);
|
|
1041
1041
|
n.success ? (console.debug("Parsed message", n.data), this.onmessage?.(n.data)) : e.data?.jsonrpc === "2.0" ? (console.error("Failed to parse message", n.error.message, e), this.onerror?.(Error("Invalid JSON-RPC message received: " + n.error.message))) : console.debug("Ignoring non-JSON-RPC message", n.error.message, e);
|
|
1042
1042
|
};
|
|
1043
1043
|
}
|
|
@@ -1219,7 +1219,7 @@ var nr = [wn], rr = class extends ie {
|
|
|
1219
1219
|
set onupdatemodelcontext(e) {
|
|
1220
1220
|
this.warnIfRequestHandlerReplaced("onupdatemodelcontext", this._onupdatemodelcontext, e), this._onupdatemodelcontext = e, this.setRequestHandler("ui/update-model-context", {
|
|
1221
1221
|
params: Xn.shape.params,
|
|
1222
|
-
result:
|
|
1222
|
+
result: ve
|
|
1223
1223
|
}, async (e, t) => {
|
|
1224
1224
|
if (!this._onupdatemodelcontext) throw Error("No onupdatemodelcontext handler set");
|
|
1225
1225
|
return this._onupdatemodelcontext(e, t);
|
|
@@ -2786,52 +2786,8 @@ async function ci(e, t) {
|
|
|
2786
2786
|
await fetch(e, t);
|
|
2787
2787
|
} catch {}
|
|
2788
2788
|
}
|
|
2789
|
-
var li = "https://eu.i.posthog.com", ui = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI"
|
|
2790
|
-
|
|
2791
|
-
"response",
|
|
2792
|
-
"messages"
|
|
2793
|
-
]);
|
|
2794
|
-
function hi(e) {
|
|
2795
|
-
if (e == null) return "";
|
|
2796
|
-
if (typeof e == "string") return e;
|
|
2797
|
-
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
2798
|
-
try {
|
|
2799
|
-
return JSON.stringify(e);
|
|
2800
|
-
} catch {
|
|
2801
|
-
return String(e);
|
|
2802
|
-
}
|
|
2803
|
-
}
|
|
2804
|
-
function gi(e, t = fi) {
|
|
2805
|
-
let n = new URLSearchParams();
|
|
2806
|
-
for (let [t, r] of Object.entries(e)) {
|
|
2807
|
-
let e = hi(r);
|
|
2808
|
-
mi.has(t) && e.length > 120 && (e = `${e.slice(0, 117)}...`), e !== "" && n.set(t, e);
|
|
2809
|
-
}
|
|
2810
|
-
let r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`;
|
|
2811
|
-
if (r.length <= pi) return r;
|
|
2812
|
-
let i = [...n.keys()].sort((e, t) => (n.get(t)?.length ?? 0) - (n.get(e)?.length ?? 0));
|
|
2813
|
-
for (let e of i) {
|
|
2814
|
-
if (r.length <= pi) break;
|
|
2815
|
-
e === "event" || e === "user_id" || (n.delete(e), r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`);
|
|
2816
|
-
}
|
|
2817
|
-
return r.slice(0, pi);
|
|
2818
|
-
}
|
|
2819
|
-
function _i(e, t) {
|
|
2820
|
-
return ci(t, {
|
|
2821
|
-
method: "POST",
|
|
2822
|
-
headers: { "Content-Type": "application/json" },
|
|
2823
|
-
keepalive: !0,
|
|
2824
|
-
body: JSON.stringify(e)
|
|
2825
|
-
});
|
|
2826
|
-
}
|
|
2827
|
-
function vi(e, t) {
|
|
2828
|
-
try {
|
|
2829
|
-
let n = gi(e, t), r = new Image();
|
|
2830
|
-
r.referrerPolicy = "no-referrer-when-downgrade", r.src = n;
|
|
2831
|
-
} catch {}
|
|
2832
|
-
return Promise.resolve();
|
|
2833
|
-
}
|
|
2834
|
-
function yi(e) {
|
|
2789
|
+
var li = "https://eu.i.posthog.com", ui = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
2790
|
+
function di(e) {
|
|
2835
2791
|
let t = e.host ?? li, n = e.apiKey ?? ui;
|
|
2836
2792
|
return ci(`${t}/i/v0/e/`, {
|
|
2837
2793
|
method: "POST",
|
|
@@ -2846,30 +2802,19 @@ function yi(e) {
|
|
|
2846
2802
|
})
|
|
2847
2803
|
});
|
|
2848
2804
|
}
|
|
2849
|
-
function
|
|
2850
|
-
return typeof window < "u" ? vi(e, t === di ? fi : t) : _i(e, t);
|
|
2851
|
-
}
|
|
2852
|
-
function xi() {
|
|
2805
|
+
function fi() {
|
|
2853
2806
|
return globalThis.crypto.randomUUID();
|
|
2854
2807
|
}
|
|
2855
|
-
function
|
|
2808
|
+
function pi() {
|
|
2856
2809
|
let e = new Uint8Array(8);
|
|
2857
2810
|
return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
|
|
2858
2811
|
}
|
|
2859
|
-
|
|
2860
|
-
|
|
2861
|
-
for (let e = 0; e < a; e++) {
|
|
2862
|
-
let t = r[e] ?? 0, n = i[e] ?? 0;
|
|
2863
|
-
if (t !== n) return t > n;
|
|
2864
|
-
}
|
|
2865
|
-
return !1;
|
|
2866
|
-
}
|
|
2867
|
-
var wi = "mcp_use_user_id", Ti = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", Ei = "https://eu.i.posthog.com", Di = null;
|
|
2868
|
-
function Oi() {
|
|
2812
|
+
var mi = "mcp_use_user_id", hi = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", gi = "https://eu.i.posthog.com", _i = null;
|
|
2813
|
+
function vi() {
|
|
2869
2814
|
return typeof localStorage < "u" && typeof localStorage.getItem == "function" && typeof localStorage.setItem == "function" && typeof localStorage.removeItem == "function";
|
|
2870
2815
|
}
|
|
2871
|
-
function
|
|
2872
|
-
if (!
|
|
2816
|
+
function yi() {
|
|
2817
|
+
if (!vi()) return null;
|
|
2873
2818
|
try {
|
|
2874
2819
|
localStorage.setItem("__mcp_use_test__", "1"), localStorage.removeItem("__mcp_use_test__");
|
|
2875
2820
|
} catch {
|
|
@@ -2878,66 +2823,60 @@ function ki() {
|
|
|
2878
2823
|
return {
|
|
2879
2824
|
getUserId() {
|
|
2880
2825
|
try {
|
|
2881
|
-
return localStorage.getItem(
|
|
2826
|
+
return localStorage.getItem(mi);
|
|
2882
2827
|
} catch {
|
|
2883
2828
|
return null;
|
|
2884
2829
|
}
|
|
2885
2830
|
},
|
|
2886
2831
|
setUserId(e) {
|
|
2887
2832
|
try {
|
|
2888
|
-
localStorage.setItem(
|
|
2833
|
+
localStorage.setItem(mi, e);
|
|
2889
2834
|
} catch {}
|
|
2890
|
-
}
|
|
2891
|
-
getDownloadedVersion: () => null,
|
|
2892
|
-
setDownloadedVersion: () => void 0
|
|
2835
|
+
}
|
|
2893
2836
|
};
|
|
2894
2837
|
}
|
|
2895
|
-
function
|
|
2838
|
+
function bi() {
|
|
2896
2839
|
try {
|
|
2897
2840
|
return globalThis.Bun === void 0 ? globalThis.Deno === void 0 ? typeof navigator < "u" && navigator.userAgent?.includes("Cloudflare-Workers") ? "cloudflare-workers" : globalThis.EdgeRuntime === void 0 ? typeof window < "u" && typeof document < "u" ? "browser" : typeof process < "u" && process.versions?.node !== void 0 ? "node" : "unknown" : "edge" : "deno" : "bun";
|
|
2898
2841
|
} catch {
|
|
2899
2842
|
return "unknown";
|
|
2900
2843
|
}
|
|
2901
2844
|
}
|
|
2902
|
-
function
|
|
2845
|
+
function xi() {
|
|
2903
2846
|
if (typeof process < "u" && {}.MCP_USE_TELEMETRY_SOURCE) return {}.MCP_USE_TELEMETRY_SOURCE;
|
|
2904
2847
|
try {
|
|
2905
|
-
if (
|
|
2848
|
+
if (vi()) return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE") ?? void 0;
|
|
2906
2849
|
} catch {}
|
|
2907
2850
|
}
|
|
2908
|
-
function
|
|
2851
|
+
function Si() {
|
|
2909
2852
|
if (typeof window < "u" && window.__MCP_USE_ANONYMIZED_TELEMETRY__ === !1 || typeof process < "u" && {}.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false") return !0;
|
|
2910
2853
|
try {
|
|
2911
|
-
if (
|
|
2854
|
+
if (vi() && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") return !0;
|
|
2912
2855
|
} catch {}
|
|
2913
2856
|
return !1;
|
|
2914
2857
|
}
|
|
2915
|
-
function
|
|
2858
|
+
function Ci() {
|
|
2916
2859
|
try {
|
|
2917
|
-
return `session-${
|
|
2860
|
+
return `session-${fi()}`;
|
|
2918
2861
|
} catch {
|
|
2919
|
-
return `session-${Date.now()}-${
|
|
2862
|
+
return `session-${Date.now()}-${pi()}`;
|
|
2920
2863
|
}
|
|
2921
2864
|
}
|
|
2922
|
-
var
|
|
2865
|
+
var wi = class e {
|
|
2923
2866
|
static instance = null;
|
|
2924
2867
|
UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
|
|
2925
2868
|
_currUserId = null;
|
|
2926
2869
|
_telemetryEnabled = !1;
|
|
2927
2870
|
_pending = /* @__PURE__ */ new Set();
|
|
2928
|
-
_scarfEnabled = !1;
|
|
2929
2871
|
_runtimeEnvironment;
|
|
2930
2872
|
_storageCapability;
|
|
2931
2873
|
_storage;
|
|
2932
|
-
_fsBacked;
|
|
2933
2874
|
_source;
|
|
2934
2875
|
_productVersion;
|
|
2935
2876
|
constructor() {
|
|
2936
|
-
this._runtimeEnvironment =
|
|
2937
|
-
let e =
|
|
2938
|
-
e ? (this._telemetryEnabled = !1, Z.debug("Telemetry disabled via opt-out")) : t ? (Z.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0
|
|
2939
|
-
this.trackPackageDownload({ triggered_by: "initialization" }).catch((e) => Z.debug(`Failed to track package download: ${e}`));
|
|
2940
|
-
}, 0)) : (this._telemetryEnabled = !1, Z.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
|
|
2877
|
+
this._runtimeEnvironment = bi(), this._storage = _i ?? yi() ?? null, this._storageCapability = this._storage ? "persistent" : "session-only", this._source = xi() || this._runtimeEnvironment;
|
|
2878
|
+
let e = Si(), t = this._runtimeEnvironment !== "unknown";
|
|
2879
|
+
e ? (this._telemetryEnabled = !1, Z.debug("Telemetry disabled via opt-out")) : t ? (Z.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0) : (this._telemetryEnabled = !1, Z.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
|
|
2941
2880
|
}
|
|
2942
2881
|
get runtimeEnvironment() {
|
|
2943
2882
|
return this._runtimeEnvironment;
|
|
@@ -2951,7 +2890,7 @@ var Pi = class e {
|
|
|
2951
2890
|
setSource(e) {
|
|
2952
2891
|
this._source = e;
|
|
2953
2892
|
try {
|
|
2954
|
-
|
|
2893
|
+
vi() && localStorage.setItem("MCP_USE_TELEMETRY_SOURCE", e);
|
|
2955
2894
|
} catch {}
|
|
2956
2895
|
Z.debug(`Telemetry source set to: ${e}`);
|
|
2957
2896
|
}
|
|
@@ -2962,7 +2901,7 @@ var Pi = class e {
|
|
|
2962
2901
|
this._productVersion = e;
|
|
2963
2902
|
}
|
|
2964
2903
|
get isEnabled() {
|
|
2965
|
-
return this._telemetryEnabled
|
|
2904
|
+
return this._telemetryEnabled;
|
|
2966
2905
|
}
|
|
2967
2906
|
get userId() {
|
|
2968
2907
|
if (this._currUserId) return this._currUserId;
|
|
@@ -2970,56 +2909,31 @@ var Pi = class e {
|
|
|
2970
2909
|
if (this._storage) {
|
|
2971
2910
|
let e = this._storage.getUserId();
|
|
2972
2911
|
if (e) return this._currUserId = e, e;
|
|
2973
|
-
let t =
|
|
2912
|
+
let t = fi();
|
|
2974
2913
|
return this._storage.setUserId(t), this._currUserId = t, t;
|
|
2975
2914
|
}
|
|
2976
|
-
this._currUserId =
|
|
2915
|
+
this._currUserId = Ci();
|
|
2977
2916
|
} catch {
|
|
2978
2917
|
this._currUserId = this.UNKNOWN_USER_ID;
|
|
2979
2918
|
}
|
|
2980
2919
|
return this._currUserId;
|
|
2981
2920
|
}
|
|
2982
2921
|
async capture(e) {
|
|
2983
|
-
if (!this._telemetryEnabled
|
|
2922
|
+
if (!this._telemetryEnabled) return;
|
|
2984
2923
|
let t = this.userId, n = {
|
|
2985
2924
|
...e.properties,
|
|
2986
2925
|
mcp_use_version: this._productVersion ?? Ur(),
|
|
2987
2926
|
language: "typescript",
|
|
2988
2927
|
source: this._source,
|
|
2989
2928
|
runtime: this._runtimeEnvironment
|
|
2990
|
-
}
|
|
2991
|
-
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
distinctId: t,
|
|
2997
|
-
properties: n
|
|
2998
|
-
});
|
|
2999
|
-
this._pending.add(r), r.finally(() => this._pending.delete(r));
|
|
3000
|
-
}
|
|
3001
|
-
if (this._scarfEnabled) {
|
|
3002
|
-
let r = bi({
|
|
3003
|
-
...n,
|
|
3004
|
-
user_id: t,
|
|
3005
|
-
event: e.name
|
|
3006
|
-
});
|
|
3007
|
-
this._pending.add(r), r.finally(() => this._pending.delete(r));
|
|
3008
|
-
}
|
|
3009
|
-
}
|
|
3010
|
-
async trackPackageDownload(e) {
|
|
3011
|
-
if (!this._scarfEnabled || !this._fsBacked || !this._storage) return;
|
|
3012
|
-
let t = Ur(), n = this._storage.getDownloadedVersion(), r = !1, i = !1;
|
|
3013
|
-
n ? Ci(t, n) && (i = !0, this._storage.setDownloadedVersion(t)) : (i = !0, r = !0, this._storage.setDownloadedVersion(t)), i && await bi({
|
|
3014
|
-
...e || {},
|
|
3015
|
-
mcp_use_version: t,
|
|
3016
|
-
user_id: this.userId,
|
|
3017
|
-
event: "package_download",
|
|
3018
|
-
first_download: r,
|
|
3019
|
-
language: "typescript",
|
|
3020
|
-
source: this._source,
|
|
3021
|
-
runtime: this._runtimeEnvironment
|
|
2929
|
+
}, r = di({
|
|
2930
|
+
host: gi,
|
|
2931
|
+
apiKey: hi,
|
|
2932
|
+
event: e.name,
|
|
2933
|
+
distinctId: t,
|
|
2934
|
+
properties: n
|
|
3022
2935
|
});
|
|
2936
|
+
this._pending.add(r), r.finally(() => this._pending.delete(r));
|
|
3023
2937
|
}
|
|
3024
2938
|
async trackAgentExecution(e) {
|
|
3025
2939
|
this.isEnabled && await this.capture(new ri(e));
|
|
@@ -3076,9 +2990,9 @@ var Pi = class e {
|
|
|
3076
2990
|
});
|
|
3077
2991
|
}
|
|
3078
2992
|
identify(e, t) {
|
|
3079
|
-
this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled &&
|
|
3080
|
-
host:
|
|
3081
|
-
apiKey:
|
|
2993
|
+
this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled && di({
|
|
2994
|
+
host: gi,
|
|
2995
|
+
apiKey: hi,
|
|
3082
2996
|
event: "$identify",
|
|
3083
2997
|
distinctId: e,
|
|
3084
2998
|
properties: { $set: t ?? {} }
|
|
@@ -3097,21 +3011,21 @@ var Pi = class e {
|
|
|
3097
3011
|
Z.debug(`Error flushing telemetry captures: ${e}`);
|
|
3098
3012
|
}
|
|
3099
3013
|
}
|
|
3100
|
-
},
|
|
3101
|
-
function
|
|
3014
|
+
}, Ti = 5 * 6e4;
|
|
3015
|
+
function Ei(e, t = 0) {
|
|
3102
3016
|
if (!e || t > 5) return !1;
|
|
3103
3017
|
if (e instanceof E) return !0;
|
|
3104
3018
|
if (e instanceof Error) {
|
|
3105
3019
|
if (e.code === 401 || e.name === "UnauthorizedError") return !0;
|
|
3106
3020
|
let n = e.message ?? "";
|
|
3107
|
-
if (n.includes("401") || n.includes("Unauthorized") || e.cause &&
|
|
3021
|
+
if (n.includes("401") || n.includes("Unauthorized") || e.cause && Ei(e.cause, t + 1)) return !0;
|
|
3108
3022
|
let r = e.data;
|
|
3109
|
-
if (r?.cause &&
|
|
3023
|
+
if (r?.cause && Ei(r.cause, t + 1)) return !0;
|
|
3110
3024
|
}
|
|
3111
3025
|
return !1;
|
|
3112
3026
|
}
|
|
3113
|
-
async function
|
|
3114
|
-
let r = e, i = n.timeoutMs ??
|
|
3027
|
+
async function Di(e, t, n = {}) {
|
|
3028
|
+
let r = e, i = n.timeoutMs ?? Ti, a = n.fetchFn ?? r.getProxyFetch?.() ?? void 0;
|
|
3115
3029
|
if (!r.hasPendingFlow) {
|
|
3116
3030
|
let n = await b(e, {
|
|
3117
3031
|
serverUrl: t,
|
|
@@ -3128,9 +3042,9 @@ async function Li(e, t, n = {}) {
|
|
|
3128
3042
|
});
|
|
3129
3043
|
return;
|
|
3130
3044
|
}
|
|
3131
|
-
await
|
|
3045
|
+
await Oi(r, i);
|
|
3132
3046
|
}
|
|
3133
|
-
async function
|
|
3047
|
+
async function Oi(e, t) {
|
|
3134
3048
|
if (typeof window > "u") throw Error("OAuth redirect requires a browser environment or a provider with getAuthorizationCode()");
|
|
3135
3049
|
if (e.useRedirectFlow) return;
|
|
3136
3050
|
let n = e.getKey?.("tokens");
|
|
@@ -3154,7 +3068,7 @@ async function Ri(e, t) {
|
|
|
3154
3068
|
}
|
|
3155
3069
|
}
|
|
3156
3070
|
mr();
|
|
3157
|
-
var
|
|
3071
|
+
var ki = class {
|
|
3158
3072
|
connector;
|
|
3159
3073
|
autoConnect;
|
|
3160
3074
|
constructor(e, t = !0) {
|
|
@@ -3248,17 +3162,17 @@ var zi = class {
|
|
|
3248
3162
|
async request(e, t = null, n) {
|
|
3249
3163
|
return this.connector.request(e, t, n);
|
|
3250
3164
|
}
|
|
3251
|
-
},
|
|
3252
|
-
function
|
|
3253
|
-
|
|
3165
|
+
}, Ai;
|
|
3166
|
+
function ji(e, t) {
|
|
3167
|
+
Ai?.addServer(e, t);
|
|
3254
3168
|
}
|
|
3255
|
-
function
|
|
3256
|
-
|
|
3169
|
+
function Mi(e) {
|
|
3170
|
+
Ai?.removeServer(e);
|
|
3257
3171
|
}
|
|
3258
|
-
function
|
|
3172
|
+
function Ni(e) {
|
|
3259
3173
|
return !!e && typeof e == "object" && "redirectUrl" in e && "clientMetadata" in e;
|
|
3260
3174
|
}
|
|
3261
|
-
var
|
|
3175
|
+
var Pi = class {
|
|
3262
3176
|
config = {};
|
|
3263
3177
|
sessions = {};
|
|
3264
3178
|
activeSessions = [];
|
|
@@ -3269,10 +3183,10 @@ var Wi = class {
|
|
|
3269
3183
|
throw Error("fromDict must be implemented by concrete class");
|
|
3270
3184
|
}
|
|
3271
3185
|
addServer(e, t) {
|
|
3272
|
-
this.config.mcpServers = this.config.mcpServers || {}, this.config.mcpServers[e] = t,
|
|
3186
|
+
this.config.mcpServers = this.config.mcpServers || {}, this.config.mcpServers[e] = t, ji(e, t);
|
|
3273
3187
|
}
|
|
3274
3188
|
async removeServer(e) {
|
|
3275
|
-
this.config.mcpServers?.[e] && (await this.closeSession(e), delete this.config.mcpServers[e],
|
|
3189
|
+
this.config.mcpServers?.[e] && (await this.closeSession(e), delete this.config.mcpServers[e], Mi(e));
|
|
3276
3190
|
}
|
|
3277
3191
|
getServerNames() {
|
|
3278
3192
|
return Object.keys(this.config.mcpServers ?? {});
|
|
@@ -3293,17 +3207,17 @@ var Wi = class {
|
|
|
3293
3207
|
...r,
|
|
3294
3208
|
authProvider: i
|
|
3295
3209
|
};
|
|
3296
|
-
} else "authProvider" in r && r.authProvider &&
|
|
3210
|
+
} else "authProvider" in r && r.authProvider && Ni(r.authProvider) && (i = r.authProvider);
|
|
3297
3211
|
let a = async () => {
|
|
3298
|
-
let e = new
|
|
3212
|
+
let e = new ki(await Promise.resolve(this.createConnectorFromConfig(r)));
|
|
3299
3213
|
return t && await e.initialize(), e;
|
|
3300
3214
|
}, o;
|
|
3301
3215
|
try {
|
|
3302
3216
|
o = await a();
|
|
3303
3217
|
} catch (n) {
|
|
3304
3218
|
let s = r;
|
|
3305
|
-
if (!t || !i || !("url" in s) || !
|
|
3306
|
-
Z.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await
|
|
3219
|
+
if (!t || !i || !("url" in s) || !Ei(n) || i.preventAutoAuth) throw n;
|
|
3220
|
+
Z.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await Di(i, s.url), o = await a();
|
|
3307
3221
|
}
|
|
3308
3222
|
return this.sessions[e] = o, this.activeSessions.includes(e) || this.activeSessions.push(e), o;
|
|
3309
3223
|
}
|
|
@@ -3358,9 +3272,9 @@ var Wi = class {
|
|
|
3358
3272
|
await this.closeAllSessions();
|
|
3359
3273
|
}
|
|
3360
3274
|
};
|
|
3361
|
-
function
|
|
3275
|
+
function Fi(e) {
|
|
3362
3276
|
let t = Object.keys(e.mcpServers ?? {});
|
|
3363
|
-
|
|
3277
|
+
wi.getInstance().trackMCPClientInit({
|
|
3364
3278
|
codeMode: !1,
|
|
3365
3279
|
sandbox: !1,
|
|
3366
3280
|
allCallbacks: !1,
|
|
@@ -3370,12 +3284,12 @@ function Gi(e) {
|
|
|
3370
3284
|
isBrowser: !0
|
|
3371
3285
|
}).catch((e) => Z.debug(`Failed to track BrowserMCPClient init: ${e}`));
|
|
3372
3286
|
}
|
|
3373
|
-
var
|
|
3287
|
+
var Ii = class e extends Pi {
|
|
3374
3288
|
static getPackageVersion() {
|
|
3375
3289
|
return Ur();
|
|
3376
3290
|
}
|
|
3377
3291
|
constructor(e) {
|
|
3378
|
-
super(e),
|
|
3292
|
+
super(e), Fi(this.config);
|
|
3379
3293
|
}
|
|
3380
3294
|
static fromDict(t) {
|
|
3381
3295
|
return new e(t);
|
|
@@ -3407,8 +3321,8 @@ var Ki = class e extends Wi {
|
|
|
3407
3321
|
}
|
|
3408
3322
|
};
|
|
3409
3323
|
mr();
|
|
3410
|
-
var
|
|
3411
|
-
function
|
|
3324
|
+
var Li = "https://favicon.tools.mcp-use.com", Ri = /^\d{1,3}(\.\d{1,3}){3}$/;
|
|
3325
|
+
function zi(e) {
|
|
3412
3326
|
try {
|
|
3413
3327
|
let t = e.includes("://") ? e : `https://${e}`;
|
|
3414
3328
|
return new URL(t).hostname;
|
|
@@ -3416,10 +3330,10 @@ function Yi(e) {
|
|
|
3416
3330
|
return null;
|
|
3417
3331
|
}
|
|
3418
3332
|
}
|
|
3419
|
-
function
|
|
3333
|
+
function Bi(e) {
|
|
3420
3334
|
let t = e.toLowerCase();
|
|
3421
3335
|
if (t === "localhost" || t.endsWith(".localhost") || t === "host.docker.internal" || t === "0.0.0.0") return !0;
|
|
3422
|
-
if (!
|
|
3336
|
+
if (!Ri.test(t)) return !1;
|
|
3423
3337
|
if (t === "127.0.0.1" || t.startsWith("127.") || t.startsWith("10.") || t.startsWith("192.168.")) return !0;
|
|
3424
3338
|
let n = /^172\.(\d+)\./.exec(t);
|
|
3425
3339
|
if (n) {
|
|
@@ -3428,28 +3342,28 @@ function Xi(e) {
|
|
|
3428
3342
|
}
|
|
3429
3343
|
return !1;
|
|
3430
3344
|
}
|
|
3431
|
-
function
|
|
3345
|
+
function Vi(e) {
|
|
3432
3346
|
let t = e.split(".");
|
|
3433
3347
|
return Array.from({ length: t.length - 1 }, (e, n) => t.slice(n).join("."));
|
|
3434
3348
|
}
|
|
3435
|
-
function
|
|
3349
|
+
function Hi(e) {
|
|
3436
3350
|
return new Promise((t, n) => {
|
|
3437
3351
|
let r = new FileReader();
|
|
3438
3352
|
r.onloadend = () => t(r.result), r.onerror = n, r.readAsDataURL(e);
|
|
3439
3353
|
});
|
|
3440
3354
|
}
|
|
3441
|
-
async function
|
|
3355
|
+
async function Ui(e) {
|
|
3442
3356
|
try {
|
|
3443
|
-
let t =
|
|
3444
|
-
if (!t ||
|
|
3445
|
-
for (let e of
|
|
3446
|
-
let t = await fetch(`${
|
|
3357
|
+
let t = zi(e);
|
|
3358
|
+
if (!t || Bi(t)) return null;
|
|
3359
|
+
for (let e of Vi(t)) try {
|
|
3360
|
+
let t = await fetch(`${Li}/${e}?response=json`, { signal: AbortSignal.timeout(2e3) });
|
|
3447
3361
|
if (!t.ok) continue;
|
|
3448
3362
|
let n = await t.json();
|
|
3449
3363
|
if (n.source === "default") continue;
|
|
3450
3364
|
let r = n.url.replace(/^http:\/\//, "https://"), i = await fetch(r, { signal: AbortSignal.timeout(2e3) });
|
|
3451
3365
|
if (!i.ok) continue;
|
|
3452
|
-
return await
|
|
3366
|
+
return await Hi(await i.blob());
|
|
3453
3367
|
} catch {
|
|
3454
3368
|
continue;
|
|
3455
3369
|
}
|
|
@@ -3458,11 +3372,11 @@ async function $i(e) {
|
|
|
3458
3372
|
return console.warn("[favicon] Error detecting favicon:", e), null;
|
|
3459
3373
|
}
|
|
3460
3374
|
}
|
|
3461
|
-
var
|
|
3462
|
-
function
|
|
3375
|
+
var Wi = "inspector-server";
|
|
3376
|
+
function Gi(e, t) {
|
|
3463
3377
|
if (!e) throw Error(t);
|
|
3464
3378
|
}
|
|
3465
|
-
async function
|
|
3379
|
+
async function Ki(e) {
|
|
3466
3380
|
try {
|
|
3467
3381
|
let t = e.serverInfo.icons?.[0]?.src;
|
|
3468
3382
|
if (t) {
|
|
@@ -3477,7 +3391,7 @@ async function na(e) {
|
|
|
3477
3391
|
} : void 0), e.addLog("debug", "Server icon converted to base64")), r;
|
|
3478
3392
|
}
|
|
3479
3393
|
if (e.url) {
|
|
3480
|
-
let t = await
|
|
3394
|
+
let t = await Ui(e.url);
|
|
3481
3395
|
if (!e.isMounted()) return e.addLog("debug", "Connection aborted after favicon detection - component unmounted"), null;
|
|
3482
3396
|
if (t) return e.setServerInfo((e) => e ? {
|
|
3483
3397
|
...e,
|
|
@@ -3489,10 +3403,10 @@ async function na(e) {
|
|
|
3489
3403
|
return e.addLog("debug", "Icon loading failed (non-critical):", t), null;
|
|
3490
3404
|
}
|
|
3491
3405
|
}
|
|
3492
|
-
function
|
|
3406
|
+
function qi(e, t) {
|
|
3493
3407
|
return t ? `state=${e}` : `client disconnected (state=${e})`;
|
|
3494
3408
|
}
|
|
3495
|
-
function
|
|
3409
|
+
function Ji(e) {
|
|
3496
3410
|
return {
|
|
3497
3411
|
name: e.name,
|
|
3498
3412
|
version: e.version,
|
|
@@ -3500,11 +3414,11 @@ function ia(e) {
|
|
|
3500
3414
|
logo_uri: e.icons?.[0]?.src
|
|
3501
3415
|
};
|
|
3502
3416
|
}
|
|
3503
|
-
function
|
|
3417
|
+
function Yi(e) {
|
|
3504
3418
|
let t = (e instanceof Error ? e.message : String(e)).toLowerCase();
|
|
3505
3419
|
return t.includes("oauth discovery failed") || t.includes("oauth-authorization-server") || t.includes("not valid json") || t.includes("404") && (t.includes("openid-configuration") || t.includes("oauth-protected-resources") || t.includes("oauth-authorization-url") || t.includes("register")) || t.includes("invalid oauth error response") && t.includes("not found");
|
|
3506
3420
|
}
|
|
3507
|
-
function
|
|
3421
|
+
function Xi(e, t) {
|
|
3508
3422
|
if (t) return t;
|
|
3509
3423
|
if (e) try {
|
|
3510
3424
|
let t = new URL(e);
|
|
@@ -3513,8 +3427,8 @@ function oa(e, t) {
|
|
|
3513
3427
|
return;
|
|
3514
3428
|
}
|
|
3515
3429
|
}
|
|
3516
|
-
function
|
|
3517
|
-
let t =
|
|
3430
|
+
function Zi(e) {
|
|
3431
|
+
let t = Xi(e.gatewayUrl, e.oauthProxyUrl);
|
|
3518
3432
|
return {
|
|
3519
3433
|
provider: new ei(e.effectiveOAuthUrl, {
|
|
3520
3434
|
storageKeyPrefix: e.storageKeyPrefix,
|
|
@@ -3535,7 +3449,7 @@ function sa(e) {
|
|
|
3535
3449
|
oauthProxyUrl: t
|
|
3536
3450
|
};
|
|
3537
3451
|
}
|
|
3538
|
-
function
|
|
3452
|
+
function Qi(e) {
|
|
3539
3453
|
let t = null, n = Date.now(), r = !1, i = e.healthCheckIntervalMs ?? 1e4, a = e.healthCheckTimeoutMs ?? 3e4;
|
|
3540
3454
|
return t = setInterval(async () => {
|
|
3541
3455
|
if (!r) {
|
|
@@ -3571,25 +3485,25 @@ function ca(e) {
|
|
|
3571
3485
|
t &&= (clearInterval(t), null);
|
|
3572
3486
|
};
|
|
3573
3487
|
}
|
|
3574
|
-
function
|
|
3488
|
+
function $i(e, t) {
|
|
3575
3489
|
let n = e.connectionRef.current;
|
|
3576
|
-
if (e.stateRef.current !== "ready" || !e.hasClient() || !n) throw Error(`MCP client is not ready (${
|
|
3490
|
+
if (e.stateRef.current !== "ready" || !e.hasClient() || !n) throw Error(`MCP client is not ready (${qi(e.stateRef.current, e.hasClient())}). Cannot ${t}.`);
|
|
3577
3491
|
return n;
|
|
3578
3492
|
}
|
|
3579
|
-
function
|
|
3493
|
+
function ea(e) {
|
|
3580
3494
|
let t = (0, A.useCallback)(async (t, n, r) => {
|
|
3581
|
-
let i =
|
|
3495
|
+
let i = $i(e, `call tool "${t}"`);
|
|
3582
3496
|
e.addLog("info", `Calling tool: ${t}`, n);
|
|
3583
3497
|
let a = Date.now();
|
|
3584
3498
|
try {
|
|
3585
3499
|
let o = await i.callTool(t, n || {}, r);
|
|
3586
|
-
return e.addLog("info", `Tool "${t}" call successful:`, o),
|
|
3500
|
+
return e.addLog("info", `Tool "${t}" call successful:`, o), wi.getInstance().trackUseMcpToolCall({
|
|
3587
3501
|
toolName: t,
|
|
3588
3502
|
success: !0,
|
|
3589
3503
|
executionTimeMs: Date.now() - a
|
|
3590
3504
|
}).catch(() => {}), o;
|
|
3591
3505
|
} catch (n) {
|
|
3592
|
-
throw e.addLog("error", `Tool "${t}" call failed:`, n),
|
|
3506
|
+
throw e.addLog("error", `Tool "${t}" call failed:`, n), wi.getInstance().trackUseMcpToolCall({
|
|
3593
3507
|
toolName: t,
|
|
3594
3508
|
success: !1,
|
|
3595
3509
|
errorType: n instanceof Error ? n.name : "UnknownError",
|
|
@@ -3597,28 +3511,28 @@ function ua(e) {
|
|
|
3597
3511
|
}).catch(() => {}), n;
|
|
3598
3512
|
}
|
|
3599
3513
|
}, [e.addLog]), n = (0, A.useCallback)(async () => {
|
|
3600
|
-
let t =
|
|
3514
|
+
let t = $i(e, "list resources");
|
|
3601
3515
|
e.addLog("info", "Listing resources");
|
|
3602
3516
|
let n = await t.listAllResources();
|
|
3603
3517
|
e.setResources(n.resources || []);
|
|
3604
3518
|
}, [e.addLog]), r = (0, A.useCallback)(async (t) => {
|
|
3605
|
-
let n =
|
|
3519
|
+
let n = $i(e, "read resource");
|
|
3606
3520
|
e.addLog("info", `Reading resource: ${t}`);
|
|
3607
3521
|
try {
|
|
3608
3522
|
let e = await n.readResource(t);
|
|
3609
|
-
return
|
|
3523
|
+
return wi.getInstance().trackUseMcpResourceRead({
|
|
3610
3524
|
resourceUri: t,
|
|
3611
3525
|
success: !0
|
|
3612
3526
|
}).catch(() => {}), e;
|
|
3613
3527
|
} catch (e) {
|
|
3614
|
-
throw
|
|
3528
|
+
throw wi.getInstance().trackUseMcpResourceRead({
|
|
3615
3529
|
resourceUri: t,
|
|
3616
3530
|
success: !1,
|
|
3617
3531
|
errorType: e instanceof Error ? e.name : "UnknownError"
|
|
3618
3532
|
}).catch(() => {}), e;
|
|
3619
3533
|
}
|
|
3620
3534
|
}, [e.addLog]), i = (0, A.useCallback)(async () => {
|
|
3621
|
-
let t =
|
|
3535
|
+
let t = $i(e, "list prompts");
|
|
3622
3536
|
e.addLog("info", "Listing prompts");
|
|
3623
3537
|
let n = await t.listPrompts();
|
|
3624
3538
|
e.setPrompts(n.prompts || []);
|
|
@@ -3643,7 +3557,7 @@ function ua(e) {
|
|
|
3643
3557
|
e.addLog("warn", "Failed to refresh prompts:", t);
|
|
3644
3558
|
}
|
|
3645
3559
|
}, [e.addLog]), c = (0, A.useCallback)(async () => {
|
|
3646
|
-
let t = await
|
|
3560
|
+
let t = await $i(e, "refresh resource templates").listResourceTemplates();
|
|
3647
3561
|
e.isMounted() && e.setResourceTemplates(t.resourceTemplates || []);
|
|
3648
3562
|
}, [e.addLog]);
|
|
3649
3563
|
return {
|
|
@@ -3666,26 +3580,26 @@ function ua(e) {
|
|
|
3666
3580
|
c,
|
|
3667
3581
|
s
|
|
3668
3582
|
]),
|
|
3669
|
-
getPrompt: (0, A.useCallback)(async (t, n) =>
|
|
3670
|
-
complete: (0, A.useCallback)(async (t) =>
|
|
3583
|
+
getPrompt: (0, A.useCallback)(async (t, n) => $i(e, "get prompt").getPrompt(t, n || {}), [e.addLog]),
|
|
3584
|
+
complete: (0, A.useCallback)(async (t) => $i(e, "request completion").complete(t), [e.addLog])
|
|
3671
3585
|
};
|
|
3672
3586
|
}
|
|
3673
|
-
var
|
|
3674
|
-
function
|
|
3587
|
+
var ta = 3e3, na = 5e3;
|
|
3588
|
+
function ra(e) {
|
|
3675
3589
|
let { url: t, enabled: n = !0, callbackUrl: r = typeof window < "u" ? Yr(new URL("/oauth/callback", window.location.origin).toString()) : "/oauth/callback", storageKeyPrefix: i = "mcp:auth", authProvider: a, headers: o, proxyConfig: s, oauthProxyUrl: c, autoProxyFallback: l = !1, logLevel: u = "silent", autoRetry: d = !1, autoReconnect: f = !0, reconnectionOptions: p, preventAutoAuth: m = !0, useRedirectFlow: h = !1, onPopupWindow: g, timeout: _ = 3e4, wrapTransport: v, serverId: ee, fetch: te, clientOptions: y, protocolNegotiation: x, onNotification: S, onSampling: C, onElicitation: ne, oauth: w } = e, re = "http", T = w?.clientId?.trim() || void 0, E = w?.clientMetadataUrl?.trim() || void 0, ie = w?.scope?.trim() || void 0, ae = (0, A.useMemo)(() => T ? { client_id: T } : void 0, [T]), D = (0, A.useMemo)(() => {
|
|
3676
3590
|
let e = `useMcp:${t || "no-url"}`, n = pr.get(e);
|
|
3677
3591
|
return u && (n.level = u), n;
|
|
3678
|
-
}, [t, u]), O = o ?? {}, oe = (0, A.useMemo)(() => Jr(y), [y]), k = C, se = ne,
|
|
3592
|
+
}, [t, u]), O = o ?? {}, oe = (0, A.useMemo)(() => Jr(y), [y]), k = C, se = ne, ce = (0, A.useMemo)(() => ({
|
|
3679
3593
|
name: "mcp-use",
|
|
3680
3594
|
title: "mcp-use",
|
|
3681
3595
|
version: Ur(),
|
|
3682
3596
|
description: "mcp-use is a complete TypeScript framework for building and using MCP",
|
|
3683
3597
|
icons: [{ src: "https://mcp-use.com/logo.png" }],
|
|
3684
3598
|
websiteUrl: "https://mcp-use.com"
|
|
3685
|
-
}), []),
|
|
3686
|
-
...
|
|
3599
|
+
}), []), j = (0, A.useMemo)(() => e.clientInfo ? {
|
|
3600
|
+
...ce,
|
|
3687
3601
|
...e.clientInfo
|
|
3688
|
-
} :
|
|
3602
|
+
} : ce, [e.clientInfo, ce]), M = (0, A.useMemo)(() => Ji(j), [j]), N = (0, A.useMemo)(() => {
|
|
3689
3603
|
if (!l) return {
|
|
3690
3604
|
enabled: !1,
|
|
3691
3605
|
proxyAddress: void 0
|
|
@@ -3702,14 +3616,14 @@ function pa(e) {
|
|
|
3702
3616
|
enabled: l.enabled !== !1 && !!e,
|
|
3703
3617
|
proxyAddress: e
|
|
3704
3618
|
};
|
|
3705
|
-
}, [l, s]),
|
|
3619
|
+
}, [l, s]), le = (0, A.useMemo)(() => f === !1 ? {
|
|
3706
3620
|
enabled: !1,
|
|
3707
3621
|
initialDelay: 0,
|
|
3708
3622
|
healthCheckInterval: !1,
|
|
3709
3623
|
healthCheckTimeout: 3e4
|
|
3710
3624
|
} : f === !0 ? {
|
|
3711
3625
|
enabled: !0,
|
|
3712
|
-
initialDelay:
|
|
3626
|
+
initialDelay: ta,
|
|
3713
3627
|
healthCheckInterval: 1e4,
|
|
3714
3628
|
healthCheckTimeout: 3e4
|
|
3715
3629
|
} : typeof f == "number" ? {
|
|
@@ -3719,34 +3633,34 @@ function pa(e) {
|
|
|
3719
3633
|
healthCheckTimeout: 3e4
|
|
3720
3634
|
} : {
|
|
3721
3635
|
enabled: f.enabled !== !1,
|
|
3722
|
-
initialDelay: f.initialDelay ??
|
|
3636
|
+
initialDelay: f.initialDelay ?? ta,
|
|
3723
3637
|
healthCheckInterval: f.healthCheckInterval ?? 1e4,
|
|
3724
3638
|
healthCheckTimeout: f.healthCheckTimeout ?? 3e4
|
|
3725
|
-
}, [f]), [
|
|
3639
|
+
}, [f]), [ue, de] = (0, A.useState)(void 0);
|
|
3726
3640
|
(0, A.useEffect)(() => {
|
|
3727
|
-
|
|
3641
|
+
de(void 0);
|
|
3728
3642
|
}, [t, s]);
|
|
3729
|
-
let
|
|
3730
|
-
if (!
|
|
3643
|
+
let P = (0, A.useMemo)(() => {
|
|
3644
|
+
if (!ue?.proxyAddress) return s;
|
|
3731
3645
|
let e = s?.headers ?? {};
|
|
3732
3646
|
return {
|
|
3733
|
-
...
|
|
3647
|
+
...ue,
|
|
3734
3648
|
headers: {
|
|
3735
3649
|
...e,
|
|
3736
|
-
...
|
|
3650
|
+
...ue.headers ?? {}
|
|
3737
3651
|
}
|
|
3738
3652
|
};
|
|
3739
|
-
}, [
|
|
3740
|
-
...
|
|
3653
|
+
}, [ue, s]), F = P?.proxyAddress, fe = P?.headers ?? {}, I = (0, A.useMemo)(() => t || "", [t]), L = (0, A.useMemo)(() => ({
|
|
3654
|
+
...fe,
|
|
3741
3655
|
...O
|
|
3742
|
-
}), [
|
|
3656
|
+
}), [fe, O]), [R, z] = (0, A.useState)("discovering"), [pe, B] = (0, A.useState)([]), [me, he] = (0, A.useState)([]), [ge, _e] = (0, A.useState)([]), [ve, ye] = (0, A.useState)([]), [be, xe] = (0, A.useState)(e._initialServerInfo?.name ? e._initialServerInfo : void 0), [Se, V] = (0, A.useState)(), [Ce, we] = (0, A.useState)(void 0), [Te, H] = (0, A.useState)(void 0), [Ee, De] = (0, A.useState)(), [Oe, ke] = (0, A.useState)({}), [Ae, je] = (0, A.useState)(void 0), [Me, Ne] = (0, A.useState)([]), [Pe, U] = (0, A.useState)(void 0), [Fe, Ie] = (0, A.useState)(void 0), W = (0, A.useRef)(null), Le = (0, A.useRef)(null), G = (0, A.useRef)(a ?? null), Re = (0, A.useRef)(null), K = (0, A.useRef)(!1), q = (0, A.useRef)(!0), ze = (0, A.useRef)(0), Be = (0, A.useRef)(0), Ve = (0, A.useRef)(null), He = (0, A.useRef)(!1), Ue = (0, A.useRef)(!1), We = (0, A.useRef)(R), Ge = (0, A.useRef)(f), Ke = (0, A.useRef)(null), qe = (0, A.useRef)(null), Je = (0, A.useRef)(null), Ye = (0, A.useRef)(k), Xe = (0, A.useRef)(se), Ze = (0, A.useRef)(k !== void 0), Qe = (0, A.useRef)(se !== void 0), $e = (0, A.useRef)(S);
|
|
3743
3657
|
k !== void 0 && (Ye.current = k), se !== void 0 && (Xe.current = se), Ze.current = k !== void 0, Qe.current = se !== void 0, $e.current = S;
|
|
3744
3658
|
let et = (0, A.useCallback)(async (e) => Ye.current(e), []), tt = (0, A.useCallback)(async (e) => Xe.current(e), []), nt = (0, A.useCallback)((e) => {
|
|
3745
3659
|
$e.current?.(e);
|
|
3746
3660
|
}, []);
|
|
3747
3661
|
(0, A.useEffect)(() => {
|
|
3748
|
-
We.current =
|
|
3749
|
-
}, [
|
|
3662
|
+
We.current = R, Ge.current = f;
|
|
3663
|
+
}, [R, f]), (0, A.useEffect)(() => {
|
|
3750
3664
|
G.current = a ?? null;
|
|
3751
3665
|
}, [a]);
|
|
3752
3666
|
let J = (0, A.useCallback)((e, t, ...n) => {
|
|
@@ -3771,39 +3685,39 @@ function pa(e) {
|
|
|
3771
3685
|
message: r,
|
|
3772
3686
|
timestamp: Date.now()
|
|
3773
3687
|
}]);
|
|
3774
|
-
}, [D]), rt =
|
|
3688
|
+
}, [D]), rt = ea({
|
|
3775
3689
|
stateRef: We,
|
|
3776
3690
|
connectionRef: Le,
|
|
3777
3691
|
hasClient: () => W.current !== null,
|
|
3778
3692
|
isMounted: () => q.current,
|
|
3779
|
-
setTools:
|
|
3780
|
-
setResources:
|
|
3781
|
-
setResourceTemplates:
|
|
3782
|
-
setPrompts:
|
|
3693
|
+
setTools: B,
|
|
3694
|
+
setResources: he,
|
|
3695
|
+
setResourceTemplates: _e,
|
|
3696
|
+
setPrompts: ye,
|
|
3783
3697
|
addLog: J
|
|
3784
3698
|
}), it = (0, A.useCallback)(async (e = !1) => {
|
|
3785
3699
|
e || J("info", "Disconnecting..."), K.current = !1, Ve.current && clearTimeout(Ve.current), Ve.current = null;
|
|
3786
3700
|
let t = Be.current, n = W.current;
|
|
3787
3701
|
if (n) try {
|
|
3788
|
-
let e =
|
|
3702
|
+
let e = Wi, t = n === W.current ? Le.current : null;
|
|
3789
3703
|
t && t._healthCheckCleanup && (t._healthCheckCleanup(), t._healthCheckCleanup = null), t && await n.closeSession(e);
|
|
3790
3704
|
} catch (t) {
|
|
3791
3705
|
e || J("warn", "Error closing connection:", t);
|
|
3792
3706
|
}
|
|
3793
3707
|
let r = Be.current !== t;
|
|
3794
|
-
W.current === n && !r && (W.current = null, Le.current = null), q.current && !e && !r && (
|
|
3708
|
+
W.current === n && !r && (W.current = null, Le.current = null), q.current && !e && !r && (z("discovering"), B([]), he([]), _e([]), ye([]), je(void 0), U(void 0), Ie(void 0), xe(void 0), V(void 0), we(void 0), H(void 0), De(void 0), ke({}));
|
|
3795
3709
|
}, [J]), Y = (0, A.useCallback)((e, n) => {
|
|
3796
3710
|
J("error", e, n ?? "");
|
|
3797
|
-
let r = n && "code" in n ? n.code : void 0, i =
|
|
3798
|
-
if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return J("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), W.current = null, a || (G.current = null), J("debug", "Cleared client and auth provider for proxy fallback"),
|
|
3711
|
+
let r = n && "code" in n ? n.code : void 0, i = N.enabled && !P?.proxyAddress, o = e.includes("CORS") || e.includes("blocked by CORS policy") || e.includes("Failed to fetch"), s = r === 400;
|
|
3712
|
+
if (i && (o || s || typeof r == "number" && r >= 404 && r < 500) && !(r === 401 || r === 403)) return J("info", `Direct connection failed with ${o ? "CORS error" : s ? "HTTP 400 (Bad Request)" : "HTTP 4xx error"}. Trying with proxy...`), W.current = null, a || (G.current = null), J("debug", "Cleared client and auth provider for proxy fallback"), de({ proxyAddress: N.proxyAddress }), q.current && z("discovering"), setTimeout(() => {
|
|
3799
3713
|
q.current && qe.current?.();
|
|
3800
3714
|
}, 1e3), !0;
|
|
3801
3715
|
if (q.current) {
|
|
3802
|
-
J("info", "Setting state to FAILED:", e),
|
|
3716
|
+
J("info", "Setting state to FAILED:", e), z("failed"), je(e);
|
|
3803
3717
|
let t = G.current?.getLastAttemptedAuthUrl?.();
|
|
3804
3718
|
t && (U(t), J("info", "Manual authentication URL may be available.", t));
|
|
3805
3719
|
}
|
|
3806
|
-
return K.current = !1, t &&
|
|
3720
|
+
return K.current = !1, t && wi.getInstance().trackUseMcpConnection({
|
|
3807
3721
|
url: t,
|
|
3808
3722
|
transportType: re,
|
|
3809
3723
|
success: !1,
|
|
@@ -3816,8 +3730,8 @@ function pa(e) {
|
|
|
3816
3730
|
J,
|
|
3817
3731
|
t,
|
|
3818
3732
|
re,
|
|
3733
|
+
N,
|
|
3819
3734
|
P,
|
|
3820
|
-
F,
|
|
3821
3735
|
a
|
|
3822
3736
|
]), at = (0, A.useCallback)(async () => {
|
|
3823
3737
|
if (!n || !t) {
|
|
@@ -3832,15 +3746,15 @@ function pa(e) {
|
|
|
3832
3746
|
J("debug", "Connect called after unmount, aborting.");
|
|
3833
3747
|
return;
|
|
3834
3748
|
}
|
|
3835
|
-
if (K.current = !0, Be.current += 1, ze.current += 1, je(void 0), U(void 0), Ke.current = null,
|
|
3836
|
-
let { provider: e, oauthProxyUrl: t } =
|
|
3837
|
-
effectiveOAuthUrl:
|
|
3749
|
+
if (K.current = !0, Be.current += 1, ze.current += 1, je(void 0), U(void 0), Ke.current = null, z("discovering"), B([]), he([]), _e([]), ye([]), xe(void 0), V(void 0), we(void 0), H(void 0), De(void 0), ke({}), J("info", `Connecting attempt #${ze.current} to ${t}...`), !G.current) {
|
|
3750
|
+
let { provider: e, oauthProxyUrl: t } = Zi({
|
|
3751
|
+
effectiveOAuthUrl: I,
|
|
3838
3752
|
storageKeyPrefix: i,
|
|
3839
|
-
oauthClientConfig:
|
|
3753
|
+
oauthClientConfig: M,
|
|
3840
3754
|
callbackUrl: r,
|
|
3841
3755
|
preventAutoAuth: m,
|
|
3842
3756
|
useRedirectFlow: h,
|
|
3843
|
-
gatewayUrl:
|
|
3757
|
+
gatewayUrl: F,
|
|
3844
3758
|
oauthProxyUrl: c,
|
|
3845
3759
|
onPopupWindow: g,
|
|
3846
3760
|
proxyOAuthRequests: !0,
|
|
@@ -3848,17 +3762,17 @@ function pa(e) {
|
|
|
3848
3762
|
clientMetadataUrl: E,
|
|
3849
3763
|
scope: ie
|
|
3850
3764
|
});
|
|
3851
|
-
G.current = e, t && J("debug", `OAuth BFF enabled: ${t}`), J("debug", `BrowserOAuthClientProvider initialized with URL: ${
|
|
3765
|
+
G.current = e, t && J("debug", `OAuth BFF enabled: ${t}`), J("debug", `BrowserOAuthClientProvider initialized with URL: ${I}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${F ? "enabled" : "disabled"}`);
|
|
3852
3766
|
}
|
|
3853
|
-
W.current ? J("debug", "BrowserMCPClient already exists, reusing.") : (W.current = new
|
|
3767
|
+
W.current ? J("debug", "BrowserMCPClient already exists, reusing.") : (W.current = new Ii(), J("debug", "BrowserMCPClient initialized in connect."));
|
|
3854
3768
|
let e = async (n) => {
|
|
3855
3769
|
if (!q.current) return J("debug", "Connection attempt aborted - component unmounted"), "failed";
|
|
3856
3770
|
J("info", `Attempting connection with transport: ${n}`), J("debug", `Client ref status at start of tryConnectWithTransport: ${W.current ? "initialized" : "NULL"}`);
|
|
3857
3771
|
try {
|
|
3858
|
-
let e =
|
|
3772
|
+
let e = Wi, r = {
|
|
3859
3773
|
url: t,
|
|
3860
3774
|
timeout: _,
|
|
3861
|
-
clientInfo:
|
|
3775
|
+
clientInfo: j,
|
|
3862
3776
|
...(() => {
|
|
3863
3777
|
let e = G.current?.getProxyFetch?.(te) ?? te;
|
|
3864
3778
|
return e ? { fetch: e } : {};
|
|
@@ -3867,7 +3781,7 @@ function pa(e) {
|
|
|
3867
3781
|
...x !== void 0 && { protocolNegotiation: x },
|
|
3868
3782
|
...p ? { reconnectionOptions: p } : f === !1 ? { reconnectionOptions: { maxRetries: 0 } } : {}
|
|
3869
3783
|
};
|
|
3870
|
-
if (
|
|
3784
|
+
if (F && (r.gatewayUrl = F, J("debug", `Using proxy gateway: ${F} for target: ${t}`)), L && Object.keys(L).length > 0 && (r.headers = L), !W.current) {
|
|
3871
3785
|
if (!q.current) return J("debug", "Connection aborted - component unmounted, client cleaned up"), "failed";
|
|
3872
3786
|
let e = /* @__PURE__ */ Error("Client not initialized - this is a bug in the connection flow");
|
|
3873
3787
|
throw J("error", "Client ref is null in tryConnectWithTransport but component is still mounted"), e;
|
|
@@ -3884,10 +3798,10 @@ function pa(e) {
|
|
|
3884
3798
|
});
|
|
3885
3799
|
let i = await W.current.connect(e);
|
|
3886
3800
|
if (Le.current = i, !q.current) return J("debug", "Connection aborted after connection creation - component unmounted"), "failed";
|
|
3887
|
-
J("info", "✅ Successfully connected to MCP server"), J("info", "Server info:", i.info.server), J("info", "Server capabilities:", i.info.capabilities),
|
|
3888
|
-
gatewayUrl:
|
|
3801
|
+
J("info", "✅ Successfully connected to MCP server"), J("info", "Server info:", i.info.server), J("info", "Server capabilities:", i.info.capabilities), le.enabled && le.healthCheckInterval !== !1 && (i._healthCheckCleanup = Qi({
|
|
3802
|
+
gatewayUrl: F,
|
|
3889
3803
|
url: t,
|
|
3890
|
-
allHeaders:
|
|
3804
|
+
allHeaders: L,
|
|
3891
3805
|
getAuthHeaders: async () => {
|
|
3892
3806
|
try {
|
|
3893
3807
|
let e = await G.current?.tokens?.();
|
|
@@ -3901,41 +3815,41 @@ function pa(e) {
|
|
|
3901
3815
|
isMountedRef: q,
|
|
3902
3816
|
stateRef: We,
|
|
3903
3817
|
autoReconnectRef: Ge,
|
|
3904
|
-
setState:
|
|
3818
|
+
setState: z,
|
|
3905
3819
|
addLog: J,
|
|
3906
3820
|
connect: at,
|
|
3907
|
-
defaultReconnectDelay:
|
|
3908
|
-
healthCheckIntervalMs:
|
|
3909
|
-
healthCheckTimeoutMs:
|
|
3910
|
-
})),
|
|
3821
|
+
defaultReconnectDelay: le.initialDelay,
|
|
3822
|
+
healthCheckIntervalMs: le.healthCheckInterval,
|
|
3823
|
+
healthCheckTimeoutMs: le.healthCheckTimeout
|
|
3824
|
+
})), wi.getInstance().trackUseMcpConnection({
|
|
3911
3825
|
url: t,
|
|
3912
3826
|
transportType: n,
|
|
3913
3827
|
success: !0,
|
|
3914
3828
|
hasOAuth: !!G.current,
|
|
3915
3829
|
hasSampling: Ze.current,
|
|
3916
3830
|
hasElicitation: Qe.current
|
|
3917
|
-
}).catch(() => {}),
|
|
3831
|
+
}).catch(() => {}), B(i.tools || []);
|
|
3918
3832
|
let [a, o, s] = await Promise.all([
|
|
3919
3833
|
i.listAllResources(),
|
|
3920
3834
|
i.listPrompts(),
|
|
3921
3835
|
i.supports("resources") ? i.listResourceTemplates() : Promise.resolve({ resourceTemplates: [] })
|
|
3922
3836
|
]);
|
|
3923
3837
|
if (!q.current) return J("debug", "Connection aborted after discovery - component unmounted"), "failed";
|
|
3924
|
-
|
|
3838
|
+
he(a.resources || []), ye(o.prompts || []), _e(s.resourceTemplates || []);
|
|
3925
3839
|
let { server: c, capabilities: l, protocolEra: u, protocolVersion: d, instructions: m, extensions: h } = i.info;
|
|
3926
3840
|
if (q.current && (we(u), H(d), De(m), ke(h)), c) {
|
|
3927
3841
|
if (J("debug", "Server info:", c), !q.current) return J("debug", "Skipping state update - component unmounted"), "failed";
|
|
3928
|
-
|
|
3842
|
+
xe(c), Re.current = Ki({
|
|
3929
3843
|
serverInfo: c,
|
|
3930
3844
|
url: t,
|
|
3931
3845
|
isMounted: () => q.current,
|
|
3932
|
-
setServerInfo:
|
|
3846
|
+
setServerInfo: xe,
|
|
3933
3847
|
addLog: J
|
|
3934
3848
|
});
|
|
3935
3849
|
}
|
|
3936
3850
|
if (l) {
|
|
3937
3851
|
if (J("debug", "Server capabilities:", l), !q.current) return J("debug", "Skipping state update - component unmounted"), "failed";
|
|
3938
|
-
|
|
3852
|
+
V(l);
|
|
3939
3853
|
}
|
|
3940
3854
|
if (G.current) {
|
|
3941
3855
|
let e = await G.current.tokens?.();
|
|
@@ -3965,18 +3879,18 @@ function pa(e) {
|
|
|
3965
3879
|
});
|
|
3966
3880
|
}
|
|
3967
3881
|
}
|
|
3968
|
-
return Ke.current = n,
|
|
3882
|
+
return Ke.current = n, z("ready"), "success";
|
|
3969
3883
|
} catch (r) {
|
|
3970
3884
|
let i = r, a = i?.message || String(r), o = G.current?.getLastAttemptedAuthUrl?.();
|
|
3971
|
-
if (o && G.current && m) return J("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), q.current && (
|
|
3972
|
-
let s =
|
|
3885
|
+
if (o && G.current && m) return J("info", "OAuth already discovered (stored auth URL present); awaiting manual authentication."), q.current && (z("pending_auth"), U(o)), K.current = !1, "auth_redirect";
|
|
3886
|
+
let s = Yi(r), c = Ei(r);
|
|
3973
3887
|
if (s && O && Object.keys(O).length > 0) return Y("Authentication failed (HTTP 401). Server does not support OAuth. Check your Authorization header value is correct."), "failed";
|
|
3974
3888
|
if (s && (!O || Object.keys(O).length === 0)) return Y("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";
|
|
3975
3889
|
if (c) {
|
|
3976
3890
|
if (s) return Y("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";
|
|
3977
3891
|
if (G.current) if (J("info", "Authentication required. OAuth provider available."), m) {
|
|
3978
3892
|
if (J("info", "Waiting for user to initiate authentication flow..."), q.current) {
|
|
3979
|
-
|
|
3893
|
+
z("pending_auth");
|
|
3980
3894
|
let e = G.current?.getLastAttemptedAuthUrl?.();
|
|
3981
3895
|
e && (U(e), J("info", "Retrieved stored auth URL for manual authentication"));
|
|
3982
3896
|
}
|
|
@@ -4014,10 +3928,10 @@ function pa(e) {
|
|
|
4014
3928
|
t,
|
|
4015
3929
|
i,
|
|
4016
3930
|
r,
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
3931
|
+
M.name,
|
|
3932
|
+
M.version,
|
|
3933
|
+
M.uri,
|
|
3934
|
+
M.logo_uri,
|
|
4021
3935
|
ae,
|
|
4022
3936
|
E,
|
|
4023
3937
|
ie,
|
|
@@ -4028,13 +3942,13 @@ function pa(e) {
|
|
|
4028
3942
|
g,
|
|
4029
3943
|
n,
|
|
4030
3944
|
_,
|
|
4031
|
-
|
|
3945
|
+
j,
|
|
4032
3946
|
oe,
|
|
4033
3947
|
x,
|
|
4034
|
-
|
|
3948
|
+
F,
|
|
4035
3949
|
c,
|
|
4036
|
-
R,
|
|
4037
3950
|
L,
|
|
3951
|
+
I,
|
|
4038
3952
|
et,
|
|
4039
3953
|
tt,
|
|
4040
3954
|
nt
|
|
@@ -4051,7 +3965,7 @@ function pa(e) {
|
|
|
4051
3965
|
else if (e === "pending_auth") {
|
|
4052
3966
|
J("info", "Proceeding with authentication from pending state...");
|
|
4053
3967
|
try {
|
|
4054
|
-
if (
|
|
3968
|
+
if (Gi(G.current, "Auth Provider not available for manual auth"), Gi(t, "Server URL is required for authentication"), a) {
|
|
4055
3969
|
J("info", "Using provided authProvider for manual authentication");
|
|
4056
3970
|
let e = new URL(t), n = e.origin + e.pathname.replace(/\/+$/, "");
|
|
4057
3971
|
await b(G.current, {
|
|
@@ -4060,15 +3974,15 @@ function pa(e) {
|
|
|
4060
3974
|
}), qe.current?.();
|
|
4061
3975
|
return;
|
|
4062
3976
|
}
|
|
4063
|
-
J("info", `Cleared ${G.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`),
|
|
4064
|
-
let e = null, n = null, { provider: o, oauthProxyUrl: s } =
|
|
4065
|
-
effectiveOAuthUrl:
|
|
3977
|
+
J("info", `Cleared ${G.current.clearStorage?.() ?? 0} OAuth storage item(s) for fresh authentication`), z("authenticating");
|
|
3978
|
+
let e = null, n = null, { provider: o, oauthProxyUrl: s } = Zi({
|
|
3979
|
+
effectiveOAuthUrl: I,
|
|
4066
3980
|
storageKeyPrefix: i,
|
|
4067
|
-
oauthClientConfig:
|
|
3981
|
+
oauthClientConfig: M,
|
|
4068
3982
|
callbackUrl: r,
|
|
4069
3983
|
preventAutoAuth: !1,
|
|
4070
3984
|
useRedirectFlow: h,
|
|
4071
|
-
gatewayUrl:
|
|
3985
|
+
gatewayUrl: F,
|
|
4072
3986
|
oauthProxyUrl: c,
|
|
4073
3987
|
onPopupWindow: (t, r, i) => {
|
|
4074
3988
|
e = i;
|
|
@@ -4119,10 +4033,10 @@ function pa(e) {
|
|
|
4119
4033
|
J("info", "Authentication succeeded; reconnecting to MCP server..."), K.current = !1, qe.current?.();
|
|
4120
4034
|
break;
|
|
4121
4035
|
case "cancelled":
|
|
4122
|
-
J("warn", "Authentication popup was closed before completing. Returning to pending_auth."),
|
|
4036
|
+
J("warn", "Authentication popup was closed before completing. Returning to pending_auth."), z("pending_auth");
|
|
4123
4037
|
break;
|
|
4124
4038
|
case "timeout":
|
|
4125
|
-
J("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."),
|
|
4039
|
+
J("warn", "Authentication timed out waiting for the popup. Returning to pending_auth."), z("pending_auth");
|
|
4126
4040
|
break;
|
|
4127
4041
|
case "error":
|
|
4128
4042
|
Y(`Authentication failed: ${p.error}`);
|
|
@@ -4131,7 +4045,7 @@ function pa(e) {
|
|
|
4131
4045
|
}
|
|
4132
4046
|
} catch (e) {
|
|
4133
4047
|
if (!q.current) return;
|
|
4134
|
-
|
|
4048
|
+
z("pending_auth"), J("error", `Manual authentication failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
4135
4049
|
}
|
|
4136
4050
|
} else if (e === "authenticating") {
|
|
4137
4051
|
J("warn", "Already attempting authentication. Check for blocked popups or wait for timeout.");
|
|
@@ -4147,14 +4061,14 @@ function pa(e) {
|
|
|
4147
4061
|
h,
|
|
4148
4062
|
g,
|
|
4149
4063
|
i,
|
|
4150
|
-
|
|
4151
|
-
|
|
4152
|
-
|
|
4064
|
+
M.name,
|
|
4065
|
+
M.uri,
|
|
4066
|
+
M.logo_uri,
|
|
4153
4067
|
ae,
|
|
4154
4068
|
E,
|
|
4155
4069
|
ie,
|
|
4156
4070
|
r,
|
|
4157
|
-
|
|
4071
|
+
j,
|
|
4158
4072
|
a
|
|
4159
4073
|
]), ct = (0, A.useCallback)(() => {
|
|
4160
4074
|
G.current?.clearStorage ? (J("info", `Cleared ${G.current.clearStorage()} item(s) from localStorage for ${t}.`), U(void 0), it()) : J("warn", "Auth provider not initialized, cannot clear storage.");
|
|
@@ -4207,19 +4121,19 @@ function pa(e) {
|
|
|
4207
4121
|
Ve.current && clearTimeout(Ve.current);
|
|
4208
4122
|
};
|
|
4209
4123
|
}, [J]), (0, A.useEffect)(() => {
|
|
4210
|
-
if (q.current = !0, !n || !t) return J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."),
|
|
4124
|
+
if (q.current = !0, !n || !t) return J("debug", n ? "No server URL provided, skipping connection." : "Connection disabled via enabled flag."), z("discovering"), () => {
|
|
4211
4125
|
q.current = !1;
|
|
4212
4126
|
};
|
|
4213
4127
|
if (J("debug", "useMcp mounted, initiating connection."), ze.current = 0, a) G.current = a, J("debug", "Using externally provided authProvider");
|
|
4214
|
-
else if (!G.current || G.current.serverUrl !==
|
|
4215
|
-
let { provider: e, oauthProxyUrl: t } =
|
|
4216
|
-
effectiveOAuthUrl:
|
|
4128
|
+
else if (!G.current || G.current.serverUrl !== I) {
|
|
4129
|
+
let { provider: e, oauthProxyUrl: t } = Zi({
|
|
4130
|
+
effectiveOAuthUrl: I,
|
|
4217
4131
|
storageKeyPrefix: i,
|
|
4218
|
-
oauthClientConfig:
|
|
4132
|
+
oauthClientConfig: M,
|
|
4219
4133
|
callbackUrl: r,
|
|
4220
4134
|
preventAutoAuth: m,
|
|
4221
4135
|
useRedirectFlow: h,
|
|
4222
|
-
gatewayUrl:
|
|
4136
|
+
gatewayUrl: F,
|
|
4223
4137
|
oauthProxyUrl: c,
|
|
4224
4138
|
onPopupWindow: g,
|
|
4225
4139
|
proxyOAuthRequests: !0,
|
|
@@ -4227,7 +4141,7 @@ function pa(e) {
|
|
|
4227
4141
|
clientMetadataUrl: E,
|
|
4228
4142
|
scope: ie
|
|
4229
4143
|
});
|
|
4230
|
-
G.current = e, t && J("debug", `OAuth proxy URL in effect: ${t}`), J("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${
|
|
4144
|
+
G.current = e, t && J("debug", `OAuth proxy URL in effect: ${t}`), J("debug", `BrowserOAuthClientProvider initialized/updated with URL: ${I}, proxy: ${t ? "enabled" : "disabled"}, gateway: ${F ? "enabled" : "disabled"}`);
|
|
4231
4145
|
}
|
|
4232
4146
|
return at(), () => {
|
|
4233
4147
|
q.current = !1, J("debug", "useMcp unmounting, disconnecting."), it(!0);
|
|
@@ -4237,16 +4151,16 @@ function pa(e) {
|
|
|
4237
4151
|
n,
|
|
4238
4152
|
i,
|
|
4239
4153
|
r,
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4154
|
+
M.name,
|
|
4155
|
+
M.version,
|
|
4156
|
+
M.uri,
|
|
4157
|
+
M.logo_uri,
|
|
4244
4158
|
ae,
|
|
4245
4159
|
E,
|
|
4246
4160
|
ie,
|
|
4247
4161
|
h,
|
|
4248
|
-
|
|
4249
|
-
|
|
4162
|
+
j,
|
|
4163
|
+
I,
|
|
4250
4164
|
s,
|
|
4251
4165
|
a
|
|
4252
4166
|
]);
|
|
@@ -4255,29 +4169,29 @@ function pa(e) {
|
|
|
4255
4169
|
lt.current = ot, ut.current = J;
|
|
4256
4170
|
}, [ot, J]), (0, A.useEffect)(() => {
|
|
4257
4171
|
let e = null;
|
|
4258
|
-
if (
|
|
4172
|
+
if (R === "failed" && d && ze.current > 0) {
|
|
4259
4173
|
if (!He.current) {
|
|
4260
4174
|
He.current = !0;
|
|
4261
|
-
let t = typeof d == "number" ? d :
|
|
4175
|
+
let t = typeof d == "number" ? d : na;
|
|
4262
4176
|
ut.current("info", `Connection failed, auto-retrying in ${t}ms...`), e = setTimeout(() => {
|
|
4263
4177
|
He.current = !1, q.current && We.current === "failed" && lt.current();
|
|
4264
4178
|
}, t);
|
|
4265
4179
|
}
|
|
4266
|
-
} else
|
|
4180
|
+
} else R !== "failed" && (He.current = !1);
|
|
4267
4181
|
return () => {
|
|
4268
4182
|
e && (clearTimeout(e), He.current = !1);
|
|
4269
4183
|
};
|
|
4270
|
-
}, [
|
|
4271
|
-
let dt = (0, A.useCallback)(async () => We.current === "ready" ?
|
|
4184
|
+
}, [R, d]);
|
|
4185
|
+
let dt = (0, A.useCallback)(async () => We.current === "ready" ? be?.icon ? be.icon : Re.current ? (J("debug", "Waiting for icon to finish loading..."), await Re.current) : (J("debug", "No icon available and no loading in progress"), null) : (J("warn", "Cannot ensure icon loaded - not connected"), null), [be, J]);
|
|
4272
4186
|
return {
|
|
4273
|
-
state:
|
|
4274
|
-
name:
|
|
4275
|
-
tools:
|
|
4276
|
-
resources:
|
|
4277
|
-
resourceTemplates:
|
|
4278
|
-
prompts:
|
|
4279
|
-
serverInfo:
|
|
4280
|
-
capabilities:
|
|
4187
|
+
state: R,
|
|
4188
|
+
name: be?.name || t || "",
|
|
4189
|
+
tools: pe,
|
|
4190
|
+
resources: me,
|
|
4191
|
+
resourceTemplates: ge,
|
|
4192
|
+
prompts: ve,
|
|
4193
|
+
serverInfo: be,
|
|
4194
|
+
capabilities: Se,
|
|
4281
4195
|
protocolEra: Ce,
|
|
4282
4196
|
protocolVersion: Te,
|
|
4283
4197
|
instructions: Ee,
|
|
@@ -4295,11 +4209,11 @@ function pa(e) {
|
|
|
4295
4209
|
ensureIconLoaded: dt
|
|
4296
4210
|
};
|
|
4297
4211
|
}
|
|
4298
|
-
var
|
|
4299
|
-
function
|
|
4212
|
+
var ia = null;
|
|
4213
|
+
function aa() {
|
|
4300
4214
|
return typeof window < "u" && window.name.startsWith("mcp_auth_");
|
|
4301
4215
|
}
|
|
4302
|
-
function
|
|
4216
|
+
function oa(e, t, n) {
|
|
4303
4217
|
return {
|
|
4304
4218
|
type: Er,
|
|
4305
4219
|
success: e,
|
|
@@ -4308,7 +4222,7 @@ function ga(e, t, n) {
|
|
|
4308
4222
|
...n.serverUrlHash ? { serverUrlHash: n.serverUrlHash } : {}
|
|
4309
4223
|
};
|
|
4310
4224
|
}
|
|
4311
|
-
function
|
|
4225
|
+
function sa(e) {
|
|
4312
4226
|
if (typeof BroadcastChannel > "u") return;
|
|
4313
4227
|
let t;
|
|
4314
4228
|
try {
|
|
@@ -4323,7 +4237,7 @@ function _a(e) {
|
|
|
4323
4237
|
}, 0);
|
|
4324
4238
|
}
|
|
4325
4239
|
}
|
|
4326
|
-
function
|
|
4240
|
+
function ca(e, t, n, r) {
|
|
4327
4241
|
if (typeof document > "u") return;
|
|
4328
4242
|
document.body.innerHTML = "";
|
|
4329
4243
|
let i = document.createElement("div");
|
|
@@ -4339,7 +4253,7 @@ function va(e, t, n, r) {
|
|
|
4339
4253
|
}
|
|
4340
4254
|
document.body.appendChild(i);
|
|
4341
4255
|
}
|
|
4342
|
-
function
|
|
4256
|
+
function la(e) {
|
|
4343
4257
|
let t = `mcp:auth:state_${e}`, n = localStorage.getItem(t) ? t : null;
|
|
4344
4258
|
if (!n) {
|
|
4345
4259
|
let t = `:state_${e}`;
|
|
@@ -4364,14 +4278,14 @@ function ya(e) {
|
|
|
4364
4278
|
value: i
|
|
4365
4279
|
};
|
|
4366
4280
|
}
|
|
4367
|
-
function
|
|
4281
|
+
function ua(e, t) {
|
|
4368
4282
|
let n = new URL(e);
|
|
4369
4283
|
n.searchParams.set("auth_error", "oauth_callback_failed"), n.searchParams.set("auth_error_description", t), window.location.href = n.toString();
|
|
4370
4284
|
}
|
|
4371
|
-
function
|
|
4372
|
-
let i =
|
|
4285
|
+
function da(e, t, n, r) {
|
|
4286
|
+
let i = oa(e, t, r), a = n?.returnUrl, o = n?.flowType === "popup" || aa();
|
|
4373
4287
|
if (n?.flowType === "redirect" && a) {
|
|
4374
|
-
e ? window.location.href = a :
|
|
4288
|
+
e ? window.location.href = a : ua(a, t ?? "Authentication failed.");
|
|
4375
4289
|
return;
|
|
4376
4290
|
}
|
|
4377
4291
|
if (window.opener && !window.opener.closed) {
|
|
@@ -4379,50 +4293,50 @@ function xa(e, t, n, r) {
|
|
|
4379
4293
|
return;
|
|
4380
4294
|
}
|
|
4381
4295
|
if (o) {
|
|
4382
|
-
|
|
4296
|
+
sa(i), ca(e ? "Authentication Successful!" : "Authentication Error", e ? "You're authenticated. You can close this window and return to the app." : t ?? "Authentication failed.", !e, a);
|
|
4383
4297
|
try {
|
|
4384
4298
|
window.close();
|
|
4385
4299
|
} catch {}
|
|
4386
4300
|
return;
|
|
4387
4301
|
}
|
|
4388
4302
|
if (a) {
|
|
4389
|
-
e ? window.location.href = a :
|
|
4303
|
+
e ? window.location.href = a : ua(a, t ?? "Authentication failed.");
|
|
4390
4304
|
return;
|
|
4391
4305
|
}
|
|
4392
4306
|
if (!e) {
|
|
4393
|
-
|
|
4307
|
+
ca("Authentication Error", t ?? "Authentication failed.", !0);
|
|
4394
4308
|
return;
|
|
4395
4309
|
}
|
|
4396
4310
|
window.location.href = "/";
|
|
4397
4311
|
}
|
|
4398
|
-
function
|
|
4399
|
-
return
|
|
4312
|
+
function fa() {
|
|
4313
|
+
return ia ||= pa(), ia;
|
|
4400
4314
|
}
|
|
4401
|
-
async function
|
|
4315
|
+
async function pa() {
|
|
4402
4316
|
let e = new URLSearchParams(window.location.search), t = e.get("state"), n = null, r = null, i = null;
|
|
4403
4317
|
try {
|
|
4404
4318
|
if (!t) throw Error("OAuth callback is missing the state parameter.");
|
|
4405
|
-
let a =
|
|
4319
|
+
let a = la(t);
|
|
4406
4320
|
if (n = a.key, r = a.value, !r.expiry || r.expiry < Date.now()) throw localStorage.removeItem(n), Error("OAuth state has expired. Please start authentication again.");
|
|
4407
4321
|
if (!r.providerOptions) throw Error("Stored OAuth state is missing provider options.");
|
|
4408
4322
|
let { serverUrl: o, ...s } = r.providerOptions;
|
|
4409
4323
|
i = new ei(o, s), await new w(new URL(o), {
|
|
4410
4324
|
authProvider: i,
|
|
4411
4325
|
fetch: i.getProxyFetch()
|
|
4412
|
-
}).finishAuth(e), localStorage.removeItem(n),
|
|
4326
|
+
}).finishAuth(e), localStorage.removeItem(n), da(!0, void 0, r, {
|
|
4413
4327
|
state: t,
|
|
4414
4328
|
serverUrlHash: r.serverUrlHash
|
|
4415
4329
|
});
|
|
4416
4330
|
} catch (e) {
|
|
4417
4331
|
let a = e instanceof Error ? e.message : String(e);
|
|
4418
|
-
console.error("[mcp-callback] OAuth callback failed:", e), n && localStorage.removeItem(n), i && localStorage.removeItem(i.getKey("last_auth_url")),
|
|
4332
|
+
console.error("[mcp-callback] OAuth callback failed:", e), n && localStorage.removeItem(n), i && localStorage.removeItem(i.getKey("last_auth_url")), da(!1, a, r, {
|
|
4419
4333
|
state: t,
|
|
4420
4334
|
serverUrlHash: r?.serverUrlHash
|
|
4421
4335
|
});
|
|
4422
4336
|
}
|
|
4423
4337
|
}
|
|
4424
4338
|
mr();
|
|
4425
|
-
var
|
|
4339
|
+
var ma = [
|
|
4426
4340
|
"url",
|
|
4427
4341
|
"displayName",
|
|
4428
4342
|
"enabled",
|
|
@@ -4446,19 +4360,19 @@ var wa = [
|
|
|
4446
4360
|
"clientInfo",
|
|
4447
4361
|
"oauth"
|
|
4448
4362
|
];
|
|
4449
|
-
function
|
|
4363
|
+
function ha(e) {
|
|
4450
4364
|
let t = {};
|
|
4451
|
-
for (let n of
|
|
4365
|
+
for (let n of ma) {
|
|
4452
4366
|
let r = e[n];
|
|
4453
4367
|
r !== void 0 && (t[n] = r);
|
|
4454
4368
|
}
|
|
4455
4369
|
return t;
|
|
4456
4370
|
}
|
|
4457
|
-
function
|
|
4458
|
-
return
|
|
4371
|
+
function ga(e) {
|
|
4372
|
+
return ha(e);
|
|
4459
4373
|
}
|
|
4460
|
-
var
|
|
4461
|
-
function
|
|
4374
|
+
var _a = 500, va = 5 * 6e4;
|
|
4375
|
+
function ya(e) {
|
|
4462
4376
|
let [t, n] = (0, A.useState)([]), [r, i] = (0, A.useState)([]), [a, o] = (0, A.useState)([]), s = (0, A.useRef)(0), c = (0, A.useRef)(0), l = (0, A.useRef)(/* @__PURE__ */ new Map()), u = (0, A.useRef)(/* @__PURE__ */ new Map()), d = (0, A.useCallback)((e) => {
|
|
4463
4377
|
for (let t of l.current.values()) clearTimeout(t.timeout), t.reject(Error(e));
|
|
4464
4378
|
l.current.clear();
|
|
@@ -4474,7 +4388,7 @@ function ka(e) {
|
|
|
4474
4388
|
timestamp: Date.now(),
|
|
4475
4389
|
read: !1
|
|
4476
4390
|
};
|
|
4477
|
-
n((e) => [r, ...e].slice(0,
|
|
4391
|
+
n((e) => [r, ...e].slice(0, _a)), e.onNotificationReceived?.(r);
|
|
4478
4392
|
}, [e.onNotificationReceived]), p = (0, A.useCallback)((e, t) => {
|
|
4479
4393
|
let n = l.current.get(e);
|
|
4480
4394
|
n && (clearTimeout(n.timeout), l.current.delete(e), i((t) => t.filter((t) => t.id !== e)), n.resolve(t));
|
|
@@ -4490,7 +4404,7 @@ function ka(e) {
|
|
|
4490
4404
|
},
|
|
4491
4405
|
timestamp: Date.now(),
|
|
4492
4406
|
serverName: e.serverName
|
|
4493
|
-
}, c = setTimeout(() => m(a, "Sampling request timed out"),
|
|
4407
|
+
}, c = setTimeout(() => m(a, "Sampling request timed out"), va);
|
|
4494
4408
|
l.current.set(a, {
|
|
4495
4409
|
resolve: n,
|
|
4496
4410
|
reject: r,
|
|
@@ -4512,7 +4426,7 @@ function ka(e) {
|
|
|
4512
4426
|
request: t,
|
|
4513
4427
|
timestamp: Date.now(),
|
|
4514
4428
|
serverName: e.serverName
|
|
4515
|
-
}, s = setTimeout(() => _(i, "Elicitation request timed out"),
|
|
4429
|
+
}, s = setTimeout(() => _(i, "Elicitation request timed out"), va);
|
|
4516
4430
|
u.current.set(i, {
|
|
4517
4431
|
resolve: n,
|
|
4518
4432
|
reject: r,
|
|
@@ -4549,14 +4463,14 @@ function ka(e) {
|
|
|
4549
4463
|
rejectAll: d
|
|
4550
4464
|
};
|
|
4551
4465
|
}
|
|
4552
|
-
var Q = pr.get("McpClientProvider"),
|
|
4466
|
+
var Q = pr.get("McpClientProvider"), ba = (0, A.createContext)(null);
|
|
4553
4467
|
function $(e, t) {
|
|
4554
4468
|
return JSON.stringify(e) === JSON.stringify(t);
|
|
4555
4469
|
}
|
|
4556
|
-
function
|
|
4557
|
-
return e.id === t.id && $(
|
|
4470
|
+
function xa(e, t) {
|
|
4471
|
+
return e.id === t.id && $(ha(e), ha(t)) && e.name === t.name && e.state === t.state && e.error === t.error && e.authUrl === t.authUrl && $(e.authTokens, t.authTokens) && e.protocolEra === t.protocolEra && e.protocolVersion === t.protocolVersion && $(e.serverInfo, t.serverInfo) && $(e.capabilities, t.capabilities) && e.instructions === t.instructions && $(e.extensions, t.extensions) && $(e.tools, t.tools) && $(e.resources, t.resources) && $(e.resourceTemplates, t.resourceTemplates) && $(e.prompts, t.prompts) && $(e.notifications, t.notifications) && e.unreadNotificationCount === t.unreadNotificationCount && $(e.pendingSamplingRequests, t.pendingSamplingRequests) && $(e.pendingElicitationRequests, t.pendingElicitationRequests) && e.client === t.client;
|
|
4558
4472
|
}
|
|
4559
|
-
function
|
|
4473
|
+
function Sa({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a, clientInfo: o, cachedMetadata: s, onUpdate: c, onUpdateConfig: l, onUpdateDisplayName: u, onReconnect: d, rpcWrapTransport: f, onGlobalSamplingRequest: p, onGlobalElicitationRequest: m }) {
|
|
4560
4474
|
let { displayName: h, onSamplingRequest: g, onElicitationRequest: _, onNotificationReceived: v, wrapTransport: ee } = t, te = (0, A.useMemo)(() => {
|
|
4561
4475
|
let { displayName: c, onSamplingRequest: l, onElicitationRequest: u, onNotificationReceived: d, wrapTransport: f, ...p } = t;
|
|
4562
4476
|
return {
|
|
@@ -4589,7 +4503,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4589
4503
|
f,
|
|
4590
4504
|
ee,
|
|
4591
4505
|
e
|
|
4592
|
-
]), b =
|
|
4506
|
+
]), b = ya({
|
|
4593
4507
|
serverId: e,
|
|
4594
4508
|
serverName: h || e,
|
|
4595
4509
|
onNotificationReceived: v,
|
|
@@ -4597,7 +4511,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4597
4511
|
onElicitationRequest: _,
|
|
4598
4512
|
onGlobalSamplingRequest: p,
|
|
4599
4513
|
onGlobalElicitationRequest: m
|
|
4600
|
-
}), x =
|
|
4514
|
+
}), x = ra({
|
|
4601
4515
|
...te,
|
|
4602
4516
|
onNotification: b.onNotification,
|
|
4603
4517
|
onSampling: b.onSampling,
|
|
@@ -4627,7 +4541,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4627
4541
|
re.current = c;
|
|
4628
4542
|
}, [c]), (0, A.useEffect)(() => {
|
|
4629
4543
|
let n = {
|
|
4630
|
-
...
|
|
4544
|
+
...ga(t),
|
|
4631
4545
|
...x,
|
|
4632
4546
|
id: e,
|
|
4633
4547
|
displayName: h || t.displayName || e,
|
|
@@ -4647,7 +4561,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4647
4561
|
setDisplayName: ne,
|
|
4648
4562
|
reconnect: w
|
|
4649
4563
|
}, r = T.current;
|
|
4650
|
-
!r || !
|
|
4564
|
+
!r || !xa(r, n) ? (T.current = n, re.current(n)) : Q.debug(`[McpServerWrapper ${e}] No meaningful changes detected, skipping onUpdate`);
|
|
4651
4565
|
}, [
|
|
4652
4566
|
e,
|
|
4653
4567
|
h,
|
|
@@ -4674,7 +4588,7 @@ function Ma({ id: e, options: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r,
|
|
|
4674
4588
|
w
|
|
4675
4589
|
]), null;
|
|
4676
4590
|
}
|
|
4677
|
-
function
|
|
4591
|
+
function Ca({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthProxyUrl: r, defaultProxyConfig: i, defaultAutoProxyFallback: a = !1, defaultServerConfig: o, clientInfo: s, storageProvider: c, enableRpcLogging: l = !1, onServerAdded: u, onServerRemoved: d, onServerStateChange: f, onSamplingRequest: p, onElicitationRequest: m }) {
|
|
4678
4592
|
let [h, g] = (0, A.useState)([]), [_, v] = (0, A.useState)([]), [ee, te] = (0, A.useState)({}), [y, b] = (0, A.useState)(!1), x = (0, A.useRef)(!1), S = (0, A.useRef)([]);
|
|
4679
4593
|
(0, A.useEffect)(() => {
|
|
4680
4594
|
S.current = _;
|
|
@@ -4737,7 +4651,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4737
4651
|
]), (0, A.useEffect)(() => {
|
|
4738
4652
|
!c || !y || (async () => {
|
|
4739
4653
|
try {
|
|
4740
|
-
let e = h.reduce((e, t) => (e[t.id] =
|
|
4654
|
+
let e = h.reduce((e, t) => (e[t.id] = ga(t.options), e), {});
|
|
4741
4655
|
await Promise.resolve(c.setServers(e));
|
|
4742
4656
|
} catch (e) {
|
|
4743
4657
|
Q.error("[McpClientProvider] Failed to save to storage:", e);
|
|
@@ -4763,7 +4677,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4763
4677
|
currentToolCount: i.tools.length,
|
|
4764
4678
|
updatedToolCount: e.tools.length,
|
|
4765
4679
|
stateChanged: a
|
|
4766
|
-
}),
|
|
4680
|
+
}), xa(i, e)) return Q.debug(`[McpClientProvider] No changes detected for server ${e.id}, skipping update`), n;
|
|
4767
4681
|
if (Q.debug(`[McpClientProvider] Updating server ${e.id} in state`), a && t.push(() => f?.(e.id, e.state)), o && e.serverInfo && c?.setServerMetadata) {
|
|
4768
4682
|
let t = {
|
|
4769
4683
|
name: e.serverInfo.name,
|
|
@@ -4811,7 +4725,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4811
4725
|
...n.options,
|
|
4812
4726
|
...t
|
|
4813
4727
|
};
|
|
4814
|
-
$(
|
|
4728
|
+
$(ha(n.options), ha(r)) || (await S.current.find((t) => t.id === e)?.disconnect(), v((t) => t.filter((t) => t.id !== e)), g((t) => t.map((t) => t.id === e ? {
|
|
4815
4729
|
id: e,
|
|
4816
4730
|
options: r
|
|
4817
4731
|
} : t)), te((t) => ({
|
|
@@ -4863,17 +4777,17 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4863
4777
|
D,
|
|
4864
4778
|
k,
|
|
4865
4779
|
y
|
|
4866
|
-
]), { capabilities:
|
|
4780
|
+
]), { capabilities: ce, ...j } = s || {}, M = (0, A.useMemo)(() => Object.keys(j).length ? j : void 0, [s]), N = (0, A.useMemo)(() => h.map((e) => {
|
|
4867
4781
|
let t = o ? {
|
|
4868
4782
|
...o,
|
|
4869
4783
|
...e.options
|
|
4870
4784
|
} : e.options;
|
|
4871
|
-
return
|
|
4785
|
+
return ce && (t = {
|
|
4872
4786
|
...t,
|
|
4873
4787
|
clientOptions: {
|
|
4874
4788
|
...t.clientOptions,
|
|
4875
4789
|
capabilities: {
|
|
4876
|
-
...
|
|
4790
|
+
...ce,
|
|
4877
4791
|
...t.clientOptions?.capabilities
|
|
4878
4792
|
}
|
|
4879
4793
|
}
|
|
@@ -4883,10 +4797,10 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4883
4797
|
};
|
|
4884
4798
|
}), [
|
|
4885
4799
|
h,
|
|
4886
|
-
|
|
4800
|
+
ce,
|
|
4887
4801
|
o
|
|
4888
|
-
]),
|
|
4889
|
-
return /* @__PURE__ */ A.createElement(
|
|
4802
|
+
]), le = typeof window < "u" && /\/oauth\/callback\/?$/.test(window.location.pathname);
|
|
4803
|
+
return /* @__PURE__ */ A.createElement(ba.Provider, { value: se }, e, !le && N.map((e) => /* @__PURE__ */ A.createElement(Sa, {
|
|
4890
4804
|
key: `${e.id}-v${ee[e.id] ?? 0}`,
|
|
4891
4805
|
id: e.id,
|
|
4892
4806
|
options: e.options,
|
|
@@ -4894,7 +4808,7 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4894
4808
|
defaultOAuthProxyUrl: r,
|
|
4895
4809
|
defaultProxyConfig: i,
|
|
4896
4810
|
defaultAutoProxyFallback: a,
|
|
4897
|
-
clientInfo:
|
|
4811
|
+
clientInfo: M,
|
|
4898
4812
|
cachedMetadata: C.current[e.id],
|
|
4899
4813
|
onUpdate: E,
|
|
4900
4814
|
onUpdateConfig: D,
|
|
@@ -4905,12 +4819,12 @@ function Na({ children: e, mcpServers: t, defaultCallbackUrl: n, defaultOAuthPro
|
|
|
4905
4819
|
onGlobalElicitationRequest: m
|
|
4906
4820
|
})));
|
|
4907
4821
|
}
|
|
4908
|
-
function
|
|
4909
|
-
let e = (0, A.useContext)(
|
|
4822
|
+
function wa() {
|
|
4823
|
+
let e = (0, A.useContext)(ba);
|
|
4910
4824
|
if (!e) throw Error("useMcpClient must be used within a McpClientProvider");
|
|
4911
4825
|
return e;
|
|
4912
4826
|
}
|
|
4913
|
-
var
|
|
4827
|
+
var Ta = class {
|
|
4914
4828
|
constructor(e = "mcp-client-servers") {
|
|
4915
4829
|
this.storageKey = e, this.metadataKey = `${e}-metadata`;
|
|
4916
4830
|
}
|
|
@@ -4976,7 +4890,7 @@ var Fa = class {
|
|
|
4976
4890
|
}
|
|
4977
4891
|
};
|
|
4978
4892
|
wr();
|
|
4979
|
-
function
|
|
4893
|
+
function Ea(e) {
|
|
4980
4894
|
let t = {};
|
|
4981
4895
|
if (!e) return t;
|
|
4982
4896
|
for (let [n, r] of Object.entries(e)) if (typeof r == "string" && (r.trim().startsWith("[") || r.trim().startsWith("{"))) try {
|
|
@@ -4987,11 +4901,11 @@ function Ia(e) {
|
|
|
4987
4901
|
else t[n] = r;
|
|
4988
4902
|
return t;
|
|
4989
4903
|
}
|
|
4990
|
-
var
|
|
4991
|
-
function
|
|
4992
|
-
return e.includes("<head>") ? e.replace("<head>", "<head>" +
|
|
4904
|
+
var Da = "<script>\n(function () {\n var files = new Map();\n window.openai = window.openai || {};\n window.openai.uploadFile = async function (file) {\n var fileId = crypto.randomUUID();\n files.set(fileId, file);\n return { fileId: fileId };\n };\n window.openai.getFileDownloadUrl = async function (ref) {\n var file = files.get(ref.fileId);\n if (!file) {\n throw new Error(\"File not found: \" + ref.fileId);\n }\n return { downloadUrl: URL.createObjectURL(file) };\n };\n})();\n<\/script>";
|
|
4905
|
+
function Oa(e) {
|
|
4906
|
+
return e.includes("<head>") ? e.replace("<head>", "<head>" + Da) : e.includes("<HEAD>") ? e.replace("<HEAD>", "<HEAD>" + Da) : e.includes("<html>") ? e.replace("<html>", "<html><head>" + Da + "</head>") : e.includes("<HTML>") ? e.replace("<HTML>", "<HTML><head>" + Da + "</head>") : e.includes("<!DOCTYPE") || e.includes("<!doctype") ? e.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, "$1<head>" + Da + "</head>") : Da + e;
|
|
4993
4907
|
}
|
|
4994
|
-
function
|
|
4908
|
+
function ka(e) {
|
|
4995
4909
|
let { resourceResult: t, listingResource: n, cspMode: r, resourceUri: i } = e, a = (Array.isArray(t?.contents) ? t.contents : [])[0], o = "", s;
|
|
4996
4910
|
if (a && (s = a.mimeType, typeof a.text == "string" ? o = a.text : typeof a.blob == "string" && (o = atob(a.blob))), !o) throw Error("No HTML content in resource");
|
|
4997
4911
|
let c = n?._meta?.ui, l = a?._meta?.ui, u = c || l ? {
|
|
@@ -5009,7 +4923,7 @@ function za(e) {
|
|
|
5009
4923
|
mimeTypeWarning: h
|
|
5010
4924
|
};
|
|
5011
4925
|
}
|
|
5012
|
-
function
|
|
4926
|
+
function Aa(e, t) {
|
|
5013
4927
|
let { cspMode: n, permissions: r, widgetCsp: i } = t;
|
|
5014
4928
|
e.searchParams.set("v", JSON.stringify({
|
|
5015
4929
|
cspMode: n,
|
|
@@ -5017,63 +4931,63 @@ function Ba(e, t) {
|
|
|
5017
4931
|
widgetCsp: i
|
|
5018
4932
|
})), e.searchParams.set("csp_mode", n), r && Object.keys(r).length > 0 && e.searchParams.set("permissions", JSON.stringify(r)), i && Object.keys(i).length > 0 && e.searchParams.set("widget_csp", JSON.stringify(i));
|
|
5019
4933
|
}
|
|
5020
|
-
function
|
|
4934
|
+
function ja(e) {
|
|
5021
4935
|
let t = new URL("https://sandbox.invalid/");
|
|
5022
|
-
|
|
5023
|
-
let n =
|
|
4936
|
+
Aa(t, e);
|
|
4937
|
+
let n = Na(t.search);
|
|
5024
4938
|
return new URL(URL.createObjectURL(new Blob([n], { type: "text/html" })));
|
|
5025
4939
|
}
|
|
5026
|
-
var Ha = "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta\n http-equiv=\"Content-Security-Policy\"\n content=\"default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src * 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data:; style-src * blob: data: 'unsafe-inline'; connect-src * data: blob: about:; frame-src * blob: data: http://localhost:* https://localhost:* http://127.0.0.1:* https://127.0.0.1:*;\"\n />\n <title>MCP Apps Sandbox Proxy</title>\n <style>\n html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }\n * { box-sizing: border-box; }\n iframe { display: block; background-color: transparent; border: 0px none transparent; padding: 0px; width: 100%; height: 100%; }\n </style>\n </head>\n <body>\n <script>\n function sanitizeDomain(domain) {\n if (typeof domain !== \"string\") return \"\";\n return domain.replace(/['\"<>;]/g, \"\").trim();\n }\n\n function buildAllowAttribute(permissions) {\n if (!permissions) return \"\";\n const allowList = [];\n if (permissions.camera) allowList.push(\"camera *\");\n if (permissions.microphone) allowList.push(\"microphone *\");\n if (permissions.geolocation) allowList.push(\"geolocation *\");\n if (permissions.clipboardWrite) allowList.push(\"clipboard-write *\");\n return allowList.join(\"; \");\n }\n\n function buildCSP(csp) {\n if (!csp) {\n return [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline'\",\n \"style-src 'unsafe-inline'\",\n \"img-src data:\",\n \"font-src data:\",\n \"media-src data:\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n ].join(\"; \");\n }\n\n const connectDomains = (csp.connectDomains || []).map(sanitizeDomain).filter(Boolean);\n const resourceDomains = (csp.resourceDomains || []).map(sanitizeDomain).filter(Boolean);\n const frameDomains = (csp.frameDomains || []).map(sanitizeDomain).filter(Boolean);\n const baseUriDomains = (csp.baseUriDomains || []).map(sanitizeDomain).filter(Boolean);\n const scriptDirectives = (csp.scriptDirectives || []).filter(function(d) { return typeof d === \"string\" && d.length > 0; });\n\n const connectSrc = connectDomains.length > 0 ? connectDomains.join(\" \") : \"'none'\";\n const resourceSrc = resourceDomains.length > 0 ? [\"data:\", \"blob:\", ...resourceDomains].join(\" \") : \"data: blob:\";\n const frameSrc = frameDomains.length > 0 ? frameDomains.join(\" \") : \"'none'\";\n const baseUri = baseUriDomains.length > 0 ? baseUriDomains.join(\" \") : \"'none'\";\n const scriptSrcParts = [\"'unsafe-inline'\", resourceSrc];\n if (scriptDirectives.length > 0) scriptSrcParts.push(scriptDirectives.join(\" \"));\n\n return [\n \"default-src 'none'\",\n \"script-src \" + scriptSrcParts.join(\" \"),\n \"style-src 'unsafe-inline' \" + resourceSrc,\n \"img-src \" + resourceSrc,\n \"font-src \" + resourceSrc,\n \"media-src \" + resourceSrc,\n \"connect-src \" + connectSrc,\n \"frame-src \" + frameSrc,\n \"object-src 'none'\",\n \"base-uri \" + baseUri,\n ].join(\"; \");\n }\n\n function buildViolationListenerScript() {\n return `<script>\ndocument.addEventListener('securitypolicyviolation', function(e) {\n var violation = {\n type: 'mcp-apps:csp-violation',\n directive: e.violatedDirective,\n blockedUri: e.blockedURI,\n sourceFile: e.sourceFile || null,\n lineNumber: e.lineNumber || null,\n columnNumber: e.columnNumber || null,\n effectiveDirective: e.effectiveDirective,\n originalPolicy: e.originalPolicy,\n disposition: e.disposition,\n timestamp: Date.now()\n };\n console.warn('[MCP Apps CSP Violation]', violation.directive, ':', violation.blockedUri);\n window.parent.postMessage(violation, '*');\n});\n\nfunction serializeConsoleArgs(args) {\n try {\n return Array.from(args || []).map(function(arg) {\n if (arg instanceof Error) {\n return {\n type: 'Error',\n message: arg.message,\n stack: arg.stack,\n name: arg.name,\n };\n }\n if (typeof arg === 'object' && arg !== null) {\n try {\n return JSON.parse(JSON.stringify(arg));\n } catch (e) {\n return String(arg);\n }\n }\n return arg;\n });\n } catch (e) {\n return [String(args)];\n }\n}\n\nfunction sendConsoleToParent(level, args) {\n try {\n window.parent.postMessage({\n type: 'iframe-console-log',\n level: level,\n args: serializeConsoleArgs(args),\n timestamp: new Date().toISOString(),\n url: window.location.href,\n }, '*');\n } catch (e) {}\n}\n\nvar originalConsoleError = console.error.bind(console);\nconsole.error = function() {\n var args = Array.from(arguments);\n originalConsoleError.apply(console, args);\n sendConsoleToParent('error', args);\n};\n\nwindow.addEventListener('error', function(event) {\n sendConsoleToParent('error', [{\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error ? {\n message: event.error.message,\n stack: event.error.stack,\n name: event.error.name,\n } : null,\n }]);\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n sendConsoleToParent('error', [{\n message: 'Unhandled Promise Rejection',\n reason: event.reason ? String(event.reason) : 'Unknown',\n error: event.reason instanceof Error ? {\n message: event.reason.message,\n stack: event.reason.stack,\n name: event.reason.name,\n } : null,\n }]);\n});\n</` + `script>`;\n }\n\n function injectCSP(html, cspValue) {\n const cspMeta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + cspValue + '\">';\n const violationListener = buildViolationListenerScript();\n const injection = cspMeta + violationListener;\n\n if (html.includes(\"<head>\")) {\n return html.replace(\"<head>\", \"<head>\" + injection);\n } else if (html.includes(\"<HEAD>\")) {\n return html.replace(\"<HEAD>\", \"<HEAD>\" + injection);\n } else if (html.includes(\"<html>\")) {\n return html.replace(\"<html>\", \"<html><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<HTML>\")) {\n return html.replace(\"<HTML>\", \"<HTML><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<!DOCTYPE\") || html.includes(\"<!doctype\")) {\n return html.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, \"$1<head>\" + injection + \"</head>\");\n } else {\n return injection + html;\n }\n }\n\n // Query params from host (csp_mode, permissions, widget_csp). AppFrame only\n // sends { html, csp } in sandbox-resource-ready; we carry the rest on the URL.\n // Blob URLs cannot reliably carry search params, so the CDN shell injects\n // window.__SANDBOX_SEARCH__ via buildSandboxProxyBlobHtml.\n const query = new URLSearchParams(\n typeof window.__SANDBOX_SEARCH__ === \"string\"\n ? window.__SANDBOX_SEARCH__\n : location.search\n );\n const queryCspMode = query.get(\"csp_mode\") || \"permissive\";\n let queryPermissions = null;\n let queryWidgetCsp = null;\n try {\n const rawPerm = query.get(\"permissions\");\n if (rawPerm) queryPermissions = JSON.parse(rawPerm);\n } catch (e) {}\n try {\n const rawCsp = query.get(\"widget_csp\");\n if (rawCsp) queryWidgetCsp = JSON.parse(rawCsp);\n } catch (e) {}\n\n const inner = document.createElement(\"iframe\");\n inner.style = \"width:100%; height:100%; border:none;\";\n inner.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\n document.body.appendChild(inner);\n\n window.addEventListener(\"message\", async (event) => {\n if (event.source === window.parent) {\n if (event.data && event.data.method === \"ui/notifications/sandbox-resource-ready\") {\n const params = event.data.params || {};\n const html = params.html;\n const sandbox = params.sandbox;\n // Prefer message csp when present; fall back to URL widget_csp\n const csp = params.csp != null ? params.csp : queryWidgetCsp;\n const permissions = params.permissions != null ? params.permissions : queryPermissions;\n const permissive =\n typeof params.permissive === \"boolean\"\n ? params.permissive\n : queryCspMode === \"permissive\";\n if (typeof sandbox === \"string\") {\n inner.setAttribute(\"sandbox\", sandbox);\n }\n const allowAttribute = buildAllowAttribute(permissions);\n if (allowAttribute) {\n inner.setAttribute(\"allow\", allowAttribute);\n }\n if (typeof html === \"string\") {\n if (permissive) {\n const permissiveCsp = [\n \"default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:\",\n \"script-src * 'unsafe-inline' 'unsafe-eval' data: blob:\",\n \"style-src * 'unsafe-inline' data: blob:\",\n \"img-src * data: blob: https: http:\",\n \"media-src * data: blob: https: http:\",\n \"font-src * data: blob: https: http:\",\n \"connect-src * data: blob: https: http: ws: wss: about:\",\n \"frame-src * data: blob: https: http: about:\",\n \"object-src * data: blob:\",\n \"base-uri *\",\n \"form-action *\",\n ].join(\"; \");\n const processedHtml = injectCSP(html, permissiveCsp);\n inner.srcdoc = processedHtml;\n } else {\n const cspValue = buildCSP(csp);\n const processedHtml = injectCSP(html, cspValue);\n inner.srcdoc = processedHtml;\n }\n }\n } else {\n if (inner && inner.contentWindow) {\n inner.contentWindow.postMessage(event.data, \"*\");\n }\n }\n } else if (event.source === inner.contentWindow) {\n window.parent.postMessage(event.data, \"*\");\n }\n });\n\n window.parent.postMessage({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/sandbox-proxy-ready\",\n params: {},\n }, \"*\");\n <\/script>\n </body>\n</html>";
|
|
5027
|
-
function
|
|
4940
|
+
var Ma = "<!doctype html>\n<html>\n <head>\n <meta charset=\"utf-8\" />\n <meta\n http-equiv=\"Content-Security-Policy\"\n content=\"default-src 'self'; img-src * data: blob: 'unsafe-inline'; media-src * blob: data:; font-src * blob: data:; script-src * 'wasm-unsafe-eval' 'unsafe-inline' 'unsafe-eval' blob: data:; style-src * blob: data: 'unsafe-inline'; connect-src * data: blob: about:; frame-src * blob: data: http://localhost:* https://localhost:* http://127.0.0.1:* https://127.0.0.1:*;\"\n />\n <title>MCP Apps Sandbox Proxy</title>\n <style>\n html, body { margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden; }\n * { box-sizing: border-box; }\n iframe { display: block; background-color: transparent; border: 0px none transparent; padding: 0px; width: 100%; height: 100%; }\n </style>\n </head>\n <body>\n <script>\n function sanitizeDomain(domain) {\n if (typeof domain !== \"string\") return \"\";\n return domain.replace(/['\"<>;]/g, \"\").trim();\n }\n\n function buildAllowAttribute(permissions) {\n if (!permissions) return \"\";\n const allowList = [];\n if (permissions.camera) allowList.push(\"camera *\");\n if (permissions.microphone) allowList.push(\"microphone *\");\n if (permissions.geolocation) allowList.push(\"geolocation *\");\n if (permissions.clipboardWrite) allowList.push(\"clipboard-write *\");\n return allowList.join(\"; \");\n }\n\n function buildCSP(csp) {\n if (!csp) {\n return [\n \"default-src 'none'\",\n \"script-src 'unsafe-inline'\",\n \"style-src 'unsafe-inline'\",\n \"img-src data:\",\n \"font-src data:\",\n \"media-src data:\",\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"object-src 'none'\",\n \"base-uri 'none'\",\n ].join(\"; \");\n }\n\n const connectDomains = (csp.connectDomains || []).map(sanitizeDomain).filter(Boolean);\n const resourceDomains = (csp.resourceDomains || []).map(sanitizeDomain).filter(Boolean);\n const frameDomains = (csp.frameDomains || []).map(sanitizeDomain).filter(Boolean);\n const baseUriDomains = (csp.baseUriDomains || []).map(sanitizeDomain).filter(Boolean);\n const scriptDirectives = (csp.scriptDirectives || []).filter(function(d) { return typeof d === \"string\" && d.length > 0; });\n\n const connectSrc = connectDomains.length > 0 ? connectDomains.join(\" \") : \"'none'\";\n const resourceSrc = resourceDomains.length > 0 ? [\"data:\", \"blob:\", ...resourceDomains].join(\" \") : \"data: blob:\";\n const frameSrc = frameDomains.length > 0 ? frameDomains.join(\" \") : \"'none'\";\n const baseUri = baseUriDomains.length > 0 ? baseUriDomains.join(\" \") : \"'none'\";\n const scriptSrcParts = [\"'unsafe-inline'\", resourceSrc];\n if (scriptDirectives.length > 0) scriptSrcParts.push(scriptDirectives.join(\" \"));\n\n return [\n \"default-src 'none'\",\n \"script-src \" + scriptSrcParts.join(\" \"),\n \"style-src 'unsafe-inline' \" + resourceSrc,\n \"img-src \" + resourceSrc,\n \"font-src \" + resourceSrc,\n \"media-src \" + resourceSrc,\n \"connect-src \" + connectSrc,\n \"frame-src \" + frameSrc,\n \"object-src 'none'\",\n \"base-uri \" + baseUri,\n ].join(\"; \");\n }\n\n function buildViolationListenerScript() {\n return `<script>\ndocument.addEventListener('securitypolicyviolation', function(e) {\n var violation = {\n type: 'mcp-apps:csp-violation',\n directive: e.violatedDirective,\n blockedUri: e.blockedURI,\n sourceFile: e.sourceFile || null,\n lineNumber: e.lineNumber || null,\n columnNumber: e.columnNumber || null,\n effectiveDirective: e.effectiveDirective,\n originalPolicy: e.originalPolicy,\n disposition: e.disposition,\n timestamp: Date.now()\n };\n console.warn('[MCP Apps CSP Violation]', violation.directive, ':', violation.blockedUri);\n window.parent.postMessage(violation, '*');\n});\n\nfunction serializeConsoleArgs(args) {\n try {\n return Array.from(args || []).map(function(arg) {\n if (arg instanceof Error) {\n return {\n type: 'Error',\n message: arg.message,\n stack: arg.stack,\n name: arg.name,\n };\n }\n if (typeof arg === 'object' && arg !== null) {\n try {\n return JSON.parse(JSON.stringify(arg));\n } catch (e) {\n return String(arg);\n }\n }\n return arg;\n });\n } catch (e) {\n return [String(args)];\n }\n}\n\nfunction sendConsoleToParent(level, args) {\n try {\n window.parent.postMessage({\n type: 'iframe-console-log',\n level: level,\n args: serializeConsoleArgs(args),\n timestamp: new Date().toISOString(),\n url: window.location.href,\n }, '*');\n } catch (e) {}\n}\n\nvar originalConsoleError = console.error.bind(console);\nconsole.error = function() {\n var args = Array.from(arguments);\n originalConsoleError.apply(console, args);\n sendConsoleToParent('error', args);\n};\n\nwindow.addEventListener('error', function(event) {\n sendConsoleToParent('error', [{\n message: event.message,\n filename: event.filename,\n lineno: event.lineno,\n colno: event.colno,\n error: event.error ? {\n message: event.error.message,\n stack: event.error.stack,\n name: event.error.name,\n } : null,\n }]);\n});\n\nwindow.addEventListener('unhandledrejection', function(event) {\n sendConsoleToParent('error', [{\n message: 'Unhandled Promise Rejection',\n reason: event.reason ? String(event.reason) : 'Unknown',\n error: event.reason instanceof Error ? {\n message: event.reason.message,\n stack: event.reason.stack,\n name: event.reason.name,\n } : null,\n }]);\n});\n</` + `script>`;\n }\n\n function injectCSP(html, cspValue) {\n const cspMeta = '<meta http-equiv=\"Content-Security-Policy\" content=\"' + cspValue + '\">';\n const violationListener = buildViolationListenerScript();\n const injection = cspMeta + violationListener;\n\n if (html.includes(\"<head>\")) {\n return html.replace(\"<head>\", \"<head>\" + injection);\n } else if (html.includes(\"<HEAD>\")) {\n return html.replace(\"<HEAD>\", \"<HEAD>\" + injection);\n } else if (html.includes(\"<html>\")) {\n return html.replace(\"<html>\", \"<html><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<HTML>\")) {\n return html.replace(\"<HTML>\", \"<HTML><head>\" + injection + \"</head>\");\n } else if (html.includes(\"<!DOCTYPE\") || html.includes(\"<!doctype\")) {\n return html.replace(/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i, \"$1<head>\" + injection + \"</head>\");\n } else {\n return injection + html;\n }\n }\n\n // Query params from host (csp_mode, permissions, widget_csp). AppFrame only\n // sends { html, csp } in sandbox-resource-ready; we carry the rest on the URL.\n // Blob URLs cannot reliably carry search params, so the CDN shell injects\n // window.__SANDBOX_SEARCH__ via buildSandboxProxyBlobHtml.\n const query = new URLSearchParams(\n typeof window.__SANDBOX_SEARCH__ === \"string\"\n ? window.__SANDBOX_SEARCH__\n : location.search\n );\n const queryCspMode = query.get(\"csp_mode\") || \"permissive\";\n let queryPermissions = null;\n let queryWidgetCsp = null;\n try {\n const rawPerm = query.get(\"permissions\");\n if (rawPerm) queryPermissions = JSON.parse(rawPerm);\n } catch (e) {}\n try {\n const rawCsp = query.get(\"widget_csp\");\n if (rawCsp) queryWidgetCsp = JSON.parse(rawCsp);\n } catch (e) {}\n\n const inner = document.createElement(\"iframe\");\n inner.style = \"width:100%; height:100%; border:none;\";\n inner.setAttribute(\"sandbox\", \"allow-scripts allow-same-origin allow-forms\");\n document.body.appendChild(inner);\n\n window.addEventListener(\"message\", async (event) => {\n if (event.source === window.parent) {\n if (event.data && event.data.method === \"ui/notifications/sandbox-resource-ready\") {\n const params = event.data.params || {};\n const html = params.html;\n const sandbox = params.sandbox;\n // Prefer message csp when present; fall back to URL widget_csp\n const csp = params.csp != null ? params.csp : queryWidgetCsp;\n const permissions = params.permissions != null ? params.permissions : queryPermissions;\n const permissive =\n typeof params.permissive === \"boolean\"\n ? params.permissive\n : queryCspMode === \"permissive\";\n if (typeof sandbox === \"string\") {\n inner.setAttribute(\"sandbox\", sandbox);\n }\n const allowAttribute = buildAllowAttribute(permissions);\n if (allowAttribute) {\n inner.setAttribute(\"allow\", allowAttribute);\n }\n if (typeof html === \"string\") {\n if (permissive) {\n const permissiveCsp = [\n \"default-src * 'unsafe-inline' 'unsafe-eval' data: blob: filesystem: about:\",\n \"script-src * 'unsafe-inline' 'unsafe-eval' data: blob:\",\n \"style-src * 'unsafe-inline' data: blob:\",\n \"img-src * data: blob: https: http:\",\n \"media-src * data: blob: https: http:\",\n \"font-src * data: blob: https: http:\",\n \"connect-src * data: blob: https: http: ws: wss: about:\",\n \"frame-src * data: blob: https: http: about:\",\n \"object-src * data: blob:\",\n \"base-uri *\",\n \"form-action *\",\n ].join(\"; \");\n const processedHtml = injectCSP(html, permissiveCsp);\n inner.srcdoc = processedHtml;\n } else {\n const cspValue = buildCSP(csp);\n const processedHtml = injectCSP(html, cspValue);\n inner.srcdoc = processedHtml;\n }\n }\n } else {\n if (inner && inner.contentWindow) {\n inner.contentWindow.postMessage(event.data, \"*\");\n }\n }\n } else if (event.source === inner.contentWindow) {\n window.parent.postMessage(event.data, \"*\");\n }\n });\n\n window.parent.postMessage({\n jsonrpc: \"2.0\",\n method: \"ui/notifications/sandbox-proxy-ready\",\n params: {},\n }, \"*\");\n <\/script>\n </body>\n</html>";
|
|
4941
|
+
function Na(e) {
|
|
5028
4942
|
let t = "<script>window.__SANDBOX_SEARCH__ = " + JSON.stringify(e).replace(/</g, "\\u003c") + ";<\/script>";
|
|
5029
|
-
return
|
|
4943
|
+
return Ma.replace("<body>", "<body>" + t);
|
|
5030
4944
|
}
|
|
5031
|
-
var
|
|
4945
|
+
var Pa = "fixed inset-0 z-[200] w-full h-full min-h-0 bg-background flex flex-col [&:fullscreen]:h-full [&:fullscreen]:w-full [&:fullscreen]:bg-background", Fa = [
|
|
5032
4946
|
"fixed top-4 left-1/2 -translate-x-1/2 z-[200]",
|
|
5033
4947
|
"rounded-3xl w-full min-w-[300px] h-[400px]",
|
|
5034
4948
|
"shadow-2xl border overflow-hidden",
|
|
5035
4949
|
"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80",
|
|
5036
4950
|
"flex flex-col"
|
|
5037
|
-
].join(" "),
|
|
5038
|
-
function
|
|
4951
|
+
].join(" "), Ia = "data-mcp-widget-fullscreen", La = "data-mcp-widget-display-mode";
|
|
4952
|
+
function Ra(e) {
|
|
5039
4953
|
(0, A.useEffect)(() => {
|
|
5040
4954
|
if (!(typeof document > "u")) {
|
|
5041
|
-
if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(
|
|
5042
|
-
document.documentElement.removeAttribute(
|
|
4955
|
+
if (e === "pip" || e === "fullscreen") return document.documentElement.setAttribute(La, e), e === "fullscreen" ? document.documentElement.setAttribute(Ia, "") : document.documentElement.removeAttribute(Ia), () => {
|
|
4956
|
+
document.documentElement.removeAttribute(La), document.documentElement.removeAttribute(Ia);
|
|
5043
4957
|
};
|
|
5044
|
-
document.documentElement.removeAttribute(
|
|
4958
|
+
document.documentElement.removeAttribute(La), document.documentElement.removeAttribute(Ia);
|
|
5045
4959
|
}
|
|
5046
4960
|
}, [e]);
|
|
5047
4961
|
}
|
|
5048
|
-
function
|
|
4962
|
+
function za({ displayMode: e, setDisplayMode: t }) {
|
|
5049
4963
|
let n = e === "fullscreen", r = e === "pip";
|
|
5050
|
-
return
|
|
4964
|
+
return Ra(e), {
|
|
5051
4965
|
handleDisplayModeChange: (0, A.useCallback)((e) => t(e), [t]),
|
|
5052
|
-
fullscreenShellClassName: n ?
|
|
5053
|
-
pipShellClassName: r ?
|
|
4966
|
+
fullscreenShellClassName: n ? Pa : void 0,
|
|
4967
|
+
pipShellClassName: r ? Fa : void 0,
|
|
5054
4968
|
isFullscreen: n,
|
|
5055
4969
|
isPip: r
|
|
5056
4970
|
};
|
|
5057
4971
|
}
|
|
5058
|
-
var
|
|
4972
|
+
var Ba = {
|
|
5059
4973
|
PIP_MAX_WIDTH: 700,
|
|
5060
4974
|
DEFAULT_HEIGHT: 400,
|
|
5061
4975
|
FULLSCREEN_HEADER_HEIGHT: 50
|
|
5062
4976
|
};
|
|
5063
|
-
function
|
|
4977
|
+
function Va(e) {
|
|
5064
4978
|
let t = e?.ui;
|
|
5065
4979
|
return t && typeof t == "object" && "resourceUri" in t && typeof t.resourceUri == "string" ? t.resourceUri : null;
|
|
5066
4980
|
}
|
|
5067
|
-
function
|
|
5068
|
-
return
|
|
4981
|
+
function Ha(e) {
|
|
4982
|
+
return Va(e) !== null;
|
|
5069
4983
|
}
|
|
5070
|
-
function
|
|
4984
|
+
function Ua(e) {
|
|
5071
4985
|
return e === er;
|
|
5072
4986
|
}
|
|
5073
|
-
var
|
|
4987
|
+
var Wa = {
|
|
5074
4988
|
name: "mcp-use-client",
|
|
5075
4989
|
version: "2.0.0"
|
|
5076
|
-
},
|
|
4990
|
+
}, Ga = 6e5, Ka = "ui/notifications/sandbox-proxy-ready", qa = {
|
|
5077
4991
|
openLinks: {},
|
|
5078
4992
|
serverTools: {},
|
|
5079
4993
|
serverResources: {},
|
|
@@ -5081,7 +4995,7 @@ var eo = {
|
|
|
5081
4995
|
updateModelContext: { text: {} },
|
|
5082
4996
|
message: { text: {} }
|
|
5083
4997
|
};
|
|
5084
|
-
function
|
|
4998
|
+
function Ja() {
|
|
5085
4999
|
return /* @__PURE__ */ A.createElement("svg", {
|
|
5086
5000
|
width: "14",
|
|
5087
5001
|
height: "14",
|
|
@@ -5094,15 +5008,15 @@ function io() {
|
|
|
5094
5008
|
"aria-hidden": !0
|
|
5095
5009
|
}, /* @__PURE__ */ A.createElement("path", { d: "M18 6 6 18" }), /* @__PURE__ */ A.createElement("path", { d: "m6 6 12 12" }));
|
|
5096
5010
|
}
|
|
5097
|
-
function
|
|
5011
|
+
function Ya(e) {
|
|
5098
5012
|
return new Promise((t) => {
|
|
5099
5013
|
let n = (r) => {
|
|
5100
|
-
r.source === e.contentWindow && r.data?.method ===
|
|
5014
|
+
r.source === e.contentWindow && r.data?.method === Ka && (window.removeEventListener("message", n), t());
|
|
5101
5015
|
};
|
|
5102
5016
|
window.addEventListener("message", n);
|
|
5103
5017
|
});
|
|
5104
5018
|
}
|
|
5105
|
-
function
|
|
5019
|
+
function Xa(e) {
|
|
5106
5020
|
let t = e.oninitialized;
|
|
5107
5021
|
return new Promise((n) => {
|
|
5108
5022
|
e.oninitialized = (...r) => {
|
|
@@ -5110,35 +5024,35 @@ function oo(e) {
|
|
|
5110
5024
|
};
|
|
5111
5025
|
});
|
|
5112
5026
|
}
|
|
5113
|
-
function
|
|
5114
|
-
let n =
|
|
5027
|
+
function Za(e, t) {
|
|
5028
|
+
let n = Ea(t);
|
|
5115
5029
|
return Object.keys(n).length > 0 ? {
|
|
5116
5030
|
...typeof e == "object" && e ? e : {},
|
|
5117
5031
|
structuredContent: n
|
|
5118
5032
|
} : e ?? null;
|
|
5119
5033
|
}
|
|
5120
|
-
function
|
|
5121
|
-
let oe = (0, A.useRef)(null), k = (0, A.useRef)(null), se = (0, A.useRef)(null),
|
|
5034
|
+
function Qa({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInput: i, toolOutput: a, partialToolInput: o, customProps: s, cancelled: c, hostInfo: l = Wa, hostContext: u, hostCapabilities: d, cspMode: f = "widget-declared", displayMode: p, onDisplayModeChange: m, inlineMaxWidth: h = 768, chromeless: g, onMessage: _, onModelContextUpdate: v, onLog: ee, onReady: te, onLifecycleChange: y, onError: b, onCspViolation: x, onResourceResolved: S, wrapTransport: C, toolCallTimeout: ne = Ga, mockOpenAiFileApis: w = !1, onInlineHeightChange: re, fullscreenHeader: T, renderFullscreenClose: E, className: ie, testId: ae = "mcp-app-frame", invoking: D, invoked: O }) {
|
|
5035
|
+
let oe = (0, A.useRef)(null), k = (0, A.useRef)(null), se = (0, A.useRef)(null), ce = (0, A.useRef)(t.kind === "live" ? t.connection : null), [j, M] = (0, A.useState)(null), [N, le] = (0, A.useState)(null), [ue, de] = (0, A.useState)(null), [P, F] = (0, A.useState)(0), [fe, I] = (0, A.useState)(!0), [L, R] = (0, A.useState)(Ba.DEFAULT_HEIGHT), [z, pe] = (0, A.useState)("inline"), B = p ?? z, me = (0, A.useMemo)(() => !u || u.displayMode === B ? u : {
|
|
5122
5036
|
...u,
|
|
5123
|
-
displayMode:
|
|
5124
|
-
}, [u,
|
|
5125
|
-
|
|
5126
|
-
let
|
|
5127
|
-
|
|
5128
|
-
let
|
|
5129
|
-
|
|
5130
|
-
let
|
|
5131
|
-
|
|
5132
|
-
let
|
|
5133
|
-
|
|
5134
|
-
let
|
|
5135
|
-
|
|
5136
|
-
let
|
|
5137
|
-
|
|
5138
|
-
let
|
|
5139
|
-
|
|
5140
|
-
let
|
|
5141
|
-
|
|
5037
|
+
displayMode: B
|
|
5038
|
+
}, [u, B]), he = (0, A.useRef)(me);
|
|
5039
|
+
he.current = me;
|
|
5040
|
+
let ge = (0, A.useRef)(_);
|
|
5041
|
+
ge.current = _;
|
|
5042
|
+
let _e = (0, A.useRef)(i);
|
|
5043
|
+
_e.current = i;
|
|
5044
|
+
let ve = (0, A.useRef)(o);
|
|
5045
|
+
ve.current = o;
|
|
5046
|
+
let ye = (0, A.useRef)(a);
|
|
5047
|
+
ye.current = a;
|
|
5048
|
+
let be = (0, A.useRef)(s);
|
|
5049
|
+
be.current = s;
|
|
5050
|
+
let xe = (0, A.useRef)(S);
|
|
5051
|
+
xe.current = S;
|
|
5052
|
+
let Se = (0, A.useRef)(v);
|
|
5053
|
+
Se.current = v;
|
|
5054
|
+
let V = (0, A.useRef)(ee);
|
|
5055
|
+
V.current = ee;
|
|
5142
5056
|
let Ce = (0, A.useRef)(b);
|
|
5143
5057
|
Ce.current = b;
|
|
5144
5058
|
let we = (0, A.useRef)(x);
|
|
@@ -5157,29 +5071,29 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5157
5071
|
ke.current = w;
|
|
5158
5072
|
let Ae = (0, A.useCallback)((e) => {
|
|
5159
5073
|
let t = De.current;
|
|
5160
|
-
return t ? typeof t == "function" ? t(e) : t :
|
|
5074
|
+
return t ? typeof t == "function" ? t(e) : t : ja({
|
|
5161
5075
|
cspMode: Oe.current,
|
|
5162
5076
|
permissions: e.permissions,
|
|
5163
5077
|
widgetCsp: e.declaredCsp
|
|
5164
5078
|
});
|
|
5165
|
-
}, []), { handleDisplayModeChange: je, fullscreenShellClassName: Me, pipShellClassName: Ne, isFullscreen: Pe, isPip: U } =
|
|
5079
|
+
}, []), { handleDisplayModeChange: je, fullscreenShellClassName: Me, pipShellClassName: Ne, isFullscreen: Pe, isPip: U } = za({
|
|
5166
5080
|
containerRef: se,
|
|
5167
|
-
displayMode:
|
|
5081
|
+
displayMode: B,
|
|
5168
5082
|
setDisplayMode: (0, A.useCallback)((e) => {
|
|
5169
|
-
m ? m(e) :
|
|
5083
|
+
m ? m(e) : pe(e);
|
|
5170
5084
|
}, [m])
|
|
5171
5085
|
}), Fe = (0, A.useRef)(je);
|
|
5172
5086
|
Fe.current = je;
|
|
5173
|
-
let Ie = (0, A.useRef)(
|
|
5174
|
-
Ie.current =
|
|
5087
|
+
let Ie = (0, A.useRef)(B);
|
|
5088
|
+
Ie.current = B;
|
|
5175
5089
|
let W = t.kind === "live" ? t.resourceUri : void 0, Le = t.kind === "preloaded" ? t.html : void 0;
|
|
5176
|
-
t.kind === "live" && (
|
|
5090
|
+
t.kind === "live" && (ce.current = t.connection), (0, A.useEffect)(() => {
|
|
5177
5091
|
let e = !1;
|
|
5178
5092
|
H.current?.({ status: "resolving" });
|
|
5179
5093
|
let n = (e) => {
|
|
5180
|
-
|
|
5094
|
+
M(e), H.current?.({ status: "sandbox-loading" });
|
|
5181
5095
|
let t = Ae(e);
|
|
5182
|
-
|
|
5096
|
+
le((e) => e?.href === t.href ? e : t), xe.current?.(e);
|
|
5183
5097
|
};
|
|
5184
5098
|
if (t.kind === "preloaded") {
|
|
5185
5099
|
n({
|
|
@@ -5195,11 +5109,11 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5195
5109
|
return;
|
|
5196
5110
|
}
|
|
5197
5111
|
let { connection: r, resourceUri: i } = t;
|
|
5198
|
-
return
|
|
5112
|
+
return ce.current = r, (async () => {
|
|
5199
5113
|
try {
|
|
5200
5114
|
let t = await r.readResource(i);
|
|
5201
5115
|
if (e) return;
|
|
5202
|
-
let a = r.resources?.find((e) => e.uri === i), o =
|
|
5116
|
+
let a = r.resources?.find((e) => e.uri === i), o = ka({
|
|
5203
5117
|
resourceResult: t,
|
|
5204
5118
|
listingResource: a,
|
|
5205
5119
|
cspMode: f,
|
|
@@ -5207,7 +5121,7 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5207
5121
|
});
|
|
5208
5122
|
if (!o.mimeTypeValid) {
|
|
5209
5123
|
let e = o.mimeTypeWarning || "Invalid MIME type - SEP-1865 requires \"text/html;profile=mcp-app\"";
|
|
5210
|
-
|
|
5124
|
+
de(e), H.current?.({
|
|
5211
5125
|
status: "error",
|
|
5212
5126
|
error: e
|
|
5213
5127
|
});
|
|
@@ -5216,7 +5130,7 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5216
5130
|
n(o);
|
|
5217
5131
|
} catch (t) {
|
|
5218
5132
|
if (e) return;
|
|
5219
|
-
|
|
5133
|
+
de(t instanceof Error ? t.message : "Failed to prepare view"), H.current?.({
|
|
5220
5134
|
status: "error",
|
|
5221
5135
|
error: t instanceof Error ? t.message : "Failed to prepare view"
|
|
5222
5136
|
});
|
|
@@ -5231,14 +5145,14 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5231
5145
|
f,
|
|
5232
5146
|
Ae
|
|
5233
5147
|
]), (0, A.useEffect)(() => {
|
|
5234
|
-
let e =
|
|
5148
|
+
let e = N;
|
|
5235
5149
|
return () => {
|
|
5236
5150
|
e?.protocol === "blob:" && URL.revokeObjectURL(e.href);
|
|
5237
5151
|
};
|
|
5238
|
-
}, [
|
|
5239
|
-
let G =
|
|
5152
|
+
}, [N]);
|
|
5153
|
+
let G = N?.protocol === "blob:", Re = !N || G ? null : (() => {
|
|
5240
5154
|
try {
|
|
5241
|
-
return
|
|
5155
|
+
return N.origin;
|
|
5242
5156
|
} catch {
|
|
5243
5157
|
return null;
|
|
5244
5158
|
}
|
|
@@ -5261,7 +5175,7 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5261
5175
|
});
|
|
5262
5176
|
return;
|
|
5263
5177
|
}
|
|
5264
|
-
e.data?.type === "iframe-console-log" &&
|
|
5178
|
+
e.data?.type === "iframe-console-log" && V.current && V.current({
|
|
5265
5179
|
level: e.data.level ?? "log",
|
|
5266
5180
|
data: e.data.args
|
|
5267
5181
|
});
|
|
@@ -5269,25 +5183,25 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5269
5183
|
};
|
|
5270
5184
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
5271
5185
|
}, [Re, G]), (0, A.useEffect)(() => {
|
|
5272
|
-
if (!
|
|
5186
|
+
if (!j || !N) return;
|
|
5273
5187
|
let t = oe.current;
|
|
5274
5188
|
if (!t) return;
|
|
5275
5189
|
let n = !1, r = null;
|
|
5276
5190
|
return (async () => {
|
|
5277
5191
|
try {
|
|
5278
5192
|
H.current?.({ status: "connecting" }), t.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms");
|
|
5279
|
-
let i = tr(
|
|
5193
|
+
let i = tr(j.permissions);
|
|
5280
5194
|
i && t.setAttribute("allow", i);
|
|
5281
|
-
let a =
|
|
5282
|
-
if (t.src =
|
|
5195
|
+
let a = Ya(t);
|
|
5196
|
+
if (t.src = N.href, await a, n) return;
|
|
5283
5197
|
r = new rr(null, l, {
|
|
5284
|
-
...d ??
|
|
5198
|
+
...d ?? qa,
|
|
5285
5199
|
sandbox: {
|
|
5286
|
-
csp: f === "permissive" ? void 0 :
|
|
5287
|
-
permissions:
|
|
5200
|
+
csp: f === "permissive" ? void 0 : j.csp,
|
|
5201
|
+
permissions: j.permissions
|
|
5288
5202
|
}
|
|
5289
|
-
}, { hostContext:
|
|
5290
|
-
let n =
|
|
5203
|
+
}, { hostContext: he.current }), r.onmessage = async ({ content: e }) => (e.length > 0 && ge.current && ge.current(e), {}), r.onopenlink = async ({ url: e }) => (e && window.open(e, "_blank", "noopener,noreferrer"), {}), r.oncalltool = (async ({ name: e, arguments: t }) => {
|
|
5204
|
+
let n = ce.current;
|
|
5291
5205
|
if (!n) throw Error("Server connection not available");
|
|
5292
5206
|
try {
|
|
5293
5207
|
return await n.callTool(e, t || {}, {
|
|
@@ -5298,51 +5212,51 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5298
5212
|
throw r?.sendToolCancelled({ reason: e instanceof Error ? e.message : String(e) }), e;
|
|
5299
5213
|
}
|
|
5300
5214
|
}), r.onreadresource = (async ({ uri: e }) => {
|
|
5301
|
-
let t =
|
|
5215
|
+
let t = ce.current;
|
|
5302
5216
|
if (!t) throw Error("Server connection not available");
|
|
5303
5217
|
return await t.readResource(e);
|
|
5304
5218
|
}), r.onlistresources = (async () => {
|
|
5305
|
-
let e =
|
|
5219
|
+
let e = ce.current;
|
|
5306
5220
|
if (!e) throw Error("Server connection not available");
|
|
5307
5221
|
return { resources: [...e.resources ?? []] };
|
|
5308
5222
|
}), r.onrequestdisplaymode = async ({ mode: e }) => {
|
|
5309
|
-
let t = e ?? "inline", n = (
|
|
5223
|
+
let t = e ?? "inline", n = (he.current?.availableDisplayModes ?? [
|
|
5310
5224
|
"inline",
|
|
5311
5225
|
"pip",
|
|
5312
5226
|
"fullscreen"
|
|
5313
5227
|
]).includes(t) ? t : Ie.current;
|
|
5314
5228
|
return await Fe.current(n), { mode: n };
|
|
5315
|
-
}, r.onupdatemodelcontext = async ({ content: e, structuredContent: t }) => (
|
|
5229
|
+
}, r.onupdatemodelcontext = async ({ content: e, structuredContent: t }) => (Se.current?.({
|
|
5316
5230
|
content: e,
|
|
5317
5231
|
structuredContent: t
|
|
5318
|
-
}), {}), r.onloggingmessage = async ({ level: e, data: t }) => (
|
|
5232
|
+
}), {}), r.onloggingmessage = async ({ level: e, data: t }) => (V.current?.({
|
|
5319
5233
|
level: e,
|
|
5320
5234
|
data: t
|
|
5321
5235
|
}), {}), r.onsizechange = async ({ height: e }) => {
|
|
5322
|
-
Ie.current === "inline" && e !== void 0 && (
|
|
5236
|
+
Ie.current === "inline" && e !== void 0 && (R(e), Ee.current?.(e));
|
|
5323
5237
|
};
|
|
5324
|
-
let o =
|
|
5238
|
+
let o = Xa(r), s = new $n(t.contentWindow, t.contentWindow);
|
|
5325
5239
|
if (C && (s = C(s, e)), await r.connect(s), n || (await r.sendSandboxResourceReady({
|
|
5326
|
-
html: ke.current ?
|
|
5327
|
-
csp:
|
|
5328
|
-
permissions:
|
|
5240
|
+
html: ke.current ? Oa(j.html) : j.html,
|
|
5241
|
+
csp: j.csp,
|
|
5242
|
+
permissions: j.permissions
|
|
5329
5243
|
}), await o, n)) return;
|
|
5330
|
-
k.current = r,
|
|
5331
|
-
let c =
|
|
5244
|
+
k.current = r, F((e) => e + 1), H.current?.({ status: "initialized" });
|
|
5245
|
+
let c = ve.current;
|
|
5332
5246
|
if (c) r.sendToolInputPartial({ arguments: c });
|
|
5333
5247
|
else {
|
|
5334
5248
|
let e = {
|
|
5335
|
-
...
|
|
5336
|
-
...
|
|
5249
|
+
..._e.current,
|
|
5250
|
+
...Ea(be.current)
|
|
5337
5251
|
};
|
|
5338
5252
|
r.sendToolInput({ arguments: e });
|
|
5339
5253
|
}
|
|
5340
|
-
let u =
|
|
5254
|
+
let u = Za(ye.current, be.current);
|
|
5341
5255
|
u && r.sendToolResult(u), H.current?.({ status: "ready" });
|
|
5342
5256
|
} catch (e) {
|
|
5343
5257
|
if (!n) {
|
|
5344
5258
|
let t = e instanceof Error ? e.message : "Failed to connect view";
|
|
5345
|
-
|
|
5259
|
+
de(t), Ce.current?.(t), H.current?.({
|
|
5346
5260
|
status: "error",
|
|
5347
5261
|
error: t
|
|
5348
5262
|
});
|
|
@@ -5360,8 +5274,8 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5360
5274
|
})());
|
|
5361
5275
|
};
|
|
5362
5276
|
}, [
|
|
5363
|
-
|
|
5364
|
-
|
|
5277
|
+
j,
|
|
5278
|
+
N,
|
|
5365
5279
|
l,
|
|
5366
5280
|
d,
|
|
5367
5281
|
f,
|
|
@@ -5371,64 +5285,64 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5371
5285
|
w
|
|
5372
5286
|
]), (0, A.useEffect)(() => {
|
|
5373
5287
|
let e = k.current;
|
|
5374
|
-
!e ||
|
|
5375
|
-
}, [
|
|
5288
|
+
!e || P === 0 || !me || e.setHostContext(me);
|
|
5289
|
+
}, [me, P]), (0, A.useEffect)(() => {
|
|
5376
5290
|
let e = k.current;
|
|
5377
|
-
!e ||
|
|
5378
|
-
}, [
|
|
5291
|
+
!e || P === 0 || !o || e.sendToolInputPartial({ arguments: o });
|
|
5292
|
+
}, [P, o]), (0, A.useEffect)(() => {
|
|
5379
5293
|
let e = k.current;
|
|
5380
|
-
if (!e ||
|
|
5294
|
+
if (!e || P === 0 || o) return;
|
|
5381
5295
|
let t = {
|
|
5382
5296
|
...i,
|
|
5383
|
-
...
|
|
5297
|
+
...Ea(s)
|
|
5384
5298
|
};
|
|
5385
5299
|
e.sendToolInput({ arguments: t });
|
|
5386
5300
|
}, [
|
|
5387
|
-
|
|
5301
|
+
P,
|
|
5388
5302
|
i,
|
|
5389
5303
|
o,
|
|
5390
5304
|
s
|
|
5391
5305
|
]), (0, A.useEffect)(() => {
|
|
5392
5306
|
let e = k.current;
|
|
5393
|
-
if (!e ||
|
|
5394
|
-
let t =
|
|
5307
|
+
if (!e || P === 0) return;
|
|
5308
|
+
let t = Za(a, s);
|
|
5395
5309
|
t && e.sendToolResult(t);
|
|
5396
5310
|
}, [
|
|
5397
|
-
|
|
5311
|
+
P,
|
|
5398
5312
|
a,
|
|
5399
5313
|
s
|
|
5400
5314
|
]), (0, A.useEffect)(() => {
|
|
5401
5315
|
let e = k.current;
|
|
5402
|
-
!e ||
|
|
5403
|
-
}, [c,
|
|
5316
|
+
!e || P === 0 || !c || e.sendToolCancelled({ reason: "Cancelled by user" });
|
|
5317
|
+
}, [c, P]);
|
|
5404
5318
|
let K = (0, A.useRef)(!1);
|
|
5405
5319
|
(0, A.useEffect)(() => {
|
|
5406
|
-
K.current ||
|
|
5407
|
-
}, [
|
|
5408
|
-
if (
|
|
5409
|
-
let e = setTimeout(() =>
|
|
5320
|
+
K.current || P === 0 || (K.current = !0, Te.current?.());
|
|
5321
|
+
}, [P]), (0, A.useEffect)(() => {
|
|
5322
|
+
if (P === 0 || !fe) return;
|
|
5323
|
+
let e = setTimeout(() => I(!1), 300);
|
|
5410
5324
|
return () => clearTimeout(e);
|
|
5411
|
-
}, [
|
|
5412
|
-
let q =
|
|
5413
|
-
if (
|
|
5414
|
-
if (!
|
|
5325
|
+
}, [P, fe]);
|
|
5326
|
+
let q = j !== null && j.prefersBorder && B !== "fullscreen";
|
|
5327
|
+
if (ue) return /* @__PURE__ */ A.createElement("div", { className: ie }, /* @__PURE__ */ A.createElement("div", { className: "border border-red-200/50 dark:border-red-800/50 bg-red-50/30 dark:bg-red-950/20 rounded-lg p-4" }, /* @__PURE__ */ A.createElement("p", { className: "text-sm text-red-600 dark:text-red-400" }, "Failed to load view: ", ue)));
|
|
5328
|
+
if (!j) return /* @__PURE__ */ A.createElement("div", { className: ie }, /* @__PURE__ */ A.createElement("div", { className: "flex items-center justify-center w-full h-[200px]" }, /* @__PURE__ */ A.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading view…")));
|
|
5415
5329
|
let ze = Me ?? Ne ?? "flex group flex-1 items-center justify-center", Be = {
|
|
5416
|
-
height: Pe || U ? "100%" : `${
|
|
5330
|
+
height: Pe || U ? "100%" : `${L}px`,
|
|
5417
5331
|
width: "100%",
|
|
5418
|
-
maxWidth:
|
|
5332
|
+
maxWidth: B === "inline" ? `${h}px` : "100%",
|
|
5419
5333
|
transition: Pe || U ? void 0 : "height 300ms ease-out"
|
|
5420
5334
|
}, Ve = /* @__PURE__ */ A.createElement("div", {
|
|
5421
5335
|
ref: se,
|
|
5422
5336
|
className: Pe ? `${ze} flex flex-col` : ze,
|
|
5423
5337
|
style: U ? {
|
|
5424
|
-
height:
|
|
5425
|
-
maxWidth:
|
|
5338
|
+
height: Ba.DEFAULT_HEIGHT,
|
|
5339
|
+
maxWidth: Ba.PIP_MAX_WIDTH,
|
|
5426
5340
|
zIndex: 100
|
|
5427
5341
|
} : Pe ? { zIndex: 100 } : void 0
|
|
5428
5342
|
}, Pe && /* @__PURE__ */ A.createElement("header", {
|
|
5429
5343
|
className: "grid shrink-0 items-center border-b border-zinc-200 bg-background px-3 dark:border-zinc-700",
|
|
5430
5344
|
style: {
|
|
5431
|
-
height:
|
|
5345
|
+
height: Ba.FULLSCREEN_HEADER_HEIGHT,
|
|
5432
5346
|
gridTemplateColumns: "auto 1fr auto"
|
|
5433
5347
|
}
|
|
5434
5348
|
}, E ? E({
|
|
@@ -5441,7 +5355,7 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5441
5355
|
"aria-label": "Exit fullscreen",
|
|
5442
5356
|
className: "flex size-8 cursor-pointer items-center justify-center rounded-full border border-zinc-200 bg-background text-foreground shadow-sm hover:bg-muted dark:border-zinc-700",
|
|
5443
5357
|
onClick: () => void je("inline")
|
|
5444
|
-
}, /* @__PURE__ */ A.createElement(
|
|
5358
|
+
}, /* @__PURE__ */ A.createElement(Ja, null)), /* @__PURE__ */ A.createElement("div", { className: "flex min-w-0 items-center justify-center gap-2 px-2" }, T?.iconUrl ? /* @__PURE__ */ A.createElement("img", {
|
|
5445
5359
|
src: T.iconUrl,
|
|
5446
5360
|
alt: "",
|
|
5447
5361
|
className: "size-6 shrink-0 rounded-md object-contain"
|
|
@@ -5462,10 +5376,10 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5462
5376
|
className: "absolute right-3 top-3 z-[110] flex size-8 cursor-pointer items-center justify-center rounded-full border border-border bg-background/90 text-foreground shadow-sm backdrop-blur-sm hover:bg-background",
|
|
5463
5377
|
style: { zIndex: 110 },
|
|
5464
5378
|
onClick: () => void je("inline")
|
|
5465
|
-
}, /* @__PURE__ */ A.createElement(
|
|
5379
|
+
}, /* @__PURE__ */ A.createElement(Ja, null))), /* @__PURE__ */ A.createElement("div", { className: Pe ? "relative flex min-h-0 w-full flex-1 flex-col" : U ? "relative w-full h-full min-h-0 flex flex-1 flex-col" : "relative w-full flex flex-1 justify-center items-center" }, fe && /* @__PURE__ */ A.createElement("div", { className: "flex absolute inset-0 items-center justify-center z-10" }, /* @__PURE__ */ A.createElement("span", { className: "text-sm text-muted-foreground" }, "Loading…")), !U && !Pe && (D || O) && /* @__PURE__ */ A.createElement("div", { className: "absolute -top-8 left-2 z-10 whitespace-nowrap pointer-events-none text-xs text-muted-foreground" }, D && !a ? D : O), /* @__PURE__ */ A.createElement("div", {
|
|
5466
5380
|
"data-testid": ae,
|
|
5467
5381
|
"data-mcp-app-tool": r,
|
|
5468
|
-
className:
|
|
5382
|
+
className: B === "fullscreen" ? "w-full h-full overflow-hidden" : "w-full overflow-hidden",
|
|
5469
5383
|
style: Be
|
|
5470
5384
|
}, /* @__PURE__ */ A.createElement("iframe", {
|
|
5471
5385
|
ref: oe,
|
|
@@ -5474,9 +5388,9 @@ function co({ viewId: e, source: t, sandboxUrl: n, toolName: r = "view", toolInp
|
|
|
5474
5388
|
}))));
|
|
5475
5389
|
return /* @__PURE__ */ A.createElement("div", { className: ie }, Ve);
|
|
5476
5390
|
}
|
|
5477
|
-
function
|
|
5391
|
+
function $a(e, t) {
|
|
5478
5392
|
return !(e.viewId !== t.viewId || e.source !== t.source || e.sandboxUrl !== t.sandboxUrl || e.displayMode !== t.displayMode || e.cancelled !== t.cancelled || e.toolInput !== t.toolInput || e.toolOutput !== t.toolOutput || e.partialToolInput !== t.partialToolInput || e.customProps !== t.customProps || e.hostContext !== t.hostContext || e.hostCapabilities !== t.hostCapabilities || e.cspMode !== t.cspMode || e.mockOpenAiFileApis !== t.mockOpenAiFileApis || e.onInlineHeightChange !== t.onInlineHeightChange || e.fullscreenHeader !== t.fullscreenHeader || e.renderFullscreenClose !== t.renderFullscreenClose || e.className !== t.className || e.onReady !== t.onReady || e.onLifecycleChange !== t.onLifecycleChange);
|
|
5479
5393
|
}
|
|
5480
|
-
var
|
|
5394
|
+
var eo = (0, A.memo)(Qa, $a);
|
|
5481
5395
|
//#endregion
|
|
5482
|
-
export { _r as a,
|
|
5396
|
+
export { _r as a, Ha as c, wa as d, yr as i, fa as l, Ca as n, Va as o, eo as r, Ua as s, Ta as t, vr as u };
|