@modelcontextprotocol/inspector-client 0.3.0 → 0.4.1

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.
@@ -7346,6 +7346,70 @@ function Q(t2) {
7346
7346
  }));
7347
7347
  }));
7348
7348
  }
7349
+ const scriptRel = "modulepreload";
7350
+ const assetsURL = function(dep) {
7351
+ return "/" + dep;
7352
+ };
7353
+ const seen = {};
7354
+ const __vitePreload = function preload(baseModule, deps, importerUrl) {
7355
+ let promise = Promise.resolve();
7356
+ if (deps && deps.length > 0) {
7357
+ document.getElementsByTagName("link");
7358
+ const cspNonceMeta = document.querySelector(
7359
+ "meta[property=csp-nonce]"
7360
+ );
7361
+ const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
7362
+ promise = Promise.allSettled(
7363
+ deps.map((dep) => {
7364
+ dep = assetsURL(dep);
7365
+ if (dep in seen) return;
7366
+ seen[dep] = true;
7367
+ const isCss = dep.endsWith(".css");
7368
+ const cssSelector = isCss ? '[rel="stylesheet"]' : "";
7369
+ if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
7370
+ return;
7371
+ }
7372
+ const link = document.createElement("link");
7373
+ link.rel = isCss ? "stylesheet" : scriptRel;
7374
+ if (!isCss) {
7375
+ link.as = "script";
7376
+ }
7377
+ link.crossOrigin = "";
7378
+ link.href = dep;
7379
+ if (cspNonce) {
7380
+ link.setAttribute("nonce", cspNonce);
7381
+ }
7382
+ document.head.appendChild(link);
7383
+ if (isCss) {
7384
+ return new Promise((res, rej) => {
7385
+ link.addEventListener("load", res);
7386
+ link.addEventListener(
7387
+ "error",
7388
+ () => rej(new Error(`Unable to preload CSS for ${dep}`))
7389
+ );
7390
+ });
7391
+ }
7392
+ })
7393
+ );
7394
+ }
7395
+ function handlePreloadError(err) {
7396
+ const e = new Event("vite:preloadError", {
7397
+ cancelable: true
7398
+ });
7399
+ e.payload = err;
7400
+ window.dispatchEvent(e);
7401
+ if (!e.defaultPrevented) {
7402
+ throw err;
7403
+ }
7404
+ }
7405
+ return promise.then((res) => {
7406
+ for (const item of res || []) {
7407
+ if (item.status !== "rejected") continue;
7408
+ handlePreloadError(item.reason);
7409
+ }
7410
+ return baseModule().catch(handlePreloadError);
7411
+ });
7412
+ };
7349
7413
  var util;
