@modelcontextprotocol/inspector-client 0.17.5 → 0.18.0

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.
@@ -58,7 +58,7 @@ var hasRequiredReact_production_min;
58
58
  function requireReact_production_min() {
59
59
  if (hasRequiredReact_production_min) return react_production_min;
60
60
  hasRequiredReact_production_min = 1;
61
- var l = Symbol.for("react.element"), n = Symbol.for("react.portal"), p2 = Symbol.for("react.fragment"), q = Symbol.for("react.strict_mode"), r2 = Symbol.for("react.profiler"), t = Symbol.for("react.provider"), u2 = Symbol.for("react.context"), v = Symbol.for("react.forward_ref"), w = Symbol.for("react.suspense"), x = Symbol.for("react.memo"), y = Symbol.for("react.lazy"), z = Symbol.iterator;
61
+ var l = /* @__PURE__ */ Symbol.for("react.element"), n = /* @__PURE__ */ Symbol.for("react.portal"), p2 = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), r2 = /* @__PURE__ */ Symbol.for("react.profiler"), t = /* @__PURE__ */ Symbol.for("react.provider"), u2 = /* @__PURE__ */ Symbol.for("react.context"), v = /* @__PURE__ */ Symbol.for("react.forward_ref"), w = /* @__PURE__ */ Symbol.for("react.suspense"), x = /* @__PURE__ */ Symbol.for("react.memo"), y = /* @__PURE__ */ Symbol.for("react.lazy"), z = Symbol.iterator;
62
62
  function A(a) {
63
63
  if (null === a || "object" !== typeof a) return null;
64
64
  a = z && a[z] || a["@@iterator"];
@@ -321,7 +321,7 @@ var hasRequiredReactJsxRuntime_production_min;
321
321
  function requireReactJsxRuntime_production_min() {
322
322
  if (hasRequiredReactJsxRuntime_production_min) return reactJsxRuntime_production_min;
323
323
  hasRequiredReactJsxRuntime_production_min = 1;
324
- var f = requireReact(), k2 = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p2 = { key: true, ref: true, __self: true, __source: true };
324
+ var f = requireReact(), k2 = /* @__PURE__ */ Symbol.for("react.element"), l = /* @__PURE__ */ Symbol.for("react.fragment"), m2 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p2 = { key: true, ref: true, __self: true, __source: true };
325
325
  function q(c, a, g) {
326
326
  var b, d = {}, e = null, h = null;
327
327
  void 0 !== g && (e = "" + g);
@@ -726,8 +726,8 @@ function requireReactDom_production_min() {
726
726
  var e = z.hasOwnProperty(b) ? z[b] : null;
727
727
  if (null !== e ? 0 !== e.type : d || !(2 < b.length) || "o" !== b[0] && "O" !== b[0] || "n" !== b[1] && "N" !== b[1]) qa(b, c, e, d) && (c = null), d || null === e ? oa(b) && (null === c ? a.removeAttribute(b) : a.setAttribute(b, "" + c)) : e.mustUseProperty ? a[e.propertyName] = null === c ? 3 === e.type ? false : "" : c : (b = e.attributeName, d = e.attributeNamespace, null === c ? a.removeAttribute(b) : (e = e.type, c = 3 === e || 4 === e && true === c ? "" : "" + c, d ? a.setAttributeNS(d, b, c) : a.setAttribute(b, c)));
728
728
  }
729
- var ua = aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, va = Symbol.for("react.element"), wa = Symbol.for("react.portal"), ya = Symbol.for("react.fragment"), za = Symbol.for("react.strict_mode"), Aa = Symbol.for("react.profiler"), Ba = Symbol.for("react.provider"), Ca = Symbol.for("react.context"), Da = Symbol.for("react.forward_ref"), Ea = Symbol.for("react.suspense"), Fa = Symbol.for("react.suspense_list"), Ga = Symbol.for("react.memo"), Ha = Symbol.for("react.lazy");
730
- var Ia = Symbol.for("react.offscreen");
729
+ var ua = aa.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, va = /* @__PURE__ */ Symbol.for("react.element"), wa = /* @__PURE__ */ Symbol.for("react.portal"), ya = /* @__PURE__ */ Symbol.for("react.fragment"), za = /* @__PURE__ */ Symbol.for("react.strict_mode"), Aa = /* @__PURE__ */ Symbol.for("react.profiler"), Ba = /* @__PURE__ */ Symbol.for("react.provider"), Ca = /* @__PURE__ */ Symbol.for("react.context"), Da = /* @__PURE__ */ Symbol.for("react.forward_ref"), Ea = /* @__PURE__ */ Symbol.for("react.suspense"), Fa = /* @__PURE__ */ Symbol.for("react.suspense_list"), Ga = /* @__PURE__ */ Symbol.for("react.memo"), Ha = /* @__PURE__ */ Symbol.for("react.lazy");
730
+ var Ia = /* @__PURE__ */ Symbol.for("react.offscreen");
731
731
  var Ja = Symbol.iterator;
732
732
  function Ka(a) {
733
733
  if (null === a || "object" !== typeof a) return null;
@@ -7310,7 +7310,7 @@ function createSlotClone$5(ownerName) {
7310
7310
  SlotClone.displayName = `${ownerName}.SlotClone`;
7311
7311
  return SlotClone;
7312
7312
  }
7313
- var SLOTTABLE_IDENTIFIER$6 = Symbol("radix.slottable");
7313
+ var SLOTTABLE_IDENTIFIER$6 = /* @__PURE__ */ Symbol("radix.slottable");
7314
7314
  function isSlottable$5(child) {
7315
7315
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$6;
7316
7316
  }
@@ -7454,7 +7454,7 @@ function createSlotClone$4(ownerName) {
7454
7454
  SlotClone.displayName = `${ownerName}.SlotClone`;
7455
7455
  return SlotClone;
7456
7456
  }
7457
- var SLOTTABLE_IDENTIFIER$5 = Symbol("radix.slottable");
7457
+ var SLOTTABLE_IDENTIFIER$5 = /* @__PURE__ */ Symbol("radix.slottable");
7458
7458
  function isSlottable$4(child) {
7459
7459
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$5;
7460
7460
  }
@@ -7520,7 +7520,7 @@ var Primitive$1 = NODES$1.reduce((primitive, node) => {
7520
7520
  const { asChild, ...primitiveProps } = props;
7521
7521
  const Comp = asChild ? Slot2 : node;
7522
7522
  if (typeof window !== "undefined") {
7523
- window[Symbol.for("radix-ui")] = true;
7523
+ window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
7524
7524
  }
7525
7525
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, { ...primitiveProps, ref: forwardedRef });
7526
7526
  });
@@ -14763,7 +14763,7 @@ const JSONRPC_VERSION = "2.0";
14763
14763
  const AssertObjectSchema = custom$1((v) => v !== null && (typeof v === "object" || typeof v === "function"));
14764
14764
  const ProgressTokenSchema = union([string(), number$1().int()]);
14765
14765
  const CursorSchema = string();
14766
- const TaskCreationParamsSchema = looseObject({
14766
+ looseObject({
14767
14767
  /**
14768
14768
  * Time in milliseconds to keep task results available after completion.
14769
14769
  * If null, the task has unlimited lifetime until manually cleaned up.
@@ -14774,7 +14774,10 @@ const TaskCreationParamsSchema = looseObject({
14774
14774
  */
14775
14775
  pollInterval: number$1().optional()
14776
14776
  });
14777
- const RelatedTaskMetadataSchema = looseObject({
14777
+ const TaskMetadataSchema = object({
14778
+ ttl: number$1().optional()
14779
+ });
14780
+ const RelatedTaskMetadataSchema = object({
14778
14781
  taskId: string()
14779
14782
  });
14780
14783
  const RequestMetaSchema = looseObject({
@@ -14787,48 +14790,45 @@ const RequestMetaSchema = looseObject({
14787
14790
  */
14788
14791
  [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
14789
14792
  });
14790
- const BaseRequestParamsSchema = looseObject({
14791
- /**
14792
- * If specified, the caller is requesting that the receiver create a task to represent the request.
14793
- * Task creation parameters are now at the top level instead of in _meta.
14794
- */
14795
- task: TaskCreationParamsSchema.optional(),
14793
+ const BaseRequestParamsSchema = object({
14796
14794
  /**
14797
14795
  * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
14798
14796
  */
14799
14797
  _meta: RequestMetaSchema.optional()
14800
14798
  });
14799
+ const TaskAugmentedRequestParamsSchema = BaseRequestParamsSchema.extend({
14800
+ /**
14801
+ * If specified, the caller is requesting task-augmented execution for this request.
14802
+ * The request will return a CreateTaskResult immediately, and the actual result can be
14803
+ * retrieved later via tasks/result.
14804
+ *
14805
+ * Task augmentation is subject to capability negotiation - receivers MUST declare support
14806
+ * for task augmentation of specific request types in their capabilities.
14807
+ */
14808
+ task: TaskMetadataSchema.optional()
14809
+ });
14810
+ const isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success;
14801
14811
  const RequestSchema = object({
14802
14812
  method: string(),
14803
- params: BaseRequestParamsSchema.optional()
14813
+ params: BaseRequestParamsSchema.loose().optional()
14804
14814
  });
14805
- const NotificationsParamsSchema = looseObject({
14815
+ const NotificationsParamsSchema = object({
14806
14816
  /**
14807
14817
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
14808
14818
  * for notes on _meta usage.
14809
14819
  */
14810
- _meta: object({
14811
- /**
14812
- * If specified, this notification is related to the provided task.
14813
- */
14814
- [RELATED_TASK_META_KEY]: optional(RelatedTaskMetadataSchema)
14815
- }).passthrough().optional()
14820
+ _meta: RequestMetaSchema.optional()
14816
14821
  });
14817
14822
  const NotificationSchema = object({
14818
14823
  method: string(),
14819
- params: NotificationsParamsSchema.optional()
14824
+ params: NotificationsParamsSchema.loose().optional()
14820
14825
  });
14821
14826
  const ResultSchema = looseObject({
14822
14827
  /**
14823
14828
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
14824
14829
  * for notes on _meta usage.
14825
14830
  */
14826
- _meta: looseObject({
14827
- /**
14828
- * If specified, this result is related to the provided task.
14829
- */
14830
- [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
14831
- }).optional()
14831
+ _meta: RequestMetaSchema.optional()
14832
14832
  });
14833
14833
  const RequestIdSchema = union([string(), number$1().int()]);
14834
14834
  const JSONRPCRequestSchema = object({
@@ -14842,12 +14842,12 @@ const JSONRPCNotificationSchema = object({
14842
14842
  ...NotificationSchema.shape
14843
14843
  }).strict();
14844
14844
  const isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success;
14845
- const JSONRPCResponseSchema = object({
14845
+ const JSONRPCResultResponseSchema = object({
14846
14846
  jsonrpc: literal(JSONRPC_VERSION),
14847
14847
  id: RequestIdSchema,
14848
14848
  result: ResultSchema
14849
14849
  }).strict();
14850
- const isJSONRPCResponse = (value) => JSONRPCResponseSchema.safeParse(value).success;
14850
+ const isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success;
14851
14851
  var ErrorCode;
14852
14852
  (function(ErrorCode2) {
14853
14853
  ErrorCode2[ErrorCode2["ConnectionClosed"] = -32e3] = "ConnectionClosed";
@@ -14859,9 +14859,9 @@ var ErrorCode;
14859
14859
  ErrorCode2[ErrorCode2["InternalError"] = -32603] = "InternalError";
14860
14860
  ErrorCode2[ErrorCode2["UrlElicitationRequired"] = -32042] = "UrlElicitationRequired";
14861
14861
  })(ErrorCode || (ErrorCode = {}));
14862
- const JSONRPCErrorSchema = object({
14862
+ const JSONRPCErrorResponseSchema = object({
14863
14863
  jsonrpc: literal(JSONRPC_VERSION),
14864
- id: RequestIdSchema,
14864
+ id: RequestIdSchema.optional(),
14865
14865
  error: object({
14866
14866
  /**
14867
14867
  * The error type that occurred.
@@ -14874,11 +14874,17 @@ const JSONRPCErrorSchema = object({
14874
14874
  /**
14875
14875
  * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).
14876
14876
  */
14877
- data: optional(unknown())
14877
+ data: unknown().optional()
14878
14878
  })
14879
14879
  }).strict();
14880
- const isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
14881
- const JSONRPCMessageSchema = union([JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResponseSchema, JSONRPCErrorSchema]);
14880
+ const isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success;
14881
+ const JSONRPCMessageSchema = union([
14882
+ JSONRPCRequestSchema,
14883
+ JSONRPCNotificationSchema,
14884
+ JSONRPCResultResponseSchema,
14885
+ JSONRPCErrorResponseSchema
14886
+ ]);
14887
+ union([JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema]);
14882
14888
  const EmptyResultSchema = ResultSchema.strict();
14883
14889
  const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
14884
14890
  /**
@@ -14886,7 +14892,7 @@ const CancelledNotificationParamsSchema = NotificationsParamsSchema.extend({
14886
14892
  *
14887
14893
  * This MUST correspond to the ID of a request previously issued in the same direction.
14888
14894
  */
14889
- requestId: RequestIdSchema,
14895
+ requestId: RequestIdSchema.optional(),
14890
14896
  /**
14891
14897
  * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.
14892
14898
  */
@@ -14911,7 +14917,15 @@ const IconSchema = object({
14911
14917
  *
14912
14918
  * If not provided, the client should assume that the icon can be used at any size.
14913
14919
  */
14914
- sizes: array(string()).optional()
14920
+ sizes: array(string()).optional(),
14921
+ /**
14922
+ * Optional specifier for the theme this icon is designed for. `light` indicates
14923
+ * the icon is designed to be used with a light background, and `dark` indicates
14924
+ * the icon is designed to be used with a dark background.
14925
+ *
14926
+ * If not provided, the client should assume the icon can be used with any theme.
14927
+ */
14928
+ theme: _enum$3(["light", "dark"]).optional()
14915
14929
  });
14916
14930
  const IconsSchema = object({
14917
14931
  /**
@@ -14947,7 +14961,15 @@ const ImplementationSchema = BaseMetadataSchema.extend({
14947
14961
  /**
14948
14962
  * An optional URL of the website for this implementation.
14949
14963
  */
14950
- websiteUrl: string().optional()
14964
+ websiteUrl: string().optional(),
14965
+ /**
14966
+ * An optional human-readable description of what this implementation does.
14967
+ *
14968
+ * This can be used by clients or servers to provide context about their purpose
14969
+ * and capabilities. For example, a server might describe the types of resources
14970
+ * or tools it provides, while a client might describe its intended use case.
14971
+ */
14972
+ description: string().optional()
14951
14973
  });
14952
14974
  const FormElicitationCapabilitySchema = intersection(object({
14953
14975
  applyDefaults: boolean().optional()
@@ -14963,54 +14985,54 @@ const ElicitationCapabilitySchema = preprocess((value) => {
14963
14985
  form: FormElicitationCapabilitySchema.optional(),
14964
14986
  url: AssertObjectSchema.optional()
14965
14987
  }), record(string(), unknown()).optional()));
14966
- const ClientTasksCapabilitySchema = object({
14988
+ const ClientTasksCapabilitySchema = looseObject({
14967
14989
  /**
14968
14990
  * Present if the client supports listing tasks.
14969
14991
  */
14970
- list: optional(object({}).passthrough()),
14992
+ list: AssertObjectSchema.optional(),
14971
14993
  /**
14972
14994
  * Present if the client supports cancelling tasks.
14973
14995
  */
14974
- cancel: optional(object({}).passthrough()),
14996
+ cancel: AssertObjectSchema.optional(),
14975
14997
  /**
14976
14998
  * Capabilities for task creation on specific request types.
14977
14999
  */
14978
- requests: optional(object({
15000
+ requests: looseObject({
14979
15001
  /**
14980
15002
  * Task support for sampling requests.
14981
15003
  */
14982
- sampling: optional(object({
14983
- createMessage: optional(object({}).passthrough())
14984
- }).passthrough()),
15004
+ sampling: looseObject({
15005
+ createMessage: AssertObjectSchema.optional()
15006
+ }).optional(),
14985
15007
  /**
14986
15008
  * Task support for elicitation requests.
14987
15009
  */
14988
- elicitation: optional(object({
14989
- create: optional(object({}).passthrough())
14990
- }).passthrough())
14991
- }).passthrough())
14992
- }).passthrough();
14993
- const ServerTasksCapabilitySchema = object({
15010
+ elicitation: looseObject({
15011
+ create: AssertObjectSchema.optional()
15012
+ }).optional()
15013
+ }).optional()
15014
+ });
15015
+ const ServerTasksCapabilitySchema = looseObject({
14994
15016
  /**
14995
15017
  * Present if the server supports listing tasks.
14996
15018
  */
14997
- list: optional(object({}).passthrough()),
15019
+ list: AssertObjectSchema.optional(),
14998
15020
  /**
14999
15021
  * Present if the server supports cancelling tasks.
15000
15022
  */
15001
- cancel: optional(object({}).passthrough()),
15023
+ cancel: AssertObjectSchema.optional(),
15002
15024
  /**
15003
15025
  * Capabilities for task creation on specific request types.
15004
15026
  */
15005
- requests: optional(object({
15027
+ requests: looseObject({
15006
15028
  /**
15007
15029
  * Task support for tool requests.
15008
15030
  */
15009
- tools: optional(object({
15010
- call: optional(object({}).passthrough())
15011
- }).passthrough())
15012
- }).passthrough())
15013
- }).passthrough();
15031
+ tools: looseObject({
15032
+ call: AssertObjectSchema.optional()
15033
+ }).optional()
15034
+ }).optional()
15035
+ });
15014
15036
  const ClientCapabilitiesSchema = object({
15015
15037
  /**
15016
15038
  * Experimental, non-standard capabilities that the client supports.
@@ -15046,7 +15068,7 @@ const ClientCapabilitiesSchema = object({
15046
15068
  /**
15047
15069
  * Present if the client supports task creation.
15048
15070
  */
15049
- tasks: optional(ClientTasksCapabilitySchema)
15071
+ tasks: ClientTasksCapabilitySchema.optional()
15050
15072
  });
15051
15073
  const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
15052
15074
  /**
@@ -15076,12 +15098,12 @@ const ServerCapabilitiesSchema = object({
15076
15098
  /**
15077
15099
  * Present if the server offers any prompt templates.
15078
15100
  */
15079
- prompts: optional(object({
15101
+ prompts: object({
15080
15102
  /**
15081
15103
  * Whether this server supports issuing notifications for changes to the prompt list.
15082
15104
  */
15083
- listChanged: optional(boolean())
15084
- })),
15105
+ listChanged: boolean().optional()
15106
+ }).optional(),
15085
15107
  /**
15086
15108
  * Present if the server offers any resources to read.
15087
15109
  */
@@ -15107,8 +15129,8 @@ const ServerCapabilitiesSchema = object({
15107
15129
  /**
15108
15130
  * Present if the server supports task creation.
15109
15131
  */
15110
- tasks: optional(ServerTasksCapabilitySchema)
15111
- }).passthrough();
15132
+ tasks: ServerTasksCapabilitySchema.optional()
15133
+ });
15112
15134
  const InitializeResultSchema = ResultSchema.extend({
15113
15135
  /**
15114
15136
  * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.
@@ -15124,11 +15146,13 @@ const InitializeResultSchema = ResultSchema.extend({
15124
15146
  instructions: string().optional()
15125
15147
  });
15126
15148
  const InitializedNotificationSchema = NotificationSchema.extend({
15127
- method: literal("notifications/initialized")
15149
+ method: literal("notifications/initialized"),
15150
+ params: NotificationsParamsSchema.optional()
15128
15151
  });
15129
15152
  const isInitializedNotification = (value) => InitializedNotificationSchema.safeParse(value).success;
15130
15153
  const PingRequestSchema = RequestSchema.extend({
15131
- method: literal("ping")
15154
+ method: literal("ping"),
15155
+ params: BaseRequestParamsSchema.optional()
15132
15156
  });
15133
15157
  const ProgressSchema = object({
15134
15158
  /**
@@ -15171,11 +15195,12 @@ const PaginatedResultSchema = ResultSchema.extend({
15171
15195
  * An opaque token representing the pagination position after the last returned result.
15172
15196
  * If present, there may be more results available.
15173
15197
  */
15174
- nextCursor: optional(CursorSchema)
15198
+ nextCursor: CursorSchema.optional()
15175
15199
  });
15200
+ const TaskStatusSchema = _enum$3(["working", "input_required", "completed", "failed", "cancelled"]);
15176
15201
  const TaskSchema = object({
15177
15202
  taskId: string(),
15178
- status: _enum$3(["working", "input_required", "completed", "failed", "cancelled"]),
15203
+ status: TaskStatusSchema,
15179
15204
  /**
15180
15205
  * Time in milliseconds to keep task results available after completion.
15181
15206
  * If null, the task has unlimited lifetime until manually cleaned up.
@@ -15216,6 +15241,7 @@ const GetTaskPayloadRequestSchema = RequestSchema.extend({
15216
15241
  taskId: string()
15217
15242
  })
15218
15243
  });
15244
+ ResultSchema.loose();
15219
15245
  const ListTasksRequestSchema = PaginatedRequestSchema.extend({
15220
15246
  method: literal("tasks/list")
15221
15247
  });
@@ -15254,7 +15280,7 @@ const Base64Schema = string().refine((val) => {
15254
15280
  try {
15255
15281
  atob(val);
15256
15282
  return true;
15257
- } catch (_a) {
15283
+ } catch {
15258
15284
  return false;
15259
15285
  }
15260
15286
  }, { message: "Invalid Base64 string" });
@@ -15264,11 +15290,12 @@ const BlobResourceContentsSchema = ResourceContentsSchema.extend({
15264
15290
  */
15265
15291
  blob: Base64Schema
15266
15292
  });
15293
+ const RoleSchema = _enum$3(["user", "assistant"]);
15267
15294
  const AnnotationsSchema = object({
15268
15295
  /**
15269
15296
  * Intended audience(s) for the resource.
15270
15297
  */
15271
- audience: array(_enum$3(["user", "assistant"])).optional(),
15298
+ audience: array(RoleSchema).optional(),
15272
15299
  /**
15273
15300
  * Importance hint for the resource, from 0 (least) to 1 (most).
15274
15301
  */
@@ -15361,7 +15388,8 @@ const ReadResourceResultSchema = ResultSchema.extend({
15361
15388
  contents: array(union([TextResourceContentsSchema, BlobResourceContentsSchema]))
15362
15389
  });
15363
15390
  const ResourceListChangedNotificationSchema = NotificationSchema.extend({
15364
- method: literal("notifications/resources/list_changed")
15391
+ method: literal("notifications/resources/list_changed"),
15392
+ params: NotificationsParamsSchema.optional()
15365
15393
  });
15366
15394
  const SubscribeRequestParamsSchema = ResourceRequestParamsSchema;
15367
15395
  const SubscribeRequestSchema = RequestSchema.extend({
@@ -15506,13 +15534,13 @@ const ToolUseContentSchema = object({
15506
15534
  * Arguments to pass to the tool.
15507
15535
  * Must conform to the tool's inputSchema.
15508
15536
  */
15509
- input: object({}).passthrough(),
15537
+ input: record(string(), unknown()),
15510
15538
  /**
15511
15539
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
15512
15540
  * for notes on _meta usage.
15513
15541
  */
15514
- _meta: optional(object({}).passthrough())
15515
- }).passthrough();
15542
+ _meta: record(string(), unknown()).optional()
15543
+ });
15516
15544
  const EmbeddedResourceSchema = object({
15517
15545
  type: literal("resource"),
15518
15546
  resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
@@ -15537,18 +15565,19 @@ const ContentBlockSchema = union([
15537
15565
  EmbeddedResourceSchema
15538
15566
  ]);
15539
15567
  const PromptMessageSchema = object({
15540
- role: _enum$3(["user", "assistant"]),
15568
+ role: RoleSchema,
15541
15569
  content: ContentBlockSchema
15542
15570
  });
15543
15571
  const GetPromptResultSchema = ResultSchema.extend({
15544
15572
  /**
15545
15573
  * An optional description for the prompt.
15546
15574
  */
15547
- description: optional(string()),
15575
+ description: string().optional(),
15548
15576
  messages: array(PromptMessageSchema)
15549
15577
  });
15550
15578
  const PromptListChangedNotificationSchema = NotificationSchema.extend({
15551
- method: literal("notifications/prompts/list_changed")
15579
+ method: literal("notifications/prompts/list_changed"),
15580
+ params: NotificationsParamsSchema.optional()
15552
15581
  });
15553
15582
  const ToolAnnotationsSchema = object({
15554
15583
  /**
@@ -15629,11 +15658,11 @@ const ToolSchema = object({
15629
15658
  /**
15630
15659
  * Optional additional tool information.
15631
15660
  */
15632
- annotations: optional(ToolAnnotationsSchema),
15661
+ annotations: ToolAnnotationsSchema.optional(),
15633
15662
  /**
15634
15663
  * Execution-related properties for this tool.
15635
15664
  */
15636
- execution: optional(ToolExecutionSchema),
15665
+ execution: ToolExecutionSchema.optional(),
15637
15666
  /**
15638
15667
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
15639
15668
  * for notes on _meta usage.
@@ -15674,12 +15703,12 @@ const CallToolResultSchema = ResultSchema.extend({
15674
15703
  * server does not support tool calls, or any other exceptional conditions,
15675
15704
  * should be reported as an MCP error response.
15676
15705
  */
15677
- isError: optional(boolean())
15706
+ isError: boolean().optional()
15678
15707
  });
15679
15708
  const CompatibilityCallToolResultSchema = CallToolResultSchema.or(ResultSchema.extend({
15680
15709
  toolResult: unknown()
15681
15710
  }));
15682
- const CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
15711
+ const CallToolRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
15683
15712
  /**
15684
15713
  * The name of the tool to call.
15685
15714
  */
@@ -15687,14 +15716,35 @@ const CallToolRequestParamsSchema = BaseRequestParamsSchema.extend({
15687
15716
  /**
15688
15717
  * Arguments to pass to the tool.
15689
15718
  */
15690
- arguments: optional(record(string(), unknown()))
15719
+ arguments: record(string(), unknown()).optional()
15691
15720
  });
15692
15721
  const CallToolRequestSchema = RequestSchema.extend({
15693
15722
  method: literal("tools/call"),
15694
15723
  params: CallToolRequestParamsSchema
15695
15724
  });
15696
15725
  const ToolListChangedNotificationSchema = NotificationSchema.extend({
15697
- method: literal("notifications/tools/list_changed")
15726
+ method: literal("notifications/tools/list_changed"),
15727
+ params: NotificationsParamsSchema.optional()
15728
+ });
15729
+ const ListChangedOptionsBaseSchema = object({
15730
+ /**
15731
+ * If true, the list will be refreshed automatically when a list changed notification is received.
15732
+ * The callback will be called with the updated list.
15733
+ *
15734
+ * If false, the callback will be called with null items, allowing manual refresh.
15735
+ *
15736
+ * @default true
15737
+ */
15738
+ autoRefresh: boolean().default(true),
15739
+ /**
15740
+ * Debounce time in milliseconds for list changed notification processing.
15741
+ *
15742
+ * Multiple notifications received within this timeframe will only trigger one refresh.
15743
+ * Set to 0 to disable debouncing.
15744
+ *
15745
+ * @default 300
15746
+ */
15747
+ debounceMs: number$1().int().nonnegative().default(300)
15698
15748
  });
15699
15749
  const LoggingLevelSchema = _enum$3(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
15700
15750
  const SetLevelRequestParamsSchema = BaseRequestParamsSchema.extend({
@@ -15735,19 +15785,19 @@ const ModelPreferencesSchema = object({
15735
15785
  /**
15736
15786
  * Optional hints to use for model selection.
15737
15787
  */
15738
- hints: optional(array(ModelHintSchema)),
15788
+ hints: array(ModelHintSchema).optional(),
15739
15789
  /**
15740
15790
  * How much to prioritize cost when selecting a model.
15741
15791
  */
15742
- costPriority: optional(number$1().min(0).max(1)),
15792
+ costPriority: number$1().min(0).max(1).optional(),
15743
15793
  /**
15744
15794
  * How much to prioritize sampling speed (latency) when selecting a model.
15745
15795
  */
15746
- speedPriority: optional(number$1().min(0).max(1)),
15796
+ speedPriority: number$1().min(0).max(1).optional(),
15747
15797
  /**
15748
15798
  * How much to prioritize intelligence and capabilities when selecting a model.
15749
15799
  */
15750
- intelligencePriority: optional(number$1().min(0).max(1))
15800
+ intelligencePriority: number$1().min(0).max(1).optional()
15751
15801
  });
15752
15802
  const ToolChoiceSchema = object({
15753
15803
  /**
@@ -15756,20 +15806,20 @@ const ToolChoiceSchema = object({
15756
15806
  * - "required": Model MUST use at least one tool before completing
15757
15807
  * - "none": Model MUST NOT use any tools
15758
15808
  */
15759
- mode: optional(_enum$3(["auto", "required", "none"]))
15809
+ mode: _enum$3(["auto", "required", "none"]).optional()
15760
15810
  });
15761
15811
  const ToolResultContentSchema = object({
15762
15812
  type: literal("tool_result"),
15763
15813
  toolUseId: string().describe("The unique identifier for the corresponding tool call."),
15764
15814
  content: array(ContentBlockSchema).default([]),
15765
- structuredContent: object({}).passthrough().optional(),
15766
- isError: optional(boolean()),
15815
+ structuredContent: object({}).loose().optional(),
15816
+ isError: boolean().optional(),
15767
15817
  /**
15768
15818
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
15769
15819
  * for notes on _meta usage.
15770
15820
  */
15771
- _meta: optional(object({}).passthrough())
15772
- }).passthrough();
15821
+ _meta: record(string(), unknown()).optional()
15822
+ });
15773
15823
  const SamplingContentSchema = discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
15774
15824
  const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
15775
15825
  TextContentSchema,
@@ -15779,15 +15829,15 @@ const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
15779
15829
  ToolResultContentSchema
15780
15830
  ]);
15781
15831
  const SamplingMessageSchema = object({
15782
- role: _enum$3(["user", "assistant"]),
15832
+ role: RoleSchema,
15783
15833
  content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)]),
15784
15834
  /**
15785
15835
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
15786
15836
  * for notes on _meta usage.
15787
15837
  */
15788
- _meta: optional(object({}).passthrough())
15789
- }).passthrough();
15790
- const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
15838
+ _meta: record(string(), unknown()).optional()
15839
+ });
15840
+ const CreateMessageRequestParamsSchema = TaskAugmentedRequestParamsSchema.extend({
15791
15841
  messages: array(SamplingMessageSchema),
15792
15842
  /**
15793
15843
  * The server's preferences for which model to select. The client MAY modify or omit this request.
@@ -15821,13 +15871,13 @@ const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
15821
15871
  * Tools that the model may use during generation.
15822
15872
  * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
15823
15873
  */
15824
- tools: optional(array(ToolSchema)),
15874
+ tools: array(ToolSchema).optional(),
15825
15875
  /**
15826
15876
  * Controls how the model uses tools.
15827
15877
  * The client MUST return an error if this field is provided but ClientCapabilities.sampling.tools is not declared.
15828
15878
  * Default is `{ mode: "auto" }`.
15829
15879
  */
15830
- toolChoice: optional(ToolChoiceSchema)
15880
+ toolChoice: ToolChoiceSchema.optional()
15831
15881
  });
15832
15882
  const CreateMessageRequestSchema = RequestSchema.extend({
15833
15883
  method: literal("sampling/createMessage"),
@@ -15849,7 +15899,7 @@ const CreateMessageResultSchema = ResultSchema.extend({
15849
15899
  * This field is an open string to allow for provider-specific stop reasons.
15850
15900
  */
15851
15901
  stopReason: optional(_enum$3(["endTurn", "stopSequence", "maxTokens"]).or(string())),
15852
- role: _enum$3(["user", "assistant"]),
15902
+ role: RoleSchema,
15853
15903
  /**
15854
15904
  * Response content. Single content block (text, image, or audio).
15855
15905
  */
@@ -15872,7 +15922,7 @@ const CreateMessageResultWithToolsSchema = ResultSchema.extend({
15872
15922
  * This field is an open string to allow for provider-specific stop reasons.
15873
15923
  */
15874
15924
  stopReason: optional(_enum$3(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string())),
15875
- role: _enum$3(["user", "assistant"]),
15925
+ role: RoleSchema,
15876
15926
  /**
15877
15927
  * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
15878
15928
  */
@@ -15956,7 +16006,7 @@ const TitledMultiSelectEnumSchemaSchema = object({
15956
16006
  const MultiSelectEnumSchemaSchema = union([UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema]);
15957
16007
  const EnumSchemaSchema = union([LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema]);
15958
16008
  const PrimitiveSchemaDefinitionSchema = union([EnumSchemaSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema]);
15959
- const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
16009
+ const ElicitRequestFormParamsSchema = TaskAugmentedRequestParamsSchema.extend({
15960
16010
  /**
15961
16011
  * The elicitation mode.
15962
16012
  *
@@ -15977,7 +16027,7 @@ const ElicitRequestFormParamsSchema = BaseRequestParamsSchema.extend({
15977
16027
  required: array(string()).optional()
15978
16028
  })
15979
16029
  });
15980
- const ElicitRequestURLParamsSchema = BaseRequestParamsSchema.extend({
16030
+ const ElicitRequestURLParamsSchema = TaskAugmentedRequestParamsSchema.extend({
15981
16031
  /**
15982
16032
  * The elicitation mode.
15983
16033
  */
@@ -16099,13 +16149,15 @@ const RootSchema = object({
16099
16149
  _meta: record(string(), unknown()).optional()
16100
16150
  });
16101
16151
  const ListRootsRequestSchema = RequestSchema.extend({
16102
- method: literal("roots/list")
16152
+ method: literal("roots/list"),
16153
+ params: BaseRequestParamsSchema.optional()
16103
16154
  });
16104
16155
  const ListRootsResultSchema = ResultSchema.extend({
16105
16156
  roots: array(RootSchema)
16106
16157
  });
16107
16158
  const RootsListChangedNotificationSchema = NotificationSchema.extend({
16108
- method: literal("notifications/roots/list_changed")
16159
+ method: literal("notifications/roots/list_changed"),
16160
+ params: NotificationsParamsSchema.optional()
16109
16161
  });
16110
16162
  union([
16111
16163
  PingRequestSchema,
@@ -16123,7 +16175,8 @@ union([
16123
16175
  ListToolsRequestSchema,
16124
16176
  GetTaskRequestSchema,
16125
16177
  GetTaskPayloadRequestSchema,
16126
- ListTasksRequestSchema
16178
+ ListTasksRequestSchema,
16179
+ CancelTaskRequestSchema
16127
16180
  ]);
16128
16181
  union([
16129
16182
  CancelledNotificationSchema,
@@ -16149,7 +16202,8 @@ union([
16149
16202
  ListRootsRequestSchema,
16150
16203
  GetTaskRequestSchema,
16151
16204
  GetTaskPayloadRequestSchema,
16152
- ListTasksRequestSchema
16205
+ ListTasksRequestSchema,
16206
+ CancelTaskRequestSchema
16153
16207
  ]);
16154
16208
  union([
16155
16209
  CancelledNotificationSchema,
@@ -16204,8 +16258,7 @@ class UrlElicitationRequiredError extends McpError {
16204
16258
  });
16205
16259
  }
16206
16260
  get elicitations() {
16207
- var _a, _b;
16208
- return (_b = (_a = this.data) === null || _a === void 0 ? void 0 : _a.elicitations) !== null && _b !== void 0 ? _b : [];
16261
+ return this.data?.elicitations ?? [];
16209
16262
  }
16210
16263
  }
16211
16264
  const SafeUrlSchema = url().superRefine((val, ctx) => {
@@ -16351,7 +16404,7 @@ object({
16351
16404
  token_type_hint: string().optional()
16352
16405
  }).strip();
16353
16406
  const name = "@modelcontextprotocol/inspector-client";
16354
- const version$1 = "0.17.5";
16407
+ const version$1 = "0.18.0";
16355
16408
  const packageJson = {
16356
16409
  name,
16357
16410
  version: version$1
@@ -16658,7 +16711,7 @@ const OAUTH_ERRORS = {
16658
16711
  };
16659
16712
  class UnauthorizedError extends Error {
16660
16713
  constructor(message) {
16661
- super(message !== null && message !== void 0 ? message : "Unauthorized");
16714
+ super(message ?? "Unauthorized");
16662
16715
  }
16663
16716
  }
16664
16717
  function isClientAuthMethod(method) {
@@ -16731,22 +16784,20 @@ async function parseErrorResponse(input) {
16731
16784
  }
16732
16785
  }
16733
16786
  async function auth(provider, options) {
16734
- var _a, _b;
16735
16787
  try {
16736
16788
  return await authInternal(provider, options);
16737
16789
  } catch (error) {
16738
16790
  if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
16739
- await ((_a = provider.invalidateCredentials) === null || _a === void 0 ? void 0 : _a.call(provider, "all"));
16791
+ await provider.invalidateCredentials?.("all");
16740
16792
  return await authInternal(provider, options);
16741
16793
  } else if (error instanceof InvalidGrantError) {
16742
- await ((_b = provider.invalidateCredentials) === null || _b === void 0 ? void 0 : _b.call(provider, "tokens"));
16794
+ await provider.invalidateCredentials?.("tokens");
16743
16795
  return await authInternal(provider, options);
16744
16796
  }
16745
16797
  throw error;
16746
16798
  }
16747
16799
  }
16748
16800
  async function authInternal(provider, { serverUrl, authorizationCode, scope: scope2, resourceMetadataUrl, fetchFn }) {
16749
- var _a, _b;
16750
16801
  let resourceMetadata;
16751
16802
  let authorizationServerUrl;
16752
16803
  try {
@@ -16754,7 +16805,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16754
16805
  if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
16755
16806
  authorizationServerUrl = resourceMetadata.authorization_servers[0];
16756
16807
  }
16757
- } catch (_c) {
16808
+ } catch {
16758
16809
  }
16759
16810
  if (!authorizationServerUrl) {
16760
16811
  authorizationServerUrl = new URL("/", serverUrl);
@@ -16768,7 +16819,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16768
16819
  if (authorizationCode !== void 0) {
16769
16820
  throw new Error("Existing OAuth client information is required when exchanging an authorization code");
16770
16821
  }
16771
- const supportsUrlBasedClientId = (metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.client_id_metadata_document_supported) === true;
16822
+ const supportsUrlBasedClientId = metadata2?.client_id_metadata_document_supported === true;
16772
16823
  const clientMetadataUrl = provider.clientMetadataUrl;
16773
16824
  if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl)) {
16774
16825
  throw new InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
@@ -16778,7 +16829,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16778
16829
  clientInformation = {
16779
16830
  client_id: clientMetadataUrl
16780
16831
  };
16781
- await ((_a = provider.saveClientInformation) === null || _a === void 0 ? void 0 : _a.call(provider, clientInformation));
16832
+ await provider.saveClientInformation?.(clientInformation);
16782
16833
  } else {
16783
16834
  if (!provider.saveClientInformation) {
16784
16835
  throw new Error("OAuth client information must be saveable for dynamic registration");
@@ -16804,7 +16855,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16804
16855
  return "AUTHORIZED";
16805
16856
  }
16806
16857
  const tokens = await provider.tokens();
16807
- if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {
16858
+ if (tokens?.refresh_token) {
16808
16859
  try {
16809
16860
  const newTokens = await refreshAuthorization(authorizationServerUrl, {
16810
16861
  metadata: metadata2,
@@ -16829,7 +16880,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16829
16880
  clientInformation,
16830
16881
  state,
16831
16882
  redirectUrl: provider.redirectUrl,
16832
- scope: scope2 || ((_b = resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.scopes_supported) === null || _b === void 0 ? void 0 : _b.join(" ")) || provider.clientMetadata.scope,
16883
+ scope: scope2 || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
16833
16884
  resource
16834
16885
  });
16835
16886
  await provider.saveCodeVerifier(codeVerifier);
@@ -16842,14 +16893,14 @@ function isHttpsUrl(value) {
16842
16893
  try {
16843
16894
  const url2 = new URL(value);
16844
16895
  return url2.protocol === "https:" && url2.pathname !== "/";
16845
- } catch (_a) {
16896
+ } catch {
16846
16897
  return false;
16847
16898
  }
16848
16899
  }
16849
16900
  async function selectResourceURL(serverUrl, provider, resourceMetadata) {
16850
16901
  const defaultResource = resourceUrlFromServerUrl(serverUrl);
16851
16902
  if (provider.validateResourceURL) {
16852
- return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);
16903
+ return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
16853
16904
  }
16854
16905
  if (!resourceMetadata) {
16855
16906
  return void 0;
@@ -16873,7 +16924,7 @@ function extractWWWAuthenticateParams(res) {
16873
16924
  if (resourceMetadataMatch) {
16874
16925
  try {
16875
16926
  resourceMetadataUrl = new URL(resourceMetadataMatch);
16876
- } catch (_a) {
16927
+ } catch {
16877
16928
  }
16878
16929
  }
16879
16930
  const scope2 = extractFieldFromWwwAuth(res, "scope") || void 0;
@@ -16897,17 +16948,16 @@ function extractFieldFromWwwAuth(response, fieldName) {
16897
16948
  return null;
16898
16949
  }
16899
16950
  async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
16900
- var _a, _b;
16901
16951
  const response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", fetchFn, {
16902
- protocolVersion: opts === null || opts === void 0 ? void 0 : opts.protocolVersion,
16903
- metadataUrl: opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl
16952
+ protocolVersion: opts?.protocolVersion,
16953
+ metadataUrl: opts?.resourceMetadataUrl
16904
16954
  });
16905
16955
  if (!response || response.status === 404) {
16906
- await ((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.cancel());
16956
+ await response?.body?.cancel();
16907
16957
  throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
16908
16958
  }
16909
16959
  if (!response.ok) {
16910
- await ((_b = response.body) === null || _b === void 0 ? void 0 : _b.cancel());
16960
+ await response.body?.cancel();
16911
16961
  throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
16912
16962
  }
16913
16963
  return OAuthProtectedResourceMetadataSchema.parse(await response.json());
@@ -16942,19 +16992,18 @@ function shouldAttemptFallback(response, pathname) {
16942
16992
  return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
16943
16993
  }
16944
16994
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
16945
- var _a, _b;
16946
16995
  const issuer = new URL(serverUrl);
16947
- const protocolVersion = (_a = opts === null || opts === void 0 ? void 0 : opts.protocolVersion) !== null && _a !== void 0 ? _a : LATEST_PROTOCOL_VERSION;
16996
+ const protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION;
16948
16997
  let url2;
16949
- if (opts === null || opts === void 0 ? void 0 : opts.metadataUrl) {
16998
+ if (opts?.metadataUrl) {
16950
16999
  url2 = new URL(opts.metadataUrl);
16951
17000
  } else {
16952
17001
  const wellKnownPath = buildWellKnownPath(wellKnownType, issuer.pathname);
16953
- url2 = new URL(wellKnownPath, (_b = opts === null || opts === void 0 ? void 0 : opts.metadataServerUrl) !== null && _b !== void 0 ? _b : issuer);
17002
+ url2 = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
16954
17003
  url2.search = issuer.search;
16955
17004
  }
16956
17005
  let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
16957
- if (!(opts === null || opts === void 0 ? void 0 : opts.metadataUrl) && shouldAttemptFallback(response, issuer.pathname)) {
17006
+ if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
16958
17007
  const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
16959
17008
  response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
16960
17009
  }
@@ -16994,7 +17043,6 @@ function buildDiscoveryUrls(authorizationServerUrl) {
16994
17043
  return urlsToTry;
16995
17044
  }
16996
17045
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
16997
- var _a;
16998
17046
  const headers = {
16999
17047
  "MCP-Protocol-Version": protocolVersion,
17000
17048
  Accept: "application/json"
@@ -17006,7 +17054,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
17006
17054
  continue;
17007
17055
  }
17008
17056
  if (!response.ok) {
17009
- await ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel());
17057
+ await response.body?.cancel();
17010
17058
  if (response.status >= 400 && response.status < 500) {
17011
17059
  continue;
17012
17060
  }
@@ -17047,7 +17095,7 @@ async function startAuthorization(authorizationServerUrl, { metadata: metadata2,
17047
17095
  if (scope2) {
17048
17096
  authorizationUrl.searchParams.set("scope", scope2);
17049
17097
  }
17050
- if (scope2 === null || scope2 === void 0 ? void 0 : scope2.includes("offline_access")) {
17098
+ if (scope2?.includes("offline_access")) {
17051
17099
  authorizationUrl.searchParams.append("prompt", "consent");
17052
17100
  }
17053
17101
  if (resource) {
@@ -17064,8 +17112,7 @@ function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redire
17064
17112
  });
17065
17113
  }
17066
17114
  async function executeTokenRequest(authorizationServerUrl, { metadata: metadata2, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
17067
- var _a;
17068
- const tokenUrl = (metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.token_endpoint) ? new URL(metadata2.token_endpoint) : new URL("/token", authorizationServerUrl);
17115
+ const tokenUrl = metadata2?.token_endpoint ? new URL(metadata2.token_endpoint) : new URL("/token", authorizationServerUrl);
17069
17116
  const headers = new Headers({
17070
17117
  "Content-Type": "application/x-www-form-urlencoded",
17071
17118
  Accept: "application/json"
@@ -17076,11 +17123,11 @@ async function executeTokenRequest(authorizationServerUrl, { metadata: metadata2
17076
17123
  if (addClientAuthentication) {
17077
17124
  await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata2);
17078
17125
  } else if (clientInformation) {
17079
- const supportedMethods = (_a = metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];
17126
+ const supportedMethods = metadata2?.token_endpoint_auth_methods_supported ?? [];
17080
17127
  const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
17081
17128
  applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
17082
17129
  }
17083
- const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {
17130
+ const response = await (fetchFn ?? fetch)(tokenUrl, {
17084
17131
  method: "POST",
17085
17132
  headers,
17086
17133
  body: tokenRequestParams
@@ -17136,7 +17183,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata: metadata
17136
17183
  return executeTokenRequest(authorizationServerUrl, {
17137
17184
  metadata: metadata2,
17138
17185
  tokenRequestParams,
17139
- clientInformation: clientInformation !== null && clientInformation !== void 0 ? clientInformation : void 0,
17186
+ clientInformation: clientInformation ?? void 0,
17140
17187
  addClientAuthentication: provider.addClientAuthentication,
17141
17188
  resource,
17142
17189
  fetchFn
@@ -17152,7 +17199,7 @@ async function registerClient(authorizationServerUrl, { metadata: metadata2, cli
17152
17199
  } else {
17153
17200
  registrationUrl = new URL("/register", authorizationServerUrl);
17154
17201
  }
17155
- const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(registrationUrl, {
17202
+ const response = await (fetchFn ?? fetch)(registrationUrl, {
17156
17203
  method: "POST",
17157
17204
  headers: {
17158
17205
  "Content-Type": "application/json"
@@ -23601,8 +23648,8 @@ function requireAjv$2() {
23601
23648
  return ajv$3;
23602
23649
  }
23603
23650
  var ajvExports$1 = requireAjv$2();
23604
- const Ajv = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports$1);
23605
- const ajv$2 = new Ajv();
23651
+ const Ajv$1 = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports$1);
23652
+ const ajv$2 = new Ajv$1();
23606
23653
  const toolOutputValidators = /* @__PURE__ */ new Map();
23607
23654
  function cacheToolOutputSchemas(tools) {
23608
23655
  toolOutputValidators.clear();
@@ -23645,6 +23692,7 @@ function generateDefaultValue(schema, propertyName, parentSchema) {
23645
23692
  return schema.default;
23646
23693
  }
23647
23694
  const isRequired = propertyName && parentSchema ? isPropertyRequired(propertyName, parentSchema) : false;
23695
+ const isRootSchema = propertyName === void 0 && parentSchema === void 0;
23648
23696
  switch (schema.type) {
23649
23697
  case "string":
23650
23698
  return isRequired ? "" : void 0;
@@ -23656,17 +23704,23 @@ function generateDefaultValue(schema, propertyName, parentSchema) {
23656
23704
  case "array":
23657
23705
  return isRequired ? [] : void 0;
23658
23706
  case "object": {
23659
- if (!schema.properties) return isRequired ? {} : void 0;
23707
+ if (!schema.properties) {
23708
+ return isRequired || isRootSchema ? {} : void 0;
23709
+ }
23660
23710
  const obj = {};
23661
23711
  Object.entries(schema.properties).forEach(([key, prop]) => {
23662
- if (isPropertyRequired(key, schema)) {
23712
+ const hasExplicitDefault = "default" in prop && prop.default !== void 0;
23713
+ if (isPropertyRequired(key, schema) || hasExplicitDefault) {
23663
23714
  const value = generateDefaultValue(prop, key, schema);
23664
23715
  if (value !== void 0) {
23665
23716
  obj[key] = value;
23666
23717
  }
23667
23718
  }
23668
23719
  });
23669
- return isRequired ? obj : Object.keys(obj).length > 0 ? obj : void 0;
23720
+ if (Object.keys(obj).length === 0) {
23721
+ return isRequired || isRootSchema ? {} : void 0;
23722
+ }
23723
+ return obj;
23670
23724
  }
23671
23725
  case "null":
23672
23726
  return null;
@@ -27360,13 +27414,12 @@ function safeParse(schema, data2) {
27360
27414
  return result;
27361
27415
  }
27362
27416
  function getObjectShape(schema) {
27363
- var _a, _b;
27364
27417
  if (!schema)
27365
27418
  return void 0;
27366
27419
  let rawShape;
27367
27420
  if (isZ4Schema(schema)) {
27368
27421
  const v4Schema = schema;
27369
- rawShape = (_b = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def) === null || _b === void 0 ? void 0 : _b.shape;
27422
+ rawShape = v4Schema._zod?.def?.shape;
27370
27423
  } else {
27371
27424
  const v3Schema = schema;
27372
27425
  rawShape = v3Schema.shape;
@@ -27376,17 +27429,16 @@ function getObjectShape(schema) {
27376
27429
  if (typeof rawShape === "function") {
27377
27430
  try {
27378
27431
  return rawShape();
27379
- } catch (_c) {
27432
+ } catch {
27380
27433
  return void 0;
27381
27434
  }
27382
27435
  }
27383
27436
  return rawShape;
27384
27437
  }
27385
27438
  function getLiteralValue(schema) {
27386
- var _a;
27387
27439
  if (isZ4Schema(schema)) {
27388
27440
  const v4Schema = schema;
27389
- const def2 = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
27441
+ const def2 = v4Schema._zod?.def;
27390
27442
  if (def2) {
27391
27443
  if (def2.value !== void 0)
27392
27444
  return def2.value;
@@ -27415,7 +27467,7 @@ function isTerminal(status) {
27415
27467
  new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
27416
27468
  function getMethodLiteral(schema) {
27417
27469
  const shape = getObjectShape(schema);
27418
- const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
27470
+ const methodSchema = shape?.method;
27419
27471
  if (!methodSchema) {
27420
27472
  throw new Error("Schema is missing a method literal");
27421
27473
  }
@@ -27457,8 +27509,8 @@ class Protocol {
27457
27509
  // Automatic pong by default.
27458
27510
  (_request) => ({})
27459
27511
  );
27460
- this._taskStore = _options === null || _options === void 0 ? void 0 : _options.taskStore;
27461
- this._taskMessageQueue = _options === null || _options === void 0 ? void 0 : _options.taskMessageQueue;
27512
+ this._taskStore = _options?.taskStore;
27513
+ this._taskMessageQueue = _options?.taskMessageQueue;
27462
27514
  if (this._taskStore) {
27463
27515
  this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
27464
27516
  const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
@@ -27471,7 +27523,6 @@ class Protocol {
27471
27523
  });
27472
27524
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
27473
27525
  const handleTaskResult = async () => {
27474
- var _a;
27475
27526
  const taskId = request.params.taskId;
27476
27527
  if (this._taskMessageQueue) {
27477
27528
  let queuedMessage;
@@ -27495,7 +27546,7 @@ class Protocol {
27495
27546
  }
27496
27547
  continue;
27497
27548
  }
27498
- await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
27549
+ await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
27499
27550
  }
27500
27551
  }
27501
27552
  const task = await this._taskStore.getTask(taskId, extra.sessionId);
@@ -27524,9 +27575,8 @@ class Protocol {
27524
27575
  return await handleTaskResult();
27525
27576
  });
27526
27577
  this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
27527
- var _a;
27528
27578
  try {
27529
- const { tasks, nextCursor } = await this._taskStore.listTasks((_a = request.params) === null || _a === void 0 ? void 0 : _a.cursor, extra.sessionId);
27579
+ const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
27530
27580
  return {
27531
27581
  tasks,
27532
27582
  nextCursor,
@@ -27565,8 +27615,11 @@ class Protocol {
27565
27615
  }
27566
27616
  }
27567
27617
  async _oncancel(notification) {
27618
+ if (!notification.params.requestId) {
27619
+ return;
27620
+ }
27568
27621
  const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
27569
- controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
27622
+ controller?.abort(notification.params.reason);
27570
27623
  }
27571
27624
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
27572
27625
  this._timeoutInfo.set(messageId, {
@@ -27607,22 +27660,21 @@ class Protocol {
27607
27660
  * The Protocol object assumes ownership of the Transport, replacing any callbacks that have already been set, and expects that it is the only user of the Transport instance going forward.
27608
27661
  */
27609
27662
  async connect(transport) {
27610
- var _a, _b, _c;
27611
27663
  this._transport = transport;
27612
- const _onclose = (_a = this.transport) === null || _a === void 0 ? void 0 : _a.onclose;
27664
+ const _onclose = this.transport?.onclose;
27613
27665
  this._transport.onclose = () => {
27614
- _onclose === null || _onclose === void 0 ? void 0 : _onclose();
27666
+ _onclose?.();
27615
27667
  this._onclose();
27616
27668
  };
27617
- const _onerror = (_b = this.transport) === null || _b === void 0 ? void 0 : _b.onerror;
27669
+ const _onerror = this.transport?.onerror;
27618
27670
  this._transport.onerror = (error) => {
27619
- _onerror === null || _onerror === void 0 ? void 0 : _onerror(error);
27671
+ _onerror?.(error);
27620
27672
  this._onerror(error);
27621
27673
  };
27622
- const _onmessage = (_c = this._transport) === null || _c === void 0 ? void 0 : _c.onmessage;
27674
+ const _onmessage = this._transport?.onmessage;
27623
27675
  this._transport.onmessage = (message, extra) => {
27624
- _onmessage === null || _onmessage === void 0 ? void 0 : _onmessage(message, extra);
27625
- if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
27676
+ _onmessage?.(message, extra);
27677
+ if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
27626
27678
  this._onresponse(message);
27627
27679
  } else if (isJSONRPCRequest(message)) {
27628
27680
  this._onrequest(message, extra);
@@ -27635,7 +27687,6 @@ class Protocol {
27635
27687
  await this._transport.start();
27636
27688
  }
27637
27689
  _onclose() {
27638
- var _a;
27639
27690
  const responseHandlers = this._responseHandlers;
27640
27691
  this._responseHandlers = /* @__PURE__ */ new Map();
27641
27692
  this._progressHandlers.clear();
@@ -27643,28 +27694,25 @@ class Protocol {
27643
27694
  this._pendingDebouncedNotifications.clear();
27644
27695
  const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
27645
27696
  this._transport = void 0;
27646
- (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
27697
+ this.onclose?.();
27647
27698
  for (const handler of responseHandlers.values()) {
27648
27699
  handler(error);
27649
27700
  }
27650
27701
  }
27651
27702
  _onerror(error) {
27652
- var _a;
27653
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
27703
+ this.onerror?.(error);
27654
27704
  }
27655
27705
  _onnotification(notification) {
27656
- var _a;
27657
- const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== void 0 ? _a : this.fallbackNotificationHandler;
27706
+ const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
27658
27707
  if (handler === void 0) {
27659
27708
  return;
27660
27709
  }
27661
27710
  Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
27662
27711
  }
27663
27712
  _onrequest(request, extra) {
27664
- var _a, _b, _c, _d, _e2, _f;
27665
- const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
27713
+ const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
27666
27714
  const capturedTransport = this._transport;
27667
- const relatedTaskId = (_d = (_c = (_b = request.params) === null || _b === void 0 ? void 0 : _b._meta) === null || _c === void 0 ? void 0 : _c[RELATED_TASK_META_KEY]) === null || _d === void 0 ? void 0 : _d.taskId;
27715
+ const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
27668
27716
  if (handler === void 0) {
27669
27717
  const errorResponse = {
27670
27718
  jsonrpc: "2.0",
@@ -27679,20 +27727,20 @@ class Protocol {
27679
27727
  type: "error",
27680
27728
  message: errorResponse,
27681
27729
  timestamp: Date.now()
27682
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
27730
+ }, capturedTransport?.sessionId).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
27683
27731
  } else {
27684
- capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
27732
+ capturedTransport?.send(errorResponse).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
27685
27733
  }
27686
27734
  return;
27687
27735
  }
27688
27736
  const abortController = new AbortController();
27689
27737
  this._requestHandlerAbortControllers.set(request.id, abortController);
27690
- const taskCreationParams = (_e2 = request.params) === null || _e2 === void 0 ? void 0 : _e2.task;
27691
- const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId) : void 0;
27738
+ const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
27739
+ const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
27692
27740
  const fullExtra = {
27693
27741
  signal: abortController.signal,
27694
- sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
27695
- _meta: (_f = request.params) === null || _f === void 0 ? void 0 : _f._meta,
27742
+ sessionId: capturedTransport?.sessionId,
27743
+ _meta: request.params?._meta,
27696
27744
  sendNotification: async (notification) => {
27697
27745
  const notificationOptions = { relatedRequestId: request.id };
27698
27746
  if (relatedTaskId) {
@@ -27701,25 +27749,24 @@ class Protocol {
27701
27749
  await this.notification(notification, notificationOptions);
27702
27750
  },
27703
27751
  sendRequest: async (r2, resultSchema, options) => {
27704
- var _a2, _b2;
27705
27752
  const requestOptions = { ...options, relatedRequestId: request.id };
27706
27753
  if (relatedTaskId && !requestOptions.relatedTask) {
27707
27754
  requestOptions.relatedTask = { taskId: relatedTaskId };
27708
27755
  }
27709
- const effectiveTaskId = (_b2 = (_a2 = requestOptions.relatedTask) === null || _a2 === void 0 ? void 0 : _a2.taskId) !== null && _b2 !== void 0 ? _b2 : relatedTaskId;
27756
+ const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
27710
27757
  if (effectiveTaskId && taskStore) {
27711
27758
  await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
27712
27759
  }
27713
27760
  return await this.request(r2, resultSchema, requestOptions);
27714
27761
  },
27715
- authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
27762
+ authInfo: extra?.authInfo,
27716
27763
  requestId: request.id,
27717
- requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo,
27764
+ requestInfo: extra?.requestInfo,
27718
27765
  taskId: relatedTaskId,
27719
27766
  taskStore,
27720
- taskRequestedTtl: taskCreationParams === null || taskCreationParams === void 0 ? void 0 : taskCreationParams.ttl,
27721
- closeSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeSSEStream,
27722
- closeStandaloneSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeStandaloneSSEStream
27767
+ taskRequestedTtl: taskCreationParams?.ttl,
27768
+ closeSSEStream: extra?.closeSSEStream,
27769
+ closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
27723
27770
  };
27724
27771
  Promise.resolve().then(() => {
27725
27772
  if (taskCreationParams) {
@@ -27739,12 +27786,11 @@ class Protocol {
27739
27786
  type: "response",
27740
27787
  message: response,
27741
27788
  timestamp: Date.now()
27742
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
27789
+ }, capturedTransport?.sessionId);
27743
27790
  } else {
27744
- await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(response));
27791
+ await capturedTransport?.send(response);
27745
27792
  }
27746
27793
  }, async (error) => {
27747
- var _a2;
27748
27794
  if (abortController.signal.aborted) {
27749
27795
  return;
27750
27796
  }
@@ -27753,7 +27799,7 @@ class Protocol {
27753
27799
  id: request.id,
27754
27800
  error: {
27755
27801
  code: Number.isSafeInteger(error["code"]) ? error["code"] : ErrorCode.InternalError,
27756
- message: (_a2 = error.message) !== null && _a2 !== void 0 ? _a2 : "Internal error",
27802
+ message: error.message ?? "Internal error",
27757
27803
  ...error["data"] !== void 0 && { data: error["data"] }
27758
27804
  }
27759
27805
  };
@@ -27762,9 +27808,9 @@ class Protocol {
27762
27808
  type: "error",
27763
27809
  message: errorResponse,
27764
27810
  timestamp: Date.now()
27765
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
27811
+ }, capturedTransport?.sessionId);
27766
27812
  } else {
27767
- await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse));
27813
+ await capturedTransport?.send(errorResponse);
27768
27814
  }
27769
27815
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
27770
27816
  this._requestHandlerAbortControllers.delete(request.id);
@@ -27798,7 +27844,7 @@ class Protocol {
27798
27844
  const resolver = this._requestResolvers.get(messageId);
27799
27845
  if (resolver) {
27800
27846
  this._requestResolvers.delete(messageId);
27801
- if (isJSONRPCResponse(response)) {
27847
+ if (isJSONRPCResultResponse(response)) {
27802
27848
  resolver(response);
27803
27849
  } else {
27804
27850
  const error = new McpError(response.error.code, response.error.message, response.error.data);
@@ -27814,7 +27860,7 @@ class Protocol {
27814
27860
  this._responseHandlers.delete(messageId);
27815
27861
  this._cleanupTimeout(messageId);
27816
27862
  let isTaskResponse = false;
27817
- if (isJSONRPCResponse(response) && response.result && typeof response.result === "object") {
27863
+ if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
27818
27864
  const result = response.result;
27819
27865
  if (result.task && typeof result.task === "object") {
27820
27866
  const task = result.task;
@@ -27827,7 +27873,7 @@ class Protocol {
27827
27873
  if (!isTaskResponse) {
27828
27874
  this._progressHandlers.delete(messageId);
27829
27875
  }
27830
- if (isJSONRPCResponse(response)) {
27876
+ if (isJSONRPCResultResponse(response)) {
27831
27877
  handler(response);
27832
27878
  } else {
27833
27879
  const error = McpError.fromError(response.error.code, response.error.message, response.error.data);
@@ -27841,8 +27887,7 @@ class Protocol {
27841
27887
  * Closes the connection.
27842
27888
  */
27843
27889
  async close() {
27844
- var _a;
27845
- await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
27890
+ await this._transport?.close();
27846
27891
  }
27847
27892
  /**
27848
27893
  * Sends a request and returns an AsyncGenerator that yields response messages.
@@ -27872,8 +27917,7 @@ class Protocol {
27872
27917
  * @experimental Use `client.experimental.tasks.requestStream()` to access this method.
27873
27918
  */
27874
27919
  async *requestStream(request, resultSchema, options) {
27875
- var _a, _b, _c, _d;
27876
- const { task } = options !== null && options !== void 0 ? options : {};
27920
+ const { task } = options ?? {};
27877
27921
  if (!task) {
27878
27922
  try {
27879
27923
  const result = await this.request(request, resultSchema, options);
@@ -27920,9 +27964,9 @@ class Protocol {
27920
27964
  yield { type: "result", result };
27921
27965
  return;
27922
27966
  }
27923
- const pollInterval = (_c = (_a = task2.pollInterval) !== null && _a !== void 0 ? _a : (_b = this._options) === null || _b === void 0 ? void 0 : _b.defaultTaskPollInterval) !== null && _c !== void 0 ? _c : 1e3;
27967
+ const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
27924
27968
  await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
27925
- (_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
27969
+ options?.signal?.throwIfAborted();
27926
27970
  }
27927
27971
  } catch (error) {
27928
27972
  yield {
@@ -27937,9 +27981,8 @@ class Protocol {
27937
27981
  * Do not use this method to emit notifications! Use notification() instead.
27938
27982
  */
27939
27983
  request(request, resultSchema, options) {
27940
- const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
27984
+ const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
27941
27985
  return new Promise((resolve2, reject) => {
27942
- var _a, _b, _c, _d, _e2, _f, _g;
27943
27986
  const earlyReject = (error) => {
27944
27987
  reject(error);
27945
27988
  };
@@ -27947,7 +27990,7 @@ class Protocol {
27947
27990
  earlyReject(new Error("Not connected"));
27948
27991
  return;
27949
27992
  }
27950
- if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.enforceStrictCapabilities) === true) {
27993
+ if (this._options?.enforceStrictCapabilities === true) {
27951
27994
  try {
27952
27995
  this.assertCapabilityForMethod(request.method);
27953
27996
  if (task) {
@@ -27958,19 +28001,19 @@ class Protocol {
27958
28001
  return;
27959
28002
  }
27960
28003
  }
27961
- (_b = options === null || options === void 0 ? void 0 : options.signal) === null || _b === void 0 ? void 0 : _b.throwIfAborted();
28004
+ options?.signal?.throwIfAborted();
27962
28005
  const messageId = this._requestMessageId++;
27963
28006
  const jsonrpcRequest = {
27964
28007
  ...request,
27965
28008
  jsonrpc: "2.0",
27966
28009
  id: messageId
27967
28010
  };
27968
- if (options === null || options === void 0 ? void 0 : options.onprogress) {
28011
+ if (options?.onprogress) {
27969
28012
  this._progressHandlers.set(messageId, options.onprogress);
27970
28013
  jsonrpcRequest.params = {
27971
28014
  ...request.params,
27972
28015
  _meta: {
27973
- ...((_c = request.params) === null || _c === void 0 ? void 0 : _c._meta) || {},
28016
+ ...request.params?._meta || {},
27974
28017
  progressToken: messageId
27975
28018
  }
27976
28019
  };
@@ -27985,17 +28028,16 @@ class Protocol {
27985
28028
  jsonrpcRequest.params = {
27986
28029
  ...jsonrpcRequest.params,
27987
28030
  _meta: {
27988
- ...((_d = jsonrpcRequest.params) === null || _d === void 0 ? void 0 : _d._meta) || {},
28031
+ ...jsonrpcRequest.params?._meta || {},
27989
28032
  [RELATED_TASK_META_KEY]: relatedTask
27990
28033
  }
27991
28034
  };
27992
28035
  }
27993
28036
  const cancel = (reason) => {
27994
- var _a2;
27995
28037
  this._responseHandlers.delete(messageId);
27996
28038
  this._progressHandlers.delete(messageId);
27997
28039
  this._cleanupTimeout(messageId);
27998
- (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
28040
+ this._transport?.send({
27999
28041
  jsonrpc: "2.0",
28000
28042
  method: "notifications/cancelled",
28001
28043
  params: {
@@ -28007,8 +28049,7 @@ class Protocol {
28007
28049
  reject(error);
28008
28050
  };
28009
28051
  this._responseHandlers.set(messageId, (response) => {
28010
- var _a2;
28011
- if ((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.aborted) {
28052
+ if (options?.signal?.aborted) {
28012
28053
  return;
28013
28054
  }
28014
28055
  if (response instanceof Error) {
@@ -28025,14 +28066,13 @@ class Protocol {
28025
28066
  reject(error);
28026
28067
  }
28027
28068
  });
28028
- (_e2 = options === null || options === void 0 ? void 0 : options.signal) === null || _e2 === void 0 ? void 0 : _e2.addEventListener("abort", () => {
28029
- var _a2;
28030
- cancel((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.reason);
28069
+ options?.signal?.addEventListener("abort", () => {
28070
+ cancel(options?.signal?.reason);
28031
28071
  });
28032
- const timeout = (_f = options === null || options === void 0 ? void 0 : options.timeout) !== null && _f !== void 0 ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
28072
+ const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
28033
28073
  const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
28034
- this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_g = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _g !== void 0 ? _g : false);
28035
- const relatedTaskId = relatedTask === null || relatedTask === void 0 ? void 0 : relatedTask.taskId;
28074
+ this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
28075
+ const relatedTaskId = relatedTask?.taskId;
28036
28076
  if (relatedTaskId) {
28037
28077
  const responseResolver = (response) => {
28038
28078
  const handler = this._responseHandlers.get(messageId);
@@ -28095,12 +28135,11 @@ class Protocol {
28095
28135
  * Emits a notification, which is a one-way message that does not expect a response.
28096
28136
  */
28097
28137
  async notification(notification, options) {
28098
- var _a, _b, _c, _d, _e2;
28099
28138
  if (!this._transport) {
28100
28139
  throw new Error("Not connected");
28101
28140
  }
28102
28141
  this.assertNotificationCapability(notification.method);
28103
- const relatedTaskId = (_a = options === null || options === void 0 ? void 0 : options.relatedTask) === null || _a === void 0 ? void 0 : _a.taskId;
28142
+ const relatedTaskId = options?.relatedTask?.taskId;
28104
28143
  if (relatedTaskId) {
28105
28144
  const jsonrpcNotification2 = {
28106
28145
  ...notification,
@@ -28108,7 +28147,7 @@ class Protocol {
28108
28147
  params: {
28109
28148
  ...notification.params,
28110
28149
  _meta: {
28111
- ...((_b = notification.params) === null || _b === void 0 ? void 0 : _b._meta) || {},
28150
+ ...notification.params?._meta || {},
28112
28151
  [RELATED_TASK_META_KEY]: options.relatedTask
28113
28152
  }
28114
28153
  }
@@ -28120,15 +28159,14 @@ class Protocol {
28120
28159
  });
28121
28160
  return;
28122
28161
  }
28123
- const debouncedMethods = (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.debouncedNotificationMethods) !== null && _d !== void 0 ? _d : [];
28124
- const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options === null || options === void 0 ? void 0 : options.relatedRequestId) && !(options === null || options === void 0 ? void 0 : options.relatedTask);
28162
+ const debouncedMethods = this._options?.debouncedNotificationMethods ?? [];
28163
+ const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask;
28125
28164
  if (canDebounce) {
28126
28165
  if (this._pendingDebouncedNotifications.has(notification.method)) {
28127
28166
  return;
28128
28167
  }
28129
28168
  this._pendingDebouncedNotifications.add(notification.method);
28130
28169
  Promise.resolve().then(() => {
28131
- var _a2, _b2;
28132
28170
  this._pendingDebouncedNotifications.delete(notification.method);
28133
28171
  if (!this._transport) {
28134
28172
  return;
@@ -28137,19 +28175,19 @@ class Protocol {
28137
28175
  ...notification,
28138
28176
  jsonrpc: "2.0"
28139
28177
  };
28140
- if (options === null || options === void 0 ? void 0 : options.relatedTask) {
28178
+ if (options?.relatedTask) {
28141
28179
  jsonrpcNotification2 = {
28142
28180
  ...jsonrpcNotification2,
28143
28181
  params: {
28144
28182
  ...jsonrpcNotification2.params,
28145
28183
  _meta: {
28146
- ...((_a2 = jsonrpcNotification2.params) === null || _a2 === void 0 ? void 0 : _a2._meta) || {},
28184
+ ...jsonrpcNotification2.params?._meta || {},
28147
28185
  [RELATED_TASK_META_KEY]: options.relatedTask
28148
28186
  }
28149
28187
  }
28150
28188
  };
28151
28189
  }
28152
- (_b2 = this._transport) === null || _b2 === void 0 ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
28190
+ this._transport?.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
28153
28191
  });
28154
28192
  return;
28155
28193
  }
@@ -28157,13 +28195,13 @@ class Protocol {
28157
28195
  ...notification,
28158
28196
  jsonrpc: "2.0"
28159
28197
  };
28160
- if (options === null || options === void 0 ? void 0 : options.relatedTask) {
28198
+ if (options?.relatedTask) {
28161
28199
  jsonrpcNotification = {
28162
28200
  ...jsonrpcNotification,
28163
28201
  params: {
28164
28202
  ...jsonrpcNotification.params,
28165
28203
  _meta: {
28166
- ...((_e2 = jsonrpcNotification.params) === null || _e2 === void 0 ? void 0 : _e2._meta) || {},
28204
+ ...jsonrpcNotification.params?._meta || {},
28167
28205
  [RELATED_TASK_META_KEY]: options.relatedTask
28168
28206
  }
28169
28207
  }
@@ -28239,11 +28277,10 @@ class Protocol {
28239
28277
  * simply propagates the error.
28240
28278
  */
28241
28279
  async _enqueueTaskMessage(taskId, message, sessionId) {
28242
- var _a;
28243
28280
  if (!this._taskStore || !this._taskMessageQueue) {
28244
28281
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
28245
28282
  }
28246
- const maxQueueSize = (_a = this._options) === null || _a === void 0 ? void 0 : _a.maxTaskQueueSize;
28283
+ const maxQueueSize = this._options?.maxTaskQueueSize;
28247
28284
  await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
28248
28285
  }
28249
28286
  /**
@@ -28276,14 +28313,13 @@ class Protocol {
28276
28313
  * @returns Promise that resolves when an update occurs or rejects if aborted
28277
28314
  */
28278
28315
  async _waitForTaskUpdate(taskId, signal) {
28279
- var _a, _b, _c;
28280
- let interval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
28316
+ let interval = this._options?.defaultTaskPollInterval ?? 1e3;
28281
28317
  try {
28282
- const task = await ((_c = this._taskStore) === null || _c === void 0 ? void 0 : _c.getTask(taskId));
28283
- if (task === null || task === void 0 ? void 0 : task.pollInterval) {
28318
+ const task = await this._taskStore?.getTask(taskId);
28319
+ if (task?.pollInterval) {
28284
28320
  interval = task.pollInterval;
28285
28321
  }
28286
- } catch (_d) {
28322
+ } catch {
28287
28323
  }
28288
28324
  return new Promise((resolve2, reject) => {
28289
28325
  if (signal.aborted) {
@@ -34657,6 +34693,7 @@ function requireAjv$1() {
34657
34693
  return ajv$1.exports;
34658
34694
  }
34659
34695
  var ajvExports = requireAjv$1();
34696
+ const Ajv = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports);
34660
34697
  var dist = { exports: {} };
34661
34698
  var formats = {};
34662
34699
  var hasRequiredFormats;
@@ -40535,7 +40572,7 @@ function requireDist() {
40535
40572
  var distExports = requireDist();
40536
40573
  const _addFormats = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
40537
40574
  function createDefaultAjvInstance() {
40538
- const ajv2 = new ajvExports.Ajv({
40575
+ const ajv2 = new Ajv({
40539
40576
  strict: false,
40540
40577
  validateFormats: true,
40541
40578
  validateSchema: false,
@@ -40567,7 +40604,7 @@ class AjvJsonSchemaValidator {
40567
40604
  * ```
40568
40605
  */
40569
40606
  constructor(ajv2) {
40570
- this._ajv = ajv2 !== null && ajv2 !== void 0 ? ajv2 : createDefaultAjvInstance();
40607
+ this._ajv = ajv2 ?? createDefaultAjvInstance();
40571
40608
  }
40572
40609
  /**
40573
40610
  * Create a validator for the given JSON Schema
@@ -40579,8 +40616,7 @@ class AjvJsonSchemaValidator {
40579
40616
  * @returns A validator function that validates input data
40580
40617
  */
40581
40618
  getValidator(schema) {
40582
- var _a;
40583
- const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? (_a = this._ajv.getSchema(schema.$id)) !== null && _a !== void 0 ? _a : this._ajv.compile(schema) : this._ajv.compile(schema);
40619
+ const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
40584
40620
  return (input) => {
40585
40621
  const valid = ajvValidator(input);
40586
40622
  if (valid) {
@@ -40640,13 +40676,12 @@ class ExperimentalClientTasks {
40640
40676
  * @experimental
40641
40677
  */
40642
40678
  async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
40643
- var _a;
40644
40679
  const clientInternal = this._client;
40645
40680
  const optionsWithTask = {
40646
40681
  ...options,
40647
40682
  // We check if the tool is known to be a task during auto-configuration, but assume
40648
40683
  // the caller knows what they're doing if they pass this explicitly
40649
- task: (_a = options === null || options === void 0 ? void 0 : options.task) !== null && _a !== void 0 ? _a : clientInternal.isToolTask(params.name) ? {} : void 0
40684
+ task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
40650
40685
  };
40651
40686
  const stream = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
40652
40687
  const validator = clientInternal.getToolOutputValidator(params.name);
@@ -40753,31 +40788,29 @@ class ExperimentalClientTasks {
40753
40788
  }
40754
40789
  }
40755
40790
  function assertToolsCallTaskCapability(requests, method, entityName) {
40756
- var _a;
40757
40791
  if (!requests) {
40758
40792
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
40759
40793
  }
40760
40794
  switch (method) {
40761
40795
  case "tools/call":
40762
- if (!((_a = requests.tools) === null || _a === void 0 ? void 0 : _a.call)) {
40796
+ if (!requests.tools?.call) {
40763
40797
  throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
40764
40798
  }
40765
40799
  break;
40766
40800
  }
40767
40801
  }
40768
40802
  function assertClientRequestTaskCapability(requests, method, entityName) {
40769
- var _a, _b;
40770
40803
  if (!requests) {
40771
40804
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
40772
40805
  }
40773
40806
  switch (method) {
40774
40807
  case "sampling/createMessage":
40775
- if (!((_a = requests.sampling) === null || _a === void 0 ? void 0 : _a.createMessage)) {
40808
+ if (!requests.sampling?.createMessage) {
40776
40809
  throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
40777
40810
  }
40778
40811
  break;
40779
40812
  case "elicitation/create":
40780
- if (!((_b = requests.elicitation) === null || _b === void 0 ? void 0 : _b.create)) {
40813
+ if (!requests.elicitation?.create) {
40781
40814
  throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
40782
40815
  }
40783
40816
  break;
@@ -40801,12 +40834,16 @@ function applyElicitationDefaults(schema, data2) {
40801
40834
  }
40802
40835
  if (Array.isArray(schema.anyOf)) {
40803
40836
  for (const sub of schema.anyOf) {
40804
- applyElicitationDefaults(sub, data2);
40837
+ if (typeof sub !== "boolean") {
40838
+ applyElicitationDefaults(sub, data2);
40839
+ }
40805
40840
  }
40806
40841
  }
40807
40842
  if (Array.isArray(schema.oneOf)) {
40808
40843
  for (const sub of schema.oneOf) {
40809
- applyElicitationDefaults(sub, data2);
40844
+ if (typeof sub !== "boolean") {
40845
+ applyElicitationDefaults(sub, data2);
40846
+ }
40810
40847
  }
40811
40848
  }
40812
40849
  }
@@ -40825,14 +40862,43 @@ class Client extends Protocol {
40825
40862
  * Initializes this client with the given name and version information.
40826
40863
  */
40827
40864
  constructor(_clientInfo, options) {
40828
- var _a, _b;
40829
40865
  super(options);
40830
40866
  this._clientInfo = _clientInfo;
40831
40867
  this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
40832
40868
  this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
40833
40869
  this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
40834
- this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
40835
- this._jsonSchemaValidator = (_b = options === null || options === void 0 ? void 0 : options.jsonSchemaValidator) !== null && _b !== void 0 ? _b : new AjvJsonSchemaValidator();
40870
+ this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
40871
+ this._capabilities = options?.capabilities ?? {};
40872
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
40873
+ if (options?.listChanged) {
40874
+ this._pendingListChangedConfig = options.listChanged;
40875
+ }
40876
+ }
40877
+ /**
40878
+ * Set up handlers for list changed notifications based on config and server capabilities.
40879
+ * This should only be called after initialization when server capabilities are known.
40880
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
40881
+ * @internal
40882
+ */
40883
+ _setupListChangedHandlers(config2) {
40884
+ if (config2.tools && this._serverCapabilities?.tools?.listChanged) {
40885
+ this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config2.tools, async () => {
40886
+ const result = await this.listTools();
40887
+ return result.tools;
40888
+ });
40889
+ }
40890
+ if (config2.prompts && this._serverCapabilities?.prompts?.listChanged) {
40891
+ this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config2.prompts, async () => {
40892
+ const result = await this.listPrompts();
40893
+ return result.prompts;
40894
+ });
40895
+ }
40896
+ if (config2.resources && this._serverCapabilities?.resources?.listChanged) {
40897
+ this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config2.resources, async () => {
40898
+ const result = await this.listResources();
40899
+ return result.resources;
40900
+ });
40901
+ }
40836
40902
  }
40837
40903
  /**
40838
40904
  * Access experimental features.
@@ -40864,21 +40930,20 @@ class Client extends Protocol {
40864
40930
  * Override request handler registration to enforce client-side validation for elicitation.
40865
40931
  */
40866
40932
  setRequestHandler(requestSchema, handler) {
40867
- var _a, _b, _c;
40868
40933
  const shape = getObjectShape(requestSchema);
40869
- const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
40934
+ const methodSchema = shape?.method;
40870
40935
  if (!methodSchema) {
40871
40936
  throw new Error("Schema is missing a method literal");
40872
40937
  }
40873
40938
  let methodValue;
40874
40939
  if (isZ4Schema(methodSchema)) {
40875
40940
  const v4Schema = methodSchema;
40876
- const v4Def = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
40877
- methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
40941
+ const v4Def = v4Schema._zod?.def;
40942
+ methodValue = v4Def?.value ?? v4Schema.value;
40878
40943
  } else {
40879
40944
  const v3Schema = methodSchema;
40880
40945
  const legacyDef = v3Schema._def;
40881
- methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
40946
+ methodValue = legacyDef?.value ?? v3Schema.value;
40882
40947
  }
40883
40948
  if (typeof methodValue !== "string") {
40884
40949
  throw new Error("Schema method literal must be a string");
@@ -40886,19 +40951,18 @@ class Client extends Protocol {
40886
40951
  const method = methodValue;
40887
40952
  if (method === "elicitation/create") {
40888
40953
  const wrappedHandler = async (request, extra) => {
40889
- var _a2, _b2, _c2;
40890
40954
  const validatedRequest = safeParse(ElicitRequestSchema, request);
40891
40955
  if (!validatedRequest.success) {
40892
40956
  const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
40893
40957
  throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
40894
40958
  }
40895
40959
  const { params } = validatedRequest.data;
40896
- const mode = (_a2 = params.mode) !== null && _a2 !== void 0 ? _a2 : "form";
40960
+ params.mode = params.mode ?? "form";
40897
40961
  const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
40898
- if (mode === "form" && !supportsFormMode) {
40962
+ if (params.mode === "form" && !supportsFormMode) {
40899
40963
  throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
40900
40964
  }
40901
- if (mode === "url" && !supportsUrlMode) {
40965
+ if (params.mode === "url" && !supportsUrlMode) {
40902
40966
  throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
40903
40967
  }
40904
40968
  const result = await Promise.resolve(handler(request, extra));
@@ -40916,12 +40980,12 @@ class Client extends Protocol {
40916
40980
  throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
40917
40981
  }
40918
40982
  const validatedResult = validationResult.data;
40919
- const requestedSchema = mode === "form" ? params.requestedSchema : void 0;
40920
- if (mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
40921
- if ((_c2 = (_b2 = this._capabilities.elicitation) === null || _b2 === void 0 ? void 0 : _b2.form) === null || _c2 === void 0 ? void 0 : _c2.applyDefaults) {
40983
+ const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
40984
+ if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
40985
+ if (this._capabilities.elicitation?.form?.applyDefaults) {
40922
40986
  try {
40923
40987
  applyElicitationDefaults(requestedSchema, validatedResult.content);
40924
- } catch (_d) {
40988
+ } catch {
40925
40989
  }
40926
40990
  }
40927
40991
  }
@@ -40958,8 +41022,7 @@ class Client extends Protocol {
40958
41022
  return super.setRequestHandler(requestSchema, handler);
40959
41023
  }
40960
41024
  assertCapability(capability, method) {
40961
- var _a;
40962
- if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a[capability])) {
41025
+ if (!this._serverCapabilities?.[capability]) {
40963
41026
  throw new Error(`Server does not support ${capability} (required for ${method})`);
40964
41027
  }
40965
41028
  }
@@ -40992,6 +41055,10 @@ class Client extends Protocol {
40992
41055
  await this.notification({
40993
41056
  method: "notifications/initialized"
40994
41057
  });
41058
+ if (this._pendingListChangedConfig) {
41059
+ this._setupListChangedHandlers(this._pendingListChangedConfig);
41060
+ this._pendingListChangedConfig = void 0;
41061
+ }
40995
41062
  } catch (error) {
40996
41063
  void this.close();
40997
41064
  throw error;
@@ -41016,16 +41083,15 @@ class Client extends Protocol {
41016
41083
  return this._instructions;
41017
41084
  }
41018
41085
  assertCapabilityForMethod(method) {
41019
- var _a, _b, _c, _d, _e2;
41020
41086
  switch (method) {
41021
41087
  case "logging/setLevel":
41022
- if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.logging)) {
41088
+ if (!this._serverCapabilities?.logging) {
41023
41089
  throw new Error(`Server does not support logging (required for ${method})`);
41024
41090
  }
41025
41091
  break;
41026
41092
  case "prompts/get":
41027
41093
  case "prompts/list":
41028
- if (!((_b = this._serverCapabilities) === null || _b === void 0 ? void 0 : _b.prompts)) {
41094
+ if (!this._serverCapabilities?.prompts) {
41029
41095
  throw new Error(`Server does not support prompts (required for ${method})`);
41030
41096
  }
41031
41097
  break;
@@ -41034,7 +41100,7 @@ class Client extends Protocol {
41034
41100
  case "resources/read":
41035
41101
  case "resources/subscribe":
41036
41102
  case "resources/unsubscribe":
41037
- if (!((_c = this._serverCapabilities) === null || _c === void 0 ? void 0 : _c.resources)) {
41103
+ if (!this._serverCapabilities?.resources) {
41038
41104
  throw new Error(`Server does not support resources (required for ${method})`);
41039
41105
  }
41040
41106
  if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) {
@@ -41043,22 +41109,21 @@ class Client extends Protocol {
41043
41109
  break;
41044
41110
  case "tools/call":
41045
41111
  case "tools/list":
41046
- if (!((_d = this._serverCapabilities) === null || _d === void 0 ? void 0 : _d.tools)) {
41112
+ if (!this._serverCapabilities?.tools) {
41047
41113
  throw new Error(`Server does not support tools (required for ${method})`);
41048
41114
  }
41049
41115
  break;
41050
41116
  case "completion/complete":
41051
- if (!((_e2 = this._serverCapabilities) === null || _e2 === void 0 ? void 0 : _e2.completions)) {
41117
+ if (!this._serverCapabilities?.completions) {
41052
41118
  throw new Error(`Server does not support completions (required for ${method})`);
41053
41119
  }
41054
41120
  break;
41055
41121
  }
41056
41122
  }
41057
41123
  assertNotificationCapability(method) {
41058
- var _a;
41059
41124
  switch (method) {
41060
41125
  case "notifications/roots/list_changed":
41061
- if (!((_a = this._capabilities.roots) === null || _a === void 0 ? void 0 : _a.listChanged)) {
41126
+ if (!this._capabilities.roots?.listChanged) {
41062
41127
  throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
41063
41128
  }
41064
41129
  break;
@@ -41095,15 +41160,13 @@ class Client extends Protocol {
41095
41160
  }
41096
41161
  }
41097
41162
  assertTaskCapability(method) {
41098
- var _a, _b;
41099
- assertToolsCallTaskCapability((_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Server");
41163
+ assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
41100
41164
  }
41101
41165
  assertTaskHandlerCapability(method) {
41102
- var _a;
41103
41166
  if (!this._capabilities) {
41104
41167
  return;
41105
41168
  }
41106
- assertClientRequestTaskCapability((_a = this._capabilities.tasks) === null || _a === void 0 ? void 0 : _a.requests, method, "Client");
41169
+ assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
41107
41170
  }
41108
41171
  async ping(options) {
41109
41172
  return this.request({ method: "ping" }, EmptyResultSchema, options);
@@ -41167,8 +41230,7 @@ class Client extends Protocol {
41167
41230
  return result;
41168
41231
  }
41169
41232
  isToolTask(toolName) {
41170
- var _a, _b, _c, _d;
41171
- if (!((_d = (_c = (_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests) === null || _c === void 0 ? void 0 : _c.tools) === null || _d === void 0 ? void 0 : _d.call)) {
41233
+ if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
41172
41234
  return false;
41173
41235
  }
41174
41236
  return this._cachedKnownTaskTools.has(toolName);
@@ -41185,7 +41247,6 @@ class Client extends Protocol {
41185
41247
  * Called after listTools() to pre-compile validators for better performance.
41186
41248
  */
41187
41249
  cacheToolMetadata(tools) {
41188
- var _a;
41189
41250
  this._cachedToolOutputValidators.clear();
41190
41251
  this._cachedKnownTaskTools.clear();
41191
41252
  this._cachedRequiredTaskTools.clear();
@@ -41194,7 +41255,7 @@ class Client extends Protocol {
41194
41255
  const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
41195
41256
  this._cachedToolOutputValidators.set(tool.name, toolValidator);
41196
41257
  }
41197
- const taskSupport = (_a = tool.execution) === null || _a === void 0 ? void 0 : _a.taskSupport;
41258
+ const taskSupport = tool.execution?.taskSupport;
41198
41259
  if (taskSupport === "required" || taskSupport === "optional") {
41199
41260
  this._cachedKnownTaskTools.add(tool.name);
41200
41261
  }
@@ -41214,6 +41275,47 @@ class Client extends Protocol {
41214
41275
  this.cacheToolMetadata(result.tools);
41215
41276
  return result;
41216
41277
  }
41278
+ /**
41279
+ * Set up a single list changed handler.
41280
+ * @internal
41281
+ */
41282
+ _setupListChangedHandler(listType, notificationSchema, options, fetcher) {
41283
+ const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
41284
+ if (!parseResult.success) {
41285
+ throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
41286
+ }
41287
+ if (typeof options.onChanged !== "function") {
41288
+ throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
41289
+ }
41290
+ const { autoRefresh, debounceMs } = parseResult.data;
41291
+ const { onChanged } = options;
41292
+ const refresh = async () => {
41293
+ if (!autoRefresh) {
41294
+ onChanged(null, null);
41295
+ return;
41296
+ }
41297
+ try {
41298
+ const items2 = await fetcher();
41299
+ onChanged(null, items2);
41300
+ } catch (e) {
41301
+ const error = e instanceof Error ? e : new Error(String(e));
41302
+ onChanged(error, null);
41303
+ }
41304
+ };
41305
+ const handler = () => {
41306
+ if (debounceMs) {
41307
+ const existingTimer = this._listChangedDebounceTimers.get(listType);
41308
+ if (existingTimer) {
41309
+ clearTimeout(existingTimer);
41310
+ }
41311
+ const timer = setTimeout(refresh, debounceMs);
41312
+ this._listChangedDebounceTimers.set(listType, timer);
41313
+ } else {
41314
+ refresh();
41315
+ }
41316
+ };
41317
+ this.setNotificationHandler(notificationSchema, handler);
41318
+ }
41217
41319
  async sendRootsListChanged() {
41218
41320
  return this.notification({ method: "notifications/roots/list_changed" });
41219
41321
  }
@@ -41343,7 +41445,7 @@ class ErrorEvent extends Event {
41343
41445
  * @param inspect - The inspect function to use (prevents having to import it from `util`)
41344
41446
  * @returns A string representation of the error
41345
41447
  */
41346
- [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
41448
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
41347
41449
  return inspect(inspectableError(this), options);
41348
41450
  }
41349
41451
  /**
@@ -41357,7 +41459,7 @@ class ErrorEvent extends Event {
41357
41459
  * @param options - The options passed to `Deno.inspect`
41358
41460
  * @returns A string representation of the error
41359
41461
  */
41360
- [Symbol.for("Deno.customInspect")](inspect, options) {
41462
+ [/* @__PURE__ */ Symbol.for("Deno.customInspect")](inspect, options) {
41361
41463
  return inspect(inspectableError(this), options);
41362
41464
  }
41363
41465
  }
@@ -41606,7 +41708,7 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
41606
41708
  ...baseInit,
41607
41709
  ...init,
41608
41710
  // Headers need special handling - merge instead of replace
41609
- headers: (init === null || init === void 0 ? void 0 : init.headers) ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
41711
+ headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
41610
41712
  };
41611
41713
  return baseFetch(url2, mergedInit);
41612
41714
  };
@@ -41623,14 +41725,13 @@ class SSEClientTransport {
41623
41725
  this._url = url2;
41624
41726
  this._resourceMetadataUrl = void 0;
41625
41727
  this._scope = void 0;
41626
- this._eventSourceInit = opts === null || opts === void 0 ? void 0 : opts.eventSourceInit;
41627
- this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
41628
- this._authProvider = opts === null || opts === void 0 ? void 0 : opts.authProvider;
41629
- this._fetch = opts === null || opts === void 0 ? void 0 : opts.fetch;
41630
- this._fetchWithInit = createFetchWithInit(opts === null || opts === void 0 ? void 0 : opts.fetch, opts === null || opts === void 0 ? void 0 : opts.requestInit);
41728
+ this._eventSourceInit = opts?.eventSourceInit;
41729
+ this._requestInit = opts?.requestInit;
41730
+ this._authProvider = opts?.authProvider;
41731
+ this._fetch = opts?.fetch;
41732
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
41631
41733
  }
41632
41734
  async _authThenStart() {
41633
- var _a;
41634
41735
  if (!this._authProvider) {
41635
41736
  throw new UnauthorizedError("No auth provider");
41636
41737
  }
@@ -41643,7 +41744,7 @@ class SSEClientTransport {
41643
41744
  fetchFn: this._fetchWithInit
41644
41745
  });
41645
41746
  } catch (error) {
41646
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
41747
+ this.onerror?.(error);
41647
41748
  throw error;
41648
41749
  }
41649
41750
  if (result !== "AUTHORIZED") {
@@ -41652,7 +41753,6 @@ class SSEClientTransport {
41652
41753
  return await this._startOrAuth();
41653
41754
  }
41654
41755
  async _commonHeaders() {
41655
- var _a;
41656
41756
  const headers = {};
41657
41757
  if (this._authProvider) {
41658
41758
  const tokens = await this._authProvider.tokens();
@@ -41663,15 +41763,14 @@ class SSEClientTransport {
41663
41763
  if (this._protocolVersion) {
41664
41764
  headers["mcp-protocol-version"] = this._protocolVersion;
41665
41765
  }
41666
- const extraHeaders = normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
41766
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
41667
41767
  return new Headers({
41668
41768
  ...headers,
41669
41769
  ...extraHeaders
41670
41770
  });
41671
41771
  }
41672
41772
  _startOrAuth() {
41673
- var _a, _b, _c;
41674
- const fetchImpl = (_c = (_b = (_a = this === null || this === void 0 ? void 0 : this._eventSourceInit) === null || _a === void 0 ? void 0 : _a.fetch) !== null && _b !== void 0 ? _b : this._fetch) !== null && _c !== void 0 ? _c : fetch;
41773
+ const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
41675
41774
  return new Promise((resolve2, reject) => {
41676
41775
  this._eventSource = new EventSource(this._url.href, {
41677
41776
  ...this._eventSourceInit,
@@ -41692,19 +41791,17 @@ class SSEClientTransport {
41692
41791
  });
41693
41792
  this._abortController = new AbortController();
41694
41793
  this._eventSource.onerror = (event) => {
41695
- var _a2;
41696
41794
  if (event.code === 401 && this._authProvider) {
41697
41795
  this._authThenStart().then(resolve2, reject);
41698
41796
  return;
41699
41797
  }
41700
41798
  const error = new SseError(event.code, event.message, event);
41701
41799
  reject(error);
41702
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
41800
+ this.onerror?.(error);
41703
41801
  };
41704
41802
  this._eventSource.onopen = () => {
41705
41803
  };
41706
41804
  this._eventSource.addEventListener("endpoint", (event) => {
41707
- var _a2;
41708
41805
  const messageEvent = event;
41709
41806
  try {
41710
41807
  this._endpoint = new URL(messageEvent.data, this._url);
@@ -41713,23 +41810,22 @@ class SSEClientTransport {
41713
41810
  }
41714
41811
  } catch (error) {
41715
41812
  reject(error);
41716
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
41813
+ this.onerror?.(error);
41717
41814
  void this.close();
41718
41815
  return;
41719
41816
  }
41720
41817
  resolve2();
41721
41818
  });
41722
41819
  this._eventSource.onmessage = (event) => {
41723
- var _a2, _b2;
41724
41820
  const messageEvent = event;
41725
41821
  let message;
41726
41822
  try {
41727
41823
  message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
41728
41824
  } catch (error) {
41729
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
41825
+ this.onerror?.(error);
41730
41826
  return;
41731
41827
  }
41732
- (_b2 = this.onmessage) === null || _b2 === void 0 ? void 0 : _b2.call(this, message);
41828
+ this.onmessage?.(message);
41733
41829
  };
41734
41830
  });
41735
41831
  }
@@ -41758,13 +41854,11 @@ class SSEClientTransport {
41758
41854
  }
41759
41855
  }
41760
41856
  async close() {
41761
- var _a, _b, _c;
41762
- (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();
41763
- (_b = this._eventSource) === null || _b === void 0 ? void 0 : _b.close();
41764
- (_c = this.onclose) === null || _c === void 0 ? void 0 : _c.call(this);
41857
+ this._abortController?.abort();
41858
+ this._eventSource?.close();
41859
+ this.onclose?.();
41765
41860
  }
41766
41861
  async send(message) {
41767
- var _a, _b, _c, _d;
41768
41862
  if (!this._endpoint) {
41769
41863
  throw new Error("Not connected");
41770
41864
  }
@@ -41776,9 +41870,9 @@ class SSEClientTransport {
41776
41870
  method: "POST",
41777
41871
  headers,
41778
41872
  body: JSON.stringify(message),
41779
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
41873
+ signal: this._abortController?.signal
41780
41874
  };
41781
- const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._endpoint, init);
41875
+ const response = await (this._fetch ?? fetch)(this._endpoint, init);
41782
41876
  if (!response.ok) {
41783
41877
  const text = await response.text().catch(() => null);
41784
41878
  if (response.status === 401 && this._authProvider) {
@@ -41798,9 +41892,9 @@ class SSEClientTransport {
41798
41892
  }
41799
41893
  throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
41800
41894
  }
41801
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
41895
+ await response.body?.cancel();
41802
41896
  } catch (error) {
41803
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
41897
+ this.onerror?.(error);
41804
41898
  throw error;
41805
41899
  }
41806
41900
  }
@@ -41844,20 +41938,18 @@ class StreamableHTTPError extends Error {
41844
41938
  }
41845
41939
  class StreamableHTTPClientTransport {
41846
41940
  constructor(url2, opts) {
41847
- var _a;
41848
41941
  this._hasCompletedAuthFlow = false;
41849
41942
  this._url = url2;
41850
41943
  this._resourceMetadataUrl = void 0;
41851
41944
  this._scope = void 0;
41852
- this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
41853
- this._authProvider = opts === null || opts === void 0 ? void 0 : opts.authProvider;
41854
- this._fetch = opts === null || opts === void 0 ? void 0 : opts.fetch;
41855
- this._fetchWithInit = createFetchWithInit(opts === null || opts === void 0 ? void 0 : opts.fetch, opts === null || opts === void 0 ? void 0 : opts.requestInit);
41856
- this._sessionId = opts === null || opts === void 0 ? void 0 : opts.sessionId;
41857
- this._reconnectionOptions = (_a = opts === null || opts === void 0 ? void 0 : opts.reconnectionOptions) !== null && _a !== void 0 ? _a : DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
41945
+ this._requestInit = opts?.requestInit;
41946
+ this._authProvider = opts?.authProvider;
41947
+ this._fetch = opts?.fetch;
41948
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
41949
+ this._sessionId = opts?.sessionId;
41950
+ this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
41858
41951
  }
41859
41952
  async _authThenStart() {
41860
- var _a;
41861
41953
  if (!this._authProvider) {
41862
41954
  throw new UnauthorizedError("No auth provider");
41863
41955
  }
@@ -41870,7 +41962,7 @@ class StreamableHTTPClientTransport {
41870
41962
  fetchFn: this._fetchWithInit
41871
41963
  });
41872
41964
  } catch (error) {
41873
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
41965
+ this.onerror?.(error);
41874
41966
  throw error;
41875
41967
  }
41876
41968
  if (result !== "AUTHORIZED") {
@@ -41879,7 +41971,6 @@ class StreamableHTTPClientTransport {
41879
41971
  return await this._startOrAuthSse({ resumptionToken: void 0 });
41880
41972
  }
41881
41973
  async _commonHeaders() {
41882
- var _a;
41883
41974
  const headers = {};
41884
41975
  if (this._authProvider) {
41885
41976
  const tokens = await this._authProvider.tokens();
@@ -41893,14 +41984,13 @@ class StreamableHTTPClientTransport {
41893
41984
  if (this._protocolVersion) {
41894
41985
  headers["mcp-protocol-version"] = this._protocolVersion;
41895
41986
  }
41896
- const extraHeaders = normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
41987
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
41897
41988
  return new Headers({
41898
41989
  ...headers,
41899
41990
  ...extraHeaders
41900
41991
  });
41901
41992
  }
41902
41993
  async _startOrAuthSse(options) {
41903
- var _a, _b, _c, _d;
41904
41994
  const { resumptionToken } = options;
41905
41995
  try {
41906
41996
  const headers = await this._commonHeaders();
@@ -41908,13 +41998,13 @@ class StreamableHTTPClientTransport {
41908
41998
  if (resumptionToken) {
41909
41999
  headers.set("last-event-id", resumptionToken);
41910
42000
  }
41911
- const response = await ((_a = this._fetch) !== null && _a !== void 0 ? _a : fetch)(this._url, {
42001
+ const response = await (this._fetch ?? fetch)(this._url, {
41912
42002
  method: "GET",
41913
42003
  headers,
41914
- signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal
42004
+ signal: this._abortController?.signal
41915
42005
  });
41916
42006
  if (!response.ok) {
41917
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
42007
+ await response.body?.cancel();
41918
42008
  if (response.status === 401 && this._authProvider) {
41919
42009
  return await this._authThenStart();
41920
42010
  }
@@ -41925,7 +42015,7 @@ class StreamableHTTPClientTransport {
41925
42015
  }
41926
42016
  this._handleSseStream(response.body, options, true);
41927
42017
  } catch (error) {
41928
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
42018
+ this.onerror?.(error);
41929
42019
  throw error;
41930
42020
  }
41931
42021
  }
@@ -41951,17 +42041,15 @@ class StreamableHTTPClientTransport {
41951
42041
  * @param attemptCount Current reconnection attempt count for this specific stream
41952
42042
  */
41953
42043
  _scheduleReconnection(options, attemptCount = 0) {
41954
- var _a;
41955
42044
  const maxRetries = this._reconnectionOptions.maxRetries;
41956
42045
  if (attemptCount >= maxRetries) {
41957
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
42046
+ this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
41958
42047
  return;
41959
42048
  }
41960
42049
  const delay = this._getNextReconnectionDelay(attemptCount);
41961
42050
  this._reconnectionTimeout = setTimeout(() => {
41962
42051
  this._startOrAuthSse(options).catch((error) => {
41963
- var _a2;
41964
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
42052
+ this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
41965
42053
  this._scheduleReconnection(options, attemptCount + 1);
41966
42054
  });
41967
42055
  }, delay);
@@ -41975,7 +42063,6 @@ class StreamableHTTPClientTransport {
41975
42063
  let hasPrimingEvent = false;
41976
42064
  let receivedResponse = false;
41977
42065
  const processStream = async () => {
41978
- var _a, _b, _c, _d;
41979
42066
  try {
41980
42067
  const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({
41981
42068
  onRetry: (retryMs) => {
@@ -41990,7 +42077,7 @@ class StreamableHTTPClientTransport {
41990
42077
  if (event.id) {
41991
42078
  lastEventId = event.id;
41992
42079
  hasPrimingEvent = true;
41993
- onresumptiontoken === null || onresumptiontoken === void 0 ? void 0 : onresumptiontoken(event.id);
42080
+ onresumptiontoken?.(event.id);
41994
42081
  }
41995
42082
  if (!event.data) {
41996
42083
  continue;
@@ -41998,15 +42085,15 @@ class StreamableHTTPClientTransport {
41998
42085
  if (!event.event || event.event === "message") {
41999
42086
  try {
42000
42087
  const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
42001
- if (isJSONRPCResponse(message)) {
42088
+ if (isJSONRPCResultResponse(message)) {
42002
42089
  receivedResponse = true;
42003
42090
  if (replayMessageId !== void 0) {
42004
42091
  message.id = replayMessageId;
42005
42092
  }
42006
42093
  }
42007
- (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);
42094
+ this.onmessage?.(message);
42008
42095
  } catch (error) {
42009
- (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);
42096
+ this.onerror?.(error);
42010
42097
  }
42011
42098
  }
42012
42099
  }
@@ -42020,7 +42107,7 @@ class StreamableHTTPClientTransport {
42020
42107
  }, 0);
42021
42108
  }
42022
42109
  } catch (error) {
42023
- (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, new Error(`SSE stream disconnected: ${error}`));
42110
+ this.onerror?.(new Error(`SSE stream disconnected: ${error}`));
42024
42111
  const canResume = isReconnectable || hasPrimingEvent;
42025
42112
  const needsReconnect = canResume && !receivedResponse;
42026
42113
  if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
@@ -42031,7 +42118,7 @@ class StreamableHTTPClientTransport {
42031
42118
  replayMessageId
42032
42119
  }, 0);
42033
42120
  } catch (error2) {
42034
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, new Error(`Failed to reconnect: ${error2 instanceof Error ? error2.message : String(error2)}`));
42121
+ this.onerror?.(new Error(`Failed to reconnect: ${error2 instanceof Error ? error2.message : String(error2)}`));
42035
42122
  }
42036
42123
  }
42037
42124
  }
@@ -42063,23 +42150,18 @@ class StreamableHTTPClientTransport {
42063
42150
  }
42064
42151
  }
42065
42152
  async close() {
42066
- var _a, _b;
42067
42153
  if (this._reconnectionTimeout) {
42068
42154
  clearTimeout(this._reconnectionTimeout);
42069
42155
  this._reconnectionTimeout = void 0;
42070
42156
  }
42071
- (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();
42072
- (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
42157
+ this._abortController?.abort();
42158
+ this.onclose?.();
42073
42159
  }
42074
42160
  async send(message, options) {
42075
- var _a, _b, _c, _d, _e2, _f, _g;
42076
42161
  try {
42077
42162
  const { resumptionToken, onresumptiontoken } = options || {};
42078
42163
  if (resumptionToken) {
42079
- this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => {
42080
- var _a2;
42081
- return (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, err);
42082
- });
42164
+ this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => this.onerror?.(err));
42083
42165
  return;
42084
42166
  }
42085
42167
  const headers = await this._commonHeaders();
@@ -42090,9 +42172,9 @@ class StreamableHTTPClientTransport {
42090
42172
  method: "POST",
42091
42173
  headers,
42092
42174
  body: JSON.stringify(message),
42093
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
42175
+ signal: this._abortController?.signal
42094
42176
  };
42095
- const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);
42177
+ const response = await (this._fetch ?? fetch)(this._url, init);
42096
42178
  const sessionId = response.headers.get("mcp-session-id");
42097
42179
  if (sessionId) {
42098
42180
  this._sessionId = sessionId;
@@ -42131,7 +42213,7 @@ class StreamableHTTPClientTransport {
42131
42213
  if (resourceMetadataUrl) {
42132
42214
  this._resourceMetadataUrl = resourceMetadataUrl;
42133
42215
  }
42134
- this._lastUpscopingHeader = wwwAuthHeader !== null && wwwAuthHeader !== void 0 ? wwwAuthHeader : void 0;
42216
+ this._lastUpscopingHeader = wwwAuthHeader ?? void 0;
42135
42217
  const result = await auth(this._authProvider, {
42136
42218
  serverUrl: this._url,
42137
42219
  resourceMetadataUrl: this._resourceMetadataUrl,
@@ -42149,12 +42231,9 @@ class StreamableHTTPClientTransport {
42149
42231
  this._hasCompletedAuthFlow = false;
42150
42232
  this._lastUpscopingHeader = void 0;
42151
42233
  if (response.status === 202) {
42152
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
42234
+ await response.body?.cancel();
42153
42235
  if (isInitializedNotification(message)) {
42154
- this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => {
42155
- var _a2;
42156
- return (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, err);
42157
- });
42236
+ this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
42158
42237
  }
42159
42238
  return;
42160
42239
  }
@@ -42162,23 +42241,23 @@ class StreamableHTTPClientTransport {
42162
42241
  const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
42163
42242
  const contentType = response.headers.get("content-type");
42164
42243
  if (hasRequests) {
42165
- if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("text/event-stream")) {
42244
+ if (contentType?.includes("text/event-stream")) {
42166
42245
  this._handleSseStream(response.body, { onresumptiontoken }, false);
42167
- } else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("application/json")) {
42246
+ } else if (contentType?.includes("application/json")) {
42168
42247
  const data2 = await response.json();
42169
42248
  const responseMessages = Array.isArray(data2) ? data2.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data2)];
42170
42249
  for (const msg of responseMessages) {
42171
- (_d = this.onmessage) === null || _d === void 0 ? void 0 : _d.call(this, msg);
42250
+ this.onmessage?.(msg);
42172
42251
  }
42173
42252
  } else {
42174
- await ((_e2 = response.body) === null || _e2 === void 0 ? void 0 : _e2.cancel());
42253
+ await response.body?.cancel();
42175
42254
  throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
42176
42255
  }
42177
42256
  } else {
42178
- await ((_f = response.body) === null || _f === void 0 ? void 0 : _f.cancel());
42257
+ await response.body?.cancel();
42179
42258
  }
42180
42259
  } catch (error) {
42181
- (_g = this.onerror) === null || _g === void 0 ? void 0 : _g.call(this, error);
42260
+ this.onerror?.(error);
42182
42261
  throw error;
42183
42262
  }
42184
42263
  }
@@ -42197,7 +42276,6 @@ class StreamableHTTPClientTransport {
42197
42276
  * the server does not allow clients to terminate sessions.
42198
42277
  */
42199
42278
  async terminateSession() {
42200
- var _a, _b, _c, _d;
42201
42279
  if (!this._sessionId) {
42202
42280
  return;
42203
42281
  }
@@ -42207,16 +42285,16 @@ class StreamableHTTPClientTransport {
42207
42285
  ...this._requestInit,
42208
42286
  method: "DELETE",
42209
42287
  headers,
42210
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
42288
+ signal: this._abortController?.signal
42211
42289
  };
42212
- const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);
42213
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
42290
+ const response = await (this._fetch ?? fetch)(this._url, init);
42291
+ await response.body?.cancel();
42214
42292
  if (!response.ok && response.status !== 405) {
42215
42293
  throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
42216
42294
  }
42217
42295
  this._sessionId = void 0;
42218
42296
  } catch (error) {
42219
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
42297
+ this.onerror?.(error);
42220
42298
  throw error;
42221
42299
  }
42222
42300
  }
@@ -42236,7 +42314,7 @@ class StreamableHTTPClientTransport {
42236
42314
  async resumeStream(lastEventId, options) {
42237
42315
  await this._startOrAuthSse({
42238
42316
  resumptionToken: lastEventId,
42239
- onresumptiontoken: options === null || options === void 0 ? void 0 : options.onresumptiontoken
42317
+ onresumptiontoken: options?.onresumptiontoken
42240
42318
  });
42241
42319
  }
42242
42320
  }
@@ -43477,7 +43555,7 @@ const TabsContent = reactExports.forwardRef(({ className, ...props }, ref2) => /
43477
43555
  }
43478
43556
  ));
43479
43557
  TabsContent.displayName = Content$2.displayName;
43480
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
43558
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
43481
43559
  var use = React$1[" use ".trim().toString()];
43482
43560
  function isPromiseLike(value) {
43483
43561
  return typeof value === "object" && value !== null && "then" in value;
@@ -43533,7 +43611,7 @@ function createSlotClone$3(ownerName) {
43533
43611
  SlotClone.displayName = `${ownerName}.SlotClone`;
43534
43612
  return SlotClone;
43535
43613
  }
43536
- var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
43614
+ var SLOTTABLE_IDENTIFIER$4 = /* @__PURE__ */ Symbol("radix.slottable");
43537
43615
  function isSlottable$3(child) {
43538
43616
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
43539
43617
  }
@@ -46109,7 +46187,7 @@ function createSlotClone$2(ownerName) {
46109
46187
  SlotClone.displayName = `${ownerName}.SlotClone`;
46110
46188
  return SlotClone;
46111
46189
  }
46112
- var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
46190
+ var SLOTTABLE_IDENTIFIER$3 = /* @__PURE__ */ Symbol("radix.slottable");
46113
46191
  function isSlottable$2(child) {
46114
46192
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
46115
46193
  }
@@ -49116,7 +49194,7 @@ function createSlotClone$1(ownerName) {
49116
49194
  SlotClone.displayName = `${ownerName}.SlotClone`;
49117
49195
  return SlotClone;
49118
49196
  }
49119
- var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
49197
+ var SLOTTABLE_IDENTIFIER$2 = /* @__PURE__ */ Symbol("radix.slottable");
49120
49198
  function isSlottable$1(child) {
49121
49199
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
49122
49200
  }
@@ -49557,7 +49635,7 @@ var Primitive = NODES.reduce((primitive, node) => {
49557
49635
  const { asChild, ...primitiveProps } = props;
49558
49636
  const Comp = asChild ? Slot2 : node;
49559
49637
  if (typeof window !== "undefined") {
49560
- window[Symbol.for("radix-ui")] = true;
49638
+ window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
49561
49639
  }
49562
49640
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, { ...primitiveProps, ref: forwardedRef });
49563
49641
  });
@@ -52394,7 +52472,22 @@ const getArrayItemDefault = (schema) => {
52394
52472
  };
52395
52473
  const DynamicJsonForm = reactExports.forwardRef(
52396
52474
  ({ schema, value, onChange, maxDepth = 3 }, ref2) => {
52397
- const isOnlyJSON = !isSimpleObject(schema);
52475
+ const canRenderTopLevelForm = (s) => {
52476
+ const primitiveTypes = ["string", "number", "integer", "boolean", "null"];
52477
+ const hasType = Array.isArray(s.type) ? s.type.length > 0 : !!s.type;
52478
+ if (!hasType) return false;
52479
+ const includesType = (t) => Array.isArray(s.type) ? s.type.includes(t) : s.type === t;
52480
+ if (primitiveTypes.some(includesType)) return true;
52481
+ if (includesType("object")) {
52482
+ const keys = Object.keys(s.properties ?? {});
52483
+ return keys.length > 0;
52484
+ }
52485
+ if (includesType("array")) {
52486
+ return !!s.items;
52487
+ }
52488
+ return false;
52489
+ };
52490
+ const isOnlyJSON = !canRenderTopLevelForm(schema);
52398
52491
  const [isJsonMode, setIsJsonMode] = reactExports.useState(isOnlyJSON);
52399
52492
  const [jsonError, setJsonError] = reactExports.useState();
52400
52493
  const [copiedJson, setCopiedJson] = reactExports.useState(false);
@@ -52536,58 +52629,64 @@ const DynamicJsonForm = reactExports.forwardRef(
52536
52629
  }
52537
52630
  switch (fieldType) {
52538
52631
  case "string": {
52539
- if (propSchema.oneOf && propSchema.oneOf.every(
52540
- (option) => typeof option.const === "string" && typeof option.title === "string"
52541
- )) {
52542
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
52543
- "select",
52544
- {
52545
- value: currentValue ?? "",
52546
- onChange: (e) => {
52547
- const val = e.target.value;
52548
- if (!val && !isRequired) {
52549
- handleFieldChange(path, void 0);
52550
- } else {
52551
- handleFieldChange(path, val);
52552
- }
52553
- },
52554
- required: isRequired,
52555
- className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800",
52556
- children: [
52557
- /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select an option..." }),
52558
- propSchema.oneOf.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx(
52559
- "option",
52560
- {
52561
- value: option.const,
52562
- children: option.title
52563
- },
52564
- option.const
52565
- ))
52566
- ]
52567
- }
52568
- );
52632
+ const titledOptions = (propSchema.oneOf ?? propSchema.anyOf)?.filter((opt) => "const" in opt);
52633
+ if (titledOptions && titledOptions.length > 0) {
52634
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
52635
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
52636
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
52637
+ "select",
52638
+ {
52639
+ value: currentValue ?? "",
52640
+ onChange: (e) => {
52641
+ const val = e.target.value;
52642
+ if (!val && !isRequired) {
52643
+ handleFieldChange(path, void 0);
52644
+ } else {
52645
+ handleFieldChange(path, val);
52646
+ }
52647
+ },
52648
+ required: isRequired,
52649
+ className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800",
52650
+ children: [
52651
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select an option..." }),
52652
+ titledOptions.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx(
52653
+ "option",
52654
+ {
52655
+ value: String(option.const),
52656
+ children: option.title ?? String(option.const)
52657
+ },
52658
+ String(option.const)
52659
+ ))
52660
+ ]
52661
+ }
52662
+ )
52663
+ ] });
52569
52664
  }
52570
52665
  if (propSchema.enum) {
52571
- return /* @__PURE__ */ jsxRuntimeExports.jsxs(
52572
- "select",
52573
- {
52574
- value: currentValue ?? "",
52575
- onChange: (e) => {
52576
- const val = e.target.value;
52577
- if (!val && !isRequired) {
52578
- handleFieldChange(path, void 0);
52579
- } else {
52580
- handleFieldChange(path, val);
52581
- }
52582
- },
52583
- required: isRequired,
52584
- className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800",
52585
- children: [
52586
- /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select an option..." }),
52587
- propSchema.enum.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option, children: option }, option))
52588
- ]
52589
- }
52590
- );
52666
+ const names2 = Array.isArray(propSchema.enumNames) ? propSchema.enumNames : void 0;
52667
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
52668
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
52669
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
52670
+ "select",
52671
+ {
52672
+ value: currentValue ?? "",
52673
+ onChange: (e) => {
52674
+ const val = e.target.value;
52675
+ if (!val && !isRequired) {
52676
+ handleFieldChange(path, void 0);
52677
+ } else {
52678
+ handleFieldChange(path, val);
52679
+ }
52680
+ },
52681
+ required: isRequired,
52682
+ className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800",
52683
+ children: [
52684
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select an option..." }),
52685
+ propSchema.enum.map((option, idx) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option, children: names2?.[idx] ?? option }, option))
52686
+ ]
52687
+ }
52688
+ )
52689
+ ] });
52591
52690
  }
52592
52691
  let inputType = "text";
52593
52692
  switch (propSchema.format) {
@@ -52672,16 +52771,19 @@ const DynamicJsonForm = reactExports.forwardRef(
52672
52771
  }
52673
52772
  );
52674
52773
  case "boolean":
52675
- return /* @__PURE__ */ jsxRuntimeExports.jsx(
52676
- Input,
52677
- {
52678
- type: "checkbox",
52679
- checked: currentValue ?? false,
52680
- onChange: (e) => handleFieldChange(path, e.target.checked),
52681
- className: "w-4 h-4",
52682
- required: isRequired
52683
- }
52684
- );
52774
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
52775
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
52776
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
52777
+ Input,
52778
+ {
52779
+ type: "checkbox",
52780
+ checked: currentValue ?? false,
52781
+ onChange: (e) => handleFieldChange(path, e.target.checked),
52782
+ className: "w-4 h-4",
52783
+ required: isRequired
52784
+ }
52785
+ )
52786
+ ] });
52685
52787
  case "null":
52686
52788
  return null;
52687
52789
  case "object":
@@ -52707,7 +52809,7 @@ const DynamicJsonForm = reactExports.forwardRef(
52707
52809
  }
52708
52810
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2 border rounded p-3", children: Object.entries(propSchema.properties).map(([key, subSchema]) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
52709
52811
  /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium mb-1", children: [
52710
- key,
52812
+ subSchema.title ?? key,
52711
52813
  propSchema.required?.includes(key) && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500 ml-1", children: "*" })
52712
52814
  ] }),
52713
52815
  renderFormFields(
@@ -52722,6 +52824,47 @@ const DynamicJsonForm = reactExports.forwardRef(
52722
52824
  case "array": {
52723
52825
  const arrayValue = Array.isArray(currentValue) ? currentValue : [];
52724
52826
  if (!propSchema.items) return null;
52827
+ const itemSchema = propSchema.items;
52828
+ let multiOptions = null;
52829
+ const titledMulti = (itemSchema.anyOf ?? itemSchema.oneOf)?.filter((opt) => "const" in opt);
52830
+ if (titledMulti && titledMulti.length > 0) {
52831
+ multiOptions = titledMulti.map((o) => ({
52832
+ value: String(o.const),
52833
+ label: o.title ?? String(o.const)
52834
+ }));
52835
+ } else if (itemSchema.enum) {
52836
+ const names2 = Array.isArray(itemSchema.enumNames) ? itemSchema.enumNames : void 0;
52837
+ multiOptions = itemSchema.enum.map((v, i) => ({
52838
+ value: v,
52839
+ label: names2?.[i] ?? v
52840
+ }));
52841
+ }
52842
+ if (multiOptions) {
52843
+ const selectSize = Math.min(Math.max(multiOptions.length, 3), 8);
52844
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
52845
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
52846
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
52847
+ "select",
52848
+ {
52849
+ multiple: true,
52850
+ size: selectSize,
52851
+ value: arrayValue,
52852
+ onChange: (e) => {
52853
+ const selected = Array.from(
52854
+ e.target.selectedOptions
52855
+ ).map((o) => o.value);
52856
+ handleFieldChange(path, selected);
52857
+ },
52858
+ className: "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800",
52859
+ children: multiOptions.map((opt) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: opt.value, children: opt.label }, opt.value))
52860
+ }
52861
+ ),
52862
+ (propSchema.minItems || propSchema.maxItems) && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500", children: [
52863
+ propSchema.minItems ? `Select at least ${propSchema.minItems}. ` : "",
52864
+ propSchema.maxItems ? `Select at most ${propSchema.maxItems}.` : ""
52865
+ ] })
52866
+ ] });
52867
+ }
52725
52868
  if (isSimpleObject(propSchema.items)) {
52726
52869
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
52727
52870
  propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
@@ -53068,7 +53211,7 @@ function createSlotClone(ownerName) {
53068
53211
  SlotClone.displayName = `${ownerName}.SlotClone`;
53069
53212
  return SlotClone;
53070
53213
  }
53071
- var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
53214
+ var SLOTTABLE_IDENTIFIER$1 = /* @__PURE__ */ Symbol("radix.slottable");
53072
53215
  function isSlottable(child) {
53073
53216
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
53074
53217
  }
@@ -54392,8 +54535,8 @@ const useTheme = () => {
54392
54535
  [theme, setThemeWithSideEffect]
54393
54536
  );
54394
54537
  };
54395
- const version = "0.17.5";
54396
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
54538
+ const version = "0.18.0";
54539
+ var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
54397
54540
  // @__NO_SIDE_EFFECTS__
54398
54541
  function createSlottable(ownerName) {
54399
54542
  const Slottable2 = ({ children }) => {
@@ -57098,7 +57241,7 @@ const ElicitationRequest = ({
57098
57241
  if (!validateFormData(formData, request.request.requestedSchema)) {
57099
57242
  return;
57100
57243
  }
57101
- const ajv2 = new Ajv();
57244
+ const ajv2 = new Ajv$1();
57102
57245
  const validate2 = ajv2.compile(request.request.requestedSchema);
57103
57246
  const isValid2 = validate2(formData);
57104
57247
  if (!isValid2) {
@@ -57939,13 +58082,13 @@ const App = () => {
57939
58082
  ) });
57940
58083
  if (window.location.pathname === "/oauth/callback") {
57941
58084
  const OAuthCallback = React.lazy(
57942
- () => __vitePreload(() => import("./OAuthCallback-Bojw9MF2.js"), true ? [] : void 0)
58085
+ () => __vitePreload(() => import("./OAuthCallback-CXY8DEIM.js"), true ? [] : void 0)
57943
58086
  );
57944
58087
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, { onConnect: onOAuthConnect }) });
57945
58088
  }
57946
58089
  if (window.location.pathname === "/oauth/callback/debug") {
57947
58090
  const OAuthDebugCallback = React.lazy(
57948
- () => __vitePreload(() => import("./OAuthDebugCallback-ms23dRpk.js"), true ? [] : void 0)
58091
+ () => __vitePreload(() => import("./OAuthDebugCallback-zr6INHin.js"), true ? [] : void 0)
57949
58092
  );
57950
58093
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthDebugCallback, { onConnect: onOAuthDebugConnect }) });
57951
58094
  }