@mcp-use/inspector 20.0.0-beta.7 → 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.
Files changed (59) hide show
  1. package/README.md +2 -18
  2. package/dist/cdn/{ChatTab-DtUGK07C.js → ChatTab-CU-Gf-GY.js} +6 -6
  3. package/dist/cdn/{ConnectionSettingsForm-CNuMa6jp.js → ConnectionSettingsForm-C4fEbp4v.js} +1 -1
  4. package/dist/cdn/{ConnectionSettingsTab-qSVQ1aIF.js → ConnectionSettingsTab-DXUrhGfL.js} +1 -1
  5. package/dist/cdn/{MCPAppsDebugControls-BpP-Ifap.js → MCPAppsDebugControls-Dp_o3k-P.js} +2 -2
  6. package/dist/cdn/{MarkdownRenderer-bX1BrKgI.js → MarkdownRenderer-COhmp4fm.js} +1 -1
  7. package/dist/cdn/{McpAppsViewPanel-jlsYQ7uS.js → McpAppsViewPanel-CMQZ28xs.js} +2 -2
  8. package/dist/cdn/{OAuthCallback--NZdLoWx.js → OAuthCallback-ClEnwZ9o.js} +1 -1
  9. package/dist/cdn/{PromptsTab-BlXDcau3.js → PromptsTab-DPjWr6W0.js} +1 -1
  10. package/dist/cdn/{ResourcesTab-D45_JojP.js → ResourcesTab-D8hOTjDs.js} +5 -5
  11. package/dist/cdn/{SamplingTab-r7tImM6L.js → SamplingTab-e1G8Qx1k.js} +3 -3
  12. package/dist/cdn/{ToolsTab-DOAO8HnS.js → ToolsTab-jNn6Cz6A.js} +5 -5
  13. package/dist/cdn/{ViewPreview-CBhrVdwx.js → ViewPreview-BpQYOKES.js} +2 -2
  14. package/dist/cdn/{dist-SxRsB1iS.js → dist-8Z7HZAGn.js} +2 -2
  15. package/dist/cdn/{index-browser-Dm3R1Mfe.js → index-browser-nWAQnCTk.js} +112 -200
  16. package/dist/cdn/inspector.css +1 -1
  17. package/dist/cdn/inspector.js +5 -5
  18. package/dist/cdn/{react-Bl-hSkvn.js → react-8UPT_kVF.js} +521 -607
  19. package/dist/cdn/{telemetry-TwPKZlFf.js → telemetry-X2tRdL3U.js} +37 -69
  20. package/dist/cdn/{useConfig-leHVjdjl.js → useConfig-BMqxaGDa.js} +2 -2
  21. package/dist/cdn/{useViewHostProps-CDOm2w6u.js → useViewHostProps-DMArgRGs.js} +1 -1
  22. package/dist/cli.js +61 -2
  23. package/dist/client/index.js +2 -7
  24. package/dist/client/telemetry/init.d.ts.map +1 -1
  25. package/dist/server/cdn-shell.d.ts.map +1 -1
  26. package/dist/server/cdn-shell.js +2 -2
  27. package/dist/server/{chunk-5GVQGIAX.js → chunk-3WVGQOQX.js} +1 -1
  28. package/dist/server/{chunk-UZZDBVKF.js → chunk-BIKA6WIX.js} +61 -2
  29. package/dist/server/{chunk-VFVFLXKP.js → chunk-KB6CHWZ4.js} +1 -1
  30. package/dist/server/cli.js +2 -2
  31. package/dist/server/index.js +3 -3
  32. package/dist/server/middleware.js +3 -3
  33. package/dist/server/version.js +1 -1
  34. package/dist/web/assets/{ChatTab-B6ubLbeA.js → ChatTab-fclW7HPg.js} +1 -1
  35. package/dist/web/assets/{ConnectionSettingsTab-Cb2eDgEu.js → ConnectionSettingsTab-DNl63AkH.js} +1 -1
  36. package/dist/web/assets/{ElicitationTab-CbnCrmu9.js → ElicitationTab-B73XazTU.js} +1 -1
  37. package/dist/web/assets/{MCPAppsDebugControls-sRglMhat.js → MCPAppsDebugControls-BYLu5GRy.js} +1 -1
  38. package/dist/web/assets/{ManufactOAuthCallback-D4uYGigW.js → ManufactOAuthCallback-Dp3icsBc.js} +1 -1
  39. package/dist/web/assets/{MarkdownRenderer-Cwxp9fLj.js → MarkdownRenderer-CcvZ7qUS.js} +1 -1
  40. package/dist/web/assets/{McpAppsViewPanel-jQYFoZNX.js → McpAppsViewPanel-KD_ZnjfO.js} +1 -1
  41. package/dist/web/assets/{NotificationsTab-DuSm762_.js → NotificationsTab-CV9kw9j-.js} +1 -1
  42. package/dist/web/assets/{OAuthCallback-VLHlUe2c.js → OAuthCallback-C9J2xEkV.js} +1 -1
  43. package/dist/web/assets/{PromptsTab-DK6XZxR8.js → PromptsTab-irNacYfj.js} +1 -1
  44. package/dist/web/assets/{ResourcesTab-CUE4MAtJ.js → ResourcesTab-C-4Fd-HY.js} +1 -1
  45. package/dist/web/assets/{SamplingTab-BYNkVCTu.js → SamplingTab-B7bM9cnF.js} +1 -1
  46. package/dist/web/assets/{ServerMetadataTab-DWjNFMbq.js → ServerMetadataTab-CnGUw9uD.js} +1 -1
  47. package/dist/web/assets/{ToolsTab-BisWWY2p.js → ToolsTab-DBHJRY9V.js} +2 -2
  48. package/dist/web/assets/{ViewPreview-COrmPpRr.js → ViewPreview-D7NNsxbe.js} +1 -1
  49. package/dist/web/assets/{checkbox-B6dtF73d.js → checkbox-C9WZqT8k.js} +1 -1
  50. package/dist/web/assets/{dist-9Oy7e0v8.js → dist-ChWdPMRV.js} +3 -3
  51. package/dist/web/assets/{index-BMaSsizY.js → index-B5OxiZlj.js} +13 -13
  52. package/dist/web/assets/index-bCIH1Sdx.css +1 -0
  53. package/dist/web/assets/{shared-CFs9CZfB.js → shared-BWLzd0mh.js} +1 -1
  54. package/dist/web/assets/{tabs-subtle-D2XkWhLL.js → tabs-subtle-DkVoZG5s.js} +1 -1
  55. package/dist/web/assets/{useConfig-B6tXvJOb.js → useConfig-CTtYs2lN.js} +1 -1
  56. package/dist/web/assets/{useViewHostProps-DZqOwiAm.js → useViewHostProps-DOJOoXbY.js} +1 -1
  57. package/dist/web/index.html +3 -3
  58. package/package.json +4 -4
  59. package/dist/web/assets/index-D7TVTIt9.css +0 -1