7350
7414
  (function(util2) {
7351
7415
  util2.assertEqual = (val) => val;
@@ -7500,6 +7564,9 @@ const quotelessJson = (obj) => {
7500
7564
  return json.replace(/"([^"]+)":/g, "$1:");
7501
7565
  };
7502
7566
  class ZodError extends Error {
7567
+ get errors() {
7568
+ return this.issues;
7569
+ }
7503
7570
  constructor(issues) {
7504
7571
  super();
7505
7572
  this.issues = [];
@@ -7518,9 +7585,6 @@ class ZodError extends Error {
7518
7585
  this.name = "ZodError";
7519
7586
  this.issues = issues;
7520
7587
  }
7521
- get errors() {
7522
- return this.issues;
7523
- }
7524
7588
  format(_mapper) {
7525
7589
  const mapper = _mapper || function(issue) {
7526
7590
  return issue.message;
@@ -7731,8 +7795,11 @@ function addIssueToContext(ctx, issueData) {
7731
7795
  path: ctx.path,
7732
7796
  errorMaps: [
7733
7797
  ctx.common.contextualErrorMap,
7798
+ // contextual error map is first priority
7734
7799
  ctx.schemaErrorMap,
7800
+ // then schema-bound map if available
7735
7801
  overrideMap,
7802
+ // then global override map
7736
7803
  overrideMap === errorMap ? void 0 : errorMap
7737
7804
  // then global default map
7738
7805
  ].filter((x2) => !!x2)
@@ -7803,11 +7870,11 @@ const isDirty = (x2) => x2.status === "dirty";
7803
7870
  const isValid = (x2) => x2.status === "valid";
7804
7871
  const isAsync = (x2) => typeof Promise !== "undefined" && x2 instanceof Promise;
7805
7872
  function __classPrivateFieldGet(receiver, state, kind, f2) {
7806
- if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
7873
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
7807
7874
  return state.get(receiver);
7808
7875
  }
7809
7876
  function __classPrivateFieldSet(receiver, state, value, kind, f2) {
7810
- if (typeof state === "function" ? receiver !== state || !f2 : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7877
+ if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7811
7878
  return state.set(receiver, value), value;
7812
7879
  }
7813
7880
  typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
@@ -7883,34 +7950,6 @@ function processCreateParams(params2) {
7883
7950
  return { errorMap: customMap, description };
7884
7951
  }
7885
7952
  class ZodType {
7886
- constructor(def) {
7887
- this.spa = this.safeParseAsync;
7888
- this._def = def;
7889
- this.parse = this.parse.bind(this);
7890
- this.safeParse = this.safeParse.bind(this);
7891
- this.parseAsync = this.parseAsync.bind(this);
7892
- this.safeParseAsync = this.safeParseAsync.bind(this);
7893
- this.spa = this.spa.bind(this);
7894
- this.refine = this.refine.bind(this);
7895
- this.refinement = this.refinement.bind(this);
7896
- this.superRefine = this.superRefine.bind(this);
7897
- this.optional = this.optional.bind(this);
7898
- this.nullable = this.nullable.bind(this);
7899
- this.nullish = this.nullish.bind(this);
7900
- this.array = this.array.bind(this);
7901
- this.promise = this.promise.bind(this);
7902
- this.or = this.or.bind(this);
7903
- this.and = this.and.bind(this);
7904
- this.transform = this.transform.bind(this);
7905
- this.brand = this.brand.bind(this);
7906
- this.default = this.default.bind(this);
7907
- this.catch = this.catch.bind(this);
7908
- this.describe = this.describe.bind(this);
7909
- this.pipe = this.pipe.bind(this);
7910
- this.readonly = this.readonly.bind(this);
7911
- this.isNullable = this.isNullable.bind(this);
7912
- this.isOptional = this.isOptional.bind(this);
7913
- }
7914
7953
  get description() {
7915
7954
  return this._def.description;
7916
7955
  }
@@ -7974,6 +8013,43 @@ class ZodType {
7974
8013
  const result = this._parseSync({ data, path: ctx.path, parent: ctx });
7975
8014
  return handleResult(ctx, result);
7976
8015
  }
8016
+ "~validate"(data) {
8017
+ var _a, _b;
8018
+ const ctx = {
8019
+ common: {
8020
+ issues: [],
8021
+ async: !!this["~standard"].async
8022
+ },
8023
+ path: [],
8024
+ schemaErrorMap: this._def.errorMap,
8025
+ parent: null,
8026
+ data,
8027
+ parsedType: getParsedType(data)
8028
+ };
8029
+ if (!this["~standard"].async) {
8030
+ try {
8031
+ const result = this._parseSync({ data, path: [], parent: ctx });
8032
+ return isValid(result) ? {
8033
+ value: result.value
8034
+ } : {
8035
+ issues: ctx.common.issues
8036
+ };
8037
+ } catch (err) {
8038
+ if ((_b = (_a = err === null || err === void 0 ? void 0 : err.message) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === null || _b === void 0 ? void 0 : _b.includes("encountered")) {
8039
+ this["~standard"].async = true;
8040
+ }
8041
+ ctx.common = {
8042
+ issues: [],
8043
+ async: true
8044
+ };
8045
+ }
8046
+ }
8047
+ return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
8048
+ value: result.value
8049
+ } : {
8050
+ issues: ctx.common.issues
8051
+ });
8052
+ }
7977
8053
  async parseAsync(data, params2) {
7978
8054
  const result = await this.safeParseAsync(data, params2);
7979
8055
  if (result.success)
@@ -8051,6 +8127,39 @@ class ZodType {
8051
8127
  superRefine(refinement) {
8052
8128
  return this._refinement(refinement);
8053
8129
  }
8130
+ constructor(def) {
8131
+ this.spa = this.safeParseAsync;
8132
+ this._def = def;
8133
+ this.parse = this.parse.bind(this);
8134
+ this.safeParse = this.safeParse.bind(this);
8135
+ this.parseAsync = this.parseAsync.bind(this);
8136
+ this.safeParseAsync = this.safeParseAsync.bind(this);
8137
+ this.spa = this.spa.bind(this);
8138
+ this.refine = this.refine.bind(this);
8139
+ this.refinement = this.refinement.bind(this);
8140
+ this.superRefine = this.superRefine.bind(this);
8141
+ this.optional = this.optional.bind(this);
8142
+ this.nullable = this.nullable.bind(this);
8143
+ this.nullish = this.nullish.bind(this);
8144
+ this.array = this.array.bind(this);
8145
+ this.promise = this.promise.bind(this);
8146
+ this.or = this.or.bind(this);
8147
+ this.and = this.and.bind(this);
8148
+ this.transform = this.transform.bind(this);
8149
+ this.brand = this.brand.bind(this);
8150
+ this.default = this.default.bind(this);
8151
+ this.catch = this.catch.bind(this);
8152
+ this.describe = this.describe.bind(this);
8153
+ this.pipe = this.pipe.bind(this);
8154
+ this.readonly = this.readonly.bind(this);
8155
+ this.isNullable = this.isNullable.bind(this);
8156
+ this.isOptional = this.isOptional.bind(this);
8157
+ this["~standard"] = {
8158
+ version: 1,
8159
+ vendor: "zod",
8160
+ validate: (data) => this["~validate"](data)
8161
+ };
8162
+ }
8054
8163
  optional() {
8055
8164
  return ZodOptional.create(this, this._def);
8056
8165
  }
@@ -8061,7 +8170,7 @@ class ZodType {
8061
8170
  return this.nullable().optional();
8062
8171
  }
8063
8172
  array() {
8064
- return ZodArray.create(this, this._def);
8173
+ return ZodArray.create(this);
8065
8174
  }
8066
8175
  promise() {
8067
8176
  return ZodPromise.create(this, this._def);
@@ -8127,16 +8236,20 @@ class ZodType {
8127
8236
  }
8128
8237
  const cuidRegex = /^c[^\s-]{8,}$/i;
8129
8238
  const cuid2Regex = /^[0-9a-z]+$/;
8130
- const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
8239
+ const ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
8131
8240
  const uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
8132
8241
  const nanoidRegex = /^[a-z0-9_-]{21}$/i;
8242
+ const jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
8133
8243
  const durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
8134
8244
  const emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
8135
8245
  const _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
8136
8246
  let emojiRegex;
8137
8247
  const ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
8138
- const ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
8248
+ const ipv4CidrRegex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/;
8249
+ const ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
8250
+ const ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
8139
8251
  const base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
8252
+ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
8140
8253
  const dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
8141
8254
  const dateRegex = new RegExp(`^${dateRegexSource}$`);
8142
8255
  function timeRegexSource(args) {
@@ -8169,6 +8282,33 @@ function isValidIP(ip, version2) {
8169
8282
  }
8170
8283
  return false;
8171
8284
  }
8285
+ function isValidJWT(jwt, alg) {
8286
+ if (!jwtRegex.test(jwt))
8287
+ return false;
8288
+ try {
8289
+ const [header] = jwt.split(".");
8290
+ const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
8291
+ const decoded = JSON.parse(atob(base64));
8292
+ if (typeof decoded !== "object" || decoded === null)
8293
+ return false;
8294
+ if (!decoded.typ || !decoded.alg)
8295
+ return false;
8296
+ if (alg && decoded.alg !== alg)
8297
+ return false;
8298
+ return true;
8299
+ } catch (_a) {
8300
+ return false;
8301
+ }
8302
+ }
8303
+ function isValidCidr(ip, version2) {
8304
+ if ((version2 === "v4" || !version2) && ipv4CidrRegex.test(ip)) {
8305
+ return true;
8306
+ }
8307
+ if ((version2 === "v6" || !version2) && ipv6CidrRegex.test(ip)) {
8308
+ return true;
8309
+ }
8310
+ return false;
8311
+ }
8172
8312
  class ZodString extends ZodType {
8173
8313
  _parse(input) {
8174
8314
  if (this._def.coerce) {
@@ -8425,6 +8565,26 @@ class ZodString extends ZodType {
8425
8565
  });
8426
8566
  status.dirty();
8427
8567
  }
8568
+ } else if (check.kind === "jwt") {
8569
+ if (!isValidJWT(input.data, check.alg)) {
8570
+ ctx = this._getOrReturnCtx(input, ctx);
8571
+ addIssueToContext(ctx, {
8572
+ validation: "jwt",
8573
+ code: ZodIssueCode.invalid_string,
8574
+ message: check.message
8575
+ });
8576
+ status.dirty();
8577
+ }
8578
+ } else if (check.kind === "cidr") {
8579
+ if (!isValidCidr(input.data, check.version)) {
8580
+ ctx = this._getOrReturnCtx(input, ctx);
8581
+ addIssueToContext(ctx, {
8582
+ validation: "cidr",
8583
+ code: ZodIssueCode.invalid_string,
8584
+ message: check.message
8585
+ });
8586
+ status.dirty();
8587
+ }
8428
8588
  } else if (check.kind === "base64") {
8429
8589
  if (!base64Regex.test(input.data)) {
8430
8590
  ctx = this._getOrReturnCtx(input, ctx);
@@ -8435,6 +8595,16 @@ class ZodString extends ZodType {
8435
8595
  });
8436
8596
  status.dirty();
8437
8597
  }
8598
+ } else if (check.kind === "base64url") {
8599
+ if (!base64urlRegex.test(input.data)) {
8600
+ ctx = this._getOrReturnCtx(input, ctx);
8601
+ addIssueToContext(ctx, {
8602
+ validation: "base64url",
8603
+ code: ZodIssueCode.invalid_string,
8604
+ message: check.message
8605
+ });
8606
+ status.dirty();
8607
+ }
8438
8608
  } else {
8439
8609
  util.assertNever(check);
8440
8610
  }
@@ -8481,9 +8651,21 @@ class ZodString extends ZodType {
8481
8651
  base64(message) {
8482
8652
  return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
8483
8653
  }
8654
+ base64url(message) {
8655
+ return this._addCheck({
8656
+ kind: "base64url",
8657
+ ...errorUtil.errToObj(message)
8658
+ });
8659
+ }
8660
+ jwt(options) {
8661
+ return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
8662
+ }
8484
8663
  ip(options) {
8485
8664
  return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
8486
8665
  }
8666
+ cidr(options) {
8667
+ return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
8668
+ }
8487
8669
  datetime(options) {
8488
8670
  var _a, _b;
8489
8671
  if (typeof options === "string") {
@@ -8574,8 +8756,7 @@ class ZodString extends ZodType {
8574
8756
  });
8575
8757
  }
8576
8758
  /**
8577
- * @deprecated Use z.string().min(1) instead.
8578
- * @see {@link ZodString.min}
8759
+ * Equivalent to `.min(1)`
8579
8760
  */
8580
8761
  nonempty(message) {
8581
8762
  return this.min(1, errorUtil.errToObj(message));
@@ -8637,9 +8818,15 @@ class ZodString extends ZodType {
8637
8818
  get isIP() {
8638
8819
  return !!this._def.checks.find((ch2) => ch2.kind === "ip");
8639
8820
  }
8821
+ get isCIDR() {
8822
+ return !!this._def.checks.find((ch2) => ch2.kind === "cidr");
8823
+ }
8640
8824
  get isBase64() {
8641
8825
  return !!this._def.checks.find((ch2) => ch2.kind === "base64");
8642
8826
  }
8827
+ get isBase64url() {
8828
+ return !!this._def.checks.find((ch2) => ch2.kind === "base64url");
8829
+ }
8643
8830
  get minLength() {
8644
8831
  let min2 = null;
8645
8832
  for (const ch2 of this._def.checks) {
@@ -8917,17 +9104,15 @@ class ZodBigInt extends ZodType {
8917
9104
  }
8918
9105
  _parse(input) {
8919
9106
  if (this._def.coerce) {
8920
- input.data = BigInt(input.data);
9107
+ try {
9108
+ input.data = BigInt(input.data);
9109
+ } catch (_a) {
9110
+ return this._getInvalidInput(input);
9111
+ }
8921
9112
  }
8922
9113
  const parsedType = this._getType(input);
8923
9114
  if (parsedType !== ZodParsedType.bigint) {
8924
- const ctx2 = this._getOrReturnCtx(input);
8925
- addIssueToContext(ctx2, {
8926
- code: ZodIssueCode.invalid_type,
8927
- expected: ZodParsedType.bigint,
8928
- received: ctx2.parsedType
8929
- });
8930
- return INVALID;
9115
+ return this._getInvalidInput(input);
8931
9116
  }
8932
9117
  let ctx = void 0;
8933
9118
  const status = new ParseStatus();
@@ -8974,6 +9159,15 @@ class ZodBigInt extends ZodType {
8974
9159
  }
8975
9160
  return { status: status.value, value: input.data };
8976
9161
  }
9162
+ _getInvalidInput(input) {
9163
+ const ctx = this._getOrReturnCtx(input);
9164
+ addIssueToContext(ctx, {
9165
+ code: ZodIssueCode.invalid_type,
9166
+ expected: ZodParsedType.bigint,
9167
+ received: ctx.parsedType
9168
+ });
9169
+ return INVALID;
9170
+ }
8977
9171
  gte(value, message) {
8978
9172
  return this.setLimit("min", value, true, errorUtil.toString(message));
8979
9173
  }
@@ -11036,16 +11230,32 @@ ZodReadonly.create = (type, params2) => {
11036
11230
  ...processCreateParams(params2)
11037
11231
  });
11038
11232
  };
11039
- function custom(check, params2 = {}, fatal) {
11233
+ function cleanParams(params2, data) {
11234
+ const p2 = typeof params2 === "function" ? params2(data) : typeof params2 === "string" ? { message: params2 } : params2;
11235
+ const p22 = typeof p2 === "string" ? { message: p2 } : p2;
11236
+ return p22;
11237
+ }
11238
+ function custom(check, _params = {}, fatal) {
11040
11239
  if (check)
11041
11240
  return ZodAny.create().superRefine((data, ctx) => {
11042
11241
  var _a, _b;
11043
- if (!check(data)) {
11044
- const p2 = typeof params2 === "function" ? params2(data) : typeof params2 === "string" ? { message: params2 } : params2;
11045
- const _fatal = (_b = (_a = p2.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
11046
- const p22 = typeof p2 === "string" ? { message: p2 } : p2;
11047
- ctx.addIssue({ code: "custom", ...p22, fatal: _fatal });
11242
+ const r2 = check(data);
11243
+ if (r2 instanceof Promise) {
11244
+ return r2.then((r3) => {
11245
+ var _a2, _b2;
11246
+ if (!r3) {
11247
+ const params2 = cleanParams(_params, data);
11248
+ const _fatal = (_b2 = (_a2 = params2.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
11249
+ ctx.addIssue({ code: "custom", ...params2, fatal: _fatal });
11250
+ }
11251
+ });
11048
11252
  }
11253
+ if (!r2) {
11254
+ const params2 = cleanParams(_params, data);
11255
+ const _fatal = (_b = (_a = params2.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
11256
+ ctx.addIssue({ code: "custom", ...params2, fatal: _fatal });
11257
+ }
11258
+ return;
11049
11259
  });
11050
11260
  return ZodAny.create();
11051
11261
  }
@@ -11309,8 +11519,8 @@ const JSONRPCResponseSchema = z.object({
11309
11519
  }).strict();
11310
11520
  var ErrorCode;
11311
11521
  (function(ErrorCode2) {
11312
- ErrorCode2[ErrorCode2["ConnectionClosed"] = -1] = "ConnectionClosed";
11313
- ErrorCode2[ErrorCode2["RequestTimeout"] = -2] = "RequestTimeout";
11522
+ ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
11523
+ ErrorCode2[ErrorCode2["RequestTimeout"] = -32001] = "RequestTimeout";
11314
11524
  ErrorCode2[ErrorCode2["ParseError"] = -32700] = "ParseError";
11315
11525
  ErrorCode2[ErrorCode2["InvalidRequest"] = -32600] = "InvalidRequest";
11316
11526
  ErrorCode2[ErrorCode2["MethodNotFound"] = -32601] = "MethodNotFound";
@@ -11438,7 +11648,13 @@ const InitializeResultSchema = ResultSchema.extend({
11438
11648
  */
11439
11649
  protocolVersion: z.string(),
11440
11650
  capabilities: ServerCapabilitiesSchema,
11441
- serverInfo: ImplementationSchema
11651
+ serverInfo: ImplementationSchema,
11652
+ /**
11653
+ * Instructions describing how to use the server and its features.
11654
+ *
11655
+ * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.
11656
+ */
11657
+ instructions: z.optional(z.string())
11442
11658
  });
11443
11659
  const InitializedNotificationSchema = NotificationSchema.extend({
11444
11660
  method: z.literal("notifications/initialized")
@@ -12077,13 +12293,13 @@ class Protocol {
12077
12293
  });
12078
12294
  }
12079
12295
  _onprogress(notification) {
12080
- const { progress, total, progressToken } = notification.params;
12296
+ const { progressToken, ...params2 } = notification.params;
12081
12297
  const handler = this._progressHandlers.get(Number(progressToken));
12082
12298
  if (handler === void 0) {
12083
12299
  this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(notification)}`));
12084
12300
  return;
12085
12301
  }
12086
- handler({ progress, total });
12302
+ handler(params2);
12087
12303
  }
12088
12304
  _onresponse(response) {
12089
12305
  const messageId = response.id;
@@ -12222,6 +12438,14 @@ class Protocol {
12222
12438
  removeRequestHandler(method) {
12223
12439
  this._requestHandlers.delete(method);
12224
12440
  }
12441
+ /**
12442
+ * Asserts that a request handler has not already been set for the given method, in preparation for a new one being automatically installed.
12443
+ */
12444
+ assertCanSetRequestHandler(method) {
12445
+ if (this._requestHandlers.has(method)) {
12446
+ throw new Error(`A request handler for ${method} already exists, which would be overridden`);
12447
+ }
12448
+ }
12225
12449
  /**
12226
12450
  * Registers a handler to invoke when this protocol object receives a notification with the given method.
12227
12451
  *
@@ -12237,14 +12461,36 @@ class Protocol {
12237
12461
  this._notificationHandlers.delete(method);
12238
12462
  }
12239
12463
  }
12464
+ function mergeCapabilities(base, additional) {
12465
+ return Object.entries(additional).reduce((acc, [key, value]) => {
12466
+ if (value && typeof value === "object") {
12467
+ acc[key] = acc[key] ? { ...acc[key], ...value } : value;
12468
+ } else {
12469
+ acc[key] = value;
12470
+ }
12471
+ return acc;
12472
+ }, { ...base });
12473
+ }
12240
12474
  class Client extends Protocol {
12241
12475
  /**
12242
12476
  * Initializes this client with the given name and version information.
12243
12477
  */
12244
12478
  constructor(_clientInfo, options) {
12479
+ var _a;
12245
12480
  super(options);
12246
12481
  this._clientInfo = _clientInfo;
12247
- this._capabilities = options.capabilities;
12482
+ this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
12483
+ }
12484
+ /**
12485
+ * Registers new capabilities. This can only be called before connecting to a transport.
12486
+ *
12487
+ * The new capabilities will be merged with any existing capabilities previously given (e.g., at initialization).
12488
+ */
12489
+ registerCapabilities(capabilities) {
12490
+ if (this.transport) {
12491
+ throw new Error("Cannot register capabilities after connecting to transport");
12492
+ }
12493
+ this._capabilities = mergeCapabilities(this._capabilities, capabilities);
12248
12494
  }
12249
12495
  assertCapability(capability, method) {
12250
12496
  var _a;
@@ -12271,6 +12517,7 @@ class Client extends Protocol {
12271
12517
  }
12272
12518
  this._serverCapabilities = result.capabilities;
12273
12519
  this._serverVersion = result.serverInfo;
12520
+ this._instructions = result.instructions;
12274
12521
  await this.notification({
12275
12522
  method: "notifications/initialized"
12276
12523
  });
@@ -12291,6 +12538,12 @@ class Client extends Protocol {
12291
12538
  getServerVersion() {
12292
12539
  return this._serverVersion;
12293
12540
  }
12541
+ /**
12542
+ * After initialization has completed, this may be populated with information about the server's instructions.
12543
+ */
12544
+ getInstructions() {
12545
+ return this._instructions;
12546
+ }
12294
12547
  assertCapabilityForMethod(method) {
12295
12548
  var _a, _b, _c, _d, _e;
12296
12549
  switch (method) {
@@ -12394,87 +12647,591 @@ class Client extends Protocol {
12394
12647
  return this.notification({ method: "notifications/roots/list_changed" });
12395
12648
  }
12396
12649
  }
12397
- class SSEClientTransport {
12398
- constructor(url) {
12399
- this._url = url;
12400
- }
12401
- start() {
12402
- if (this._eventSource) {
12403
- throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
12404
- }
12405
- return new Promise((resolve, reject) => {
12406
- this._eventSource = new EventSource(this._url.href);
12407
- this._abortController = new AbortController();
12408
- this._eventSource.onerror = (event) => {
12409
- var _a;
12410
- const error = new Error(`SSE error: ${JSON.stringify(event)}`);
12411
- reject(error);
12412
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
12413
- };
12414
- this._eventSource.onopen = () => {
12415
- };
12416
- this._eventSource.addEventListener("endpoint", (event) => {
12417
- var _a;
12418
- const messageEvent = event;
12419
- try {
12420
- this._endpoint = new URL(messageEvent.data, this._url);
12421
- if (this._endpoint.origin !== this._url.origin) {
12422
- throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
12423
- }
12424
- } catch (error) {
12425
- reject(error);
12426
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
12427
- void this.close();
12428
- return;
12429
- }
12430
- resolve();
12431
- });
12432
- this._eventSource.onmessage = (event) => {
12433
- var _a, _b;
12434
- const messageEvent = event;
12435
- let message;
12436
- try {
12437
- message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
12438
- } catch (error) {
12439
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
12440
- return;
12441
- }
12442
- (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, message);
12443
- };
12444
- });
12650
+ var __defProp = Object.defineProperty, __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value, __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
12651
+ class ParseError extends Error {
12652
+ constructor(message, options) {
12653
+ super(message), __publicField(this, "type"), __publicField(this, "field"), __publicField(this, "value"), __publicField(this, "line"), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
12445
12654
  }
12446
- async close() {
12447
- var _a, _b, _c;
12448
- (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();
12449
- (_b = this._eventSource) === null || _b === void 0 ? void 0 : _b.close();
12450
- (_c = this.onclose) === null || _c === void 0 ? void 0 : _c.call(this);
12655
+ }
12656
+ function noop(_arg) {
12657
+ }
12658
+ function createParser(callbacks) {
12659
+ const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
12660
+ let incompleteLine = "", isFirstChunk = true, id2, data = "", eventType = "";
12661
+ function feed(newChunk) {
12662
+ const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
12663
+ for (const line of complete)
12664
+ parseLine(line);
12665
+ incompleteLine = incomplete, isFirstChunk = false;
12451
12666
  }
12452
- async send(message) {
12453
- var _a, _b;
12454
- if (!this._endpoint) {
12455
- throw new Error("Not connected");
12667
+ function parseLine(line) {
12668
+ if (line === "") {
12669
+ dispatchEvent();
12670
+ return;
12456
12671
  }
12457
- try {
12458
- const response = await fetch(this._endpoint, {
12459
- method: "POST",
12460
- headers: {
12461
- "Content-Type": "application/json"
12462
- },
12463
- body: JSON.stringify(message),
12464
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
12465
- });
12466
- if (!response.ok) {
12467
- const text = await response.text().catch(() => null);
12468
- throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
12469
- }
12470
- } catch (error) {
12471
- (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);
12472
- throw error;
12672
+ if (line.startsWith(":")) {
12673
+ onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
12674
+ return;
12675
+ }
12676
+ const fieldSeparatorIndex = line.indexOf(":");
12677
+ if (fieldSeparatorIndex !== -1) {
12678
+ const field = line.slice(0, fieldSeparatorIndex), offset2 = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset2);
12679
+ processField(field, value, line);
12680
+ return;
12473
12681
  }
12682
+ processField(line, "", line);
12474
12683
  }
12475
- }
12476
- const StdErrNotificationSchema = NotificationSchema.extend({
12477
- method: z.literal("notifications/stderr"),
12684
+ function processField(field, value, line) {
12685
+ switch (field) {
12686
+ case "event":
12687
+ eventType = value;
12688
+ break;
12689
+ case "data":
12690
+ data = `${data}${value}
12691
+ `;
12692
+ break;
12693
+ case "id":
12694
+ id2 = value.includes("\0") ? void 0 : value;
12695
+ break;
12696
+ case "retry":
12697
+ /^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
12698
+ new ParseError(`Invalid \`retry\` value: "${value}"`, {
12699
+ type: "invalid-retry",
12700
+ value,
12701
+ line
12702
+ })
12703
+ );
12704
+ break;
12705
+ default:
12706
+ onError(
12707
+ new ParseError(
12708
+ `Unknown field "${field.length > 20 ? `${field.slice(0, 20)}…` : field}"`,
12709
+ { type: "unknown-field", field, value, line }
12710
+ )
12711
+ );
12712
+ break;
12713
+ }
12714
+ }
12715
+ function dispatchEvent() {
12716
+ data.length > 0 && onEvent({
12717
+ id: id2,
12718
+ event: eventType || void 0,
12719
+ // If the data buffer's last character is a U+000A LINE FEED (LF) character,
12720
+ // then remove the last character from the data buffer.
12721
+ data: data.endsWith(`
12722
+ `) ? data.slice(0, -1) : data
12723
+ }), id2 = void 0, data = "", eventType = "";
12724
+ }
12725
+ function reset(options = {}) {
12726
+ incompleteLine && options.consume && parseLine(incompleteLine), id2 = void 0, data = "", eventType = "", incompleteLine = "";
12727
+ }
12728
+ return { feed, reset };
12729
+ }
12730
+ function splitLines(chunk) {
12731
+ const lines = [];
12732
+ let incompleteLine = "";
12733
+ const totalLength = chunk.length;
12734
+ for (let i = 0; i < totalLength; i++) {
12735
+ const char = chunk[i];
12736
+ char === "\r" && chunk[i + 1] === `
12737
+ ` ? (lines.push(incompleteLine), incompleteLine = "", i++) : char === "\r" || char === `
12738
+ ` ? (lines.push(incompleteLine), incompleteLine = "") : incompleteLine += char;
12739
+ }
12740
+ return [lines, incompleteLine];
12741
+ }
12742
+ class ErrorEvent extends Event {
12743
+ /**
12744
+ * Constructs a new `ErrorEvent` instance. This is typically not called directly,
12745
+ * but rather emitted by the `EventSource` object when an error occurs.
12746
+ *
12747
+ * @param type - The type of the event (should be "error")
12748
+ * @param errorEventInitDict - Optional properties to include in the error event
12749
+ */
12750
+ constructor(type, errorEventInitDict) {
12751
+ var _a, _b;
12752
+ super(type), this.code = (_a = errorEventInitDict == null ? void 0 : errorEventInitDict.code) != null ? _a : void 0, this.message = (_b = errorEventInitDict == null ? void 0 : errorEventInitDict.message) != null ? _b : void 0;
12753
+ }
12754
+ /**
12755
+ * Node.js "hides" the `message` and `code` properties of the `ErrorEvent` instance,
12756
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
12757
+ * we explicitly include the properties in the `inspect` method.
12758
+ *
12759
+ * This is automatically called by Node.js when you `console.log` an instance of this class.
12760
+ *
12761
+ * @param _depth - The current depth
12762
+ * @param options - The options passed to `util.inspect`
12763
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
12764
+ * @returns A string representation of the error
12765
+ */
12766
+ [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
12767
+ return inspect(inspectableError(this), options);
12768
+ }
12769
+ /**
12770
+ * Deno "hides" the `message` and `code` properties of the `ErrorEvent` instance,
12771
+ * when it is `console.log`'ed. This makes it harder to debug errors. To ease debugging,
12772
+ * we explicitly include the properties in the `inspect` method.
12773
+ *
12774
+ * This is automatically called by Deno when you `console.log` an instance of this class.
12775
+ *
12776
+ * @param inspect - The inspect function to use (prevents having to import it from `util`)
12777
+ * @param options - The options passed to `Deno.inspect`
12778
+ * @returns A string representation of the error
12779
+ */
12780
+ [Symbol.for("Deno.customInspect")](inspect, options) {
12781
+ return inspect(inspectableError(this), options);
12782
+ }
12783
+ }
12784
+ function syntaxError(message) {
12785
+ const DomException = globalThis.DOMException;
12786
+ return typeof DomException == "function" ? new DomException(message, "SyntaxError") : new SyntaxError(message);
12787
+ }
12788
+ function flattenError(err) {
12789
+ return err instanceof Error ? "errors" in err && Array.isArray(err.errors) ? err.errors.map(flattenError).join(", ") : "cause" in err && err.cause instanceof Error ? `${err}: ${flattenError(err.cause)}` : err.message : `${err}`;
12790
+ }
12791
+ function inspectableError(err) {
12792
+ return {
12793
+ type: err.type,
12794
+ message: err.message,
12795
+ code: err.code,
12796
+ defaultPrevented: err.defaultPrevented,
12797
+ cancelable: err.cancelable,
12798
+ timeStamp: err.timeStamp
12799
+ };
12800
+ }
12801
+ var __typeError = (msg) => {
12802
+ throw TypeError(msg);
12803
+ }, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value), __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method), _readyState, _url, _redirectUrl, _withCredentials, _fetch, _reconnectInterval, _reconnectTimer, _lastEventId, _controller, _parser, _onError, _onMessage, _onOpen, _EventSource_instances, connect_fn, _onFetchResponse, _onFetchError, getRequestOptions_fn, _onEvent, _onRetryChange, failConnection_fn, scheduleReconnect_fn, _reconnect;
12804
+ class EventSource extends EventTarget {
12805
+ constructor(url, eventSourceInitDict) {
12806
+ var _a, _b;
12807
+ super(), __privateAdd(this, _EventSource_instances), this.CONNECTING = 0, this.OPEN = 1, this.CLOSED = 2, __privateAdd(this, _readyState), __privateAdd(this, _url), __privateAdd(this, _redirectUrl), __privateAdd(this, _withCredentials), __privateAdd(this, _fetch), __privateAdd(this, _reconnectInterval), __privateAdd(this, _reconnectTimer), __privateAdd(this, _lastEventId, null), __privateAdd(this, _controller), __privateAdd(this, _parser), __privateAdd(this, _onError, null), __privateAdd(this, _onMessage, null), __privateAdd(this, _onOpen, null), __privateAdd(this, _onFetchResponse, async (response) => {
12808
+ var _a2;
12809
+ __privateGet(this, _parser).reset();
12810
+ const { body, redirected, status, headers } = response;
12811
+ if (status === 204) {
12812
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Server sent HTTP 204, not reconnecting", 204), this.close();
12813
+ return;
12814
+ }
12815
+ if (redirected ? __privateSet(this, _redirectUrl, new URL(response.url)) : __privateSet(this, _redirectUrl, void 0), status !== 200) {
12816
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, `Non-200 status code (${status})`, status);
12817
+ return;
12818
+ }
12819
+ if (!(headers.get("content-type") || "").startsWith("text/event-stream")) {
12820
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, 'Invalid content type, expected "text/event-stream"', status);
12821
+ return;
12822
+ }
12823
+ if (__privateGet(this, _readyState) === this.CLOSED)
12824
+ return;
12825
+ __privateSet(this, _readyState, this.OPEN);
12826
+ const openEvent = new Event("open");
12827
+ if ((_a2 = __privateGet(this, _onOpen)) == null || _a2.call(this, openEvent), this.dispatchEvent(openEvent), typeof body != "object" || !body || !("getReader" in body)) {
12828
+ __privateMethod(this, _EventSource_instances, failConnection_fn).call(this, "Invalid response body, expected a web ReadableStream", status), this.close();
12829
+ return;
12830
+ }
12831
+ const decoder = new TextDecoder(), reader = body.getReader();
12832
+ let open = true;
12833
+ do {
12834
+ const { done, value } = await reader.read();
12835
+ value && __privateGet(this, _parser).feed(decoder.decode(value, { stream: !done })), done && (open = false, __privateGet(this, _parser).reset(), __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this));
12836
+ } while (open);
12837
+ }), __privateAdd(this, _onFetchError, (err) => {
12838
+ __privateSet(this, _controller, void 0), !(err.name === "AbortError" || err.type === "aborted") && __privateMethod(this, _EventSource_instances, scheduleReconnect_fn).call(this, flattenError(err));
12839
+ }), __privateAdd(this, _onEvent, (event) => {
12840
+ typeof event.id == "string" && __privateSet(this, _lastEventId, event.id);
12841
+ const messageEvent = new MessageEvent(event.event || "message", {
12842
+ data: event.data,
12843
+ origin: __privateGet(this, _redirectUrl) ? __privateGet(this, _redirectUrl).origin : __privateGet(this, _url).origin,
12844
+ lastEventId: event.id || ""
12845
+ });
12846
+ __privateGet(this, _onMessage) && (!event.event || event.event === "message") && __privateGet(this, _onMessage).call(this, messageEvent), this.dispatchEvent(messageEvent);
12847
+ }), __privateAdd(this, _onRetryChange, (value) => {
12848
+ __privateSet(this, _reconnectInterval, value);
12849
+ }), __privateAdd(this, _reconnect, () => {
12850
+ __privateSet(this, _reconnectTimer, void 0), __privateGet(this, _readyState) === this.CONNECTING && __privateMethod(this, _EventSource_instances, connect_fn).call(this);
12851
+ });
12852
+ try {
12853
+ if (url instanceof URL)
12854
+ __privateSet(this, _url, url);
12855
+ else if (typeof url == "string")
12856
+ __privateSet(this, _url, new URL(url, getBaseURL()));
12857
+ else
12858
+ throw new Error("Invalid URL");
12859
+ } catch {
12860
+ throw syntaxError("An invalid or illegal string was specified");
12861
+ }
12862
+ __privateSet(this, _parser, createParser({
12863
+ onEvent: __privateGet(this, _onEvent),
12864
+ onRetry: __privateGet(this, _onRetryChange)
12865
+ })), __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _reconnectInterval, 3e3), __privateSet(this, _fetch, (_a = eventSourceInitDict == null ? void 0 : eventSourceInitDict.fetch) != null ? _a : globalThis.fetch), __privateSet(this, _withCredentials, (_b = eventSourceInitDict == null ? void 0 : eventSourceInitDict.withCredentials) != null ? _b : false), __privateMethod(this, _EventSource_instances, connect_fn).call(this);
12866
+ }
12867
+ /**
12868
+ * Returns the state of this EventSource object's connection. It can have the values described below.
12869
+ *
12870
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/readyState)
12871
+ *
12872
+ * Note: typed as `number` instead of `0 | 1 | 2` for compatibility with the `EventSource` interface,
12873
+ * defined in the TypeScript `dom` library.
12874
+ *
12875
+ * @public
12876
+ */
12877
+ get readyState() {
12878
+ return __privateGet(this, _readyState);
12879
+ }
12880
+ /**
12881
+ * Returns the URL providing the event stream.
12882
+ *
12883
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/url)
12884
+ *
12885
+ * @public
12886
+ */
12887
+ get url() {
12888
+ return __privateGet(this, _url).href;
12889
+ }
12890
+ /**
12891
+ * Returns true if the credentials mode for connection requests to the URL providing the event stream is set to "include", and false otherwise.
12892
+ *
12893
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/withCredentials)
12894
+ */
12895
+ get withCredentials() {
12896
+ return __privateGet(this, _withCredentials);
12897
+ }
12898
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/error_event) */
12899
+ get onerror() {
12900
+ return __privateGet(this, _onError);
12901
+ }
12902
+ set onerror(value) {
12903
+ __privateSet(this, _onError, value);
12904
+ }
12905
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/message_event) */
12906
+ get onmessage() {
12907
+ return __privateGet(this, _onMessage);
12908
+ }
12909
+ set onmessage(value) {
12910
+ __privateSet(this, _onMessage, value);
12911
+ }
12912
+ /** [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/open_event) */
12913
+ get onopen() {
12914
+ return __privateGet(this, _onOpen);
12915
+ }
12916
+ set onopen(value) {
12917
+ __privateSet(this, _onOpen, value);
12918
+ }
12919
+ addEventListener(type, listener, options) {
12920
+ const listen = listener;
12921
+ super.addEventListener(type, listen, options);
12922
+ }
12923
+ removeEventListener(type, listener, options) {
12924
+ const listen = listener;
12925
+ super.removeEventListener(type, listen, options);
12926
+ }
12927
+ /**
12928
+ * Aborts any instances of the fetch algorithm started for this EventSource object, and sets the readyState attribute to CLOSED.
12929
+ *
12930
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/EventSource/close)
12931
+ *
12932
+ * @public
12933
+ */
12934
+ close() {
12935
+ __privateGet(this, _reconnectTimer) && clearTimeout(__privateGet(this, _reconnectTimer)), __privateGet(this, _readyState) !== this.CLOSED && (__privateGet(this, _controller) && __privateGet(this, _controller).abort(), __privateSet(this, _readyState, this.CLOSED), __privateSet(this, _controller, void 0));
12936
+ }
12937
+ }
12938
+ _readyState = /* @__PURE__ */ new WeakMap(), _url = /* @__PURE__ */ new WeakMap(), _redirectUrl = /* @__PURE__ */ new WeakMap(), _withCredentials = /* @__PURE__ */ new WeakMap(), _fetch = /* @__PURE__ */ new WeakMap(), _reconnectInterval = /* @__PURE__ */ new WeakMap(), _reconnectTimer = /* @__PURE__ */ new WeakMap(), _lastEventId = /* @__PURE__ */ new WeakMap(), _controller = /* @__PURE__ */ new WeakMap(), _parser = /* @__PURE__ */ new WeakMap(), _onError = /* @__PURE__ */ new WeakMap(), _onMessage = /* @__PURE__ */ new WeakMap(), _onOpen = /* @__PURE__ */ new WeakMap(), _EventSource_instances = /* @__PURE__ */ new WeakSet(), /**
12939
+ * Connect to the given URL and start receiving events
12940
+ *
12941
+ * @internal
12942
+ */
12943
+ connect_fn = function() {
12944
+ __privateSet(this, _readyState, this.CONNECTING), __privateSet(this, _controller, new AbortController()), __privateGet(this, _fetch)(__privateGet(this, _url), __privateMethod(this, _EventSource_instances, getRequestOptions_fn).call(this)).then(__privateGet(this, _onFetchResponse)).catch(__privateGet(this, _onFetchError));
12945
+ }, _onFetchResponse = /* @__PURE__ */ new WeakMap(), _onFetchError = /* @__PURE__ */ new WeakMap(), /**
12946
+ * Get request options for the `fetch()` request
12947
+ *
12948
+ * @returns The request options
12949
+ * @internal
12950
+ */
12951
+ getRequestOptions_fn = function() {
12952
+ var _a;
12953
+ const init = {
12954
+ // [spec] Let `corsAttributeState` be `Anonymous`…
12955
+ // [spec] …will have their mode set to "cors"…
12956
+ mode: "cors",
12957
+ redirect: "follow",
12958
+ headers: { Accept: "text/event-stream", ...__privateGet(this, _lastEventId) ? { "Last-Event-ID": __privateGet(this, _lastEventId) } : void 0 },
12959
+ cache: "no-store",
12960
+ signal: (_a = __privateGet(this, _controller)) == null ? void 0 : _a.signal
12961
+ };
12962
+ return "window" in globalThis && (init.credentials = this.withCredentials ? "include" : "same-origin"), init;
12963
+ }, _onEvent = /* @__PURE__ */ new WeakMap(), _onRetryChange = /* @__PURE__ */ new WeakMap(), /**
12964
+ * Handles the process referred to in the EventSource specification as "failing a connection".
12965
+ *
12966
+ * @param error - The error causing the connection to fail
12967
+ * @param code - The HTTP status code, if available
12968
+ * @internal
12969
+ */
12970
+ failConnection_fn = function(message, code) {
12971
+ var _a;
12972
+ __privateGet(this, _readyState) !== this.CLOSED && __privateSet(this, _readyState, this.CLOSED);
12973
+ const errorEvent = new ErrorEvent("error", { code, message });
12974
+ (_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent);
12975
+ }, /**
12976
+ * Schedules a reconnection attempt against the EventSource endpoint.
12977
+ *
12978
+ * @param message - The error causing the connection to fail
12979
+ * @param code - The HTTP status code, if available
12980
+ * @internal
12981
+ */
12982
+ scheduleReconnect_fn = function(message, code) {
12983
+ var _a;
12984
+ if (__privateGet(this, _readyState) === this.CLOSED)
12985
+ return;
12986
+ __privateSet(this, _readyState, this.CONNECTING);
12987
+ const errorEvent = new ErrorEvent("error", { code, message });
12988
+ (_a = __privateGet(this, _onError)) == null || _a.call(this, errorEvent), this.dispatchEvent(errorEvent), __privateSet(this, _reconnectTimer, setTimeout(__privateGet(this, _reconnect), __privateGet(this, _reconnectInterval)));
12989
+ }, _reconnect = /* @__PURE__ */ new WeakMap(), /**
12990
+ * ReadyState representing an EventSource currently trying to connect
12991
+ *
12992
+ * @public
12993
+ */
12994
+ EventSource.CONNECTING = 0, /**
12995
+ * ReadyState representing an EventSource connection that is open (eg connected)
12996
+ *
12997
+ * @public
12998
+ */
12999
+ EventSource.OPEN = 1, /**
13000
+ * ReadyState representing an EventSource connection that is closed (eg disconnected)
13001
+ *
13002
+ * @public
13003
+ */
13004
+ EventSource.CLOSED = 2;
13005
+ function getBaseURL() {
13006
+ const doc = "document" in globalThis ? globalThis.document : void 0;
13007
+ return doc && typeof doc == "object" && "baseURI" in doc && typeof doc.baseURI == "string" ? doc.baseURI : void 0;
13008
+ }
13009
+ class SseError extends Error {
13010
+ constructor(code, message, event) {
13011
+ super(`SSE error: ${message}`);
13012
+ this.code = code;
13013
+ this.event = event;
13014
+ }
13015
+ }
13016
+ class SSEClientTransport {
13017
+ constructor(url, opts) {
13018
+ this._url = url;
13019
+ this._eventSourceInit = opts === null || opts === void 0 ? void 0 : opts.eventSourceInit;
13020
+ this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
13021
+ }
13022
+ start() {
13023
+ if (this._eventSource) {
13024
+ throw new Error("SSEClientTransport already started! If using Client class, note that connect() calls start() automatically.");
13025
+ }
13026
+ return new Promise((resolve, reject) => {
13027
+ this._eventSource = new EventSource(this._url.href, this._eventSourceInit);
13028
+ this._abortController = new AbortController();
13029
+ this._eventSource.onerror = (event) => {
13030
+ var _a;
13031
+ const error = new SseError(event.code, event.message, event);
13032
+ reject(error);
13033
+ (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
13034
+ };
13035
+ this._eventSource.onopen = () => {
13036
+ };
13037
+ this._eventSource.addEventListener("endpoint", (event) => {
13038
+ var _a;
13039
+ const messageEvent = event;
13040
+ try {
13041
+ this._endpoint = new URL(messageEvent.data, this._url);
13042
+ if (this._endpoint.origin !== this._url.origin) {
13043
+ throw new Error(`Endpoint origin does not match connection origin: ${this._endpoint.origin}`);
13044
+ }
13045
+ } catch (error) {
13046
+ reject(error);
13047
+ (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
13048
+ void this.close();
13049
+ return;
13050
+ }
13051
+ resolve();
13052
+ });
13053
+ this._eventSource.onmessage = (event) => {
13054
+ var _a, _b;
13055
+ const messageEvent = event;
13056
+ let message;
13057
+ try {
13058
+ message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
13059
+ } catch (error) {
13060
+ (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
13061
+ return;
13062
+ }
13063
+ (_b = this.onmessage) === null || _b === void 0 ? void 0 : _b.call(this, message);
13064
+ };
13065
+ });
13066
+ }
13067
+ async close() {
13068
+ var _a, _b, _c;
13069
+ (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();
13070
+ (_b = this._eventSource) === null || _b === void 0 ? void 0 : _b.close();
13071
+ (_c = this.onclose) === null || _c === void 0 ? void 0 : _c.call(this);
13072
+ }
13073
+ async send(message) {
13074
+ var _a, _b, _c;
13075
+ if (!this._endpoint) {
13076
+ throw new Error("Not connected");
13077
+ }
13078
+ try {
13079
+ const headers = new Headers((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
13080
+ headers.set("content-type", "application/json");
13081
+ const init = {
13082
+ ...this._requestInit,
13083
+ method: "POST",
13084
+ headers,
13085
+ body: JSON.stringify(message),
13086
+ signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal
13087
+ };
13088
+ const response = await fetch(this._endpoint, init);
13089
+ if (!response.ok) {
13090
+ const text = await response.text().catch(() => null);
13091
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
13092
+ }
13093
+ } catch (error) {
13094
+ (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
13095
+ throw error;
13096
+ }
13097
+ }
13098
+ }
13099
+ let crypto;
13100
+ crypto = globalThis.crypto;
13101
+ function getRandomValues(size2) {
13102
+ return crypto.getRandomValues(new Uint8Array(size2));
13103
+ }
13104
+ function random(size2) {
13105
+ const mask = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";
13106
+ let result = "";
13107
+ const randomUints = getRandomValues(size2);
13108
+ for (let i = 0; i < size2; i++) {
13109
+ const randomIndex = randomUints[i] % mask.length;
13110
+ result += mask[randomIndex];
13111
+ }
13112
+ return result;
13113
+ }
13114
+ function generateVerifier(length) {
13115
+ return random(length);
13116
+ }
13117
+ async function generateChallenge(code_verifier) {
13118
+ const buffer = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(code_verifier));
13119
+ return btoa(String.fromCharCode(...new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/=/g, "");
13120
+ }
13121
+ async function pkceChallenge(length) {
13122
+ if (!length)
13123
+ length = 43;
13124
+ if (length < 43 || length > 128) {
13125
+ throw `Expected a length between 43 and 128. Received ${length}.`;
13126
+ }
13127
+ const verifier = generateVerifier(length);
13128
+ const challenge = await generateChallenge(verifier);
13129
+ return {
13130
+ code_verifier: verifier,
13131
+ code_challenge: challenge
13132
+ };
13133
+ }
13134
+ const SESSION_KEYS = {
13135
+ CODE_VERIFIER: "mcp_code_verifier",
13136
+ SERVER_URL: "mcp_server_url",
13137
+ ACCESS_TOKEN: "mcp_access_token",
13138
+ REFRESH_TOKEN: "mcp_refresh_token"
13139
+ };
13140
+ const OAuthMetadataSchema = z.object({
13141
+ authorization_endpoint: z.string(),
13142
+ token_endpoint: z.string()
13143
+ });
13144
+ const OAuthTokensSchema = z.object({
13145
+ access_token: z.string(),
13146
+ refresh_token: z.string().optional(),
13147
+ expires_in: z.number().optional()
13148
+ });
13149
+ async function discoverOAuthMetadata(serverUrl) {
13150
+ try {
13151
+ const url = new URL("/.well-known/oauth-authorization-server", serverUrl);
13152
+ const response = await fetch(url.toString());
13153
+ if (response.ok) {
13154
+ const metadata = await response.json();
13155
+ const validatedMetadata = OAuthMetadataSchema.parse({
13156
+ authorization_endpoint: metadata.authorization_endpoint,
13157
+ token_endpoint: metadata.token_endpoint
13158
+ });
13159
+ return validatedMetadata;
13160
+ }
13161
+ } catch (error) {
13162
+ console.warn("OAuth metadata discovery failed:", error);
13163
+ }
13164
+ const baseUrl = new URL(serverUrl);
13165
+ const defaultMetadata = {
13166
+ authorization_endpoint: new URL("/authorize", baseUrl).toString(),
13167
+ token_endpoint: new URL("/token", baseUrl).toString()
13168
+ };
13169
+ return OAuthMetadataSchema.parse(defaultMetadata);
13170
+ }
13171
+ async function startOAuthFlow(serverUrl) {
13172
+ const challenge = await pkceChallenge();
13173
+ const codeVerifier = challenge.code_verifier;
13174
+ const codeChallenge = challenge.code_challenge;
13175
+ sessionStorage.setItem(SESSION_KEYS.CODE_VERIFIER, codeVerifier);
13176
+ const metadata = await discoverOAuthMetadata(serverUrl);
13177
+ const authUrl = new URL(metadata.authorization_endpoint);
13178
+ authUrl.searchParams.set("response_type", "code");
13179
+ authUrl.searchParams.set("code_challenge", codeChallenge);
13180
+ authUrl.searchParams.set("code_challenge_method", "S256");
13181
+ authUrl.searchParams.set(
13182
+ "redirect_uri",
13183
+ window.location.origin + "/oauth/callback"
13184
+ );
13185
+ return authUrl.toString();
13186
+ }
13187
+ async function handleOAuthCallback(serverUrl, code) {
13188
+ const codeVerifier = sessionStorage.getItem(SESSION_KEYS.CODE_VERIFIER);
13189
+ if (!codeVerifier) {
13190
+ throw new Error("No code verifier found");
13191
+ }
13192
+ const metadata = await discoverOAuthMetadata(serverUrl);
13193
+ const response = await fetch(metadata.token_endpoint, {
13194
+ method: "POST",
13195
+ headers: {
13196
+ "Content-Type": "application/json"
13197
+ },
13198
+ body: JSON.stringify({
13199
+ grant_type: "authorization_code",
13200
+ code,
13201
+ code_verifier: codeVerifier,
13202
+ redirect_uri: window.location.origin + "/oauth/callback"
13203
+ })
13204
+ });
13205
+ if (!response.ok) {
13206
+ throw new Error("Token exchange failed");
13207
+ }
13208
+ const tokens = await response.json();
13209
+ return OAuthTokensSchema.parse(tokens);
13210
+ }
13211
+ async function refreshAccessToken(serverUrl) {
13212
+ const refreshToken = sessionStorage.getItem(SESSION_KEYS.REFRESH_TOKEN);
13213
+ if (!refreshToken) {
13214
+ throw new Error("No refresh token available");
13215
+ }
13216
+ const metadata = await discoverOAuthMetadata(serverUrl);
13217
+ const response = await fetch(metadata.token_endpoint, {
13218
+ method: "POST",
13219
+ headers: {
13220
+ "Content-Type": "application/json"
13221
+ },
13222
+ body: JSON.stringify({
13223
+ grant_type: "refresh_token",
13224
+ refresh_token: refreshToken
13225
+ })
13226
+ });
13227
+ if (!response.ok) {
13228
+ throw new Error("Token refresh failed");
13229
+ }
13230
+ const tokens = await response.json();
13231
+ return OAuthTokensSchema.parse(tokens);
13232
+ }
13233
+ const StdErrNotificationSchema = NotificationSchema.extend({
13234
+ method: z.literal("notifications/stderr"),
12478
13235
  params: z.object({
12479
13236
  content: z.string()
12480
13237
  })
@@ -12482,6 +13239,253 @@ const StdErrNotificationSchema = NotificationSchema.extend({
12482
13239
  ClientNotificationSchema.or(
12483
13240
  StdErrNotificationSchema
12484
13241
  );
13242
+ const DEFAULT_REQUEST_TIMEOUT_MSEC = 1e4;
13243
+ function useConnection({
13244
+ transportType,
13245
+ command,
13246
+ args,
13247
+ sseUrl,
13248
+ env,
13249
+ proxyServerUrl,
13250
+ requestTimeout = DEFAULT_REQUEST_TIMEOUT_MSEC,
13251
+ onNotification,
13252
+ onStdErrNotification,
13253
+ onPendingRequest,
13254
+ getRoots
13255
+ }) {
13256
+ const [connectionStatus, setConnectionStatus] = reactExports.useState("disconnected");
13257
+ const [serverCapabilities, setServerCapabilities] = reactExports.useState(null);
13258
+ const [mcpClient, setMcpClient] = reactExports.useState(null);
13259
+ const [requestHistory, setRequestHistory] = reactExports.useState([]);
13260
+ const pushHistory = (request, response) => {
13261
+ setRequestHistory((prev) => [
13262
+ ...prev,
13263
+ {
13264
+ request: JSON.stringify(request),
13265
+ response: response !== void 0 ? JSON.stringify(response) : void 0
13266
+ }
13267
+ ]);
13268
+ };
13269
+ const makeRequest = async (request, schema) => {
13270
+ if (!mcpClient) {
13271
+ throw new Error("MCP client not connected");
13272
+ }
13273
+ try {
13274
+ const abortController = new AbortController();
13275
+ const timeoutId = setTimeout(() => {
13276
+ abortController.abort("Request timed out");
13277
+ }, requestTimeout);
13278
+ let response;
13279
+ try {
13280
+ response = await mcpClient.request(request, schema, {
13281
+ signal: abortController.signal
13282
+ });
13283
+ pushHistory(request, response);
13284
+ } catch (error) {
13285
+ const errorMessage = error instanceof Error ? error.message : String(error);
13286
+ pushHistory(request, { error: errorMessage });
13287
+ throw error;
13288
+ } finally {
13289
+ clearTimeout(timeoutId);
13290
+ }
13291
+ return response;
13292
+ } catch (e) {
13293
+ const errorString = e.message ?? String(e);
13294
+ B.error(errorString);
13295
+ throw e;
13296
+ }
13297
+ };
13298
+ const sendNotification = async (notification) => {
13299
+ if (!mcpClient) {
13300
+ throw new Error("MCP client not connected");
13301
+ }
13302
+ try {
13303
+ await mcpClient.notification(notification);
13304
+ pushHistory(notification);
13305
+ } catch (e) {
13306
+ B.error(e.message ?? String(e));
13307
+ throw e;
13308
+ }
13309
+ };
13310
+ const initiateOAuthFlow = async () => {
13311
+ sessionStorage.removeItem(SESSION_KEYS.ACCESS_TOKEN);
13312
+ sessionStorage.removeItem(SESSION_KEYS.REFRESH_TOKEN);
13313
+ sessionStorage.setItem(SESSION_KEYS.SERVER_URL, sseUrl);
13314
+ const redirectUrl = await startOAuthFlow(sseUrl);
13315
+ window.location.href = redirectUrl;
13316
+ };
13317
+ const handleTokenRefresh = async () => {
13318
+ try {
13319
+ const tokens = await refreshAccessToken(sseUrl);
13320
+ sessionStorage.setItem(SESSION_KEYS.ACCESS_TOKEN, tokens.access_token);
13321
+ if (tokens.refresh_token) {
13322
+ sessionStorage.setItem(
13323
+ SESSION_KEYS.REFRESH_TOKEN,
13324
+ tokens.refresh_token
13325
+ );
13326
+ }
13327
+ return tokens.access_token;
13328
+ } catch (error) {
13329
+ console.error("Token refresh failed:", error);
13330
+ await initiateOAuthFlow();
13331
+ throw error;
13332
+ }
13333
+ };
13334
+ const handleAuthError = async (error) => {
13335
+ if (error instanceof SseError && error.code === 401) {
13336
+ if (sessionStorage.getItem(SESSION_KEYS.REFRESH_TOKEN)) {
13337
+ try {
13338
+ await handleTokenRefresh();
13339
+ return true;
13340
+ } catch (error2) {
13341
+ console.error("Token refresh failed:", error2);
13342
+ }
13343
+ } else {
13344
+ await initiateOAuthFlow();
13345
+ }
13346
+ }
13347
+ return false;
13348
+ };
13349
+ const connect = async (_e, retryCount = 0) => {
13350
+ try {
13351
+ const client = new Client(
13352
+ {
13353
+ name: "mcp-inspector",
13354
+ version: "0.0.1"
13355
+ },
13356
+ {
13357
+ capabilities: {
13358
+ sampling: {},
13359
+ roots: {
13360
+ listChanged: true
13361
+ }
13362
+ }
13363
+ }
13364
+ );
13365
+ const backendUrl = new URL(`${proxyServerUrl}/sse`);
13366
+ backendUrl.searchParams.append("transportType", transportType);
13367
+ if (transportType === "stdio") {
13368
+ backendUrl.searchParams.append("command", command);
13369
+ backendUrl.searchParams.append("args", args);
13370
+ backendUrl.searchParams.append("env", JSON.stringify(env));
13371
+ } else {
13372
+ backendUrl.searchParams.append("url", sseUrl);
13373
+ }
13374
+ const headers = {};
13375
+ const accessToken = sessionStorage.getItem(SESSION_KEYS.ACCESS_TOKEN);
13376
+ if (accessToken) {
13377
+ headers["Authorization"] = `Bearer ${accessToken}`;
13378
+ }
13379
+ const clientTransport = new SSEClientTransport(backendUrl, {
13380
+ eventSourceInit: {
13381
+ fetch: (url, init) => fetch(url, { ...init, headers })
13382
+ },
13383
+ requestInit: {
13384
+ headers
13385
+ }
13386
+ });
13387
+ if (onNotification) {
13388
+ client.setNotificationHandler(
13389
+ ProgressNotificationSchema,
13390
+ onNotification
13391
+ );
13392
+ }
13393
+ if (onStdErrNotification) {
13394
+ client.setNotificationHandler(
13395
+ StdErrNotificationSchema,
13396
+ onStdErrNotification
13397
+ );
13398
+ }
13399
+ try {
13400
+ await client.connect(clientTransport);
13401
+ } catch (error) {
13402
+ console.error("Failed to connect to MCP server:", error);
13403
+ const shouldRetry = await handleAuthError(error);
13404
+ if (shouldRetry) {
13405
+ return connect(void 0, retryCount + 1);
13406
+ }
13407
+ if (error instanceof SseError && error.code === 401) {
13408
+ return;
13409
+ }
13410
+ throw error;
13411
+ }
13412
+ const capabilities = client.getServerCapabilities();
13413
+ setServerCapabilities(capabilities ?? null);
13414
+ if (onPendingRequest) {
13415
+ client.setRequestHandler(CreateMessageRequestSchema, (request) => {
13416
+ return new Promise((resolve, reject) => {
13417
+ onPendingRequest(request, resolve, reject);
13418
+ });
13419
+ });
13420
+ }
13421
+ if (getRoots) {
13422
+ client.setRequestHandler(ListRootsRequestSchema, async () => {
13423
+ return { roots: getRoots() };
13424
+ });
13425
+ }
13426
+ setMcpClient(client);
13427
+ setConnectionStatus("connected");
13428
+ } catch (e) {
13429
+ console.error(e);
13430
+ setConnectionStatus("error");
13431
+ }
13432
+ };
13433
+ return {
13434
+ connectionStatus,
13435
+ serverCapabilities,
13436
+ mcpClient,
13437
+ requestHistory,
13438
+ makeRequest,
13439
+ sendNotification,
13440
+ connect
13441
+ };
13442
+ }
13443
+ function useDraggablePane(initialHeight) {
13444
+ const [height, setHeight] = reactExports.useState(initialHeight);
13445
+ const [isDragging, setIsDragging] = reactExports.useState(false);
13446
+ const dragStartY = reactExports.useRef(0);
13447
+ const dragStartHeight = reactExports.useRef(0);
13448
+ const handleDragStart = reactExports.useCallback(
13449
+ (e) => {
13450
+ setIsDragging(true);
13451
+ dragStartY.current = e.clientY;
13452
+ dragStartHeight.current = height;
13453
+ document.body.style.userSelect = "none";
13454
+ },
13455
+ [height]
13456
+ );
13457
+ const handleDragMove = reactExports.useCallback(
13458
+ (e) => {
13459
+ if (!isDragging) return;
13460
+ const deltaY = dragStartY.current - e.clientY;
13461
+ const newHeight = Math.max(
13462
+ 100,
13463
+ Math.min(800, dragStartHeight.current + deltaY)
13464
+ );
13465
+ setHeight(newHeight);
13466
+ },
13467
+ [isDragging]
13468
+ );
13469
+ const handleDragEnd = reactExports.useCallback(() => {
13470
+ setIsDragging(false);
13471
+ document.body.style.userSelect = "";
13472
+ }, []);
13473
+ reactExports.useEffect(() => {
13474
+ if (isDragging) {
13475
+ window.addEventListener("mousemove", handleDragMove);
13476
+ window.addEventListener("mouseup", handleDragEnd);
13477
+ return () => {
13478
+ window.removeEventListener("mousemove", handleDragMove);
13479
+ window.removeEventListener("mouseup", handleDragEnd);
13480
+ };
13481
+ }
13482
+ }, [isDragging, handleDragMove, handleDragEnd]);
13483
+ return {
13484
+ height,
13485
+ isDragging,
13486
+ handleDragStart
13487
+ };
13488
+ }
12485
13489
  function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
12486
13490
  return function handleEvent(event) {
12487
13491
  originalEventHandler == null ? void 0 : originalEventHandler(event);
@@ -12490,7 +13494,7 @@ function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForD
12490
13494
  }
12491
13495
  };
12492
13496
  }
12493
- function createContextScope$3(scopeName, createContextScopeDeps = []) {
13497
+ function createContextScope(scopeName, createContextScopeDeps = []) {
12494
13498
  let defaultContexts = [];
12495
13499
  function createContext3(rootComponentName, defaultContext) {
12496
13500
  const BaseContext = reactExports.createContext(defaultContext);
@@ -12527,66 +13531,9 @@ function createContextScope$3(scopeName, createContextScopeDeps = []) {
12527
13531
  };
12528
13532
  };
12529
13533
  createScope.scopeName = scopeName;
12530
- return [createContext3, composeContextScopes$3(createScope, ...createContextScopeDeps)];
12531
- }
12532
- function composeContextScopes$3(...scopes) {
12533
- const baseScope = scopes[0];
12534
- if (scopes.length === 1) return baseScope;
12535
- const createScope = () => {
12536
- const scopeHooks = scopes.map((createScope2) => ({
12537
- useScope: createScope2(),
12538
- scopeName: createScope2.scopeName
12539
- }));
12540
- return function useComposedScopes(overrideScopes) {
12541
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
12542
- const scopeProps = useScope(overrideScopes);
12543
- const currentScope = scopeProps[`__scope${scopeName}`];
12544
- return { ...nextScopes2, ...currentScope };
12545
- }, {});
12546
- return reactExports.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
12547
- };
12548
- };
12549
- createScope.scopeName = baseScope.scopeName;
12550
- return createScope;
12551
- }
12552
- function createContextScope$2(scopeName, createContextScopeDeps = []) {
12553
- let defaultContexts = [];
12554
- function createContext3(rootComponentName, defaultContext) {
12555
- const BaseContext = reactExports.createContext(defaultContext);
12556
- const index2 = defaultContexts.length;
12557
- defaultContexts = [...defaultContexts, defaultContext];
12558
- function Provider(props) {
12559
- const { scope, children, ...context } = props;
12560
- const Context = (scope == null ? void 0 : scope[scopeName][index2]) || BaseContext;
12561
- const value = reactExports.useMemo(() => context, Object.values(context));
12562
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Context.Provider, { value, children });
12563
- }
12564
- function useContext2(consumerName, scope) {
12565
- const Context = (scope == null ? void 0 : scope[scopeName][index2]) || BaseContext;
12566
- const context = reactExports.useContext(Context);
12567
- if (context) return context;
12568
- if (defaultContext !== void 0) return defaultContext;
12569
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
12570
- }
12571
- Provider.displayName = rootComponentName + "Provider";
12572
- return [Provider, useContext2];
12573
- }
12574
- const createScope = () => {
12575
- const scopeContexts = defaultContexts.map((defaultContext) => {
12576
- return reactExports.createContext(defaultContext);
12577
- });
12578
- return function useScope(scope) {
12579
- const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
12580
- return reactExports.useMemo(
12581
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
12582
- [scope, contexts]
12583
- );
12584
- };
12585
- };
12586
- createScope.scopeName = scopeName;
12587
- return [createContext3, composeContextScopes$2(createScope, ...createContextScopeDeps)];
13534
+ return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
12588
13535
  }
12589
- function composeContextScopes$2(...scopes) {
13536
+ function composeContextScopes(...scopes) {
12590
13537
  const baseScope = scopes[0];
12591
13538
  if (scopes.length === 1) return baseScope;
12592
13539
  const createScope = () => {
@@ -12608,13 +13555,34 @@ function composeContextScopes$2(...scopes) {
12608
13555
  }
12609
13556
  function setRef(ref, value) {
12610
13557
  if (typeof ref === "function") {
12611
- ref(value);
13558
+ return ref(value);
12612
13559
  } else if (ref !== null && ref !== void 0) {
12613
13560
  ref.current = value;
12614
13561
  }
12615
13562
  }
12616
13563
  function composeRefs(...refs) {
12617
- return (node) => refs.forEach((ref) => setRef(ref, node));
13564
+ return (node) => {
13565
+ let hasCleanup = false;
13566
+ const cleanups = refs.map((ref) => {
13567
+ const cleanup = setRef(ref, node);
13568
+ if (!hasCleanup && typeof cleanup == "function") {
13569
+ hasCleanup = true;
13570
+ }
13571
+ return cleanup;
13572
+ });
13573
+ if (hasCleanup) {
13574
+ return () => {
13575
+ for (let i = 0; i < cleanups.length; i++) {
13576
+ const cleanup = cleanups[i];
13577
+ if (typeof cleanup == "function") {
13578
+ cleanup();
13579
+ } else {
13580
+ setRef(refs[i], null);
13581
+ }
13582
+ }
13583
+ };
13584
+ }
13585
+ };
12618
13586
  }
12619
13587
  function useComposedRefs(...refs) {
12620
13588
  return reactExports.useCallback(composeRefs(...refs), refs);
@@ -12642,11 +13610,11 @@ var SlotClone = reactExports.forwardRef((props, forwardedRef) => {
12642
13610
  const { children, ...slotProps } = props;
12643
13611
  if (reactExports.isValidElement(children)) {
12644
13612
  const childrenRef = getElementRef$1(children);
12645
- return reactExports.cloneElement(children, {
12646
- ...mergeProps(slotProps, children.props),
12647
- // @ts-ignore
12648
- ref: forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef
12649
- });
13613
+ const props2 = mergeProps(slotProps, children.props);
13614
+ if (children.type !== reactExports.Fragment) {
13615
+ props2.ref = forwardedRef ? composeRefs(forwardedRef, childrenRef) : childrenRef;
13616
+ }
13617
+ return reactExports.cloneElement(children, props2);
12650
13618
  }
12651
13619
  return reactExports.Children.count(children) > 1 ? reactExports.Children.only(null) : null;
12652
13620
  });
@@ -12696,7 +13664,7 @@ function getElementRef$1(element) {
12696
13664
  }
12697
13665
  function createCollection(name) {
12698
13666
  const PROVIDER_NAME = name + "CollectionProvider";
12699
- const [createCollectionContext, createCollectionScope2] = createContextScope$2(PROVIDER_NAME);
13667
+ const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
12700
13668
  const [CollectionProviderImpl, useCollectionContext] = createCollectionContext(
12701
13669
  PROVIDER_NAME,
12702
13670
  { collectionRef: { current: null }, itemMap: /* @__PURE__ */ new Map() }
@@ -12754,63 +13722,6 @@ function createCollection(name) {
12754
13722
  createCollectionScope2
12755
13723
  ];
12756
13724
  }
12757
- function createContextScope$1(scopeName, createContextScopeDeps = []) {
12758
- let defaultContexts = [];
12759
- function createContext3(rootComponentName, defaultContext) {
12760
- const BaseContext = reactExports.createContext(defaultContext);
12761
- const index2 = defaultContexts.length;
12762
- defaultContexts = [...defaultContexts, defaultContext];
12763
- function Provider(props) {
12764
- const { scope, children, ...context } = props;
12765
- const Context = (scope == null ? void 0 : scope[scopeName][index2]) || BaseContext;
12766
- const value = reactExports.useMemo(() => context, Object.values(context));
12767
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Context.Provider, { value, children });
12768
- }
12769
- function useContext2(consumerName, scope) {
12770
- const Context = (scope == null ? void 0 : scope[scopeName][index2]) || BaseContext;
12771
- const context = reactExports.useContext(Context);
12772
- if (context) return context;
12773
- if (defaultContext !== void 0) return defaultContext;
12774
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
12775
- }
12776
- Provider.displayName = rootComponentName + "Provider";
12777
- return [Provider, useContext2];
12778
- }
12779
- const createScope = () => {
12780
- const scopeContexts = defaultContexts.map((defaultContext) => {
12781
- return reactExports.createContext(defaultContext);
12782
- });
12783
- return function useScope(scope) {
12784
- const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
12785
- return reactExports.useMemo(
12786
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
12787
- [scope, contexts]
12788
- );
12789
- };
12790
- };
12791
- createScope.scopeName = scopeName;
12792
- return [createContext3, composeContextScopes$1(createScope, ...createContextScopeDeps)];
12793
- }
12794
- function composeContextScopes$1(...scopes) {
12795
- const baseScope = scopes[0];
12796
- if (scopes.length === 1) return baseScope;
12797
- const createScope = () => {
12798
- const scopeHooks = scopes.map((createScope2) => ({
12799
- useScope: createScope2(),
12800
- scopeName: createScope2.scopeName
12801
- }));
12802
- return function useComposedScopes(overrideScopes) {
12803
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
12804
- const scopeProps = useScope(overrideScopes);
12805
- const currentScope = scopeProps[`__scope${scopeName}`];
12806
- return { ...nextScopes2, ...currentScope };
12807
- }, {});
12808
- return reactExports.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
12809
- };
12810
- };
12811
- createScope.scopeName = baseScope.scopeName;
12812
- return createScope;
12813
- }
12814
13725
  var useLayoutEffect2 = Boolean(globalThis == null ? void 0 : globalThis.document) ? reactExports.useLayoutEffect : () => {
12815
13726
  };
12816
13727
  var useReactId = React$1["useId".toString()] || (() => void 0);
@@ -12818,9 +13729,9 @@ var count$1 = 0;
12818
13729
  function useId(deterministicId) {
12819
13730
  const [id2, setId] = reactExports.useState(useReactId());
12820
13731
  useLayoutEffect2(() => {
12821
- if (!deterministicId) setId((reactId) => reactId ?? String(count$1++));
13732
+ setId((reactId) => reactId ?? String(count$1++));
12822
13733
  }, [deterministicId]);
12823
- return deterministicId || (id2 ? `radix-${id2}` : "");
13734
+ return id2 ? `radix-${id2}` : "";
12824
13735
  }
12825
13736
  var NODES = [
12826
13737
  "a",
@@ -12914,7 +13825,7 @@ var ENTRY_FOCUS = "rovingFocusGroup.onEntryFocus";
12914
13825
  var EVENT_OPTIONS$1 = { bubbles: false, cancelable: true };
12915
13826
  var GROUP_NAME$1 = "RovingFocusGroup";
12916
13827
  var [Collection$1, useCollection$1, createCollectionScope$1] = createCollection(GROUP_NAME$1);
12917
- var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope$1(
13828
+ var [createRovingFocusGroupContext, createRovingFocusGroupScope] = createContextScope(
12918
13829
  GROUP_NAME$1,
12919
13830
  [createCollectionScope$1]
12920
13831
  );
@@ -13240,7 +14151,7 @@ function getElementRef(element) {
13240
14151
  return element.props.ref || element.ref;
13241
14152
  }
13242
14153
  var TABS_NAME = "Tabs";
13243
- var [createTabsContext, createTabsScope] = createContextScope$3(TABS_NAME, [
14154
+ var [createTabsContext, createTabsScope] = createContextScope(TABS_NAME, [
13244
14155
  createRovingFocusGroupScope
13245
14156
  ]);
13246
14157
  var useRovingFocusGroupScope = createRovingFocusGroupScope();
@@ -16002,6 +16913,31 @@ const Bell = createLucideIcon("Bell", [
16002
16913
  ["path", { d: "M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9", key: "1qo2s2" }],
16003
16914
  ["path", { d: "M10.3 21a1.94 1.94 0 0 0 3.4 0", key: "qgo35s" }]
16004
16915
  ]);
16916
+ /**
16917
+ * @license lucide-react v0.447.0 - ISC
16918
+ *
16919
+ * This source code is licensed under the ISC license.
16920
+ * See the LICENSE file in the root directory of this source tree.
16921
+ */
16922
+ const Bug = createLucideIcon("Bug", [
16923
+ ["path", { d: "m8 2 1.88 1.88", key: "fmnt4t" }],
16924
+ ["path", { d: "M14.12 3.88 16 2", key: "qol33r" }],
16925
+ ["path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1", key: "d7y7pr" }],
16926
+ [
16927
+ "path",
16928
+ {
16929
+ d: "M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",
16930
+ key: "xs1cw7"
16931
+ }
16932
+ ],
16933
+ ["path", { d: "M12 20v-9", key: "1qisl0" }],
16934
+ ["path", { d: "M6.53 9C4.6 8.8 3 7.1 3 5", key: "32zzws" }],
16935
+ ["path", { d: "M6 13H2", key: "82j7cp" }],
16936
+ ["path", { d: "M3 21c0-2.1 1.7-3.9 3.8-4", key: "4p0ekp" }],
16937
+ ["path", { d: "M20.97 5c0 2.1-1.6 3.8-3.5 4", key: "18gb23" }],
16938
+ ["path", { d: "M22 13h-4", key: "1jl80f" }],
16939
+ ["path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4", key: "k3fwyw" }]
16940
+ ]);
16005
16941
  /**
16006
16942
  * @license lucide-react v0.447.0 - ISC
16007
16943
  *
@@ -16031,6 +16967,17 @@ const CircleAlert = createLucideIcon("CircleAlert", [
16031
16967
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
16032
16968
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
16033
16969
  ]);
16970
+ /**
16971
+ * @license lucide-react v0.447.0 - ISC
16972
+ *
16973
+ * This source code is licensed under the ISC license.
16974
+ * See the LICENSE file in the root directory of this source tree.
16975
+ */
16976
+ const CircleHelp = createLucideIcon("CircleHelp", [
16977
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
16978
+ ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
16979
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
16980
+ ]);
16034
16981
  /**
16035
16982
  * @license lucide-react v0.447.0 - ISC
16036
16983
  *
@@ -16041,6 +16988,46 @@ const Copy = createLucideIcon("Copy", [
16041
16988
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
16042
16989
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
16043
16990
  ]);
16991
+ /**
16992
+ * @license lucide-react v0.447.0 - ISC
16993
+ *
16994
+ * This source code is licensed under the ISC license.
16995
+ * See the LICENSE file in the root directory of this source tree.
16996
+ */
16997
+ const EyeOff = createLucideIcon("EyeOff", [
16998
+ [
16999
+ "path",
17000
+ {
17001
+ d: "M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",
17002
+ key: "ct8e1f"
17003
+ }
17004
+ ],
17005
+ ["path", { d: "M14.084 14.158a3 3 0 0 1-4.242-4.242", key: "151rxh" }],
17006
+ [
17007
+ "path",
17008
+ {
17009
+ d: "M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",
17010
+ key: "13bj9a"
17011
+ }
17012
+ ],
17013
+ ["path", { d: "m2 2 20 20", key: "1ooewy" }]
17014
+ ]);
17015
+ /**
17016
+ * @license lucide-react v0.447.0 - ISC
17017
+ *
17018
+ * This source code is licensed under the ISC license.
17019
+ * See the LICENSE file in the root directory of this source tree.
17020
+ */
17021
+ const Eye = createLucideIcon("Eye", [
17022
+ [
17023
+ "path",
17024
+ {
17025
+ d: "M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",
17026
+ key: "1nclc0"
17027
+ }
17028
+ ],
17029
+ ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
17030
+ ]);
16044
17031
  /**
16045
17032
  * @license lucide-react v0.447.0 - ISC
16046
17033
  *
@@ -16089,6 +17076,22 @@ const FolderTree = createLucideIcon("FolderTree", [
16089
17076
  ["path", { d: "M3 5a2 2 0 0 0 2 2h3", key: "f2jnh7" }],
16090
17077
  ["path", { d: "M3 3v13a2 2 0 0 0 2 2h3", key: "k8epm1" }]
16091
17078
  ]);
17079
+ /**
17080
+ * @license lucide-react v0.447.0 - ISC
17081
+ *
17082
+ * This source code is licensed under the ISC license.
17083
+ * See the LICENSE file in the root directory of this source tree.
17084
+ */
17085
+ const Github = createLucideIcon("Github", [
17086
+ [
17087
+ "path",
17088
+ {
17089
+ d: "M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",
17090
+ key: "tonef"
17091
+ }
17092
+ ],
17093
+ ["path", { d: "M9 18c-4.51 2-5-2-7-2", key: "9comsn" }]
17094
+ ]);
16092
17095
  /**
16093
17096
  * @license lucide-react v0.447.0 - ISC
16094
17097
  *
@@ -18287,7 +19290,7 @@ function isTopLayer(element) {
18287
19290
  function isContainingBlock(elementOrCss) {
18288
19291
  const webkit = isWebKit();
18289
19292
  const css = isElement(elementOrCss) ? getComputedStyle$1(elementOrCss) : elementOrCss;
18290
- return css.transform !== "none" || css.perspective !== "none" || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
19293
+ return ["transform", "translate", "scale", "rotate", "perspective"].some((value) => css[value] ? css[value] !== "none" : false) || (css.containerType ? css.containerType !== "normal" : false) || !webkit && (css.backdropFilter ? css.backdropFilter !== "none" : false) || !webkit && (css.filter ? css.filter !== "none" : false) || ["transform", "translate", "scale", "rotate", "perspective", "filter"].some((value) => (css.willChange || "").includes(value)) || ["paint", "layout", "strict", "content"].some((value) => (css.contain || "").includes(value));
18291
19294
  }
18292
19295
  function getContainingBlock(element) {
18293
19296
  let currentNode = getParentNode(element);
@@ -18793,6 +19796,9 @@ const platform = {
18793
19796
  isElement,
18794
19797
  isRTL
18795
19798
  };
19799
+ function rectsAreEqual(a, b2) {
19800
+ return a.x === b2.x && a.y === b2.y && a.width === b2.width && a.height === b2.height;
19801
+ }
18796
19802
  function observeMove(element, onMove) {
18797
19803
  let io = null;
18798
19804
  let timeoutId;
@@ -18811,12 +19817,13 @@ function observeMove(element, onMove) {
18811
19817
  threshold = 1;
18812
19818
  }
18813
19819
  cleanup();
19820
+ const elementRectForRootMargin = element.getBoundingClientRect();
18814
19821
  const {
18815
19822
  left,
18816
19823
  top,
18817
19824
  width,
18818
19825
  height
18819
- } = element.getBoundingClientRect();
19826
+ } = elementRectForRootMargin;
18820
19827
  if (!skip) {
18821
19828
  onMove();
18822
19829
  }
@@ -18847,6 +19854,9 @@ function observeMove(element, onMove) {
18847
19854
  refresh(false, ratio);
18848
19855
  }
18849
19856
  }
19857
+ if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
19858
+ refresh();
19859
+ }
18850
19860
  isFirstUpdate = false;
18851
19861
  }
18852
19862
  try {
@@ -18910,7 +19920,7 @@ function autoUpdate(reference, floating, update, options) {
18910
19920
  }
18911
19921
  function frameLoop() {
18912
19922
  const nextRefRect = getBoundingClientRect(reference);
18913
- if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
19923
+ if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
18914
19924
  update();
18915
19925
  }
18916
19926
  prevRefRect = nextRefRect;
@@ -19247,63 +20257,6 @@ var Arrow$1 = reactExports.forwardRef((props, forwardedRef) => {
19247
20257
  });
19248
20258
  Arrow$1.displayName = NAME$1;
19249
20259
  var Root = Arrow$1;
19250
- function createContextScope(scopeName, createContextScopeDeps = []) {
19251
- let defaultContexts = [];
19252
- function createContext3(rootComponentName, defaultContext) {
19253
- const BaseContext = reactExports.createContext(defaultContext);
19254
- const index2 = defaultContexts.length;
19255
- defaultContexts = [...defaultContexts, defaultContext];
19256
- function Provider(props) {
19257
- const { scope, children, ...context } = props;
19258
- const Context = (scope == null ? void 0 : scope[scopeName][index2]) || BaseContext;
19259
- const value = reactExports.useMemo(() => context, Object.values(context));
19260
- return /* @__PURE__ */ jsxRuntimeExports.jsx(Context.Provider, { value, children });
19261
- }
19262
- function useContext2(consumerName, scope) {
19263
- const Context = (scope == null ? void 0 : scope[scopeName][index2]) || BaseContext;
19264
- const context = reactExports.useContext(Context);
19265
- if (context) return context;
19266
- if (defaultContext !== void 0) return defaultContext;
19267
- throw new Error(`\`${consumerName}\` must be used within \`${rootComponentName}\``);
19268
- }
19269
- Provider.displayName = rootComponentName + "Provider";
19270
- return [Provider, useContext2];
19271
- }
19272
- const createScope = () => {
19273
- const scopeContexts = defaultContexts.map((defaultContext) => {
19274
- return reactExports.createContext(defaultContext);
19275
- });
19276
- return function useScope(scope) {
19277
- const contexts = (scope == null ? void 0 : scope[scopeName]) || scopeContexts;
19278
- return reactExports.useMemo(
19279
- () => ({ [`__scope${scopeName}`]: { ...scope, [scopeName]: contexts } }),
19280
- [scope, contexts]
19281
- );
19282
- };
19283
- };
19284
- createScope.scopeName = scopeName;
19285
- return [createContext3, composeContextScopes(createScope, ...createContextScopeDeps)];
19286
- }
19287
- function composeContextScopes(...scopes) {
19288
- const baseScope = scopes[0];
19289
- if (scopes.length === 1) return baseScope;
19290
- const createScope = () => {
19291
- const scopeHooks = scopes.map((createScope2) => ({
19292
- useScope: createScope2(),
19293
- scopeName: createScope2.scopeName
19294
- }));
19295
- return function useComposedScopes(overrideScopes) {
19296
- const nextScopes = scopeHooks.reduce((nextScopes2, { useScope, scopeName }) => {
19297
- const scopeProps = useScope(overrideScopes);
19298
- const currentScope = scopeProps[`__scope${scopeName}`];
19299
- return { ...nextScopes2, ...currentScope };
19300
- }, {});
19301
- return reactExports.useMemo(() => ({ [`__scope${baseScope.scopeName}`]: nextScopes }), [nextScopes]);
19302
- };
19303
- };
19304
- createScope.scopeName = baseScope.scopeName;
19305
- return createScope;
19306
- }
19307
20260
  function useSize(element) {
19308
20261
  const [size2, setSize] = reactExports.useState(void 0);
19309
20262
  useLayoutEffect2(() => {
@@ -19633,7 +20586,7 @@ var VisuallyHidden = reactExports.forwardRef(
19633
20586
  ...props,
19634
20587
  ref: forwardedRef,
19635
20588
  style: {
19636
- // See: https://github.com/twbs/bootstrap/blob/master/scss/mixins/_screen-reader.scss
20589
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
19637
20590
  position: "absolute",
19638
20591
  border: 0,
19639
20592
  width: 1,
@@ -20249,9 +21202,9 @@ var handleScroll = function(axis, endTarget, event, sourceDelta, noOverscroll) {
20249
21202
  !targetInLock && target !== document.body || // self content
20250
21203
  targetInLock && (endTarget.contains(target) || endTarget === target)
20251
21204
  );
20252
- if (isDeltaPositive && (Math.abs(availableScroll) < 1 || !noOverscroll)) {
21205
+ if (isDeltaPositive && (Math.abs(availableScroll) < 1 || false)) {
20253
21206
  shouldCancelScroll = true;
20254
- } else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || !noOverscroll)) {
21207
+ } else if (!isDeltaPositive && (Math.abs(availableScrollTop) < 1 || false)) {
20255
21208
  shouldCancelScroll = true;
20256
21209
  }
20257
21210
  return shouldCancelScroll;
@@ -20333,7 +21286,7 @@ function RemoveScrollSideCar(props) {
20333
21286
  return true;
20334
21287
  }
20335
21288
  var cancelingAxis = activeAxis.current || currentAxis;
20336
- return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY, true);
21289
+ return handleScroll(cancelingAxis, parent, event, cancelingAxis === "h" ? deltaX : deltaY);
20337
21290
  }, []);
20338
21291
  var shouldPrevent = reactExports.useCallback(function(_event) {
20339
21292
  var event = _event;
@@ -20428,7 +21381,7 @@ var OPEN_KEYS = [" ", "Enter", "ArrowUp", "ArrowDown"];
20428
21381
  var SELECTION_KEYS = [" ", "Enter"];
20429
21382
  var SELECT_NAME = "Select";
20430
21383
  var [Collection, useCollection, createCollectionScope] = createCollection(SELECT_NAME);
20431
- var [createSelectContext, createSelectScope] = createContextScope$3(SELECT_NAME, [
21384
+ var [createSelectContext, createSelectScope] = createContextScope(SELECT_NAME, [
20432
21385
  createCollectionScope,
20433
21386
  createPopperScope
20434
21387
  ]);
@@ -21697,7 +22650,7 @@ const useTheme = () => {
21697
22650
  }, [])
21698
22651
  ];
21699
22652
  };
21700
- const version = "0.3.0";
22653
+ const version = "0.4.1";
21701
22654
  const Sidebar = ({
21702
22655
  connectionStatus,
21703
22656
  transportType,
@@ -21715,6 +22668,7 @@ const Sidebar = ({
21715
22668
  }) => {
21716
22669
  const [theme, setTheme] = useTheme();
21717
22670
  const [showEnvVars, setShowEnvVars] = reactExports.useState(false);
22671
+ const [shownEnvVars, setShownEnvVars] = reactExports.useState(/* @__PURE__ */ new Set());
21718
22672
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-80 bg-card border-r border-border flex flex-col h-full", children: [
21719
22673
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-between p-4 border-b border-gray-200", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("h1", { className: "ml-2 text-lg font-semibold", children: [
21720
22674
  "MCP Inspector v",
@@ -21746,7 +22700,8 @@ const Sidebar = ({
21746
22700
  {
21747
22701
  placeholder: "Command",
21748
22702
  value: command,
21749
- onChange: (e) => setCommand(e.target.value)
22703
+ onChange: (e) => setCommand(e.target.value),
22704
+ className: "font-mono"
21750
22705
  }
21751
22706
  )
21752
22707
  ] }),
@@ -21757,7 +22712,8 @@ const Sidebar = ({
21757
22712
  {
21758
22713
  placeholder: "Arguments (space-separated)",
21759
22714
  value: args,
21760
- onChange: (e) => setArgs(e.target.value)
22715
+ onChange: (e) => setArgs(e.target.value),
22716
+ className: "font-mono"
21761
22717
  }
21762
22718
  )
21763
22719
  ] })
@@ -21768,7 +22724,8 @@ const Sidebar = ({
21768
22724
  {
21769
22725
  placeholder: "URL",
21770
22726
  value: sseUrl,
21771
- onChange: (e) => setSseUrl(e.target.value)
22727
+ onChange: (e) => setSseUrl(e.target.value),
22728
+ className: "font-mono"
21772
22729
  }
21773
22730
  )
21774
22731
  ] }),
@@ -21786,53 +22743,94 @@ const Sidebar = ({
21786
22743
  }
21787
22744
  ),
21788
22745
  showEnvVars && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
21789
- Object.entries(env).map(([key, value], idx) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-[1fr,auto] gap-2", children: [
21790
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1", children: [
22746
+ Object.entries(env).map(([key, value], idx) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2 pb-4", children: [
22747
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
21791
22748
  /* @__PURE__ */ jsxRuntimeExports.jsx(
21792
22749
  Input,
21793
22750
  {
21794
22751
  placeholder: "Key",
21795
22752
  value: key,
21796
22753
  onChange: (e) => {
22754
+ const newKey = e.target.value;
21797
22755
  const newEnv = { ...env };
21798
22756
  delete newEnv[key];
21799
- newEnv[e.target.value] = value;
22757
+ newEnv[newKey] = value;
21800
22758
  setEnv(newEnv);
21801
- }
22759
+ setShownEnvVars((prev) => {
22760
+ const next = new Set(prev);
22761
+ if (next.has(key)) {
22762
+ next.delete(key);
22763
+ next.add(newKey);
22764
+ }
22765
+ return next;
22766
+ });
22767
+ },
22768
+ className: "font-mono"
21802
22769
  }
21803
22770
  ),
22771
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22772
+ Button,
22773
+ {
22774
+ variant: "destructive",
22775
+ size: "icon",
22776
+ className: "h-9 w-9 p-0 shrink-0",
22777
+ onClick: () => {
22778
+ const { [key]: _removed, ...rest } = env;
22779
+ setEnv(rest);
22780
+ },
22781
+ children: "×"
22782
+ }
22783
+ )
22784
+ ] }),
22785
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2", children: [
21804
22786
  /* @__PURE__ */ jsxRuntimeExports.jsx(
21805
22787
  Input,
21806
22788
  {
22789
+ type: shownEnvVars.has(key) ? "text" : "password",
21807
22790
  placeholder: "Value",
21808
22791
  value,
21809
22792
  onChange: (e) => {
21810
22793
  const newEnv = { ...env };
21811
22794
  newEnv[key] = e.target.value;
21812
22795
  setEnv(newEnv);
21813
- }
22796
+ },
22797
+ className: "font-mono"
22798
+ }
22799
+ ),
22800
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22801
+ Button,
22802
+ {
22803
+ variant: "outline",
22804
+ size: "icon",
22805
+ className: "h-9 w-9 p-0 shrink-0",
22806
+ onClick: () => {
22807
+ setShownEnvVars((prev) => {
22808
+ const next = new Set(prev);
22809
+ if (next.has(key)) {
22810
+ next.delete(key);
22811
+ } else {
22812
+ next.add(key);
22813
+ }
22814
+ return next;
22815
+ });
22816
+ },
22817
+ "aria-label": shownEnvVars.has(key) ? "Hide value" : "Show value",
22818
+ "aria-pressed": shownEnvVars.has(key),
22819
+ title: shownEnvVars.has(key) ? "Hide value" : "Show value",
22820
+ children: shownEnvVars.has(key) ? /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4", "aria-hidden": "true" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(EyeOff, { className: "h-4 w-4", "aria-hidden": "true" })
21814
22821
  }
21815
22822
  )
21816
- ] }),
21817
- /* @__PURE__ */ jsxRuntimeExports.jsx(
21818
- Button,
21819
- {
21820
- variant: "destructive",
21821
- onClick: () => {
21822
- const { [key]: removed, ...rest } = env;
21823
- setEnv(rest);
21824
- },
21825
- children: "Remove"
21826
- }
21827
- )
22823
+ ] })
21828
22824
  ] }, idx)),
21829
22825
  /* @__PURE__ */ jsxRuntimeExports.jsx(
21830
22826
  Button,
21831
22827
  {
21832
22828
  variant: "outline",
22829
+ className: "w-full mt-2",
21833
22830
  onClick: () => {
22831
+ const key = "";
21834
22832
  const newEnv = { ...env };
21835
- newEnv[""] = "";
22833
+ newEnv[key] = "";
21836
22834
  setEnv(newEnv);
21837
22835
  },
21838
22836
  children: "Add Environment Variable"
@@ -21867,21 +22865,59 @@ const Sidebar = ({
21867
22865
  ] }) })
21868
22866
  ] })
21869
22867
  ] }) }),
21870
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 border-t", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center space-x-2", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
21871
- Select,
21872
- {
21873
- value: theme,
21874
- onValueChange: (value) => setTheme(value),
21875
- children: [
21876
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "w-[120px]", id: "theme-select", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
21877
- /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
21878
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "system", children: "System" }),
21879
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "light", children: "Light" }),
21880
- /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "dark", children: "Dark" })
21881
- ] })
21882
- ]
21883
- }
21884
- ) }) })
22868
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "p-4 border-t", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between", children: [
22869
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
22870
+ Select,
22871
+ {
22872
+ value: theme,
22873
+ onValueChange: (value) => setTheme(value),
22874
+ children: [
22875
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectTrigger, { className: "w-[100px]", id: "theme-select", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SelectValue, {}) }),
22876
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(SelectContent, { children: [
22877
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "system", children: "System" }),
22878
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "light", children: "Light" }),
22879
+ /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItem, { value: "dark", children: "Dark" })
22880
+ ] })
22881
+ ]
22882
+ }
22883
+ ),
22884
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [
22885
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22886
+ "a",
22887
+ {
22888
+ href: "https://modelcontextprotocol.io/docs/tools/inspector",
22889
+ target: "_blank",
22890
+ rel: "noopener noreferrer",
22891
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", title: "Inspector Documentation", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CircleHelp, { className: "w-4 h-4 text-gray-800" }) })
22892
+ }
22893
+ ),
22894
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22895
+ "a",
22896
+ {
22897
+ href: "https://modelcontextprotocol.io/docs/tools/debugging",
22898
+ target: "_blank",
22899
+ rel: "noopener noreferrer",
22900
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", title: "Debugging Guide", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Bug, { className: "w-4 h-4 text-gray-800" }) })
22901
+ }
22902
+ ),
22903
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
22904
+ "a",
22905
+ {
22906
+ href: "https://github.com/modelcontextprotocol/inspector",
22907
+ target: "_blank",
22908
+ rel: "noopener noreferrer",
22909
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(
22910
+ Button,
22911
+ {
22912
+ variant: "ghost",
22913
+ title: "Report bugs or contribute on GitHub",
22914
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Github, { className: "w-4 h-4 text-gray-800" })
22915
+ }
22916
+ )
22917
+ }
22918
+ )
22919
+ ] })
22920
+ ] }) })
21885
22921
  ] });