@@ -6,27 +6,25 @@ var l = /* @__PURE__ */ e({
6
6
  BrowserOAuthClientProvider: () => B,
7
7
  DialectJsonSchemaValidator: () => K,
8
8
  HttpConnector: () => Y,
9
- MCPClient: () => ze,
9
+ MCPClient: () => ke,
10
10
  MCPConnection: () => $,
11
11
  MCPSession: () => $,
12
- POSTHOG_API_KEY: () => se,
13
- POSTHOG_HOST: () => oe,
14
- SCARF_GATEWAY_URL: () => T,
15
- Tel: () => L,
16
- Telemetry: () => I,
12
+ POSTHOG_API_KEY: () => oe,
13
+ POSTHOG_HOST: () => ae,
14
+ Tel: () => N,
15
+ Telemetry: () => M,
17
16
  VERSION: () => x,
18
- capturePostHog: () => O,
19
- captureScarf: () => k,
20
- completeOAuthFlow: () => W,
17
+ capturePostHog: () => E,
18
+ completeOAuthFlow: () => G,
21
19
  createOAuthProvider: () => V,
22
20
  getPackageVersion: () => S,
23
- isUnauthorized: () => U,
21
+ isUnauthorized: () => W,
24
22
  logger: () => b,
25
23
  normalizeClientInfo: () => Q,
26
24
  resolveCallbacks: () => X,
27
- setTelemetrySource: () => R,
25
+ setTelemetrySource: () => P,
28
26
  shouldAutoProvisionOAuth: () => Z,
29
- telFetch: () => w
27
+ telFetch: () => T
30
28
  }), u;
31
29
  function d(e) {
32
30
  u = e;
@@ -192,7 +190,7 @@ var C = class {}, te = class extends C {
192
190
  public_identifier: this.data.publicIdentifier ?? null
193
191
  };
194
192
  }
195
- }, ie = class extends C {
193
+ }, w = class extends C {
196
194
  constructor(e) {
197
195
  super(), this.data = e;
198
196
  }
@@ -215,7 +213,7 @@ var C = class {}, te = class extends C {
215
213
  return null;
216
214
  }
217
215
  }
218
- }, ae = class extends C {
216
+ }, ie = class extends C {
219
217
  constructor(e) {
220
218
  super(), this.data = e;
221
219
  }
@@ -226,59 +224,15 @@ var C = class {}, te = class extends C {
226
224
  return { server_name: this.data.serverName };
227
225
  }
228
226
  };