21886
22922
  };
21887
22923
  const ToolsTab = ({
@@ -21896,6 +22932,9 @@ const ToolsTab = ({
21896
22932
  error
21897
22933
  }) => {
21898
22934
  const [params2, setParams] = reactExports.useState({});
22935
+ reactExports.useEffect(() => {
22936
+ setParams({});
22937
+ }, [selectedTool]);
21899
22938
  const renderToolResult = () => {
21900
22939
  if (!toolResult) return null;
21901
22940
  if ("content" in toolResult) {
@@ -21922,23 +22961,34 @@ const ToolsTab = ({
21922
22961
  "Tool Result: ",
21923
22962
  isError ? "Error" : "Success"
21924
22963
  ] }),
21925
- structuredResult.content.map((item, index2) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2", children: [
21926
- item.type === "text" && /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64", children: item.text }),
21927
- item.type === "image" && /* @__PURE__ */ jsxRuntimeExports.jsx(
21928
- "img",
21929
- {
21930
- src: `data:${item.mimeType};base64,${item.data}`,
21931
- alt: "Tool result image",
21932
- className: "max-w-full h-auto"
21933
- }
21934
- ),
21935
- item.type === "resource" && /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 whitespace-pre-wrap break-words p-4 rounded text-sm overflow-auto max-h-64", children: JSON.stringify(item.resource, null, 2) })
21936
- ] }, index2))
22964
+ structuredResult.content.map((item, index2) => {
22965
+ var _a, _b;
22966
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2", children: [
22967
+ item.type === "text" && /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64", children: item.text }),
22968
+ item.type === "image" && /* @__PURE__ */ jsxRuntimeExports.jsx(
22969
+ "img",
22970
+ {
22971
+ src: `data:${item.mimeType};base64,${item.data}`,
22972
+ alt: "Tool result image",
22973
+ className: "max-w-full h-auto"
22974
+ }
22975
+ ),
22976
+ item.type === "resource" && (((_b = (_a = item.resource) == null ? void 0 : _a.mimeType) == null ? void 0 : _b.startsWith("audio/")) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
22977
+ "audio",
22978
+ {
22979
+ controls: true,
22980
+ src: `data:${item.resource.mimeType};base64,${item.resource.blob}`,
22981
+ className: "w-full",
22982
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Your browser does not support audio playback" })
22983
+ }
22984
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 whitespace-pre-wrap break-words p-4 rounded text-sm overflow-auto max-h-64", children: JSON.stringify(item.resource, null, 2) }))
22985
+ ] }, index2);
22986
+ })
21937
22987
  ] });
21938
22988
  } else if ("toolResult" in toolResult) {
21939
22989
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
21940
22990
  /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: "font-semibold mb-2", children: "Tool Result (Legacy):" }),
21941
- /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "bg-gray-50 p-4 rounded text-sm overflow-auto max-h-64", children: JSON.stringify(toolResult.toolResult, null, 2) })
22991
+ /* @__PURE__ */ jsxRuntimeExports.jsx("pre", { className: "bg-gray-50 dark:bg-gray-800 dark:text-gray-100 p-4 rounded text-sm overflow-auto max-h-64", children: JSON.stringify(toolResult.toolResult, null, 2) })
21942
22992
  ] });
21943
22993
  }
21944
22994
  };
@@ -21948,7 +22998,10 @@ const ToolsTab = ({
21948
22998
  {
21949
22999
  items: tools,
21950
23000
  listItems: listTools,
21951
- clearItems: clearTools,
23001
+ clearItems: () => {
23002
+ clearTools();
23003
+ setSelectedTool(null);
23004
+ },
21952
23005
  setSelectedItem: setSelectedTool,
21953
23006
  renderItem: (tool) => /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
21954
23007
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "flex-1", children: tool.name }),
@@ -21990,22 +23043,47 @@ const ToolsTab = ({
21990
23043
  }),
21991
23044
  className: "mt-1"
21992
23045
  }