229
- async function w(e, t) {
227
+ async function T(e, t) {
230
228
  try {
231
229
  await fetch(e, t);
232
230
  } catch {}
233
231
  }
234
- var oe = "https://eu.i.posthog.com", se = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", T = "https://mcpuse.gateway.scarf.sh/events-ts", E = "https://mcpuse.gateway.scarf.sh/simple/", D = 1800, ce = /* @__PURE__ */ new Set([
235
- "query",
236
- "response",
237
- "messages"
238
- ]);
239
- function le(e) {
240
- if (e == null) return "";
241
- if (typeof e == "string") return e;
242
- if (typeof e == "number" || typeof e == "boolean") return String(e);
243
- try {
244
- return JSON.stringify(e);
245
- } catch {
246
- return String(e);
247
- }
248
- }
249
- function ue(e, t = E) {
250
- let n = new URLSearchParams();
251
- for (let [t, r] of Object.entries(e)) {
252
- let e = le(r);
253
- ce.has(t) && e.length > 120 && (e = `${e.slice(0, 117)}...`), e !== "" && n.set(t, e);
254
- }
255
- let r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`;
256
- if (r.length <= D) return r;
257
- let i = [...n.keys()].sort((e, t) => (n.get(t)?.length ?? 0) - (n.get(e)?.length ?? 0));
258
- for (let e of i) {
259
- if (r.length <= D) break;
260
- e === "event" || e === "user_id" || (n.delete(e), r = `${t}${t.includes("?") ? "&" : "?"}${n.toString()}`);
261
- }
262
- return r.slice(0, D);
263
- }
264
- function de(e, t) {
265
- return w(t, {
266
- method: "POST",
267
- headers: { "Content-Type": "application/json" },
268
- keepalive: !0,
269
- body: JSON.stringify(e)
270
- });
271
- }
272
- function fe(e, t) {
273
- try {
274
- let n = ue(e, t), r = new Image();
275
- r.referrerPolicy = "no-referrer-when-downgrade", r.src = n;
276
- } catch {}
277
- return Promise.resolve();
278
- }
279
- function O(e) {
232
+ var ae = "https://eu.i.posthog.com", oe = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
233
+ function E(e) {
280
234
  let t = e.host ?? "https://eu.i.posthog.com", n = e.apiKey ?? "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
281
- return w(`${t}/i/v0/e/`, {
235
+ return T(`${t}/i/v0/e/`, {
282
236
  method: "POST",
283
237
  headers: { "Content-Type": "application/json" },
284
238
  keepalive: !0,
@@ -291,30 +245,19 @@ function O(e) {
291
245
  })
292
246
  });
293
247
  }
294
- function k(e, t = T) {
295
- return typeof window < "u" ? fe(e, t === "https://mcpuse.gateway.scarf.sh/events-ts" ? E : t) : de(e, t);
296
- }
297
- function A() {
248
+ function D() {
298
249
  return globalThis.crypto.randomUUID();
299
250
  }
300
- function pe() {
251
+ function se() {
301
252
  let e = new Uint8Array(8);
302
253
  return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
303
254
  }
304
- function me(e, t) {
305
- let n = (e) => e.split("-")[0].split(".").map((e) => parseInt(e, 10) || 0), r = n(e), i = n(t), a = Math.max(r.length, i.length);
306
- for (let e = 0; e < a; e++) {
307
- let t = r[e] ?? 0, n = i[e] ?? 0;
308
- if (t !== n) return t > n;
309
- }
310
- return !1;
311
- }
312
- var j = "mcp_use_user_id", M = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", N = "https://eu.i.posthog.com", P = null;
313
- function F() {
255
+ var O = "mcp_use_user_id", k = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI", A = "https://eu.i.posthog.com", ce = null;
256
+ function j() {
314
257
  return typeof localStorage < "u" && typeof localStorage.getItem == "function" && typeof localStorage.setItem == "function" && typeof localStorage.removeItem == "function";
315
258
  }
316
- function he() {
317
- if (!F()) return null;
259
+ function le() {
260
+ if (!j()) return null;
318
261
  try {
319
262
  localStorage.setItem("__mcp_use_test__", "1"), localStorage.removeItem("__mcp_use_test__");
320
263
  } catch {
@@ -323,66 +266,60 @@ function he() {
323
266
  return {
324
267
  getUserId() {
325
268
  try {
326
- return localStorage.getItem(j);
269
+ return localStorage.getItem(O);
327
270
  } catch {
328
271
  return null;
329
272
  }
330
273
  },
331
274
  setUserId(e) {
332
275
  try {
333
- localStorage.setItem(j, e);
276
+ localStorage.setItem(O, e);
334
277
  } catch {}
335
- },
336
- getDownloadedVersion: () => null,
337
- setDownloadedVersion: () => void 0
278
+ }
338
279
  };
339
280
  }
340
- function ge() {
281
+ function ue() {
341
282
  try {
342
283
  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";
343
284
  } catch {
344
285
  return "unknown";
345
286
  }
346
287
  }
347
- function _e() {
288
+ function de() {
348
289
  if (typeof process < "u" && {}.MCP_USE_TELEMETRY_SOURCE) return {}.MCP_USE_TELEMETRY_SOURCE;
349
290
  try {
350
- if (F()) return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE") ?? void 0;
291
+ if (j()) return localStorage.getItem("MCP_USE_TELEMETRY_SOURCE") ?? void 0;
351
292
  } catch {}
352
293
  }
353
- function ve() {
294
+ function fe() {
354
295
  if (typeof window < "u" && window.__MCP_USE_ANONYMIZED_TELEMETRY__ === !1 || typeof process < "u" && {}.MCP_USE_ANONYMIZED_TELEMETRY?.toLowerCase() === "false") return !0;
355
296
  try {
356
- if (F() && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") return !0;
297
+ if (j() && localStorage.getItem("MCP_USE_ANONYMIZED_TELEMETRY") === "false") return !0;
357
298
  } catch {}
358
299
  return !1;
359
300
  }
360
- function ye() {
301
+ function pe() {
361
302
  try {
362
- return `session-${A()}`;
303
+ return `session-${D()}`;
363
304
  } catch {
364
- return `session-${Date.now()}-${pe()}`;
305
+ return `session-${Date.now()}-${se()}`;
365
306
  }
366
307
  }
367
- var I = class e {
308
+ var M = class e {
368
309
  static instance = null;
369
310
  UNKNOWN_USER_ID = "UNKNOWN_USER_ID";
370
311
  _currUserId = null;
371
312
  _telemetryEnabled = !1;
372
313
  _pending = /* @__PURE__ */ new Set();
373
- _scarfEnabled = !1;
374
314
  _runtimeEnvironment;
375
315
  _storageCapability;
376
316
  _storage;
377
- _fsBacked;
378
317
  _source;
379
318
  _productVersion;
380
319
  constructor() {
381
- this._runtimeEnvironment = ge(), this._fsBacked = P !== null, this._storage = P ?? he() ?? null, this._storageCapability = this._storage ? "persistent" : "session-only", this._source = _e() || this._runtimeEnvironment;
382
- let e = ve(), t = this._runtimeEnvironment !== "unknown";
383
- e ? (this._telemetryEnabled = !1, b.debug("Telemetry disabled via opt-out")) : t ? (b.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0, this._scarfEnabled = !0, this._fsBacked && setTimeout(() => {
384
- this.trackPackageDownload({ triggered_by: "initialization" }).catch((e) => b.debug(`Failed to track package download: ${e}`));
385
- }, 0)) : (this._telemetryEnabled = !1, b.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
320
+ this._runtimeEnvironment = ue(), this._storage = ce ?? le() ?? null, this._storageCapability = this._storage ? "persistent" : "session-only", this._source = de() || this._runtimeEnvironment;
321
+ let e = fe(), t = this._runtimeEnvironment !== "unknown";
322
+ e ? (this._telemetryEnabled = !1, b.debug("Telemetry disabled via opt-out")) : t ? (b.debug("Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."), this._telemetryEnabled = !0) : (this._telemetryEnabled = !1, b.debug(`Telemetry disabled - unknown environment: ${this._runtimeEnvironment}`));
386
323
  }
387
324
  get runtimeEnvironment() {
388
325
  return this._runtimeEnvironment;
@@ -396,7 +333,7 @@ var I = class e {
396
333
  setSource(e) {
397
334
  this._source = e;
398
335
  try {
399
- F() && localStorage.setItem("MCP_USE_TELEMETRY_SOURCE", e);
336
+ j() && localStorage.setItem("MCP_USE_TELEMETRY_SOURCE", e);
400
337
  } catch {}
401
338
  b.debug(`Telemetry source set to: ${e}`);
402
339
  }
@@ -407,7 +344,7 @@ var I = class e {
407
344
  this._productVersion = e;
408
345
  }
409
346
  get isEnabled() {
410
- return this._telemetryEnabled || this._scarfEnabled;
347
+ return this._telemetryEnabled;
411
348
  }
412
349
  get userId() {
413
350
  if (this._currUserId) return this._currUserId;
@@ -415,56 +352,31 @@ var I = class e {
415
352
  if (this._storage) {
416
353
  let e = this._storage.getUserId();
417
354
  if (e) return this._currUserId = e, e;
418
- let t = A();
355
+ let t = D();
419
356
  return this._storage.setUserId(t), this._currUserId = t, t;
420
357
  }
421
- this._currUserId = ye();
358
+ this._currUserId = pe();
422
359
  } catch {
423
360
  this._currUserId = this.UNKNOWN_USER_ID;
424
361
  }
425
362
  return this._currUserId;
426
363
  }
427
364
  async capture(e) {
428
- if (!this._telemetryEnabled && !this._scarfEnabled) return;
365
+ if (!this._telemetryEnabled) return;
429
366
  let t = this.userId, n = {
430
367
  ...e.properties,
431
368
  mcp_use_version: this._productVersion ?? S(),
432
369
  language: "typescript",
433
370
  source: this._source,
434
371
  runtime: this._runtimeEnvironment
435
- };
436
- if (this._telemetryEnabled) {
437
- let r = O({
438
- host: N,
439
- apiKey: M,
440
- event: e.name,
441
- distinctId: t,
442
- properties: n
443
- });
444
- this._pending.add(r), r.finally(() => this._pending.delete(r));
445
- }
446
- if (this._scarfEnabled) {
447
- let r = k({
448
- ...n,
449
- user_id: t,
450
- event: e.name
451
- });
452
- this._pending.add(r), r.finally(() => this._pending.delete(r));
453
- }
454
- }
455
- async trackPackageDownload(e) {
456
- if (!this._scarfEnabled || !this._fsBacked || !this._storage) return;
457
- let t = S(), n = this._storage.getDownloadedVersion(), r = !1, i = !1;
458
- n ? me(t, n) && (i = !0, this._storage.setDownloadedVersion(t)) : (i = !0, r = !0, this._storage.setDownloadedVersion(t)), i && await k({
459
- ...e || {},
460
- mcp_use_version: t,
461
- user_id: this.userId,
462
- event: "package_download",
463
- first_download: r,
464
- language: "typescript",
465
- source: this._source,
466
- runtime: this._runtimeEnvironment
372
+ }, r = E({
373
+ host: A,
374
+ apiKey: k,
375
+ event: e.name,
376
+ distinctId: t,
377
+ properties: n
467
378
  });
379
+ this._pending.add(r), r.finally(() => this._pending.delete(r));
468
380
  }
469
381
  async trackAgentExecution(e) {
470
382
  this.isEnabled && await this.capture(new te(e));
@@ -476,13 +388,13 @@ var I = class e {
476
388
  this.isEnabled && await this.capture(new re(e));
477
389
  }
478
390
  async trackClientAddServer(e, t) {
479
- this.isEnabled && await this.capture(new ie({
391
+ this.isEnabled && await this.capture(new w({
480
392
  serverName: e,
481
393
  serverConfig: t
482
394
  }));
483
395
  }
484
396
  async trackClientRemoveServer(e) {
485
- this.isEnabled && await this.capture(new ae({ serverName: e }));
397
+ this.isEnabled && await this.capture(new ie({ serverName: e }));
486
398
  }
487
399
  async trackUseMcpConnection(e) {
488
400
  this.isEnabled && await this.capture({
@@ -521,9 +433,9 @@ var I = class e {
521
433
  });
522
434
  }
523
435
  identify(e, t) {
524
- this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled && O({
525
- host: N,
526
- apiKey: M,
436
+ this._currUserId = e, this._storage?.setUserId(e), this._telemetryEnabled && E({
437
+ host: A,
438
+ apiKey: k,
527
439
  event: "$identify",
528
440
  distinctId: e,
529
441
  properties: { $set: t ?? {} }
@@ -542,15 +454,15 @@ var I = class e {
542
454
  b.debug(`Error flushing telemetry captures: ${e}`);
543
455
  }
544
456
  }
545
- }, L = I;
546
- function R(e) {
547
- L.getInstance().setSource(e);
457
+ }, N = M;
458
+ function P(e) {
459
+ N.getInstance().setSource(e);
548
460
  }
549
461
  d({
550
- addServer: (e, t) => I.getInstance().trackClientAddServer(e, t).catch(() => void 0),
551
- removeServer: (e) => I.getInstance().trackClientRemoveServer(e).catch(() => void 0)
552
- }), h((e) => I.getInstance().trackConnectorInit(e).catch(() => void 0));
553
- function z(e) {
462
+ addServer: (e, t) => M.getInstance().trackClientAddServer(e, t).catch(() => void 0),
463
+ removeServer: (e) => M.getInstance().trackClientRemoveServer(e).catch(() => void 0)
464
+ }), h((e) => M.getInstance().trackConnectorInit(e).catch(() => void 0));
465
+ function F(e) {
554
466
  let t = () => {
555
467
  throw Error(`Invalid url to pass to open(): ${e}`);
556
468
  }, n;
@@ -559,12 +471,12 @@ function z(e) {
559
471
  } catch {
560
472
  t();
561
473
  }
562
- return n.protocol !== "https:" && n.protocol !== "http:" && t(), n.hostname !== encodeURIComponent(n.hostname) && t(), n.username &&= encodeURIComponent(n.username), n.password &&= encodeURIComponent(n.password), n.pathname = n.pathname.slice(0, 1) + encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi, "/"), n.search = n.search.slice(0, 1) + Array.from(n.searchParams.entries()).map(be).join("&"), n.hash = n.hash.slice(0, 1) + encodeURIComponent(n.hash.slice(1)), n.href;
474
+ return n.protocol !== "https:" && n.protocol !== "http:" && t(), n.hostname !== encodeURIComponent(n.hostname) && t(), n.username &&= encodeURIComponent(n.username), n.password &&= encodeURIComponent(n.password), n.pathname = n.pathname.slice(0, 1) + encodeURIComponent(n.pathname.slice(1)).replace(/%2f/gi, "/"), n.search = n.search.slice(0, 1) + Array.from(n.searchParams.entries()).map(I).join("&"), n.hash = n.hash.slice(0, 1) + encodeURIComponent(n.hash.slice(1)), n.href;
563
475
  }
564
- function be([e, t]) {
476
+ function I([e, t]) {
565
477
  return `${encodeURIComponent(e)}${t.length > 0 ? `=${encodeURIComponent(t)}` : ""}`;
566
478
  }
567
- var xe = class {
479
+ var L = class {
568
480
  get(e) {
569
481
  return localStorage.getItem(e);
570
482
  }
@@ -582,7 +494,7 @@ var xe = class {
582
494
  }
583
495
  return e;
584
496
  }
585
- }, Se = class e {
497
+ }, R = class e {
586
498
  serverUrl;
587
499
  storageKeyPrefix;
588
500
  serverUrlHash;
@@ -595,7 +507,7 @@ var xe = class {
595
507
  store;
596
508
  allowClientSecret;
597
509
  constructor(n, r, i) {
598
- t(r.clientMetadataUrl), this.serverUrl = n, this.storageKeyPrefix = r.storageKeyPrefix || "mcp:auth", this.serverUrlHash = e.hashString(n), this.clientName = r.clientName || "mcp-use", this.clientUri = r.clientUri || (typeof window < "u" ? window.location.origin : "https://mcp-use.com"), this.logoUri = r.logoUri || "https://mcp-use.com/logo.png", this.callbackUrl = z(r.callbackUrl || (typeof window < "u" ? new URL("/oauth/callback", window.location.origin).toString() : "/oauth/callback")), this.clientMetadataUrl = r.clientMetadataUrl, this.scope = r.scope, this.store = i, this.allowClientSecret = r.allowClientSecret ?? !0;
510
+ t(r.clientMetadataUrl), this.serverUrl = n, this.storageKeyPrefix = r.storageKeyPrefix || "mcp:auth", this.serverUrlHash = e.hashString(n), this.clientName = r.clientName || "mcp-use", this.clientUri = r.clientUri || (typeof window < "u" ? window.location.origin : "https://mcp-use.com"), this.logoUri = r.logoUri || "https://mcp-use.com/logo.png", this.callbackUrl = F(r.callbackUrl || (typeof window < "u" ? new URL("/oauth/callback", window.location.origin).toString() : "/oauth/callback")), this.clientMetadataUrl = r.clientMetadataUrl, this.scope = r.scope, this.store = i, this.allowClientSecret = r.allowClientSecret ?? !0;
599
511
  }
600
512
  getKey(e) {
601
513
  return `${this.storageKeyPrefix}_${this.serverUrlHash}_${e}`;
@@ -751,14 +663,14 @@ var xe = class {
751
663
  returnUrl: t.returnUrl
752
664
  };
753
665
  e.searchParams.set("state", n);
754
- let a = z(e.toString());
666
+ let a = F(e.toString());
755
667
  return await this.store.set(r, JSON.stringify(i)), await this.store.set(this.getKey("last_auth_url"), a), a;
756
668
  }
757
669
  async getTokenEndpoint() {
758
670
  return (await this.discoveryState())?.authorizationServerMetadata?.token_endpoint ?? null;
759
671
  }
760
672
  };
761
- async function Ce(e) {
673
+ async function z(e) {
762
674
  return typeof e == "string" ? e : e instanceof URLSearchParams || e instanceof FormData ? Object.fromEntries(e.entries()) : e instanceof Blob ? await e.text() : e;
763
675
  }
764
676
  var B = class {
@@ -773,10 +685,10 @@ var B = class {
773
685
  onPopupWindow;
774
686
  constructor(e, t = {}) {
775
687
  if (t.staticClientInfo?.client_secret) throw Error("Browser OAuth clients must be public clients; staticClientInfo.client_secret is not allowed.");
776
- this.serverUrl = e, this.session = new Se(e, {
688
+ this.serverUrl = e, this.session = new R(e, {
777
689
  ...t,
778
690
  allowClientSecret: !1
779
- }, new xe()), this.preventAutoAuth = t.preventAutoAuth, this.useRedirectFlow = t.useRedirectFlow, this.oauthProxyUrl = t.oauthProxyUrl, this.connectionUrl = t.connectionUrl, this.proxyOAuthRequests = t.proxyOAuthRequests ?? !0, this.staticClientInfo = t.staticClientInfo, this.onPopupWindow = t.onPopupWindow;
691
+ }, new L()), this.preventAutoAuth = t.preventAutoAuth, this.useRedirectFlow = t.useRedirectFlow, this.oauthProxyUrl = t.oauthProxyUrl, this.connectionUrl = t.connectionUrl, this.proxyOAuthRequests = t.proxyOAuthRequests ?? !0, this.staticClientInfo = t.staticClientInfo, this.onPopupWindow = t.onPopupWindow;
780
692
  }
781
693
  get storageKeyPrefix() {
782
694
  return this.session.storageKeyPrefix;
@@ -862,7 +774,7 @@ var B = class {
862
774
  } catch {}
863
775
  return e;
864
776
  }
865
- let f = a?.body ? await Ce(a.body) : void 0, p = await (await t(d, {
777
+ let f = a?.body ? await z(a.body) : void 0, p = await (await t(d, {
866
778
  method: "POST",
867
779
  headers: { "Content-Type": "application/json" },
868
780
  body: JSON.stringify({
@@ -952,7 +864,7 @@ var B = class {
952
864
  }
953
865
  getLastAttemptedAuthUrl() {
954
866
  let e = localStorage.getItem(this.getKey("last_auth_url"));
955
- return e ? z(e) : null;
867
+ return e ? F(e) : null;
956
868
  }
957
869
  clearStorage() {
958
870
  let e = `${this.storageKeyPrefix}_${this.serverUrlHash}_`, t = `${this.storageKeyPrefix}:state_`, n = [], r = 0;
@@ -976,15 +888,15 @@ var B = class {
976
888
  async function V(e, t = {}) {
977
889
  return new B(e, t);
978
890
  }
979
- var we = "mcp_auth_callback", Te = "mcp_auth_callback";
980
- function H(e) {
891
+ var H = "mcp_auth_callback", me = "mcp_auth_callback";
892
+ function U(e) {
981
893
  try {
982
894
  return typeof localStorage < "u" && !!localStorage.getItem(e);
983
895
  } catch {
984
896
  return !1;
985
897
  }
986
898
  }
987
- function Ee({ popup: e, state: t, tokensKey: n, timeoutMs: r = 5 * 6e4, closePollMs: i = 1e3, closeGraceMs: a = 2e4, expectedOrigin: o = typeof window < "u" ? window.location.origin : "" }) {
899
+ function he({ popup: e, state: t, tokensKey: n, timeoutMs: r = 5 * 6e4, closePollMs: i = 1e3, closeGraceMs: a = 2e4, expectedOrigin: o = typeof window < "u" ? window.location.origin : "" }) {
988
900
  return new Promise((s) => {
989
901
  let c = !1, l = null, u = null, d = null, f = null, p = () => {
990
902
  if (l &&= (clearInterval(l), null), u &&= (clearTimeout(u), null), d &&= (clearTimeout(d), null), typeof window < "u" && (window.removeEventListener("message", g), window.removeEventListener("storage", v)), f) {
@@ -996,7 +908,7 @@ function Ee({ popup: e, state: t, tokensKey: n, timeoutMs: r = 5 * 6e4, closePol
996
908
  }, m = (e) => {
997
909
  c || (c = !0, p(), s(e));
998
910
  }, h = (e) => {
999
- !e || e.type !== Te || e.state && t && e.state !== t || (e.success ? m({ kind: "success" }) : m({
911
+ !e || e.type !== me || e.state && t && e.state !== t || (e.success ? m({ kind: "success" }) : m({
1000
912
  kind: "error",
1001
913
  error: e.error ?? "Authentication failed in callback."
1002
914
  }));
@@ -1008,7 +920,7 @@ function Ee({ popup: e, state: t, tokensKey: n, timeoutMs: r = 5 * 6e4, closePol
1008
920
  e.key === n && e.newValue && m({ kind: "success" });
1009
921
  };
1010
922
  if (typeof window < "u" && (window.addEventListener("message", g), window.addEventListener("storage", v)), typeof BroadcastChannel < "u") try {
1011
- f = new BroadcastChannel(we), f.addEventListener("message", _);
923
+ f = new BroadcastChannel(H), f.addEventListener("message", _);
1012
924
  } catch {
1013
925
  f = null;
1014
926
  }
@@ -1021,34 +933,34 @@ function Ee({ popup: e, state: t, tokensKey: n, timeoutMs: r = 5 * 6e4, closePol
1021
933
  t = !1;
1022
934
  }
1023
935
  if (t) {
1024
- if (l &&= (clearInterval(l), null), H(n)) {
936
+ if (l &&= (clearInterval(l), null), U(n)) {
1025
937
  m({ kind: "success" });
1026
938
  return;
1027
939
  }
1028
940
  d = setTimeout(() => {
1029
- m(H(n) ? { kind: "success" } : { kind: "cancelled" });
941
+ m(U(n) ? { kind: "success" } : { kind: "cancelled" });
1030
942
  }, a);
1031
943
  }
1032
944
  }, i)), u = setTimeout(() => {
1033
- m(H(n) ? { kind: "success" } : { kind: "timeout" });
945
+ m(U(n) ? { kind: "success" } : { kind: "timeout" });
1034
946
  }, r);
1035
947
  });
1036
948
  }
1037
- var De = 5 * 6e4;
1038
- function U(e, t = 0) {
949
+ var ge = 5 * 6e4;
950
+ function W(e, t = 0) {
1039
951
  if (!e || t > 5) return !1;
1040
952
  if (e instanceof s) return !0;
1041
953
  if (e instanceof Error) {
1042
954
  if (e.code === 401 || e.name === "UnauthorizedError") return !0;
1043
955
  let n = e.message ?? "";
1044
- if (n.includes("401") || n.includes("Unauthorized") || e.cause && U(e.cause, t + 1)) return !0;
956
+ if (n.includes("401") || n.includes("Unauthorized") || e.cause && W(e.cause, t + 1)) return !0;
1045
957
  let r = e.data;
1046
- if (r?.cause && U(r.cause, t + 1)) return !0;
958
+ if (r?.cause && W(r.cause, t + 1)) return !0;
1047
959
  }
1048
960
  return !1;
1049
961
  }
1050
- async function W(e, t, n = {}) {
1051
- let i = e, a = n.timeoutMs ?? De, o = n.fetchFn ?? i.getProxyFetch?.() ?? void 0;
962
+ async function G(e, t, n = {}) {
963
+ let i = e, a = n.timeoutMs ?? ge, o = n.fetchFn ?? i.getProxyFetch?.() ?? void 0;
1052
964
  if (!i.hasPendingFlow) {
1053
965
  let n = await r(e, {
1054
966
  serverUrl: t,
@@ -1065,9 +977,9 @@ async function W(e, t, n = {}) {
1065
977
  });
1066
978
  return;
1067
979
  }
1068
- await G(i, a);
980
+ await _e(i, a);
1069
981
  }
1070
- async function G(e, t) {
982
+ async function _e(e, t) {
1071
983
  if (typeof window > "u") throw Error("OAuth redirect requires a browser environment or a provider with getAuthorizationCode()");
1072
984
  if (e.useRedirectFlow) return;
1073
985
  let n = e.getKey?.("tokens");
@@ -1076,7 +988,7 @@ async function G(e, t) {
1076
988
  if (i) try {
1077
989
  r = new URL(i).searchParams.get("state");
1078
990
  } catch {}
1079
- let a = await Ee({
991
+ let a = await he({
1080
992
  popup: null,
1081
993
  state: r,
1082
994
  tokensKey: n,
@@ -1090,21 +1002,21 @@ async function G(e, t) {
1090
1002
  default: throw Error("Unexpected OAuth popup result");
1091
1003
  }
1092
1004
  }
1093
- var Oe = "http://json-schema.org/draft-04/schema", ke = /* @__PURE__ */ new Set(["http://json-schema.org/draft-07/schema", "https://json-schema.org/draft-07/schema"]), Ae = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]), je = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
1094
- function Me(e) {
1005
+ var ve = "http://json-schema.org/draft-04/schema", ye = /* @__PURE__ */ new Set(["http://json-schema.org/draft-07/schema", "https://json-schema.org/draft-07/schema"]), be = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2019-09/schema", "http://json-schema.org/draft/2019-09/schema"]), xe = /* @__PURE__ */ new Set(["https://json-schema.org/draft/2020-12/schema", "http://json-schema.org/draft/2020-12/schema"]);
1006
+ function Se(e) {
1095
1007
  if (!("$schema" in e) || typeof e.$schema != "string") return "2020-12";
1096
1008
  let t = e.$schema.replace(/#$/, "");
1097
- if (t === Oe) return "4";
1098
- if (ke.has(t)) return "7";
1099
- if (Ae.has(t)) return "2019-09";
1100
- if (je.has(t)) return "2020-12";
1009
+ if (t === ve) return "4";
1010
+ if (ye.has(t)) return "7";
1011
+ if (be.has(t)) return "2019-09";
1012
+ if (xe.has(t)) return "2020-12";
1101
1013
  }
1102
1014
  var K = class {
1103
1015
  getValidator(e) {
1104
- let t = Me(e);
1016
+ let t = Se(e);
1105
1017
  return (t === void 0 ? new o() : new o({ draft: t })).getValidator(e);
1106
1018
  }
1107
- }, Ne = { "~standard": {
1019
+ }, Ce = { "~standard": {
1108
1020
  version: 1,
1109
1021
  vendor: "mcp-use",
1110
1022
  validate: (e) => ({ value: e })
@@ -1370,7 +1282,7 @@ var K = class {
1370
1282
  return b.debug(`Sending raw request '${e}' with params`, t), await this.client.request({
1371
1283
  method: e,
1372
1284
  params: t ?? {}
1373
- }, Ne, n);
1285
+ }, Ce, n);
1374
1286
  }
1375
1287
  async cleanupResources() {
1376
1288
  let e = [];
@@ -1403,7 +1315,7 @@ function J(e, t = 0) {
1403
1315
  }
1404
1316
  return !1;
1405
1317
  }
1406
- function Pe(e, t, n, r) {
1318
+ function we(e, t, n, r) {
1407
1319
  let i = new URL(e), a = t.replace(/\/$/, "");
1408
1320
  return async (e, t) => {
1409
1321
  let o = new Request(e, t), s = new URL(o.url);
@@ -1437,7 +1349,7 @@ var Y = class extends q {
1437
1349
  let n = e.replace(/\/$/, "");
1438
1350
  this.baseUrl = n, this.headers = { ...t.headers ?? {} }, this.gatewayUrl = t.gatewayUrl, this.serverId = t.serverId, t.authToken && (this.headers.Authorization = `Bearer ${t.authToken}`), this.timeout = t.timeout ?? 1e4;
1439
1351
  let r = t.fetch ?? globalThis.fetch.bind(globalThis);
1440
- this.customFetch = this.gatewayUrl ? Pe(n, this.gatewayUrl, r, this.serverId) : t.fetch, this.clientInfo = t.clientInfo ?? {
1352
+ this.customFetch = this.gatewayUrl ? we(n, this.gatewayUrl, r, this.serverId) : t.fetch, this.clientInfo = t.clientInfo ?? {
1441
1353
  name: "http-connector",
1442
1354
  version: "1.0.0"
1443
1355
  }, this.protocolNegotiation = t.protocolNegotiation ?? "auto", this.reconnectionOptions = t.reconnectionOptions;
@@ -1665,7 +1577,7 @@ function Z(e) {
1665
1577
  }
1666
1578
  return !0;
1667
1579
  }
1668
- function Fe() {
1580
+ function Te() {
1669
1581
  return {
1670
1582
  name: "mcp-use",
1671
1583
  title: "mcp-use",
@@ -1676,7 +1588,7 @@ function Fe() {
1676
1588
  };
1677
1589
  }
1678
1590
  function Q(e) {
1679
- let t = Fe();
1591
+ let t = Te();
1680
1592
  if (!e || typeof e != "object") return t;
1681
1593
  let n = e;
1682
1594
  return !n.name || !n.version ? t : {
@@ -1779,10 +1691,10 @@ var $ = class {
1779
1691
  return this.connector.request(e, t, n);
1780
1692
  }
1781
1693
  };
1782
- function Ie(e) {
1694
+ function Ee(e) {
1783
1695
  return !!e && typeof e == "object" && "redirectUrl" in e && "clientMetadata" in e;
1784
1696
  }
1785
- var Le = class {
1697
+ var De = class {
1786
1698
  config = {};
1787
1699
  sessions = {};
1788
1700
  activeSessions = [];
@@ -1817,7 +1729,7 @@ var Le = class {
1817
1729
  ...r,
1818
1730
  authProvider: i
1819
1731
  };
1820
- } else "authProvider" in r && r.authProvider && Ie(r.authProvider) && (i = r.authProvider);
1732
+ } else "authProvider" in r && r.authProvider && Ee(r.authProvider) && (i = r.authProvider);
1821
1733
  let a = async () => {
1822
1734
  let e = new $(await Promise.resolve(this.createConnectorFromConfig(r)));
1823
1735
  return t && await e.initialize(), e;
@@ -1826,8 +1738,8 @@ var Le = class {
1826
1738
  o = await a();
1827
1739
  } catch (n) {
1828
1740
  let s = r;
1829
- if (!t || !i || !("url" in s) || !U(n) || i.preventAutoAuth) throw n;
1830
- b.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await W(i, s.url), o = await a();
1741
+ if (!t || !i || !("url" in s) || !W(n) || i.preventAutoAuth) throw n;
1742
+ b.info(`[MCPClient] Unauthorized connecting to '${e}'; completing OAuth\u2026`), await G(i, s.url), o = await a();
1831
1743
  }
1832
1744
  return this.sessions[e] = o, this.activeSessions.includes(e) || this.activeSessions.push(e), o;
1833
1745
  }
@@ -1882,9 +1794,9 @@ var Le = class {
1882
1794
  await this.closeAllSessions();
1883
1795
  }
1884
1796
  };
1885
- function Re(e) {
1797
+ function Oe(e) {
1886
1798
  let t = Object.keys(e.mcpServers ?? {});
1887
- L.getInstance().trackMCPClientInit({
1799
+ N.getInstance().trackMCPClientInit({
1888
1800
  codeMode: !1,
1889
1801
  sandbox: !1,
1890
1802
  allCallbacks: !1,
@@ -1894,12 +1806,12 @@ function Re(e) {
1894
1806
  isBrowser: !0
1895
1807
  }).catch((e) => b.debug(`Failed to track BrowserMCPClient init: ${e}`));
1896
1808
  }
1897
- var ze = class e extends Le {
1809
+ var ke = class e extends De {
1898
1810
  static getPackageVersion() {
1899
1811
  return S();
1900
1812
  }
1901
1813
  constructor(e) {
1902
- super(e), Re(this.config);
1814
+ super(e), Oe(this.config);
1903
1815
  }
1904
1816
  static fromDict(t) {
1905
1817
  return new e(t);
@@ -1931,4 +1843,4 @@ var ze = class e extends Le {
1931
1843
  }
1932
1844
  };
1933
1845
  //#endregion
1934
- export { b as a, l as i, L as n, R as o, k as r, T as t };
1846
+ export { P as i, l as n, b as r, N as t };