21993
- ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
21994
- Input,
21995
- {
21996
- type: value.type === "number" ? "number" : "text",
21997
- id: key,
21998
- name: key,
21999
- placeholder: value.description,
22000
- onChange: (e) => setParams({
22001
- ...params2,
22002
- [key]: (
22003
- // @ts-expect-error value type is currently unknown
22004
- value.type === "number" ? Number(e.target.value) : e.target.value
22005
- )
22006
- }),
22007
- className: "mt-1"
22008
- }
23046
+ ) : (
23047
+ /* @ts-expect-error value type is currently unknown */
23048
+ value.type === "object" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
23049
+ Textarea,
23050
+ {
23051
+ id: key,
23052
+ name: key,
23053
+ placeholder: value.description,
23054
+ onChange: (e) => {
23055
+ try {
23056
+ const parsed = JSON.parse(e.target.value);
23057
+ setParams({
23058
+ ...params2,
23059
+ [key]: parsed
23060
+ });
23061
+ } catch (err) {
23062
+ setParams({
23063
+ ...params2,
23064
+ [key]: e.target.value
23065
+ });
23066
+ }
23067
+ },
23068
+ className: "mt-1"
23069
+ }
23070
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx(
23071
+ Input,
23072
+ {
23073
+ type: value.type === "number" ? "number" : "text",
23074
+ id: key,
23075
+ name: key,
23076
+ placeholder: value.description,
23077
+ onChange: (e) => setParams({
23078
+ ...params2,
23079
+ [key]: (
23080
+ // @ts-expect-error value type is currently unknown
23081
+ value.type === "number" ? Number(e.target.value) : e.target.value
23082
+ )
23083
+ }),
23084
+ className: "mt-1"
23085
+ }
23086
+ )
22009
23087
  )
22010
23088
  ] }, key)
22011
23089
  ),
@@ -22018,13 +23096,16 @@ const ToolsTab = ({
22018
23096
  ] })
22019
23097
  ] });
22020
23098
  };
22021
- const DEFAULT_REQUEST_TIMEOUT_MSEC = 1e4;
22022
23099
  const params = new URLSearchParams(window.location.search);
22023
23100
  const PROXY_PORT = params.get("proxyPort") ?? "3000";
22024
- const REQUEST_TIMEOUT = parseInt(params.get("timeout") ?? "") || DEFAULT_REQUEST_TIMEOUT_MSEC;
22025
23101
  const PROXY_SERVER_URL = `http://localhost:${PROXY_PORT}`;
22026
23102
  const App = () => {
22027
- const [connectionStatus, setConnectionStatus] = reactExports.useState("disconnected");
23103
+ if (window.location.pathname === "/oauth/callback") {
23104
+ const OAuthCallback = React.lazy(
23105
+ () => __vitePreload(() => import("./OAuthCallback-DCSQTqKf.js"), true ? [] : void 0)
23106
+ );
23107
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, {}) });
23108
+ }
22028
23109
  const [resources, setResources] = reactExports.useState([]);
22029
23110
  const [resourceTemplates, setResourceTemplates] = reactExports.useState([]);
22030
23111
  const [resourceContent, setResourceContent] = reactExports.useState("");
@@ -22043,10 +23124,12 @@ const App = () => {
22043
23124
  const [args, setArgs] = reactExports.useState(() => {
22044
23125
  return localStorage.getItem("lastArgs") || "";
22045
23126
  });
22046
- const [sseUrl, setSseUrl] = reactExports.useState("http://localhost:3001/sse");
22047
- const [transportType, setTransportType] = reactExports.useState("stdio");
22048
- const [requestHistory, setRequestHistory] = reactExports.useState([]);
22049
- const [mcpClient, setMcpClient] = reactExports.useState(null);
23127
+ const [sseUrl, setSseUrl] = reactExports.useState(() => {
23128
+ return localStorage.getItem("lastSseUrl") || "http://localhost:3001/sse";
23129
+ });
23130
+ const [transportType, setTransportType] = reactExports.useState(() => {
23131
+ return localStorage.getItem("lastTransportType") || "stdio";
23132
+ });
22050
23133
  const [notifications, setNotifications] = reactExports.useState([]);
22051
23134
  const [stdErrNotifications, setStdErrNotifications] = reactExports.useState([]);
22052
23135
  const [roots, setRoots] = reactExports.useState([]);
@@ -22078,51 +23161,81 @@ const App = () => {
22078
23161
  const [nextPromptCursor, setNextPromptCursor] = reactExports.useState();
22079
23162
  const [nextToolCursor, setNextToolCursor] = reactExports.useState();
22080
23163
  const progressTokenRef = reactExports.useRef(0);
22081
- const [historyPaneHeight, setHistoryPaneHeight] = reactExports.useState(300);
22082
- const [isDragging, setIsDragging] = reactExports.useState(false);
22083
- const dragStartY = reactExports.useRef(0);
22084
- const dragStartHeight = reactExports.useRef(0);
22085
- const handleDragStart = reactExports.useCallback(
22086
- (e) => {
22087
- setIsDragging(true);
22088
- dragStartY.current = e.clientY;
22089
- dragStartHeight.current = historyPaneHeight;
22090
- document.body.style.userSelect = "none";
23164
+ const { height: historyPaneHeight, handleDragStart } = useDraggablePane(300);
23165
+ const {
23166
+ connectionStatus,
23167
+ serverCapabilities,
23168
+ mcpClient,
23169
+ requestHistory,
23170
+ makeRequest: makeConnectionRequest,
23171
+ sendNotification,
23172
+ connect: connectMcpServer
23173
+ } = useConnection({
23174
+ transportType,
23175
+ command,
23176
+ args,
23177
+ sseUrl,
23178
+ env,
23179
+ proxyServerUrl: PROXY_SERVER_URL,
23180
+ onNotification: (notification) => {
23181
+ setNotifications((prev) => [...prev, notification]);
22091
23182
  },
22092
- [historyPaneHeight]
22093
- );
22094
- const handleDragMove = reactExports.useCallback(
22095
- (e) => {
22096
- if (!isDragging) return;
22097
- const deltaY = dragStartY.current - e.clientY;
22098
- const newHeight = Math.max(
22099
- 100,
22100
- Math.min(800, dragStartHeight.current + deltaY)
22101
- );
22102
- setHistoryPaneHeight(newHeight);
23183
+ onStdErrNotification: (notification) => {
23184
+ setStdErrNotifications((prev) => [
23185
+ ...prev,
23186
+ notification
23187
+ ]);
22103
23188
  },
22104
- [isDragging]
22105
- );
22106
- const handleDragEnd = reactExports.useCallback(() => {
22107
- setIsDragging(false);
22108
- document.body.style.userSelect = "";
22109
- }, []);
22110
- reactExports.useEffect(() => {
22111
- if (isDragging) {
22112
- window.addEventListener("mousemove", handleDragMove);
22113
- window.addEventListener("mouseup", handleDragEnd);
22114
- return () => {
22115
- window.removeEventListener("mousemove", handleDragMove);
22116
- window.removeEventListener("mouseup", handleDragEnd);
22117
- };
23189
+ onPendingRequest: (request, resolve, reject) => {
23190
+ setPendingSampleRequests((prev) => [
23191
+ ...prev,
23192
+ { id: nextRequestId.current++, request, resolve, reject }
23193
+ ]);
23194
+ },
23195
+ getRoots: () => rootsRef.current
23196
+ });
23197
+ const makeRequest = async (request, schema, tabKey) => {
23198
+ try {
23199
+ const response = await makeConnectionRequest(request, schema);
23200
+ if (tabKey !== void 0) {
23201
+ clearError(tabKey);
23202
+ }
23203
+ return response;
23204
+ } catch (e) {
23205
+ const errorString = e.message ?? String(e);
23206
+ if (tabKey !== void 0) {
23207
+ setErrors((prev) => ({
23208
+ ...prev,
23209
+ [tabKey]: errorString
23210
+ }));
23211
+ }
23212
+ throw e;
22118
23213
  }
22119
- }, [isDragging, handleDragMove, handleDragEnd]);
23214
+ };
22120
23215
  reactExports.useEffect(() => {
22121
23216
  localStorage.setItem("lastCommand", command);
22122
23217
  }, [command]);
22123
23218
  reactExports.useEffect(() => {
22124
23219
  localStorage.setItem("lastArgs", args);
22125
23220
  }, [args]);
23221
+ reactExports.useEffect(() => {
23222
+ localStorage.setItem("lastSseUrl", sseUrl);
23223
+ }, [sseUrl]);
23224
+ reactExports.useEffect(() => {
23225
+ localStorage.setItem("lastTransportType", transportType);
23226
+ }, [transportType]);
23227
+ reactExports.useEffect(() => {
23228
+ const serverUrl = params.get("serverUrl");
23229
+ if (serverUrl) {
23230
+ setSseUrl(serverUrl);
23231
+ setTransportType("sse");
23232
+ const newUrl = new URL(window.location.href);
23233
+ newUrl.searchParams.delete("serverUrl");
23234
+ window.history.replaceState({}, "", newUrl.toString());
23235
+ B.success("Successfully authenticated with OAuth");
23236
+ connectMcpServer();
23237
+ }
23238
+ }, []);
22126
23239
  reactExports.useEffect(() => {
22127
23240
  fetch(`${PROXY_SERVER_URL}/config`).then((response) => response.json()).then((data) => {
22128
23241
  setEnv(data.defaultEnvironment);
@@ -22139,65 +23252,14 @@ const App = () => {
22139
23252
  reactExports.useEffect(() => {
22140
23253
  rootsRef.current = roots;
22141
23254
  }, [roots]);
22142
- const pushHistory = (request, response) => {
22143
- setRequestHistory((prev) => [
22144
- ...prev,
22145
- {
22146
- request: JSON.stringify(request),
22147
- response: response !== void 0 ? JSON.stringify(response) : void 0
22148
- }
22149
- ]);
22150
- };
23255
+ reactExports.useEffect(() => {
23256
+ if (!window.location.hash) {
23257
+ window.location.hash = "resources";
23258
+ }
23259
+ }, []);
22151
23260
  const clearError = (tabKey) => {
22152
23261
  setErrors((prev) => ({ ...prev, [tabKey]: null }));
22153
23262
  };
22154
- const makeRequest = async (request, schema, tabKey) => {
22155
- if (!mcpClient) {
22156
- throw new Error("MCP client not connected");
22157
- }
22158
- try {
22159
- const abortController = new AbortController();
22160
- const timeoutId = setTimeout(() => {
22161
- abortController.abort("Request timed out");
22162
- }, REQUEST_TIMEOUT);
22163
- let response;
22164
- try {
22165
- response = await mcpClient.request(request, schema, {
22166
- signal: abortController.signal
22167
- });
22168
- } finally {
22169
- clearTimeout(timeoutId);
22170
- }
22171
- pushHistory(request, response);
22172
- if (tabKey !== void 0) {
22173
- clearError(tabKey);
22174
- }
22175
- return response;
22176
- } catch (e) {
22177
- const errorString = e.message ?? String(e);
22178
- if (tabKey === void 0) {
22179
- B.error(errorString);
22180
- } else {
22181
- setErrors((prev) => ({
22182
- ...prev,
22183
- [tabKey]: errorString
22184
- }));
22185
- }
22186
- throw e;
22187
- }
22188
- };
22189
- const sendNotification = async (notification) => {
22190
- if (!mcpClient) {
22191
- throw new Error("MCP client not connected");
22192
- }
22193
- try {
22194
- await mcpClient.notification(notification);
22195
- pushHistory(notification);
22196
- } catch (e) {
22197
- B.error(e.message ?? String(e));
22198
- throw e;
22199
- }
22200
- };
22201
23263
  const listResources = async () => {
22202
23264
  const response = await makeRequest(
22203
23265
  {
@@ -22290,70 +23352,6 @@ const App = () => {
22290
23352
  const handleRootsChange = async () => {
22291
23353
  await sendNotification({ method: "notifications/roots/list_changed" });
22292
23354
  };
22293
- const connectMcpServer = async () => {
22294
- try {
22295
- const client = new Client(
22296
- {
22297
- name: "mcp-inspector",
22298
- version: "0.0.1"
22299
- },
22300
- {
22301
- capabilities: {
22302
- // Support all client capabilities since we're an inspector tool
22303
- sampling: {},
22304
- roots: {
22305
- listChanged: true
22306
- }
22307
- }
22308
- }
22309
- );
22310
- const backendUrl = new URL(`${PROXY_SERVER_URL}/sse`);
22311
- backendUrl.searchParams.append("transportType", transportType);
22312
- if (transportType === "stdio") {
22313
- backendUrl.searchParams.append("command", command);
22314
- backendUrl.searchParams.append("args", args);
22315
- backendUrl.searchParams.append("env", JSON.stringify(env));
22316
- } else {
22317
- backendUrl.searchParams.append("url", sseUrl);
22318
- }
22319
- const clientTransport = new SSEClientTransport(backendUrl);
22320
- client.setNotificationHandler(
22321
- ProgressNotificationSchema,
22322
- (notification) => {
22323
- setNotifications((prevNotifications) => [
22324
- ...prevNotifications,
22325
- notification
22326
- ]);
22327
- }
22328
- );
22329
- client.setNotificationHandler(
22330
- StdErrNotificationSchema,
22331
- (notification) => {
22332
- setStdErrNotifications((prevErrorNotifications) => [
22333
- ...prevErrorNotifications,
22334
- notification
22335
- ]);
22336
- }
22337
- );
22338
- await client.connect(clientTransport);
22339
- client.setRequestHandler(CreateMessageRequestSchema, (request) => {
22340
- return new Promise((resolve, reject) => {
22341
- setPendingSampleRequests((prev) => [
22342
- ...prev,
22343
- { id: nextRequestId.current++, request, resolve, reject }
22344
- ]);
22345
- });
22346
- });
22347
- client.setRequestHandler(ListRootsRequestSchema, async () => {
22348
- return { roots: rootsRef.current };
22349
- });
22350
- setMcpClient(client);
22351
- setConnectionStatus("connected");
22352
- } catch (e) {
22353
- console.error(e);
22354
- setConnectionStatus("error");
22355
- }
22356
- };
22357
23355
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-screen bg-background", children: [
22358
23356
  /* @__PURE__ */ jsxRuntimeExports.jsx(
22359
23357
  Sidebar,
@@ -22374,156 +23372,187 @@ const App = () => {
22374
23372
  }
22375
23373
  ),
22376
23374
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 flex flex-col overflow-hidden", children: [
22377
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: mcpClient ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { defaultValue: "resources", className: "w-full p-4", children: [
22378
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "mb-4 p-0", children: [
22379
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "resources", children: [
22380
- /* @__PURE__ */ jsxRuntimeExports.jsx(Files, { className: "w-4 h-4 mr-2" }),
22381
- "Resources"
22382
- ] }),
22383
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "prompts", children: [
22384
- /* @__PURE__ */ jsxRuntimeExports.jsx(MessageSquare, { className: "w-4 h-4 mr-2" }),
22385
- "Prompts"
22386
- ] }),
22387
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "tools", children: [
22388
- /* @__PURE__ */ jsxRuntimeExports.jsx(Hammer, { className: "w-4 h-4 mr-2" }),
22389
- "Tools"
22390
- ] }),
22391
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "ping", children: [
22392
- /* @__PURE__ */ jsxRuntimeExports.jsx(Bell, { className: "w-4 h-4 mr-2" }),
22393
- "Ping"
22394
- ] }),
22395
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "sampling", className: "relative", children: [
22396
- /* @__PURE__ */ jsxRuntimeExports.jsx(Hash, { className: "w-4 h-4 mr-2" }),
22397
- "Sampling",
22398
- pendingSampleRequests.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center", children: pendingSampleRequests.length })
22399
- ] }),
22400
- /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "roots", children: [
22401
- /* @__PURE__ */ jsxRuntimeExports.jsx(FolderTree, { className: "w-4 h-4 mr-2" }),
22402
- "Roots"
22403
- ] })
22404
- ] }),
22405
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-full", children: [
22406
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22407
- ResourcesTab,
22408
- {
22409
- resources,
22410
- resourceTemplates,
22411
- listResources: () => {
22412
- clearError("resources");
22413
- listResources();
22414
- },
22415
- clearResources: () => {
22416
- setResources([]);
22417
- setNextResourceCursor(void 0);
22418
- },
22419
- listResourceTemplates: () => {
22420
- clearError("resources");
22421
- listResourceTemplates();
22422
- },
22423
- clearResourceTemplates: () => {
22424
- setResourceTemplates([]);
22425
- setNextResourceTemplateCursor(void 0);
22426
- },
22427
- readResource: (uri) => {
22428
- clearError("resources");
22429
- readResource(uri);
22430
- },
22431
- selectedResource,
22432
- setSelectedResource: (resource) => {
22433
- clearError("resources");
22434
- setSelectedResource(resource);
22435
- },
22436
- resourceContent,
22437
- nextCursor: nextResourceCursor,
22438
- nextTemplateCursor: nextResourceTemplateCursor,
22439
- error: errors.resources
22440
- }
22441
- ),
22442
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22443
- PromptsTab,
22444
- {
22445
- prompts,
22446
- listPrompts: () => {
22447
- clearError("prompts");
22448
- listPrompts();
22449
- },
22450
- clearPrompts: () => {
22451
- setPrompts([]);
22452
- setNextPromptCursor(void 0);
22453
- },
22454
- getPrompt: (name, args2) => {
22455
- clearError("prompts");
22456
- getPrompt(name, args2);
22457
- },
22458
- selectedPrompt,
22459
- setSelectedPrompt: (prompt) => {
22460
- clearError("prompts");
22461
- setSelectedPrompt(prompt);
22462
- },
22463
- promptContent,
22464
- nextCursor: nextPromptCursor,
22465
- error: errors.prompts
22466
- }
22467
- ),
22468
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22469
- ToolsTab,
22470
- {
22471
- tools,
22472
- listTools: () => {
22473
- clearError("tools");
22474
- listTools();
22475
- },
22476
- clearTools: () => {
22477
- setTools([]);
22478
- setNextToolCursor(void 0);
22479
- },
22480
- callTool: (name, params2) => {
22481
- clearError("tools");
22482
- callTool(name, params2);
22483
- },
22484
- selectedTool,
22485
- setSelectedTool: (tool) => {
22486
- clearError("tools");
22487
- setSelectedTool(tool);
22488
- setToolResult(null);
22489
- },
22490
- toolResult,
22491
- nextCursor: nextToolCursor,
22492
- error: errors.tools
22493
- }
22494
- ),
22495
- /* @__PURE__ */ jsxRuntimeExports.jsx(ConsoleTab, {}),
22496
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22497
- PingTab,
22498
- {
22499
- onPingClick: () => {
22500
- void makeRequest(
22501
- {
22502
- method: "ping"
23375
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-auto", children: mcpClient ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
23376
+ Tabs,
23377
+ {
23378
+ defaultValue: Object.keys(serverCapabilities ?? {}).includes(
23379
+ window.location.hash.slice(1)
23380
+ ) ? window.location.hash.slice(1) : (serverCapabilities == null ? void 0 : serverCapabilities.resources) ? "resources" : (serverCapabilities == null ? void 0 : serverCapabilities.prompts) ? "prompts" : (serverCapabilities == null ? void 0 : serverCapabilities.tools) ? "tools" : "ping",
23381
+ className: "w-full p-4",
23382
+ onValueChange: (value) => window.location.hash = value,
23383
+ children: [
23384
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "mb-4 p-0", children: [
23385
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
23386
+ TabsTrigger,
23387
+ {
23388
+ value: "resources",
23389
+ disabled: !(serverCapabilities == null ? void 0 : serverCapabilities.resources),
23390
+ children: [
23391
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Files, { className: "w-4 h-4 mr-2" }),
23392
+ "Resources"
23393
+ ]
23394
+ }
23395
+ ),
23396
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
23397
+ TabsTrigger,
23398
+ {
23399
+ value: "prompts",
23400
+ disabled: !(serverCapabilities == null ? void 0 : serverCapabilities.prompts),
23401
+ children: [
23402
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MessageSquare, { className: "w-4 h-4 mr-2" }),
23403
+ "Prompts"
23404
+ ]
23405
+ }
23406
+ ),
23407
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
23408
+ TabsTrigger,
23409
+ {
23410
+ value: "tools",
23411
+ disabled: !(serverCapabilities == null ? void 0 : serverCapabilities.tools),
23412
+ children: [
23413
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Hammer, { className: "w-4 h-4 mr-2" }),
23414
+ "Tools"
23415
+ ]
23416
+ }
23417
+ ),
23418
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "ping", children: [
23419
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Bell, { className: "w-4 h-4 mr-2" }),
23420
+ "Ping"
23421
+ ] }),
23422
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "sampling", className: "relative", children: [
23423
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Hash, { className: "w-4 h-4 mr-2" }),
23424
+ "Sampling",
23425
+ pendingSampleRequests.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "absolute -top-1 -right-1 bg-red-500 text-white text-xs rounded-full h-4 w-4 flex items-center justify-center", children: pendingSampleRequests.length })
23426
+ ] }),
23427
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "roots", children: [
23428
+ /* @__PURE__ */ jsxRuntimeExports.jsx(FolderTree, { className: "w-4 h-4 mr-2" }),
23429
+ "Roots"
23430
+ ] })
23431
+ ] }),
23432
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: !(serverCapabilities == null ? void 0 : serverCapabilities.resources) && !(serverCapabilities == null ? void 0 : serverCapabilities.prompts) && !(serverCapabilities == null ? void 0 : serverCapabilities.tools) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg text-gray-500", children: "The connected server does not support any MCP capabilities" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
23433
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
23434
+ ResourcesTab,
23435
+ {
23436
+ resources,
23437
+ resourceTemplates,
23438
+ listResources: () => {
23439
+ clearError("resources");
23440
+ listResources();
22503
23441
  },
22504
- EmptyResultSchema
22505
- );
22506
- }
22507
- }
22508
- ),
22509
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22510
- SamplingTab,
22511
- {
22512
- pendingRequests: pendingSampleRequests,
22513
- onApprove: handleApproveSampling,
22514
- onReject: handleRejectSampling
22515
- }
22516
- ),
22517
- /* @__PURE__ */ jsxRuntimeExports.jsx(
22518
- RootsTab,
22519
- {
22520
- roots,
22521
- setRoots,
22522
- onRootsChange: handleRootsChange
22523
- }
22524
- )
22525
- ] })
22526
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg text-gray-500", children: "Connect to an MCP server to start inspecting" }) }) }),
23442
+ clearResources: () => {
23443
+ setResources([]);
23444
+ setNextResourceCursor(void 0);
23445
+ },
23446
+ listResourceTemplates: () => {
23447
+ clearError("resources");
23448
+ listResourceTemplates();
23449
+ },
23450
+ clearResourceTemplates: () => {
23451
+ setResourceTemplates([]);
23452
+ setNextResourceTemplateCursor(void 0);
23453
+ },
23454
+ readResource: (uri) => {
23455
+ clearError("resources");
23456
+ readResource(uri);
23457
+ },
23458
+ selectedResource,
23459
+ setSelectedResource: (resource) => {
23460
+ clearError("resources");
23461
+ setSelectedResource(resource);
23462
+ },
23463
+ resourceContent,
23464
+ nextCursor: nextResourceCursor,
23465
+ nextTemplateCursor: nextResourceTemplateCursor,
23466
+ error: errors.resources
23467
+ }
23468
+ ),
23469
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
23470
+ PromptsTab,
23471
+ {
23472
+ prompts,
23473
+ listPrompts: () => {
23474
+ clearError("prompts");
23475
+ listPrompts();
23476
+ },
23477
+ clearPrompts: () => {
23478
+ setPrompts([]);
23479
+ setNextPromptCursor(void 0);
23480
+ },
23481
+ getPrompt: (name, args2) => {
23482
+ clearError("prompts");
23483
+ getPrompt(name, args2);
23484
+ },
23485
+ selectedPrompt,
23486
+ setSelectedPrompt: (prompt) => {
23487
+ clearError("prompts");
23488
+ setSelectedPrompt(prompt);
23489
+ },
23490
+ promptContent,
23491
+ nextCursor: nextPromptCursor,
23492
+ error: errors.prompts
23493
+ }
23494
+ ),
23495
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
23496
+ ToolsTab,
23497
+ {
23498
+ tools,
23499
+ listTools: () => {
23500
+ clearError("tools");
23501
+ listTools();
23502
+ },
23503
+ clearTools: () => {
23504
+ setTools([]);
23505
+ setNextToolCursor(void 0);
23506
+ },
23507
+ callTool: (name, params2) => {
23508
+ clearError("tools");
23509
+ callTool(name, params2);
23510
+ },
23511
+ selectedTool,
23512
+ setSelectedTool: (tool) => {
23513
+ clearError("tools");
23514
+ setSelectedTool(tool);
23515
+ setToolResult(null);
23516
+ },
23517
+ toolResult,
23518
+ nextCursor: nextToolCursor,
23519
+ error: errors.tools
23520
+ }
23521
+ ),
23522
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ConsoleTab, {}),
23523
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
23524
+ PingTab,
23525
+ {
23526
+ onPingClick: () => {
23527
+ void makeRequest(
23528
+ {
23529
+ method: "ping"
23530
+ },
23531
+ EmptyResultSchema
23532
+ );
23533
+ }
23534
+ }
23535
+ ),
23536
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
23537
+ SamplingTab,
23538
+ {
23539
+ pendingRequests: pendingSampleRequests,
23540
+ onApprove: handleApproveSampling,
23541
+ onReject: handleRejectSampling
23542
+ }
23543
+ ),
23544
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
23545
+ RootsTab,
23546
+ {
23547
+ roots,
23548
+ setRoots,
23549
+ onRootsChange: handleRootsChange
23550
+ }
23551
+ )
23552
+ ] }) })
23553
+ ]
23554
+ }
23555
+ ) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-lg text-gray-500", children: "Connect to an MCP server to start inspecting" }) }) }),
22527
23556
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
22528
23557
  "div",
22529
23558
  {
@@ -22559,3 +23588,9 @@ createRoot(document.getElementById("root")).render(
22559
23588
  /* @__PURE__ */ jsxRuntimeExports.jsx(Q, {})
22560
23589
  ] })
22561
23590
  );
23591
+ export {
23592
+ SESSION_KEYS as S,
23593
+ handleOAuthCallback as h,
23594
+ jsxRuntimeExports as j,
23595
+ reactExports as r
23596
+ };