@modelcontextprotocol/inspector 0.17.5 → 0.19.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.19.0";
16355
16408
  const packageJson = {
16356
16409
  name,
16357
16410
  version: version$1
@@ -16407,6 +16460,12 @@ const DEFAULT_INSPECTOR_CONFIG = {
16407
16460
  description: "Session token for authenticating with the MCP Proxy Server (displayed in proxy console on startup)",
16408
16461
  value: "",
16409
16462
  is_session_item: true
16463
+ },
16464
+ MCP_TASK_TTL: {
16465
+ label: "Task TTL",
16466
+ description: "Default Time-to-Live (TTL) in milliseconds for newly created tasks",
16467
+ value: 6e4,
16468
+ is_session_item: false
16410
16469
  }
16411
16470
  };
16412
16471
  const META_PREFIX_LABEL_REGEX = /^[a-z](?:[a-z\d-]*[a-z\d])?$/i;
@@ -16658,7 +16717,7 @@ const OAUTH_ERRORS = {
16658
16717
  };
16659
16718
  class UnauthorizedError extends Error {
16660
16719
  constructor(message) {
16661
- super(message !== null && message !== void 0 ? message : "Unauthorized");
16720
+ super(message ?? "Unauthorized");
16662
16721
  }
16663
16722
  }
16664
16723
  function isClientAuthMethod(method) {
@@ -16731,22 +16790,20 @@ async function parseErrorResponse(input) {
16731
16790
  }
16732
16791
  }
16733
16792
  async function auth(provider, options) {
16734
- var _a, _b;
16735
16793
  try {
16736
16794
  return await authInternal(provider, options);
16737
16795
  } catch (error) {
16738
16796
  if (error instanceof InvalidClientError || error instanceof UnauthorizedClientError) {
16739
- await ((_a = provider.invalidateCredentials) === null || _a === void 0 ? void 0 : _a.call(provider, "all"));
16797
+ await provider.invalidateCredentials?.("all");
16740
16798
  return await authInternal(provider, options);
16741
16799
  } else if (error instanceof InvalidGrantError) {
16742
- await ((_b = provider.invalidateCredentials) === null || _b === void 0 ? void 0 : _b.call(provider, "tokens"));
16800
+ await provider.invalidateCredentials?.("tokens");
16743
16801
  return await authInternal(provider, options);
16744
16802
  }
16745
16803
  throw error;
16746
16804
  }
16747
16805
  }
16748
16806
  async function authInternal(provider, { serverUrl, authorizationCode, scope: scope2, resourceMetadataUrl, fetchFn }) {
16749
- var _a, _b;
16750
16807
  let resourceMetadata;
16751
16808
  let authorizationServerUrl;
16752
16809
  try {
@@ -16754,7 +16811,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16754
16811
  if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
16755
16812
  authorizationServerUrl = resourceMetadata.authorization_servers[0];
16756
16813
  }
16757
- } catch (_c) {
16814
+ } catch {
16758
16815
  }
16759
16816
  if (!authorizationServerUrl) {
16760
16817
  authorizationServerUrl = new URL("/", serverUrl);
@@ -16768,7 +16825,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16768
16825
  if (authorizationCode !== void 0) {
16769
16826
  throw new Error("Existing OAuth client information is required when exchanging an authorization code");
16770
16827
  }
16771
- const supportsUrlBasedClientId = (metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.client_id_metadata_document_supported) === true;
16828
+ const supportsUrlBasedClientId = metadata2?.client_id_metadata_document_supported === true;
16772
16829
  const clientMetadataUrl = provider.clientMetadataUrl;
16773
16830
  if (clientMetadataUrl && !isHttpsUrl(clientMetadataUrl)) {
16774
16831
  throw new InvalidClientMetadataError(`clientMetadataUrl must be a valid HTTPS URL with a non-root pathname, got: ${clientMetadataUrl}`);
@@ -16778,7 +16835,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16778
16835
  clientInformation = {
16779
16836
  client_id: clientMetadataUrl
16780
16837
  };
16781
- await ((_a = provider.saveClientInformation) === null || _a === void 0 ? void 0 : _a.call(provider, clientInformation));
16838
+ await provider.saveClientInformation?.(clientInformation);
16782
16839
  } else {
16783
16840
  if (!provider.saveClientInformation) {
16784
16841
  throw new Error("OAuth client information must be saveable for dynamic registration");
@@ -16804,7 +16861,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16804
16861
  return "AUTHORIZED";
16805
16862
  }
16806
16863
  const tokens = await provider.tokens();
16807
- if (tokens === null || tokens === void 0 ? void 0 : tokens.refresh_token) {
16864
+ if (tokens?.refresh_token) {
16808
16865
  try {
16809
16866
  const newTokens = await refreshAuthorization(authorizationServerUrl, {
16810
16867
  metadata: metadata2,
@@ -16829,7 +16886,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
16829
16886
  clientInformation,
16830
16887
  state,
16831
16888
  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,
16889
+ scope: scope2 || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope,
16833
16890
  resource
16834
16891
  });
16835
16892
  await provider.saveCodeVerifier(codeVerifier);
@@ -16842,14 +16899,14 @@ function isHttpsUrl(value) {
16842
16899
  try {
16843
16900
  const url2 = new URL(value);
16844
16901
  return url2.protocol === "https:" && url2.pathname !== "/";
16845
- } catch (_a) {
16902
+ } catch {
16846
16903
  return false;
16847
16904
  }
16848
16905
  }
16849
16906
  async function selectResourceURL(serverUrl, provider, resourceMetadata) {
16850
16907
  const defaultResource = resourceUrlFromServerUrl(serverUrl);
16851
16908
  if (provider.validateResourceURL) {
16852
- return await provider.validateResourceURL(defaultResource, resourceMetadata === null || resourceMetadata === void 0 ? void 0 : resourceMetadata.resource);
16909
+ return await provider.validateResourceURL(defaultResource, resourceMetadata?.resource);
16853
16910
  }
16854
16911
  if (!resourceMetadata) {
16855
16912
  return void 0;
@@ -16873,7 +16930,7 @@ function extractWWWAuthenticateParams(res) {
16873
16930
  if (resourceMetadataMatch) {
16874
16931
  try {
16875
16932
  resourceMetadataUrl = new URL(resourceMetadataMatch);
16876
- } catch (_a) {
16933
+ } catch {
16877
16934
  }
16878
16935
  }
16879
16936
  const scope2 = extractFieldFromWwwAuth(res, "scope") || void 0;
@@ -16897,17 +16954,16 @@ function extractFieldFromWwwAuth(response, fieldName) {
16897
16954
  return null;
16898
16955
  }
16899
16956
  async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
16900
- var _a, _b;
16901
16957
  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
16958
+ protocolVersion: opts?.protocolVersion,
16959
+ metadataUrl: opts?.resourceMetadataUrl
16904
16960
  });
16905
16961
  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());
16962
+ await response?.body?.cancel();
16907
16963
  throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
16908
16964
  }
16909
16965
  if (!response.ok) {
16910
- await ((_b = response.body) === null || _b === void 0 ? void 0 : _b.cancel());
16966
+ await response.body?.cancel();
16911
16967
  throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
16912
16968
  }
16913
16969
  return OAuthProtectedResourceMetadataSchema.parse(await response.json());
@@ -16942,19 +16998,18 @@ function shouldAttemptFallback(response, pathname) {
16942
16998
  return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
16943
16999
  }
16944
17000
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
16945
- var _a, _b;
16946
17001
  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;
17002
+ const protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION;
16948
17003
  let url2;
16949
- if (opts === null || opts === void 0 ? void 0 : opts.metadataUrl) {
17004
+ if (opts?.metadataUrl) {
16950
17005
  url2 = new URL(opts.metadataUrl);
16951
17006
  } else {
16952
17007
  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);
17008
+ url2 = new URL(wellKnownPath, opts?.metadataServerUrl ?? issuer);
16954
17009
  url2.search = issuer.search;
16955
17010
  }
16956
17011
  let response = await tryMetadataDiscovery(url2, protocolVersion, fetchFn);
16957
- if (!(opts === null || opts === void 0 ? void 0 : opts.metadataUrl) && shouldAttemptFallback(response, issuer.pathname)) {
17012
+ if (!opts?.metadataUrl && shouldAttemptFallback(response, issuer.pathname)) {
16958
17013
  const rootUrl = new URL(`/.well-known/${wellKnownType}`, issuer);
16959
17014
  response = await tryMetadataDiscovery(rootUrl, protocolVersion, fetchFn);
16960
17015
  }
@@ -16994,7 +17049,6 @@ function buildDiscoveryUrls(authorizationServerUrl) {
16994
17049
  return urlsToTry;
16995
17050
  }
16996
17051
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
16997
- var _a;
16998
17052
  const headers = {
16999
17053
  "MCP-Protocol-Version": protocolVersion,
17000
17054
  Accept: "application/json"
@@ -17006,7 +17060,7 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
17006
17060
  continue;
17007
17061
  }
17008
17062
  if (!response.ok) {
17009
- await ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel());
17063
+ await response.body?.cancel();
17010
17064
  if (response.status >= 400 && response.status < 500) {
17011
17065
  continue;
17012
17066
  }
@@ -17047,7 +17101,7 @@ async function startAuthorization(authorizationServerUrl, { metadata: metadata2,
17047
17101
  if (scope2) {
17048
17102
  authorizationUrl.searchParams.set("scope", scope2);
17049
17103
  }
17050
- if (scope2 === null || scope2 === void 0 ? void 0 : scope2.includes("offline_access")) {
17104
+ if (scope2?.includes("offline_access")) {
17051
17105
  authorizationUrl.searchParams.append("prompt", "consent");
17052
17106
  }
17053
17107
  if (resource) {
@@ -17064,8 +17118,7 @@ function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redire
17064
17118
  });
17065
17119
  }
17066
17120
  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);
17121
+ const tokenUrl = metadata2?.token_endpoint ? new URL(metadata2.token_endpoint) : new URL("/token", authorizationServerUrl);
17069
17122
  const headers = new Headers({
17070
17123
  "Content-Type": "application/x-www-form-urlencoded",
17071
17124
  Accept: "application/json"
@@ -17076,11 +17129,11 @@ async function executeTokenRequest(authorizationServerUrl, { metadata: metadata2
17076
17129
  if (addClientAuthentication) {
17077
17130
  await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata2);
17078
17131
  } 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 : [];
17132
+ const supportedMethods = metadata2?.token_endpoint_auth_methods_supported ?? [];
17080
17133
  const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
17081
17134
  applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
17082
17135
  }
17083
- const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {
17136
+ const response = await (fetchFn ?? fetch)(tokenUrl, {
17084
17137
  method: "POST",
17085
17138
  headers,
17086
17139
  body: tokenRequestParams
@@ -17136,7 +17189,7 @@ async function fetchToken(provider, authorizationServerUrl, { metadata: metadata
17136
17189
  return executeTokenRequest(authorizationServerUrl, {
17137
17190
  metadata: metadata2,
17138
17191
  tokenRequestParams,
17139
- clientInformation: clientInformation !== null && clientInformation !== void 0 ? clientInformation : void 0,
17192
+ clientInformation: clientInformation ?? void 0,
17140
17193
  addClientAuthentication: provider.addClientAuthentication,
17141
17194
  resource,
17142
17195
  fetchFn
@@ -17152,7 +17205,7 @@ async function registerClient(authorizationServerUrl, { metadata: metadata2, cli
17152
17205
  } else {
17153
17206
  registrationUrl = new URL("/register", authorizationServerUrl);
17154
17207
  }
17155
- const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(registrationUrl, {
17208
+ const response = await (fetchFn ?? fetch)(registrationUrl, {
17156
17209
  method: "POST",
17157
17210
  headers: {
17158
17211
  "Content-Type": "application/json"
@@ -17297,15 +17350,18 @@ class InspectorOAuthClientProvider {
17297
17350
  return [.../* @__PURE__ */ new Set([this.redirectUrl, this.debugRedirectUrl])];
17298
17351
  }
17299
17352
  get clientMetadata() {
17300
- return {
17353
+ const metadata2 = {
17301
17354
  redirect_uris: this.redirect_uris,
17302
17355
  token_endpoint_auth_method: "none",
17303
17356
  grant_types: ["authorization_code", "refresh_token"],
17304
17357
  response_types: ["code"],
17305
17358
  client_name: "MCP Inspector",
17306
- client_uri: "https://github.com/modelcontextprotocol/inspector",
17307
- scope: this.scope ?? ""
17359
+ client_uri: "https://github.com/modelcontextprotocol/inspector"
17308
17360
  };
17361
+ if (this.scope) {
17362
+ metadata2.scope = this.scope;
17363
+ }
17364
+ return metadata2;
17309
17365
  }
17310
17366
  state() {
17311
17367
  return generateOAuthState();
@@ -23601,8 +23657,8 @@ function requireAjv$2() {
23601
23657
  return ajv$3;
23602
23658
  }
23603
23659
  var ajvExports$1 = requireAjv$2();
23604
- const Ajv = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports$1);
23605
- const ajv$2 = new Ajv();
23660
+ const Ajv$1 = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports$1);
23661
+ const ajv$2 = new Ajv$1();
23606
23662
  const toolOutputValidators = /* @__PURE__ */ new Map();
23607
23663
  function cacheToolOutputSchemas(tools) {
23608
23664
  toolOutputValidators.clear();
@@ -23645,6 +23701,7 @@ function generateDefaultValue(schema, propertyName, parentSchema) {
23645
23701
  return schema.default;
23646
23702
  }
23647
23703
  const isRequired = propertyName && parentSchema ? isPropertyRequired(propertyName, parentSchema) : false;
23704
+ const isRootSchema = propertyName === void 0 && parentSchema === void 0;
23648
23705
  switch (schema.type) {
23649
23706
  case "string":
23650
23707
  return isRequired ? "" : void 0;
@@ -23656,17 +23713,23 @@ function generateDefaultValue(schema, propertyName, parentSchema) {
23656
23713
  case "array":
23657
23714
  return isRequired ? [] : void 0;
23658
23715
  case "object": {
23659
- if (!schema.properties) return isRequired ? {} : void 0;
23716
+ if (!schema.properties) {
23717
+ return isRequired || isRootSchema ? {} : void 0;
23718
+ }
23660
23719
  const obj = {};
23661
23720
  Object.entries(schema.properties).forEach(([key, prop]) => {
23662
- if (isPropertyRequired(key, schema)) {
23721
+ const hasExplicitDefault = "default" in prop && prop.default !== void 0;
23722
+ if (isPropertyRequired(key, schema) || hasExplicitDefault) {
23663
23723
  const value = generateDefaultValue(prop, key, schema);
23664
23724
  if (value !== void 0) {
23665
23725
  obj[key] = value;
23666
23726
  }
23667
23727
  }
23668
23728
  });
23669
- return isRequired ? obj : Object.keys(obj).length > 0 ? obj : void 0;
23729
+ if (Object.keys(obj).length === 0) {
23730
+ return isRequired || isRootSchema ? {} : void 0;
23731
+ }
23732
+ return obj;
23670
23733
  }
23671
23734
  case "null":
23672
23735
  return null;
@@ -27360,13 +27423,12 @@ function safeParse(schema, data2) {
27360
27423
  return result;
27361
27424
  }
27362
27425
  function getObjectShape(schema) {
27363
- var _a, _b;
27364
27426
  if (!schema)
27365
27427
  return void 0;
27366
27428
  let rawShape;
27367
27429
  if (isZ4Schema(schema)) {
27368
27430
  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;
27431
+ rawShape = v4Schema._zod?.def?.shape;
27370
27432
  } else {
27371
27433
  const v3Schema = schema;
27372
27434
  rawShape = v3Schema.shape;
@@ -27376,17 +27438,16 @@ function getObjectShape(schema) {
27376
27438
  if (typeof rawShape === "function") {
27377
27439
  try {
27378
27440
  return rawShape();
27379
- } catch (_c) {
27441
+ } catch {
27380
27442
  return void 0;
27381
27443
  }
27382
27444
  }
27383
27445
  return rawShape;
27384
27446
  }
27385
27447
  function getLiteralValue(schema) {
27386
- var _a;
27387
27448
  if (isZ4Schema(schema)) {
27388
27449
  const v4Schema = schema;
27389
- const def2 = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
27450
+ const def2 = v4Schema._zod?.def;
27390
27451
  if (def2) {
27391
27452
  if (def2.value !== void 0)
27392
27453
  return def2.value;
@@ -27415,7 +27476,7 @@ function isTerminal(status) {
27415
27476
  new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
27416
27477
  function getMethodLiteral(schema) {
27417
27478
  const shape = getObjectShape(schema);
27418
- const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
27479
+ const methodSchema = shape?.method;
27419
27480
  if (!methodSchema) {
27420
27481
  throw new Error("Schema is missing a method literal");
27421
27482
  }
@@ -27457,8 +27518,8 @@ class Protocol {
27457
27518
  // Automatic pong by default.
27458
27519
  (_request) => ({})
27459
27520
  );
27460
- this._taskStore = _options === null || _options === void 0 ? void 0 : _options.taskStore;
27461
- this._taskMessageQueue = _options === null || _options === void 0 ? void 0 : _options.taskMessageQueue;
27521
+ this._taskStore = _options?.taskStore;
27522
+ this._taskMessageQueue = _options?.taskMessageQueue;
27462
27523
  if (this._taskStore) {
27463
27524
  this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
27464
27525
  const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
@@ -27471,7 +27532,6 @@ class Protocol {
27471
27532
  });
27472
27533
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
27473
27534
  const handleTaskResult = async () => {
27474
- var _a;
27475
27535
  const taskId = request.params.taskId;
27476
27536
  if (this._taskMessageQueue) {
27477
27537
  let queuedMessage;
@@ -27495,7 +27555,7 @@ class Protocol {
27495
27555
  }
27496
27556
  continue;
27497
27557
  }
27498
- await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
27558
+ await this._transport?.send(queuedMessage.message, { relatedRequestId: extra.requestId });
27499
27559
  }
27500
27560
  }
27501
27561
  const task = await this._taskStore.getTask(taskId, extra.sessionId);
@@ -27524,9 +27584,8 @@ class Protocol {
27524
27584
  return await handleTaskResult();
27525
27585
  });
27526
27586
  this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
27527
- var _a;
27528
27587
  try {
27529
- const { tasks, nextCursor } = await this._taskStore.listTasks((_a = request.params) === null || _a === void 0 ? void 0 : _a.cursor, extra.sessionId);
27588
+ const { tasks, nextCursor } = await this._taskStore.listTasks(request.params?.cursor, extra.sessionId);
27530
27589
  return {
27531
27590
  tasks,
27532
27591
  nextCursor,
@@ -27565,8 +27624,11 @@ class Protocol {
27565
27624
  }
27566
27625
  }
27567
27626
  async _oncancel(notification) {
27627
+ if (!notification.params.requestId) {
27628
+ return;
27629
+ }
27568
27630
  const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
27569
- controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
27631
+ controller?.abort(notification.params.reason);
27570
27632
  }
27571
27633
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
27572
27634
  this._timeoutInfo.set(messageId, {
@@ -27607,22 +27669,21 @@ class Protocol {
27607
27669
  * 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
27670
  */
27609
27671
  async connect(transport) {
27610
- var _a, _b, _c;
27611
27672
  this._transport = transport;
27612
- const _onclose = (_a = this.transport) === null || _a === void 0 ? void 0 : _a.onclose;
27673
+ const _onclose = this.transport?.onclose;
27613
27674
  this._transport.onclose = () => {
27614
- _onclose === null || _onclose === void 0 ? void 0 : _onclose();
27675
+ _onclose?.();
27615
27676
  this._onclose();
27616
27677
  };
27617
- const _onerror = (_b = this.transport) === null || _b === void 0 ? void 0 : _b.onerror;
27678
+ const _onerror = this.transport?.onerror;
27618
27679
  this._transport.onerror = (error) => {
27619
- _onerror === null || _onerror === void 0 ? void 0 : _onerror(error);
27680
+ _onerror?.(error);
27620
27681
  this._onerror(error);
27621
27682
  };
27622
- const _onmessage = (_c = this._transport) === null || _c === void 0 ? void 0 : _c.onmessage;
27683
+ const _onmessage = this._transport?.onmessage;
27623
27684
  this._transport.onmessage = (message, extra) => {
27624
- _onmessage === null || _onmessage === void 0 ? void 0 : _onmessage(message, extra);
27625
- if (isJSONRPCResponse(message) || isJSONRPCError(message)) {
27685
+ _onmessage?.(message, extra);
27686
+ if (isJSONRPCResultResponse(message) || isJSONRPCErrorResponse(message)) {
27626
27687
  this._onresponse(message);
27627
27688
  } else if (isJSONRPCRequest(message)) {
27628
27689
  this._onrequest(message, extra);
@@ -27635,7 +27696,6 @@ class Protocol {
27635
27696
  await this._transport.start();
27636
27697
  }
27637
27698
  _onclose() {
27638
- var _a;
27639
27699
  const responseHandlers = this._responseHandlers;
27640
27700
  this._responseHandlers = /* @__PURE__ */ new Map();
27641
27701
  this._progressHandlers.clear();
@@ -27643,28 +27703,25 @@ class Protocol {
27643
27703
  this._pendingDebouncedNotifications.clear();
27644
27704
  const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
27645
27705
  this._transport = void 0;
27646
- (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
27706
+ this.onclose?.();
27647
27707
  for (const handler of responseHandlers.values()) {
27648
27708
  handler(error);
27649
27709
  }
27650
27710
  }
27651
27711
  _onerror(error) {
27652
- var _a;
27653
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
27712
+ this.onerror?.(error);
27654
27713
  }
27655
27714
  _onnotification(notification) {
27656
- var _a;
27657
- const handler = (_a = this._notificationHandlers.get(notification.method)) !== null && _a !== void 0 ? _a : this.fallbackNotificationHandler;
27715
+ const handler = this._notificationHandlers.get(notification.method) ?? this.fallbackNotificationHandler;
27658
27716
  if (handler === void 0) {
27659
27717
  return;
27660
27718
  }
27661
27719
  Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
27662
27720
  }
27663
27721
  _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;
27722
+ const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
27666
27723
  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;
27724
+ const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
27668
27725
  if (handler === void 0) {
27669
27726
  const errorResponse = {
27670
27727
  jsonrpc: "2.0",
@@ -27679,20 +27736,20 @@ class Protocol {
27679
27736
  type: "error",
27680
27737
  message: errorResponse,
27681
27738
  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}`)));
27739
+ }, capturedTransport?.sessionId).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
27683
27740
  } 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}`)));
27741
+ capturedTransport?.send(errorResponse).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
27685
27742
  }
27686
27743
  return;
27687
27744
  }
27688
27745
  const abortController = new AbortController();
27689
27746
  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;
27747
+ const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
27748
+ const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport?.sessionId) : void 0;
27692
27749
  const fullExtra = {
27693
27750
  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,
27751
+ sessionId: capturedTransport?.sessionId,
27752
+ _meta: request.params?._meta,
27696
27753
  sendNotification: async (notification) => {
27697
27754
  const notificationOptions = { relatedRequestId: request.id };
27698
27755
  if (relatedTaskId) {
@@ -27701,25 +27758,24 @@ class Protocol {
27701
27758
  await this.notification(notification, notificationOptions);
27702
27759
  },
27703
27760
  sendRequest: async (r2, resultSchema, options) => {
27704
- var _a2, _b2;
27705
27761
  const requestOptions = { ...options, relatedRequestId: request.id };
27706
27762
  if (relatedTaskId && !requestOptions.relatedTask) {
27707
27763
  requestOptions.relatedTask = { taskId: relatedTaskId };
27708
27764
  }
27709
- const effectiveTaskId = (_b2 = (_a2 = requestOptions.relatedTask) === null || _a2 === void 0 ? void 0 : _a2.taskId) !== null && _b2 !== void 0 ? _b2 : relatedTaskId;
27765
+ const effectiveTaskId = requestOptions.relatedTask?.taskId ?? relatedTaskId;
27710
27766
  if (effectiveTaskId && taskStore) {
27711
27767
  await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
27712
27768
  }
27713
27769
  return await this.request(r2, resultSchema, requestOptions);
27714
27770
  },
27715
- authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
27771
+ authInfo: extra?.authInfo,
27716
27772
  requestId: request.id,
27717
- requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo,
27773
+ requestInfo: extra?.requestInfo,
27718
27774
  taskId: relatedTaskId,
27719
27775
  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
27776
+ taskRequestedTtl: taskCreationParams?.ttl,
27777
+ closeSSEStream: extra?.closeSSEStream,
27778
+ closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
27723
27779
  };
27724
27780
  Promise.resolve().then(() => {
27725
27781
  if (taskCreationParams) {
@@ -27739,12 +27795,11 @@ class Protocol {
27739
27795
  type: "response",
27740
27796
  message: response,
27741
27797
  timestamp: Date.now()
27742
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
27798
+ }, capturedTransport?.sessionId);
27743
27799
  } else {
27744
- await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(response));
27800
+ await capturedTransport?.send(response);
27745
27801
  }
27746
27802
  }, async (error) => {
27747
- var _a2;
27748
27803
  if (abortController.signal.aborted) {
27749
27804
  return;
27750
27805
  }
@@ -27753,7 +27808,7 @@ class Protocol {
27753
27808
  id: request.id,
27754
27809
  error: {
27755
27810
  code: Number.isSafeInteger(error["code"]) ? error["code"] : ErrorCode.InternalError,
27756
- message: (_a2 = error.message) !== null && _a2 !== void 0 ? _a2 : "Internal error",
27811
+ message: error.message ?? "Internal error",
27757
27812
  ...error["data"] !== void 0 && { data: error["data"] }
27758
27813
  }
27759
27814
  };
@@ -27762,9 +27817,9 @@ class Protocol {
27762
27817
  type: "error",
27763
27818
  message: errorResponse,
27764
27819
  timestamp: Date.now()
27765
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
27820
+ }, capturedTransport?.sessionId);
27766
27821
  } else {
27767
- await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse));
27822
+ await capturedTransport?.send(errorResponse);
27768
27823
  }
27769
27824
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
27770
27825
  this._requestHandlerAbortControllers.delete(request.id);
@@ -27798,7 +27853,7 @@ class Protocol {
27798
27853
  const resolver = this._requestResolvers.get(messageId);
27799
27854
  if (resolver) {
27800
27855
  this._requestResolvers.delete(messageId);
27801
- if (isJSONRPCResponse(response)) {
27856
+ if (isJSONRPCResultResponse(response)) {
27802
27857
  resolver(response);
27803
27858
  } else {
27804
27859
  const error = new McpError(response.error.code, response.error.message, response.error.data);
@@ -27814,7 +27869,7 @@ class Protocol {
27814
27869
  this._responseHandlers.delete(messageId);
27815
27870
  this._cleanupTimeout(messageId);
27816
27871
  let isTaskResponse = false;
27817
- if (isJSONRPCResponse(response) && response.result && typeof response.result === "object") {
27872
+ if (isJSONRPCResultResponse(response) && response.result && typeof response.result === "object") {
27818
27873
  const result = response.result;
27819
27874
  if (result.task && typeof result.task === "object") {
27820
27875
  const task = result.task;
@@ -27827,7 +27882,7 @@ class Protocol {
27827
27882
  if (!isTaskResponse) {
27828
27883
  this._progressHandlers.delete(messageId);
27829
27884
  }
27830
- if (isJSONRPCResponse(response)) {
27885
+ if (isJSONRPCResultResponse(response)) {
27831
27886
  handler(response);
27832
27887
  } else {
27833
27888
  const error = McpError.fromError(response.error.code, response.error.message, response.error.data);
@@ -27841,8 +27896,7 @@ class Protocol {
27841
27896
  * Closes the connection.
27842
27897
  */
27843
27898
  async close() {
27844
- var _a;
27845
- await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
27899
+ await this._transport?.close();
27846
27900
  }
27847
27901
  /**
27848
27902
  * Sends a request and returns an AsyncGenerator that yields response messages.
@@ -27872,8 +27926,7 @@ class Protocol {
27872
27926
  * @experimental Use `client.experimental.tasks.requestStream()` to access this method.
27873
27927
  */
27874
27928
  async *requestStream(request, resultSchema, options) {
27875
- var _a, _b, _c, _d;
27876
- const { task } = options !== null && options !== void 0 ? options : {};
27929
+ const { task } = options ?? {};
27877
27930
  if (!task) {
27878
27931
  try {
27879
27932
  const result = await this.request(request, resultSchema, options);
@@ -27920,9 +27973,9 @@ class Protocol {
27920
27973
  yield { type: "result", result };
27921
27974
  return;
27922
27975
  }
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;
27976
+ const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
27924
27977
  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();
27978
+ options?.signal?.throwIfAborted();
27926
27979
  }
27927
27980
  } catch (error) {
27928
27981
  yield {
@@ -27937,9 +27990,8 @@ class Protocol {
27937
27990
  * Do not use this method to emit notifications! Use notification() instead.
27938
27991
  */
27939
27992
  request(request, resultSchema, options) {
27940
- const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
27993
+ const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
27941
27994
  return new Promise((resolve2, reject) => {
27942
- var _a, _b, _c, _d, _e2, _f, _g;
27943
27995
  const earlyReject = (error) => {
27944
27996
  reject(error);
27945
27997
  };
@@ -27947,7 +27999,7 @@ class Protocol {
27947
27999
  earlyReject(new Error("Not connected"));
27948
28000
  return;
27949
28001
  }
27950
- if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.enforceStrictCapabilities) === true) {
28002
+ if (this._options?.enforceStrictCapabilities === true) {
27951
28003
  try {
27952
28004
  this.assertCapabilityForMethod(request.method);
27953
28005
  if (task) {
@@ -27958,19 +28010,19 @@ class Protocol {
27958
28010
  return;
27959
28011
  }
27960
28012
  }
27961
- (_b = options === null || options === void 0 ? void 0 : options.signal) === null || _b === void 0 ? void 0 : _b.throwIfAborted();
28013
+ options?.signal?.throwIfAborted();
27962
28014
  const messageId = this._requestMessageId++;
27963
28015
  const jsonrpcRequest = {
27964
28016
  ...request,
27965
28017
  jsonrpc: "2.0",
27966
28018
  id: messageId
27967
28019
  };
27968
- if (options === null || options === void 0 ? void 0 : options.onprogress) {
28020
+ if (options?.onprogress) {
27969
28021
  this._progressHandlers.set(messageId, options.onprogress);
27970
28022
  jsonrpcRequest.params = {
27971
28023
  ...request.params,
27972
28024
  _meta: {
27973
- ...((_c = request.params) === null || _c === void 0 ? void 0 : _c._meta) || {},
28025
+ ...request.params?._meta || {},
27974
28026
  progressToken: messageId
27975
28027
  }
27976
28028
  };
@@ -27985,17 +28037,16 @@ class Protocol {
27985
28037
  jsonrpcRequest.params = {
27986
28038
  ...jsonrpcRequest.params,
27987
28039
  _meta: {
27988
- ...((_d = jsonrpcRequest.params) === null || _d === void 0 ? void 0 : _d._meta) || {},
28040
+ ...jsonrpcRequest.params?._meta || {},
27989
28041
  [RELATED_TASK_META_KEY]: relatedTask
27990
28042
  }
27991
28043
  };
27992
28044
  }
27993
28045
  const cancel = (reason) => {
27994
- var _a2;
27995
28046
  this._responseHandlers.delete(messageId);
27996
28047
  this._progressHandlers.delete(messageId);
27997
28048
  this._cleanupTimeout(messageId);
27998
- (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
28049
+ this._transport?.send({
27999
28050
  jsonrpc: "2.0",
28000
28051
  method: "notifications/cancelled",
28001
28052
  params: {
@@ -28007,8 +28058,7 @@ class Protocol {
28007
28058
  reject(error);
28008
28059
  };
28009
28060
  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) {
28061
+ if (options?.signal?.aborted) {
28012
28062
  return;
28013
28063
  }
28014
28064
  if (response instanceof Error) {
@@ -28025,14 +28075,13 @@ class Protocol {
28025
28075
  reject(error);
28026
28076
  }
28027
28077
  });
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);
28078
+ options?.signal?.addEventListener("abort", () => {
28079
+ cancel(options?.signal?.reason);
28031
28080
  });
28032
- const timeout = (_f = options === null || options === void 0 ? void 0 : options.timeout) !== null && _f !== void 0 ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
28081
+ const timeout = options?.timeout ?? DEFAULT_REQUEST_TIMEOUT_MSEC;
28033
28082
  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;
28083
+ this._setupTimeout(messageId, timeout, options?.maxTotalTimeout, timeoutHandler, options?.resetTimeoutOnProgress ?? false);
28084
+ const relatedTaskId = relatedTask?.taskId;
28036
28085
  if (relatedTaskId) {
28037
28086
  const responseResolver = (response) => {
28038
28087
  const handler = this._responseHandlers.get(messageId);
@@ -28095,12 +28144,11 @@ class Protocol {
28095
28144
  * Emits a notification, which is a one-way message that does not expect a response.
28096
28145
  */
28097
28146
  async notification(notification, options) {
28098
- var _a, _b, _c, _d, _e2;
28099
28147
  if (!this._transport) {
28100
28148
  throw new Error("Not connected");
28101
28149
  }
28102
28150
  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;
28151
+ const relatedTaskId = options?.relatedTask?.taskId;
28104
28152
  if (relatedTaskId) {
28105
28153
  const jsonrpcNotification2 = {
28106
28154
  ...notification,
@@ -28108,7 +28156,7 @@ class Protocol {
28108
28156
  params: {
28109
28157
  ...notification.params,
28110
28158
  _meta: {
28111
- ...((_b = notification.params) === null || _b === void 0 ? void 0 : _b._meta) || {},
28159
+ ...notification.params?._meta || {},
28112
28160
  [RELATED_TASK_META_KEY]: options.relatedTask
28113
28161
  }
28114
28162
  }
@@ -28120,15 +28168,14 @@ class Protocol {
28120
28168
  });
28121
28169
  return;
28122
28170
  }
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);
28171
+ const debouncedMethods = this._options?.debouncedNotificationMethods ?? [];
28172
+ const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !options?.relatedRequestId && !options?.relatedTask;
28125
28173
  if (canDebounce) {
28126
28174
  if (this._pendingDebouncedNotifications.has(notification.method)) {
28127
28175
  return;
28128
28176
  }
28129
28177
  this._pendingDebouncedNotifications.add(notification.method);
28130
28178
  Promise.resolve().then(() => {
28131
- var _a2, _b2;
28132
28179
  this._pendingDebouncedNotifications.delete(notification.method);
28133
28180
  if (!this._transport) {
28134
28181
  return;
@@ -28137,19 +28184,19 @@ class Protocol {
28137
28184
  ...notification,
28138
28185
  jsonrpc: "2.0"
28139
28186
  };
28140
- if (options === null || options === void 0 ? void 0 : options.relatedTask) {
28187
+ if (options?.relatedTask) {
28141
28188
  jsonrpcNotification2 = {
28142
28189
  ...jsonrpcNotification2,
28143
28190
  params: {
28144
28191
  ...jsonrpcNotification2.params,
28145
28192
  _meta: {
28146
- ...((_a2 = jsonrpcNotification2.params) === null || _a2 === void 0 ? void 0 : _a2._meta) || {},
28193
+ ...jsonrpcNotification2.params?._meta || {},
28147
28194
  [RELATED_TASK_META_KEY]: options.relatedTask
28148
28195
  }
28149
28196
  }
28150
28197
  };
28151
28198
  }
28152
- (_b2 = this._transport) === null || _b2 === void 0 ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
28199
+ this._transport?.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
28153
28200
  });
28154
28201
  return;
28155
28202
  }
@@ -28157,13 +28204,13 @@ class Protocol {
28157
28204
  ...notification,
28158
28205
  jsonrpc: "2.0"
28159
28206
  };
28160
- if (options === null || options === void 0 ? void 0 : options.relatedTask) {
28207
+ if (options?.relatedTask) {
28161
28208
  jsonrpcNotification = {
28162
28209
  ...jsonrpcNotification,
28163
28210
  params: {
28164
28211
  ...jsonrpcNotification.params,
28165
28212
  _meta: {
28166
- ...((_e2 = jsonrpcNotification.params) === null || _e2 === void 0 ? void 0 : _e2._meta) || {},
28213
+ ...jsonrpcNotification.params?._meta || {},
28167
28214
  [RELATED_TASK_META_KEY]: options.relatedTask
28168
28215
  }
28169
28216
  }
@@ -28239,11 +28286,10 @@ class Protocol {
28239
28286
  * simply propagates the error.
28240
28287
  */
28241
28288
  async _enqueueTaskMessage(taskId, message, sessionId) {
28242
- var _a;
28243
28289
  if (!this._taskStore || !this._taskMessageQueue) {
28244
28290
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
28245
28291
  }
28246
- const maxQueueSize = (_a = this._options) === null || _a === void 0 ? void 0 : _a.maxTaskQueueSize;
28292
+ const maxQueueSize = this._options?.maxTaskQueueSize;
28247
28293
  await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
28248
28294
  }
28249
28295
  /**
@@ -28276,14 +28322,13 @@ class Protocol {
28276
28322
  * @returns Promise that resolves when an update occurs or rejects if aborted
28277
28323
  */
28278
28324
  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;
28325
+ let interval = this._options?.defaultTaskPollInterval ?? 1e3;
28281
28326
  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) {
28327
+ const task = await this._taskStore?.getTask(taskId);
28328
+ if (task?.pollInterval) {
28284
28329
  interval = task.pollInterval;
28285
28330
  }
28286
- } catch (_d) {
28331
+ } catch {
28287
28332
  }
28288
28333
  return new Promise((resolve2, reject) => {
28289
28334
  if (signal.aborted) {
@@ -34657,6 +34702,7 @@ function requireAjv$1() {
34657
34702
  return ajv$1.exports;
34658
34703
  }
34659
34704
  var ajvExports = requireAjv$1();
34705
+ const Ajv = /* @__PURE__ */ getDefaultExportFromCjs(ajvExports);
34660
34706
  var dist = { exports: {} };
34661
34707
  var formats = {};
34662
34708
  var hasRequiredFormats;
@@ -40535,7 +40581,7 @@ function requireDist() {
40535
40581
  var distExports = requireDist();
40536
40582
  const _addFormats = /* @__PURE__ */ getDefaultExportFromCjs(distExports);
40537
40583
  function createDefaultAjvInstance() {
40538
- const ajv2 = new ajvExports.Ajv({
40584
+ const ajv2 = new Ajv({
40539
40585
  strict: false,
40540
40586
  validateFormats: true,
40541
40587
  validateSchema: false,
@@ -40567,7 +40613,7 @@ class AjvJsonSchemaValidator {
40567
40613
  * ```
40568
40614
  */
40569
40615
  constructor(ajv2) {
40570
- this._ajv = ajv2 !== null && ajv2 !== void 0 ? ajv2 : createDefaultAjvInstance();
40616
+ this._ajv = ajv2 ?? createDefaultAjvInstance();
40571
40617
  }
40572
40618
  /**
40573
40619
  * Create a validator for the given JSON Schema
@@ -40579,8 +40625,7 @@ class AjvJsonSchemaValidator {
40579
40625
  * @returns A validator function that validates input data
40580
40626
  */
40581
40627
  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);
40628
+ const ajvValidator = "$id" in schema && typeof schema.$id === "string" ? this._ajv.getSchema(schema.$id) ?? this._ajv.compile(schema) : this._ajv.compile(schema);
40584
40629
  return (input) => {
40585
40630
  const valid = ajvValidator(input);
40586
40631
  if (valid) {
@@ -40640,13 +40685,12 @@ class ExperimentalClientTasks {
40640
40685
  * @experimental
40641
40686
  */
40642
40687
  async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
40643
- var _a;
40644
40688
  const clientInternal = this._client;
40645
40689
  const optionsWithTask = {
40646
40690
  ...options,
40647
40691
  // We check if the tool is known to be a task during auto-configuration, but assume
40648
40692
  // 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
40693
+ task: options?.task ?? (clientInternal.isToolTask(params.name) ? {} : void 0)
40650
40694
  };
40651
40695
  const stream = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
40652
40696
  const validator = clientInternal.getToolOutputValidator(params.name);
@@ -40753,31 +40797,29 @@ class ExperimentalClientTasks {
40753
40797
  }
40754
40798
  }
40755
40799
  function assertToolsCallTaskCapability(requests, method, entityName) {
40756
- var _a;
40757
40800
  if (!requests) {
40758
40801
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
40759
40802
  }
40760
40803
  switch (method) {
40761
40804
  case "tools/call":
40762
- if (!((_a = requests.tools) === null || _a === void 0 ? void 0 : _a.call)) {
40805
+ if (!requests.tools?.call) {
40763
40806
  throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
40764
40807
  }
40765
40808
  break;
40766
40809
  }
40767
40810
  }
40768
40811
  function assertClientRequestTaskCapability(requests, method, entityName) {
40769
- var _a, _b;
40770
40812
  if (!requests) {
40771
40813
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
40772
40814
  }
40773
40815
  switch (method) {
40774
40816
  case "sampling/createMessage":
40775
- if (!((_a = requests.sampling) === null || _a === void 0 ? void 0 : _a.createMessage)) {
40817
+ if (!requests.sampling?.createMessage) {
40776
40818
  throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
40777
40819
  }
40778
40820
  break;
40779
40821
  case "elicitation/create":
40780
- if (!((_b = requests.elicitation) === null || _b === void 0 ? void 0 : _b.create)) {
40822
+ if (!requests.elicitation?.create) {
40781
40823
  throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
40782
40824
  }
40783
40825
  break;
@@ -40801,12 +40843,16 @@ function applyElicitationDefaults(schema, data2) {
40801
40843
  }
40802
40844
  if (Array.isArray(schema.anyOf)) {
40803
40845
  for (const sub of schema.anyOf) {
40804
- applyElicitationDefaults(sub, data2);
40846
+ if (typeof sub !== "boolean") {
40847
+ applyElicitationDefaults(sub, data2);
40848
+ }
40805
40849
  }
40806
40850
  }
40807
40851
  if (Array.isArray(schema.oneOf)) {
40808
40852
  for (const sub of schema.oneOf) {
40809
- applyElicitationDefaults(sub, data2);
40853
+ if (typeof sub !== "boolean") {
40854
+ applyElicitationDefaults(sub, data2);
40855
+ }
40810
40856
  }
40811
40857
  }
40812
40858
  }
@@ -40825,14 +40871,43 @@ class Client extends Protocol {
40825
40871
  * Initializes this client with the given name and version information.
40826
40872
  */
40827
40873
  constructor(_clientInfo, options) {
40828
- var _a, _b;
40829
40874
  super(options);
40830
40875
  this._clientInfo = _clientInfo;
40831
40876
  this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
40832
40877
  this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
40833
40878
  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();
40879
+ this._listChangedDebounceTimers = /* @__PURE__ */ new Map();
40880
+ this._capabilities = options?.capabilities ?? {};
40881
+ this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator();
40882
+ if (options?.listChanged) {
40883
+ this._pendingListChangedConfig = options.listChanged;
40884
+ }
40885
+ }
40886
+ /**
40887
+ * Set up handlers for list changed notifications based on config and server capabilities.
40888
+ * This should only be called after initialization when server capabilities are known.
40889
+ * Handlers are silently skipped if the server doesn't advertise the corresponding listChanged capability.
40890
+ * @internal
40891
+ */
40892
+ _setupListChangedHandlers(config2) {
40893
+ if (config2.tools && this._serverCapabilities?.tools?.listChanged) {
40894
+ this._setupListChangedHandler("tools", ToolListChangedNotificationSchema, config2.tools, async () => {
40895
+ const result = await this.listTools();
40896
+ return result.tools;
40897
+ });
40898
+ }
40899
+ if (config2.prompts && this._serverCapabilities?.prompts?.listChanged) {
40900
+ this._setupListChangedHandler("prompts", PromptListChangedNotificationSchema, config2.prompts, async () => {
40901
+ const result = await this.listPrompts();
40902
+ return result.prompts;
40903
+ });
40904
+ }
40905
+ if (config2.resources && this._serverCapabilities?.resources?.listChanged) {
40906
+ this._setupListChangedHandler("resources", ResourceListChangedNotificationSchema, config2.resources, async () => {
40907
+ const result = await this.listResources();
40908
+ return result.resources;
40909
+ });
40910
+ }
40836
40911
  }
40837
40912
  /**
40838
40913
  * Access experimental features.
@@ -40864,21 +40939,20 @@ class Client extends Protocol {
40864
40939
  * Override request handler registration to enforce client-side validation for elicitation.
40865
40940
  */
40866
40941
  setRequestHandler(requestSchema, handler) {
40867
- var _a, _b, _c;
40868
40942
  const shape = getObjectShape(requestSchema);
40869
- const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
40943
+ const methodSchema = shape?.method;
40870
40944
  if (!methodSchema) {
40871
40945
  throw new Error("Schema is missing a method literal");
40872
40946
  }
40873
40947
  let methodValue;
40874
40948
  if (isZ4Schema(methodSchema)) {
40875
40949
  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;
40950
+ const v4Def = v4Schema._zod?.def;
40951
+ methodValue = v4Def?.value ?? v4Schema.value;
40878
40952
  } else {
40879
40953
  const v3Schema = methodSchema;
40880
40954
  const legacyDef = v3Schema._def;
40881
- methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
40955
+ methodValue = legacyDef?.value ?? v3Schema.value;
40882
40956
  }
40883
40957
  if (typeof methodValue !== "string") {
40884
40958
  throw new Error("Schema method literal must be a string");
@@ -40886,19 +40960,18 @@ class Client extends Protocol {
40886
40960
  const method = methodValue;
40887
40961
  if (method === "elicitation/create") {
40888
40962
  const wrappedHandler = async (request, extra) => {
40889
- var _a2, _b2, _c2;
40890
40963
  const validatedRequest = safeParse(ElicitRequestSchema, request);
40891
40964
  if (!validatedRequest.success) {
40892
40965
  const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
40893
40966
  throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation request: ${errorMessage}`);
40894
40967
  }
40895
40968
  const { params } = validatedRequest.data;
40896
- const mode = (_a2 = params.mode) !== null && _a2 !== void 0 ? _a2 : "form";
40969
+ params.mode = params.mode ?? "form";
40897
40970
  const { supportsFormMode, supportsUrlMode } = getSupportedElicitationModes(this._capabilities.elicitation);
40898
- if (mode === "form" && !supportsFormMode) {
40971
+ if (params.mode === "form" && !supportsFormMode) {
40899
40972
  throw new McpError(ErrorCode.InvalidParams, "Client does not support form-mode elicitation requests");
40900
40973
  }
40901
- if (mode === "url" && !supportsUrlMode) {
40974
+ if (params.mode === "url" && !supportsUrlMode) {
40902
40975
  throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
40903
40976
  }
40904
40977
  const result = await Promise.resolve(handler(request, extra));
@@ -40916,12 +40989,12 @@ class Client extends Protocol {
40916
40989
  throw new McpError(ErrorCode.InvalidParams, `Invalid elicitation result: ${errorMessage}`);
40917
40990
  }
40918
40991
  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) {
40992
+ const requestedSchema = params.mode === "form" ? params.requestedSchema : void 0;
40993
+ if (params.mode === "form" && validatedResult.action === "accept" && validatedResult.content && requestedSchema) {
40994
+ if (this._capabilities.elicitation?.form?.applyDefaults) {
40922
40995
  try {
40923
40996
  applyElicitationDefaults(requestedSchema, validatedResult.content);
40924
- } catch (_d) {
40997
+ } catch {
40925
40998
  }
40926
40999
  }
40927
41000
  }
@@ -40946,7 +41019,9 @@ class Client extends Protocol {
40946
41019
  }
40947
41020
  return taskValidationResult.data;
40948
41021
  }
40949
- const validationResult = safeParse(CreateMessageResultSchema, result);
41022
+ const hasTools = params.tools || params.toolChoice;
41023
+ const resultSchema = hasTools ? CreateMessageResultWithToolsSchema : CreateMessageResultSchema;
41024
+ const validationResult = safeParse(resultSchema, result);
40950
41025
  if (!validationResult.success) {
40951
41026
  const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
40952
41027
  throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
@@ -40958,8 +41033,7 @@ class Client extends Protocol {
40958
41033
  return super.setRequestHandler(requestSchema, handler);
40959
41034
  }
40960
41035
  assertCapability(capability, method) {
40961
- var _a;
40962
- if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a[capability])) {
41036
+ if (!this._serverCapabilities?.[capability]) {
40963
41037
  throw new Error(`Server does not support ${capability} (required for ${method})`);
40964
41038
  }
40965
41039
  }
@@ -40992,6 +41066,10 @@ class Client extends Protocol {
40992
41066
  await this.notification({
40993
41067
  method: "notifications/initialized"
40994
41068
  });
41069
+ if (this._pendingListChangedConfig) {
41070
+ this._setupListChangedHandlers(this._pendingListChangedConfig);
41071
+ this._pendingListChangedConfig = void 0;
41072
+ }
40995
41073
  } catch (error) {
40996
41074
  void this.close();
40997
41075
  throw error;
@@ -41016,16 +41094,15 @@ class Client extends Protocol {
41016
41094
  return this._instructions;
41017
41095
  }
41018
41096
  assertCapabilityForMethod(method) {
41019
- var _a, _b, _c, _d, _e2;
41020
41097
  switch (method) {
41021
41098
  case "logging/setLevel":
41022
- if (!((_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.logging)) {
41099
+ if (!this._serverCapabilities?.logging) {
41023
41100
  throw new Error(`Server does not support logging (required for ${method})`);
41024
41101
  }
41025
41102
  break;
41026
41103
  case "prompts/get":
41027
41104
  case "prompts/list":
41028
- if (!((_b = this._serverCapabilities) === null || _b === void 0 ? void 0 : _b.prompts)) {
41105
+ if (!this._serverCapabilities?.prompts) {
41029
41106
  throw new Error(`Server does not support prompts (required for ${method})`);
41030
41107
  }
41031
41108
  break;
@@ -41034,7 +41111,7 @@ class Client extends Protocol {
41034
41111
  case "resources/read":
41035
41112
  case "resources/subscribe":
41036
41113
  case "resources/unsubscribe":
41037
- if (!((_c = this._serverCapabilities) === null || _c === void 0 ? void 0 : _c.resources)) {
41114
+ if (!this._serverCapabilities?.resources) {
41038
41115
  throw new Error(`Server does not support resources (required for ${method})`);
41039
41116
  }
41040
41117
  if (method === "resources/subscribe" && !this._serverCapabilities.resources.subscribe) {
@@ -41043,22 +41120,21 @@ class Client extends Protocol {
41043
41120
  break;
41044
41121
  case "tools/call":
41045
41122
  case "tools/list":
41046
- if (!((_d = this._serverCapabilities) === null || _d === void 0 ? void 0 : _d.tools)) {
41123
+ if (!this._serverCapabilities?.tools) {
41047
41124
  throw new Error(`Server does not support tools (required for ${method})`);
41048
41125
  }
41049
41126
  break;
41050
41127
  case "completion/complete":
41051
- if (!((_e2 = this._serverCapabilities) === null || _e2 === void 0 ? void 0 : _e2.completions)) {
41128
+ if (!this._serverCapabilities?.completions) {
41052
41129
  throw new Error(`Server does not support completions (required for ${method})`);
41053
41130
  }
41054
41131
  break;
41055
41132
  }
41056
41133
  }
41057
41134
  assertNotificationCapability(method) {
41058
- var _a;
41059
41135
  switch (method) {
41060
41136
  case "notifications/roots/list_changed":
41061
- if (!((_a = this._capabilities.roots) === null || _a === void 0 ? void 0 : _a.listChanged)) {
41137
+ if (!this._capabilities.roots?.listChanged) {
41062
41138
  throw new Error(`Client does not support roots list changed notifications (required for ${method})`);
41063
41139
  }
41064
41140
  break;
@@ -41095,15 +41171,13 @@ class Client extends Protocol {
41095
41171
  }
41096
41172
  }
41097
41173
  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");
41174
+ assertToolsCallTaskCapability(this._serverCapabilities?.tasks?.requests, method, "Server");
41100
41175
  }
41101
41176
  assertTaskHandlerCapability(method) {
41102
- var _a;
41103
41177
  if (!this._capabilities) {
41104
41178
  return;
41105
41179
  }
41106
- assertClientRequestTaskCapability((_a = this._capabilities.tasks) === null || _a === void 0 ? void 0 : _a.requests, method, "Client");
41180
+ assertClientRequestTaskCapability(this._capabilities.tasks?.requests, method, "Client");
41107
41181
  }
41108
41182
  async ping(options) {
41109
41183
  return this.request({ method: "ping" }, EmptyResultSchema, options);
@@ -41167,8 +41241,7 @@ class Client extends Protocol {
41167
41241
  return result;
41168
41242
  }
41169
41243
  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)) {
41244
+ if (!this._serverCapabilities?.tasks?.requests?.tools?.call) {
41172
41245
  return false;
41173
41246
  }
41174
41247
  return this._cachedKnownTaskTools.has(toolName);
@@ -41185,7 +41258,6 @@ class Client extends Protocol {
41185
41258
  * Called after listTools() to pre-compile validators for better performance.
41186
41259
  */
41187
41260
  cacheToolMetadata(tools) {
41188
- var _a;
41189
41261
  this._cachedToolOutputValidators.clear();
41190
41262
  this._cachedKnownTaskTools.clear();
41191
41263
  this._cachedRequiredTaskTools.clear();
@@ -41194,7 +41266,7 @@ class Client extends Protocol {
41194
41266
  const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
41195
41267
  this._cachedToolOutputValidators.set(tool.name, toolValidator);
41196
41268
  }
41197
- const taskSupport = (_a = tool.execution) === null || _a === void 0 ? void 0 : _a.taskSupport;
41269
+ const taskSupport = tool.execution?.taskSupport;
41198
41270
  if (taskSupport === "required" || taskSupport === "optional") {
41199
41271
  this._cachedKnownTaskTools.add(tool.name);
41200
41272
  }
@@ -41214,6 +41286,47 @@ class Client extends Protocol {
41214
41286
  this.cacheToolMetadata(result.tools);
41215
41287
  return result;
41216
41288
  }
41289
+ /**
41290
+ * Set up a single list changed handler.
41291
+ * @internal
41292
+ */
41293
+ _setupListChangedHandler(listType, notificationSchema, options, fetcher) {
41294
+ const parseResult = ListChangedOptionsBaseSchema.safeParse(options);
41295
+ if (!parseResult.success) {
41296
+ throw new Error(`Invalid ${listType} listChanged options: ${parseResult.error.message}`);
41297
+ }
41298
+ if (typeof options.onChanged !== "function") {
41299
+ throw new Error(`Invalid ${listType} listChanged options: onChanged must be a function`);
41300
+ }
41301
+ const { autoRefresh, debounceMs } = parseResult.data;
41302
+ const { onChanged } = options;
41303
+ const refresh = async () => {
41304
+ if (!autoRefresh) {
41305
+ onChanged(null, null);
41306
+ return;
41307
+ }
41308
+ try {
41309
+ const items2 = await fetcher();
41310
+ onChanged(null, items2);
41311
+ } catch (e) {
41312
+ const error = e instanceof Error ? e : new Error(String(e));
41313
+ onChanged(error, null);
41314
+ }
41315
+ };
41316
+ const handler = () => {
41317
+ if (debounceMs) {
41318
+ const existingTimer = this._listChangedDebounceTimers.get(listType);
41319
+ if (existingTimer) {
41320
+ clearTimeout(existingTimer);
41321
+ }
41322
+ const timer = setTimeout(refresh, debounceMs);
41323
+ this._listChangedDebounceTimers.set(listType, timer);
41324
+ } else {
41325
+ refresh();
41326
+ }
41327
+ };
41328
+ this.setNotificationHandler(notificationSchema, handler);
41329
+ }
41217
41330
  async sendRootsListChanged() {
41218
41331
  return this.notification({ method: "notifications/roots/list_changed" });
41219
41332
  }
@@ -41343,7 +41456,7 @@ class ErrorEvent extends Event {
41343
41456
  * @param inspect - The inspect function to use (prevents having to import it from `util`)
41344
41457
  * @returns A string representation of the error
41345
41458
  */
41346
- [Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
41459
+ [/* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom")](_depth, options, inspect) {
41347
41460
  return inspect(inspectableError(this), options);
41348
41461
  }
41349
41462
  /**
@@ -41357,7 +41470,7 @@ class ErrorEvent extends Event {
41357
41470
  * @param options - The options passed to `Deno.inspect`
41358
41471
  * @returns A string representation of the error
41359
41472
  */
41360
- [Symbol.for("Deno.customInspect")](inspect, options) {
41473
+ [/* @__PURE__ */ Symbol.for("Deno.customInspect")](inspect, options) {
41361
41474
  return inspect(inspectableError(this), options);
41362
41475
  }
41363
41476
  }
@@ -41606,7 +41719,7 @@ function createFetchWithInit(baseFetch = fetch, baseInit) {
41606
41719
  ...baseInit,
41607
41720
  ...init,
41608
41721
  // 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
41722
+ headers: init?.headers ? { ...normalizeHeaders(baseInit.headers), ...normalizeHeaders(init.headers) } : baseInit.headers
41610
41723
  };
41611
41724
  return baseFetch(url2, mergedInit);
41612
41725
  };
@@ -41623,14 +41736,13 @@ class SSEClientTransport {
41623
41736
  this._url = url2;
41624
41737
  this._resourceMetadataUrl = void 0;
41625
41738
  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);
41739
+ this._eventSourceInit = opts?.eventSourceInit;
41740
+ this._requestInit = opts?.requestInit;
41741
+ this._authProvider = opts?.authProvider;
41742
+ this._fetch = opts?.fetch;
41743
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
41631
41744
  }
41632
41745
  async _authThenStart() {
41633
- var _a;
41634
41746
  if (!this._authProvider) {
41635
41747
  throw new UnauthorizedError("No auth provider");
41636
41748
  }
@@ -41643,7 +41755,7 @@ class SSEClientTransport {
41643
41755
  fetchFn: this._fetchWithInit
41644
41756
  });
41645
41757
  } catch (error) {
41646
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
41758
+ this.onerror?.(error);
41647
41759
  throw error;
41648
41760
  }
41649
41761
  if (result !== "AUTHORIZED") {
@@ -41652,7 +41764,6 @@ class SSEClientTransport {
41652
41764
  return await this._startOrAuth();
41653
41765
  }
41654
41766
  async _commonHeaders() {
41655
- var _a;
41656
41767
  const headers = {};
41657
41768
  if (this._authProvider) {
41658
41769
  const tokens = await this._authProvider.tokens();
@@ -41663,15 +41774,14 @@ class SSEClientTransport {
41663
41774
  if (this._protocolVersion) {
41664
41775
  headers["mcp-protocol-version"] = this._protocolVersion;
41665
41776
  }
41666
- const extraHeaders = normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
41777
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
41667
41778
  return new Headers({
41668
41779
  ...headers,
41669
41780
  ...extraHeaders
41670
41781
  });
41671
41782
  }
41672
41783
  _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;
41784
+ const fetchImpl = this?._eventSourceInit?.fetch ?? this._fetch ?? fetch;
41675
41785
  return new Promise((resolve2, reject) => {
41676
41786
  this._eventSource = new EventSource(this._url.href, {
41677
41787
  ...this._eventSourceInit,
@@ -41692,19 +41802,17 @@ class SSEClientTransport {
41692
41802
  });
41693
41803
  this._abortController = new AbortController();
41694
41804
  this._eventSource.onerror = (event) => {
41695
- var _a2;
41696
41805
  if (event.code === 401 && this._authProvider) {
41697
41806
  this._authThenStart().then(resolve2, reject);
41698
41807
  return;
41699
41808
  }
41700
41809
  const error = new SseError(event.code, event.message, event);
41701
41810
  reject(error);
41702
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
41811
+ this.onerror?.(error);
41703
41812
  };
41704
41813
  this._eventSource.onopen = () => {
41705
41814
  };
41706
41815
  this._eventSource.addEventListener("endpoint", (event) => {
41707
- var _a2;
41708
41816
  const messageEvent = event;
41709
41817
  try {
41710
41818
  this._endpoint = new URL(messageEvent.data, this._url);
@@ -41713,23 +41821,22 @@ class SSEClientTransport {
41713
41821
  }
41714
41822
  } catch (error) {
41715
41823
  reject(error);
41716
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
41824
+ this.onerror?.(error);
41717
41825
  void this.close();
41718
41826
  return;
41719
41827
  }
41720
41828
  resolve2();
41721
41829
  });
41722
41830
  this._eventSource.onmessage = (event) => {
41723
- var _a2, _b2;
41724
41831
  const messageEvent = event;
41725
41832
  let message;
41726
41833
  try {
41727
41834
  message = JSONRPCMessageSchema.parse(JSON.parse(messageEvent.data));
41728
41835
  } catch (error) {
41729
- (_a2 = this.onerror) === null || _a2 === void 0 ? void 0 : _a2.call(this, error);
41836
+ this.onerror?.(error);
41730
41837
  return;
41731
41838
  }
41732
- (_b2 = this.onmessage) === null || _b2 === void 0 ? void 0 : _b2.call(this, message);
41839
+ this.onmessage?.(message);
41733
41840
  };
41734
41841
  });
41735
41842
  }
@@ -41758,13 +41865,11 @@ class SSEClientTransport {
41758
41865
  }
41759
41866
  }
41760
41867
  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);
41868
+ this._abortController?.abort();
41869
+ this._eventSource?.close();
41870
+ this.onclose?.();
41765
41871
  }
41766
41872
  async send(message) {
41767
- var _a, _b, _c, _d;
41768
41873
  if (!this._endpoint) {
41769
41874
  throw new Error("Not connected");
41770
41875
  }
@@ -41776,9 +41881,9 @@ class SSEClientTransport {
41776
41881
  method: "POST",
41777
41882
  headers,
41778
41883
  body: JSON.stringify(message),
41779
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
41884
+ signal: this._abortController?.signal
41780
41885
  };
41781
- const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._endpoint, init);
41886
+ const response = await (this._fetch ?? fetch)(this._endpoint, init);
41782
41887
  if (!response.ok) {
41783
41888
  const text = await response.text().catch(() => null);
41784
41889
  if (response.status === 401 && this._authProvider) {
@@ -41798,9 +41903,9 @@ class SSEClientTransport {
41798
41903
  }
41799
41904
  throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
41800
41905
  }
41801
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
41906
+ await response.body?.cancel();
41802
41907
  } catch (error) {
41803
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
41908
+ this.onerror?.(error);
41804
41909
  throw error;
41805
41910
  }
41806
41911
  }
@@ -41844,20 +41949,18 @@ class StreamableHTTPError extends Error {
41844
41949
  }
41845
41950
  class StreamableHTTPClientTransport {
41846
41951
  constructor(url2, opts) {
41847
- var _a;
41848
41952
  this._hasCompletedAuthFlow = false;
41849
41953
  this._url = url2;
41850
41954
  this._resourceMetadataUrl = void 0;
41851
41955
  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;
41956
+ this._requestInit = opts?.requestInit;
41957
+ this._authProvider = opts?.authProvider;
41958
+ this._fetch = opts?.fetch;
41959
+ this._fetchWithInit = createFetchWithInit(opts?.fetch, opts?.requestInit);
41960
+ this._sessionId = opts?.sessionId;
41961
+ this._reconnectionOptions = opts?.reconnectionOptions ?? DEFAULT_STREAMABLE_HTTP_RECONNECTION_OPTIONS;
41858
41962
  }
41859
41963
  async _authThenStart() {
41860
- var _a;
41861
41964
  if (!this._authProvider) {
41862
41965
  throw new UnauthorizedError("No auth provider");
41863
41966
  }
@@ -41870,7 +41973,7 @@ class StreamableHTTPClientTransport {
41870
41973
  fetchFn: this._fetchWithInit
41871
41974
  });
41872
41975
  } catch (error) {
41873
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error);
41976
+ this.onerror?.(error);
41874
41977
  throw error;
41875
41978
  }
41876
41979
  if (result !== "AUTHORIZED") {
@@ -41879,7 +41982,6 @@ class StreamableHTTPClientTransport {
41879
41982
  return await this._startOrAuthSse({ resumptionToken: void 0 });
41880
41983
  }
41881
41984
  async _commonHeaders() {
41882
- var _a;
41883
41985
  const headers = {};
41884
41986
  if (this._authProvider) {
41885
41987
  const tokens = await this._authProvider.tokens();
@@ -41893,14 +41995,13 @@ class StreamableHTTPClientTransport {
41893
41995
  if (this._protocolVersion) {
41894
41996
  headers["mcp-protocol-version"] = this._protocolVersion;
41895
41997
  }
41896
- const extraHeaders = normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
41998
+ const extraHeaders = normalizeHeaders(this._requestInit?.headers);
41897
41999
  return new Headers({
41898
42000
  ...headers,
41899
42001
  ...extraHeaders
41900
42002
  });
41901
42003
  }
41902
42004
  async _startOrAuthSse(options) {
41903
- var _a, _b, _c, _d;
41904
42005
  const { resumptionToken } = options;
41905
42006
  try {
41906
42007
  const headers = await this._commonHeaders();
@@ -41908,13 +42009,13 @@ class StreamableHTTPClientTransport {
41908
42009
  if (resumptionToken) {
41909
42010
  headers.set("last-event-id", resumptionToken);
41910
42011
  }
41911
- const response = await ((_a = this._fetch) !== null && _a !== void 0 ? _a : fetch)(this._url, {
42012
+ const response = await (this._fetch ?? fetch)(this._url, {
41912
42013
  method: "GET",
41913
42014
  headers,
41914
- signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal
42015
+ signal: this._abortController?.signal
41915
42016
  });
41916
42017
  if (!response.ok) {
41917
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
42018
+ await response.body?.cancel();
41918
42019
  if (response.status === 401 && this._authProvider) {
41919
42020
  return await this._authThenStart();
41920
42021
  }
@@ -41925,7 +42026,7 @@ class StreamableHTTPClientTransport {
41925
42026
  }
41926
42027
  this._handleSseStream(response.body, options, true);
41927
42028
  } catch (error) {
41928
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
42029
+ this.onerror?.(error);
41929
42030
  throw error;
41930
42031
  }
41931
42032
  }
@@ -41951,17 +42052,15 @@ class StreamableHTTPClientTransport {
41951
42052
  * @param attemptCount Current reconnection attempt count for this specific stream
41952
42053
  */
41953
42054
  _scheduleReconnection(options, attemptCount = 0) {
41954
- var _a;
41955
42055
  const maxRetries = this._reconnectionOptions.maxRetries;
41956
42056
  if (attemptCount >= maxRetries) {
41957
- (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
42057
+ this.onerror?.(new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
41958
42058
  return;
41959
42059
  }
41960
42060
  const delay = this._getNextReconnectionDelay(attemptCount);
41961
42061
  this._reconnectionTimeout = setTimeout(() => {
41962
42062
  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)}`));
42063
+ this.onerror?.(new Error(`Failed to reconnect SSE stream: ${error instanceof Error ? error.message : String(error)}`));
41965
42064
  this._scheduleReconnection(options, attemptCount + 1);
41966
42065
  });
41967
42066
  }, delay);
@@ -41975,7 +42074,6 @@ class StreamableHTTPClientTransport {
41975
42074
  let hasPrimingEvent = false;
41976
42075
  let receivedResponse = false;
41977
42076
  const processStream = async () => {
41978
- var _a, _b, _c, _d;
41979
42077
  try {
41980
42078
  const reader = stream.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream({
41981
42079
  onRetry: (retryMs) => {
@@ -41990,7 +42088,7 @@ class StreamableHTTPClientTransport {
41990
42088
  if (event.id) {
41991
42089
  lastEventId = event.id;
41992
42090
  hasPrimingEvent = true;
41993
- onresumptiontoken === null || onresumptiontoken === void 0 ? void 0 : onresumptiontoken(event.id);
42091
+ onresumptiontoken?.(event.id);
41994
42092
  }
41995
42093
  if (!event.data) {
41996
42094
  continue;
@@ -41998,15 +42096,15 @@ class StreamableHTTPClientTransport {
41998
42096
  if (!event.event || event.event === "message") {
41999
42097
  try {
42000
42098
  const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
42001
- if (isJSONRPCResponse(message)) {
42099
+ if (isJSONRPCResultResponse(message)) {
42002
42100
  receivedResponse = true;
42003
42101
  if (replayMessageId !== void 0) {
42004
42102
  message.id = replayMessageId;
42005
42103
  }
42006
42104
  }
42007
- (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);
42105
+ this.onmessage?.(message);
42008
42106
  } catch (error) {
42009
- (_b = this.onerror) === null || _b === void 0 ? void 0 : _b.call(this, error);
42107
+ this.onerror?.(error);
42010
42108
  }
42011
42109
  }
42012
42110
  }
@@ -42020,7 +42118,7 @@ class StreamableHTTPClientTransport {
42020
42118
  }, 0);
42021
42119
  }
42022
42120
  } catch (error) {
42023
- (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, new Error(`SSE stream disconnected: ${error}`));
42121
+ this.onerror?.(new Error(`SSE stream disconnected: ${error}`));
42024
42122
  const canResume = isReconnectable || hasPrimingEvent;
42025
42123
  const needsReconnect = canResume && !receivedResponse;
42026
42124
  if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
@@ -42031,7 +42129,7 @@ class StreamableHTTPClientTransport {
42031
42129
  replayMessageId
42032
42130
  }, 0);
42033
42131
  } 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)}`));
42132
+ this.onerror?.(new Error(`Failed to reconnect: ${error2 instanceof Error ? error2.message : String(error2)}`));
42035
42133
  }
42036
42134
  }
42037
42135
  }
@@ -42063,23 +42161,18 @@ class StreamableHTTPClientTransport {
42063
42161
  }
42064
42162
  }
42065
42163
  async close() {
42066
- var _a, _b;
42067
42164
  if (this._reconnectionTimeout) {
42068
42165
  clearTimeout(this._reconnectionTimeout);
42069
42166
  this._reconnectionTimeout = void 0;
42070
42167
  }
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);
42168
+ this._abortController?.abort();
42169
+ this.onclose?.();
42073
42170
  }
42074
42171
  async send(message, options) {
42075
- var _a, _b, _c, _d, _e2, _f, _g;
42076
42172
  try {
42077
42173
  const { resumptionToken, onresumptiontoken } = options || {};
42078
42174
  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
- });
42175
+ this._startOrAuthSse({ resumptionToken, replayMessageId: isJSONRPCRequest(message) ? message.id : void 0 }).catch((err) => this.onerror?.(err));
42083
42176
  return;
42084
42177
  }
42085
42178
  const headers = await this._commonHeaders();
@@ -42090,9 +42183,9 @@ class StreamableHTTPClientTransport {
42090
42183
  method: "POST",
42091
42184
  headers,
42092
42185
  body: JSON.stringify(message),
42093
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
42186
+ signal: this._abortController?.signal
42094
42187
  };
42095
- const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);
42188
+ const response = await (this._fetch ?? fetch)(this._url, init);
42096
42189
  const sessionId = response.headers.get("mcp-session-id");
42097
42190
  if (sessionId) {
42098
42191
  this._sessionId = sessionId;
@@ -42131,7 +42224,7 @@ class StreamableHTTPClientTransport {
42131
42224
  if (resourceMetadataUrl) {
42132
42225
  this._resourceMetadataUrl = resourceMetadataUrl;
42133
42226
  }
42134
- this._lastUpscopingHeader = wwwAuthHeader !== null && wwwAuthHeader !== void 0 ? wwwAuthHeader : void 0;
42227
+ this._lastUpscopingHeader = wwwAuthHeader ?? void 0;
42135
42228
  const result = await auth(this._authProvider, {
42136
42229
  serverUrl: this._url,
42137
42230
  resourceMetadataUrl: this._resourceMetadataUrl,
@@ -42149,12 +42242,9 @@ class StreamableHTTPClientTransport {
42149
42242
  this._hasCompletedAuthFlow = false;
42150
42243
  this._lastUpscopingHeader = void 0;
42151
42244
  if (response.status === 202) {
42152
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
42245
+ await response.body?.cancel();
42153
42246
  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
- });
42247
+ this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => this.onerror?.(err));
42158
42248
  }
42159
42249
  return;
42160
42250
  }
@@ -42162,23 +42252,23 @@ class StreamableHTTPClientTransport {
42162
42252
  const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
42163
42253
  const contentType = response.headers.get("content-type");
42164
42254
  if (hasRequests) {
42165
- if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("text/event-stream")) {
42255
+ if (contentType?.includes("text/event-stream")) {
42166
42256
  this._handleSseStream(response.body, { onresumptiontoken }, false);
42167
- } else if (contentType === null || contentType === void 0 ? void 0 : contentType.includes("application/json")) {
42257
+ } else if (contentType?.includes("application/json")) {
42168
42258
  const data2 = await response.json();
42169
42259
  const responseMessages = Array.isArray(data2) ? data2.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data2)];
42170
42260
  for (const msg of responseMessages) {
42171
- (_d = this.onmessage) === null || _d === void 0 ? void 0 : _d.call(this, msg);
42261
+ this.onmessage?.(msg);
42172
42262
  }
42173
42263
  } else {
42174
- await ((_e2 = response.body) === null || _e2 === void 0 ? void 0 : _e2.cancel());
42264
+ await response.body?.cancel();
42175
42265
  throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
42176
42266
  }
42177
42267
  } else {
42178
- await ((_f = response.body) === null || _f === void 0 ? void 0 : _f.cancel());
42268
+ await response.body?.cancel();
42179
42269
  }
42180
42270
  } catch (error) {
42181
- (_g = this.onerror) === null || _g === void 0 ? void 0 : _g.call(this, error);
42271
+ this.onerror?.(error);
42182
42272
  throw error;
42183
42273
  }
42184
42274
  }
@@ -42197,7 +42287,6 @@ class StreamableHTTPClientTransport {
42197
42287
  * the server does not allow clients to terminate sessions.
42198
42288
  */
42199
42289
  async terminateSession() {
42200
- var _a, _b, _c, _d;
42201
42290
  if (!this._sessionId) {
42202
42291
  return;
42203
42292
  }
@@ -42207,16 +42296,16 @@ class StreamableHTTPClientTransport {
42207
42296
  ...this._requestInit,
42208
42297
  method: "DELETE",
42209
42298
  headers,
42210
- signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
42299
+ signal: this._abortController?.signal
42211
42300
  };
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());
42301
+ const response = await (this._fetch ?? fetch)(this._url, init);
42302
+ await response.body?.cancel();
42214
42303
  if (!response.ok && response.status !== 405) {
42215
42304
  throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
42216
42305
  }
42217
42306
  this._sessionId = void 0;
42218
42307
  } catch (error) {
42219
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
42308
+ this.onerror?.(error);
42220
42309
  throw error;
42221
42310
  }
42222
42311
  }
@@ -42236,7 +42325,7 @@ class StreamableHTTPClientTransport {
42236
42325
  async resumeStream(lastEventId, options) {
42237
42326
  await this._startOrAuthSse({
42238
42327
  resumptionToken: lastEventId,
42239
- onresumptiontoken: options === null || options === void 0 ? void 0 : options.onresumptiontoken
42328
+ onresumptiontoken: options?.onresumptiontoken
42240
42329
  });
42241
42330
  }
42242
42331
  }
@@ -42272,6 +42361,9 @@ const getMCPProxyAuthToken = (config2) => {
42272
42361
  header: "X-MCP-Proxy-Auth"
42273
42362
  };
42274
42363
  };
42364
+ const getMCPTaskTtl = (config2) => {
42365
+ return config2.MCP_TASK_TTL.value;
42366
+ };
42275
42367
  const getInitialTransportType = () => {
42276
42368
  const param = getSearchParam("transport");
42277
42369
  if (param === "stdio" || param === "sse" || param === "streamable-http") {
@@ -42389,6 +42481,7 @@ function useConnection({
42389
42481
  null
42390
42482
  );
42391
42483
  const [serverImplementation, setServerImplementation] = reactExports.useState(null);
42484
+ const receiverTasksRef = reactExports.useRef(/* @__PURE__ */ new Map());
42392
42485
  reactExports.useEffect(() => {
42393
42486
  if (!oauthClientId) {
42394
42487
  clearClientInformationFromSessionStorage({
@@ -42563,7 +42656,7 @@ function useConnection({
42563
42656
  }
42564
42657
  };
42565
42658
  const is401Error = (error) => {
42566
- return error instanceof SseError && error.code === 401 || error instanceof Error && error.message.includes("401") || error instanceof Error && error.message.includes("Unauthorized");
42659
+ return error instanceof SseError && error.code === 401 || error instanceof StreamableHTTPError && error.code === 401 || error instanceof Error && error.message.includes("401") || error instanceof Error && error.message.includes("Unauthorized") || error instanceof Error && error.message.includes("Missing Authorization header");
42567
42660
  };
42568
42661
  const isProxyAuthError = (error) => {
42569
42662
  return error instanceof Error && error.message.includes("Authentication required. Use the session token");
@@ -42583,11 +42676,20 @@ function useConnection({
42583
42676
  }
42584
42677
  saveScopeToSessionStorage(sseUrl, scope2);
42585
42678
  const serverAuthProvider = new InspectorOAuthClientProvider(sseUrl);
42586
- const result = await auth(serverAuthProvider, {
42587
- serverUrl: sseUrl,
42588
- scope: scope2
42589
- });
42590
- return result === "AUTHORIZED";
42679
+ try {
42680
+ const result = await auth(serverAuthProvider, {
42681
+ serverUrl: sseUrl,
42682
+ scope: scope2
42683
+ });
42684
+ return result === "AUTHORIZED";
42685
+ } catch (authError) {
42686
+ toast2({
42687
+ title: "OAuth Authentication Failed",
42688
+ description: authError instanceof Error ? authError.message : String(authError),
42689
+ variant: "destructive"
42690
+ });
42691
+ return false;
42692
+ }
42591
42693
  }
42592
42694
  return false;
42593
42695
  };
@@ -42608,6 +42710,16 @@ function useConnection({
42608
42710
  elicitation: {},
42609
42711
  roots: {
42610
42712
  listChanged: true
42713
+ },
42714
+ tasks: {
42715
+ list: {},
42716
+ cancel: {},
42717
+ ...onPendingRequest || onElicitationRequest ? {
42718
+ requests: {
42719
+ ...onPendingRequest ? { sampling: { createMessage: {} } } : void 0,
42720
+ ...onElicitationRequest ? { elicitation: { create: {} } } : void 0
42721
+ }
42722
+ } : void 0
42611
42723
  }
42612
42724
  }
42613
42725
  };
@@ -42683,6 +42795,7 @@ function useConnection({
42683
42795
  requestHeaders["Accept"] = "text/event-stream";
42684
42796
  requestHeaders["content-type"] = "application/json";
42685
42797
  transportOptions = {
42798
+ authProvider: serverAuthProvider,
42686
42799
  fetch: async (url2, init) => {
42687
42800
  const response = await fetch(url2, {
42688
42801
  ...init,
@@ -42698,6 +42811,7 @@ function useConnection({
42698
42811
  break;
42699
42812
  case "streamable-http":
42700
42813
  transportOptions = {
42814
+ authProvider: serverAuthProvider,
42701
42815
  fetch: async (url2, init) => {
42702
42816
  requestHeaders["Accept"] = "text/event-stream, application/json";
42703
42817
  requestHeaders["Content-Type"] = "application/json";
@@ -42766,6 +42880,7 @@ function useConnection({
42766
42880
  );
42767
42881
  }
42768
42882
  transportOptions = {
42883
+ authProvider: serverAuthProvider,
42769
42884
  eventSourceInit: {
42770
42885
  fetch: (url2, init) => fetch(url2, {
42771
42886
  ...init,
@@ -42782,6 +42897,7 @@ function useConnection({
42782
42897
  mcpProxyServerUrl = new URL(`${getMCPProxyAddress(config2)}/mcp`);
42783
42898
  mcpProxyServerUrl.searchParams.append("url", sseUrl);
42784
42899
  transportOptions = {
42900
+ authProvider: serverAuthProvider,
42785
42901
  eventSourceInit: {
42786
42902
  fetch: (url2, init) => fetch(url2, {
42787
42903
  ...init,
@@ -42811,7 +42927,8 @@ function useConnection({
42811
42927
  ResourceUpdatedNotificationSchema,
42812
42928
  ResourceListChangedNotificationSchema,
42813
42929
  ToolListChangedNotificationSchema,
42814
- PromptListChangedNotificationSchema
42930
+ PromptListChangedNotificationSchema,
42931
+ TaskStatusNotificationSchema
42815
42932
  ].forEach((notificationSchema) => {
42816
42933
  client2.setNotificationHandler(notificationSchema, onNotification);
42817
42934
  });
@@ -42871,11 +42988,170 @@ function useConnection({
42871
42988
  }
42872
42989
  setServerCapabilities(capabilities ?? null);
42873
42990
  setCompletionsSupported(capabilities?.completions !== void 0);
42991
+ const nowIso = () => (/* @__PURE__ */ new Date()).toISOString();
42992
+ const makeTaskId = () => {
42993
+ const cryptoAny = globalThis.crypto;
42994
+ return cryptoAny?.randomUUID?.() ?? `task_${Date.now()}_${Math.random().toString(16).slice(2)}`;
42995
+ };
42996
+ const emitTaskStatus = async (task) => {
42997
+ try {
42998
+ const notification = {
42999
+ method: "notifications/tasks/status",
43000
+ params: task
43001
+ };
43002
+ await client2.notification(notification);
43003
+ pushHistory(notification);
43004
+ } catch (e) {
43005
+ console.warn("Failed to send notifications/tasks/status", e);
43006
+ }
43007
+ };
43008
+ const upsertReceiverTask = async (task) => {
43009
+ const record2 = receiverTasksRef.current.get(task.taskId);
43010
+ if (record2) {
43011
+ receiverTasksRef.current.set(task.taskId, { ...record2, task });
43012
+ }
43013
+ await emitTaskStatus(task);
43014
+ };
43015
+ const createReceiverTask = (opts) => {
43016
+ const taskId = makeTaskId();
43017
+ const createdAt = nowIso();
43018
+ const ttl = opts.ttl ?? getMCPTaskTtl(config2);
43019
+ let resolvePayload = () => void 0;
43020
+ let rejectPayload = () => void 0;
43021
+ const payloadPromise = new Promise((resolve2, reject) => {
43022
+ resolvePayload = resolve2;
43023
+ rejectPayload = reject;
43024
+ });
43025
+ const task = {
43026
+ taskId,
43027
+ status: opts.initialStatus,
43028
+ ttl,
43029
+ createdAt,
43030
+ lastUpdatedAt: createdAt,
43031
+ ...opts.pollInterval !== void 0 ? { pollInterval: opts.pollInterval } : void 0,
43032
+ ...opts.statusMessage ? { statusMessage: opts.statusMessage } : {}
43033
+ };
43034
+ const record2 = {
43035
+ task,
43036
+ payloadPromise,
43037
+ resolvePayload,
43038
+ rejectPayload
43039
+ };
43040
+ if (ttl !== null && ttl > 0) {
43041
+ record2.cleanupTimeoutId = setTimeout(() => {
43042
+ receiverTasksRef.current.delete(taskId);
43043
+ }, ttl);
43044
+ }
43045
+ receiverTasksRef.current.set(taskId, record2);
43046
+ void emitTaskStatus(task);
43047
+ return record2;
43048
+ };
43049
+ client2.setRequestHandler(ListTasksRequestSchema, async () => {
43050
+ return {
43051
+ tasks: Array.from(receiverTasksRef.current.values()).map(
43052
+ (r2) => r2.task
43053
+ )
43054
+ };
43055
+ });
43056
+ client2.setRequestHandler(GetTaskRequestSchema, async (request) => {
43057
+ const record2 = receiverTasksRef.current.get(request.params.taskId);
43058
+ if (!record2) {
43059
+ throw new McpError(
43060
+ ErrorCode.InvalidParams,
43061
+ `Unknown taskId: ${request.params.taskId}`
43062
+ );
43063
+ }
43064
+ return record2.task;
43065
+ });
43066
+ client2.setRequestHandler(GetTaskPayloadRequestSchema, async (request) => {
43067
+ const record2 = receiverTasksRef.current.get(request.params.taskId);
43068
+ if (!record2) {
43069
+ throw new McpError(
43070
+ ErrorCode.InvalidParams,
43071
+ `Unknown taskId: ${request.params.taskId}`
43072
+ );
43073
+ }
43074
+ return await record2.payloadPromise;
43075
+ });
43076
+ client2.setRequestHandler(CancelTaskRequestSchema, async (request) => {
43077
+ const record2 = receiverTasksRef.current.get(request.params.taskId);
43078
+ if (!record2) {
43079
+ throw new McpError(
43080
+ ErrorCode.InvalidParams,
43081
+ `Unknown taskId: ${request.params.taskId}`
43082
+ );
43083
+ }
43084
+ const terminalStatuses = [
43085
+ "completed",
43086
+ "failed",
43087
+ "cancelled"
43088
+ ];
43089
+ if (!terminalStatuses.includes(record2.task.status)) {
43090
+ const updated = {
43091
+ ...record2.task,
43092
+ status: "cancelled",
43093
+ lastUpdatedAt: nowIso(),
43094
+ statusMessage: "Cancelled"
43095
+ };
43096
+ receiverTasksRef.current.set(request.params.taskId, {
43097
+ ...record2,
43098
+ task: updated
43099
+ });
43100
+ record2.rejectPayload(
43101
+ new McpError(ErrorCode.InternalError, "Task was cancelled")
43102
+ );
43103
+ await emitTaskStatus(updated);
43104
+ }
43105
+ return receiverTasksRef.current.get(request.params.taskId).task;
43106
+ });
42874
43107
  if (onPendingRequest) {
42875
43108
  client2.setRequestHandler(CreateMessageRequestSchema, (request) => {
42876
- return new Promise((resolve2, reject) => {
42877
- onPendingRequest(request, resolve2, reject);
43109
+ const taskSpec = request.params?.task;
43110
+ if (!taskSpec) {
43111
+ return new Promise((resolve2, reject) => {
43112
+ onPendingRequest(request, resolve2, reject);
43113
+ });
43114
+ }
43115
+ const record2 = createReceiverTask({
43116
+ ttl: taskSpec.ttl,
43117
+ initialStatus: "input_required",
43118
+ statusMessage: "Awaiting user input"
42878
43119
  });
43120
+ void (async () => {
43121
+ try {
43122
+ const payload = await new Promise((resolve2, reject) => {
43123
+ onPendingRequest(request, resolve2, reject);
43124
+ });
43125
+ record2.resolvePayload(payload);
43126
+ const updated = {
43127
+ ...record2.task,
43128
+ status: "completed",
43129
+ lastUpdatedAt: nowIso()
43130
+ };
43131
+ receiverTasksRef.current.set(record2.task.taskId, {
43132
+ ...record2,
43133
+ task: updated
43134
+ });
43135
+ await upsertReceiverTask(updated);
43136
+ } catch (e) {
43137
+ record2.rejectPayload(e);
43138
+ const updated = {
43139
+ ...record2.task,
43140
+ status: "failed",
43141
+ lastUpdatedAt: nowIso(),
43142
+ statusMessage: e instanceof Error ? e.message : "Task failed"
43143
+ };
43144
+ receiverTasksRef.current.set(record2.task.taskId, {
43145
+ ...record2,
43146
+ task: updated
43147
+ });
43148
+ await upsertReceiverTask(updated);
43149
+ }
43150
+ })();
43151
+ const createTaskResult = {
43152
+ task: record2.task
43153
+ };
43154
+ return createTaskResult;
42879
43155
  });
42880
43156
  }
42881
43157
  if (getRoots) {
@@ -42883,6 +43159,56 @@ function useConnection({
42883
43159
  return { roots: getRoots() };
42884
43160
  });
42885
43161
  }
43162
+ if (onElicitationRequest) {
43163
+ client2.setRequestHandler(ElicitRequestSchema, (request) => {
43164
+ const taskSpec = request.params?.task;
43165
+ if (!taskSpec) {
43166
+ return new Promise((resolve2) => {
43167
+ onElicitationRequest(request, resolve2);
43168
+ });
43169
+ }
43170
+ const record2 = createReceiverTask({
43171
+ ttl: taskSpec.ttl,
43172
+ initialStatus: "input_required",
43173
+ statusMessage: "Awaiting user input"
43174
+ });
43175
+ void (async () => {
43176
+ try {
43177
+ const payload = await new Promise((resolve2) => {
43178
+ onElicitationRequest(request, resolve2);
43179
+ });
43180
+ record2.resolvePayload(payload);
43181
+ const updated = {
43182
+ ...record2.task,
43183
+ status: "completed",
43184
+ lastUpdatedAt: nowIso()
43185
+ };
43186
+ receiverTasksRef.current.set(record2.task.taskId, {
43187
+ ...record2,
43188
+ task: updated
43189
+ });
43190
+ await upsertReceiverTask(updated);
43191
+ } catch (e) {
43192
+ record2.rejectPayload(e);
43193
+ const updated = {
43194
+ ...record2.task,
43195
+ status: "failed",
43196
+ lastUpdatedAt: nowIso(),
43197
+ statusMessage: e instanceof Error ? e.message : "Task failed"
43198
+ };
43199
+ receiverTasksRef.current.set(record2.task.taskId, {
43200
+ ...record2,
43201
+ task: updated
43202
+ });
43203
+ await upsertReceiverTask(updated);
43204
+ }
43205
+ })();
43206
+ const createTaskResult = {
43207
+ task: record2.task
43208
+ };
43209
+ return createTaskResult;
43210
+ });
43211
+ }
42886
43212
  if (capabilities?.logging && defaultLoggingLevel) {
42887
43213
  lastRequest = "logging/setLevel";
42888
43214
  await client2.setLoggingLevel(defaultLoggingLevel);
@@ -42897,13 +43223,6 @@ function useConnection({
42897
43223
  );
42898
43224
  lastRequest = "";
42899
43225
  }
42900
- if (onElicitationRequest) {
42901
- client2.setRequestHandler(ElicitRequestSchema, async (request) => {
42902
- return new Promise((resolve2) => {
42903
- onElicitationRequest(request, resolve2);
42904
- });
42905
- });
42906
- }
42907
43226
  setMcpClient(client2);
42908
43227
  setConnectionStatus("connected");
42909
43228
  } catch (e) {
@@ -42913,12 +43232,42 @@ function useConnection({
42913
43232
  description: `Server declares logging capability but doesn't implement method: "${lastRequest}"`,
42914
43233
  variant: "destructive"
42915
43234
  });
43235
+ } else {
43236
+ toast2({
43237
+ title: "Connection error",
43238
+ description: `Connection failed: "${e}"`,
43239
+ variant: "destructive"
43240
+ });
42916
43241
  }
42917
43242
  console.error(e);
42918
43243
  setConnectionStatus("error");
42919
43244
  }
42920
43245
  };
43246
+ const cancelTask = async (taskId) => {
43247
+ return makeRequest(
43248
+ {
43249
+ method: "tasks/cancel",
43250
+ params: { taskId }
43251
+ },
43252
+ CancelTaskResultSchema
43253
+ );
43254
+ };
43255
+ const listTasks = async (cursor) => {
43256
+ return makeRequest(
43257
+ {
43258
+ method: "tasks/list",
43259
+ params: { cursor }
43260
+ },
43261
+ ListTasksResultSchema
43262
+ );
43263
+ };
42921
43264
  const disconnect = async () => {
43265
+ receiverTasksRef.current.forEach((record2) => {
43266
+ if (record2.cleanupTimeoutId) {
43267
+ clearTimeout(record2.cleanupTimeoutId);
43268
+ }
43269
+ });
43270
+ receiverTasksRef.current.clear();
42922
43271
  if (transportType === "streamable-http")
42923
43272
  await clientTransport.terminateSession();
42924
43273
  await mcpClient?.close();
@@ -42944,6 +43293,8 @@ function useConnection({
42944
43293
  requestHistory,
42945
43294
  clearRequestHistory,
42946
43295
  makeRequest,
43296
+ cancelTask,
43297
+ listTasks,
42947
43298
  sendNotification,
42948
43299
  handleCompletion,
42949
43300
  completionsSupported,
@@ -43477,7 +43828,7 @@ const TabsContent = reactExports.forwardRef(({ className, ...props }, ref2) => /
43477
43828
  }
43478
43829
  ));
43479
43830
  TabsContent.displayName = Content$2.displayName;
43480
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
43831
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
43481
43832
  var use = React$1[" use ".trim().toString()];
43482
43833
  function isPromiseLike(value) {
43483
43834
  return typeof value === "object" && value !== null && "then" in value;
@@ -43533,7 +43884,7 @@ function createSlotClone$3(ownerName) {
43533
43884
  SlotClone.displayName = `${ownerName}.SlotClone`;
43534
43885
  return SlotClone;
43535
43886
  }
43536
- var SLOTTABLE_IDENTIFIER$4 = Symbol("radix.slottable");
43887
+ var SLOTTABLE_IDENTIFIER$4 = /* @__PURE__ */ Symbol("radix.slottable");
43537
43888
  function isSlottable$3(child) {
43538
43889
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$4;
43539
43890
  }
@@ -43688,7 +44039,7 @@ const createLucideIcon = (iconName, iconNode) => {
43688
44039
  Component.displayName = toPascalCase(iconName);
43689
44040
  return Component;
43690
44041
  };
43691
- const __iconNode$A = [
44042
+ const __iconNode$F = [
43692
44043
  ["path", { d: "M10.268 21a2 2 0 0 0 3.464 0", key: "vwvbt9" }],
43693
44044
  [
43694
44045
  "path",
@@ -43698,8 +44049,8 @@ const __iconNode$A = [
43698
44049
  }
43699
44050
  ]
43700
44051
  ];
43701
- const Bell = createLucideIcon("bell", __iconNode$A);
43702
- const __iconNode$z = [
44052
+ const Bell = createLucideIcon("bell", __iconNode$F);
44053
+ const __iconNode$E = [
43703
44054
  ["path", { d: "m8 2 1.88 1.88", key: "fmnt4t" }],
43704
44055
  ["path", { d: "M14.12 3.88 16 2", key: "qol33r" }],
43705
44056
  ["path", { d: "M9 7.13v-1a3.003 3.003 0 1 1 6 0v1", key: "d7y7pr" }],
@@ -43718,56 +44069,72 @@ const __iconNode$z = [
43718
44069
  ["path", { d: "M22 13h-4", key: "1jl80f" }],
43719
44070
  ["path", { d: "M17.2 17c2.1.1 3.8 1.9 3.8 4", key: "k3fwyw" }]
43720
44071
  ];
43721
- const Bug = createLucideIcon("bug", __iconNode$z);
43722
- const __iconNode$y = [
44072
+ const Bug = createLucideIcon("bug", __iconNode$E);
44073
+ const __iconNode$D = [
43723
44074
  ["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
43724
44075
  ["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
43725
44076
  ];
43726
- const CheckCheck = createLucideIcon("check-check", __iconNode$y);
43727
- const __iconNode$x = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
43728
- const Check = createLucideIcon("check", __iconNode$x);
43729
- const __iconNode$w = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
43730
- const ChevronDown = createLucideIcon("chevron-down", __iconNode$w);
43731
- const __iconNode$v = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
43732
- const ChevronRight = createLucideIcon("chevron-right", __iconNode$v);
43733
- const __iconNode$u = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
43734
- const ChevronUp = createLucideIcon("chevron-up", __iconNode$u);
43735
- const __iconNode$t = [
44077
+ const CheckCheck = createLucideIcon("check-check", __iconNode$D);
44078
+ const __iconNode$C = [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]];
44079
+ const Check = createLucideIcon("check", __iconNode$C);
44080
+ const __iconNode$B = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]];
44081
+ const ChevronDown = createLucideIcon("chevron-down", __iconNode$B);
44082
+ const __iconNode$A = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]];
44083
+ const ChevronRight = createLucideIcon("chevron-right", __iconNode$A);
44084
+ const __iconNode$z = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
44085
+ const ChevronUp = createLucideIcon("chevron-up", __iconNode$z);
44086
+ const __iconNode$y = [
43736
44087
  ["path", { d: "m7 15 5 5 5-5", key: "1hf1tw" }],
43737
44088
  ["path", { d: "m7 9 5-5 5 5", key: "sgt6xg" }]
43738
44089
  ];
43739
- const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$t);
43740
- const __iconNode$s = [
44090
+ const ChevronsUpDown = createLucideIcon("chevrons-up-down", __iconNode$y);
44091
+ const __iconNode$x = [
43741
44092
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
43742
44093
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
43743
44094
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
43744
44095
  ];
43745
- const CircleAlert = createLucideIcon("circle-alert", __iconNode$s);
43746
- const __iconNode$r = [
44096
+ const CircleAlert = createLucideIcon("circle-alert", __iconNode$x);
44097
+ const __iconNode$w = [
43747
44098
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
43748
44099
  ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
43749
44100
  ];
43750
- const CircleCheck = createLucideIcon("circle-check", __iconNode$r);
43751
- const __iconNode$q = [
44101
+ const CircleCheck = createLucideIcon("circle-check", __iconNode$w);
44102
+ const __iconNode$v = [
44103
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
44104
+ ["polygon", { points: "10 8 16 12 10 16 10 8", key: "1cimsy" }]
44105
+ ];
44106
+ const CirclePlay = createLucideIcon("circle-play", __iconNode$v);
44107
+ const __iconNode$u = [
43752
44108
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
43753
44109
  ["path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3", key: "1u773s" }],
43754
44110
  ["path", { d: "M12 17h.01", key: "p32p05" }]
43755
44111
  ];
43756
- const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$q);
43757
- const __iconNode$p = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
43758
- const Circle = createLucideIcon("circle", __iconNode$p);
43759
- const __iconNode$o = [
44112
+ const CircleQuestionMark = createLucideIcon("circle-question-mark", __iconNode$u);
44113
+ const __iconNode$t = [
44114
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
44115
+ ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
44116
+ ["path", { d: "m9 9 6 6", key: "z0biqf" }]
44117
+ ];
44118
+ const CircleX = createLucideIcon("circle-x", __iconNode$t);
44119
+ const __iconNode$s = [["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]];
44120
+ const Circle = createLucideIcon("circle", __iconNode$s);
44121
+ const __iconNode$r = [
44122
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
44123
+ ["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
44124
+ ];
44125
+ const Clock = createLucideIcon("clock", __iconNode$r);
44126
+ const __iconNode$q = [
43760
44127
  ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
43761
44128
  ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
43762
44129
  ];
43763
- const Copy = createLucideIcon("copy", __iconNode$o);
43764
- const __iconNode$n = [
44130
+ const Copy = createLucideIcon("copy", __iconNode$q);
44131
+ const __iconNode$p = [
43765
44132
  ["path", { d: "M15 3h6v6", key: "1q9fwt" }],
43766
44133
  ["path", { d: "M10 14 21 3", key: "gplh6r" }],
43767
44134
  ["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
43768
44135
  ];
43769
- const ExternalLink = createLucideIcon("external-link", __iconNode$n);
43770
- const __iconNode$m = [
44136
+ const ExternalLink = createLucideIcon("external-link", __iconNode$p);
44137
+ const __iconNode$o = [
43771
44138
  [
43772
44139
  "path",
43773
44140
  {
@@ -43785,8 +44152,8 @@ const __iconNode$m = [
43785
44152
  ],
43786
44153
  ["path", { d: "m2 2 20 20", key: "1ooewy" }]
43787
44154
  ];
43788
- const EyeOff = createLucideIcon("eye-off", __iconNode$m);
43789
- const __iconNode$l = [
44155
+ const EyeOff = createLucideIcon("eye-off", __iconNode$o);
44156
+ const __iconNode$n = [
43790
44157
  [
43791
44158
  "path",
43792
44159
  {
@@ -43796,22 +44163,22 @@ const __iconNode$l = [
43796
44163
  ],
43797
44164
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
43798
44165
  ];
43799
- const Eye = createLucideIcon("eye", __iconNode$l);
43800
- const __iconNode$k = [
44166
+ const Eye = createLucideIcon("eye", __iconNode$n);
44167
+ const __iconNode$m = [
43801
44168
  ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
43802
44169
  ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
43803
44170
  ["path", { d: "M10 9H8", key: "b1mrlr" }],
43804
44171
  ["path", { d: "M16 13H8", key: "t4e002" }],
43805
44172
  ["path", { d: "M16 17H8", key: "z1uh3a" }]
43806
44173
  ];
43807
- const FileText = createLucideIcon("file-text", __iconNode$k);
43808
- const __iconNode$j = [
44174
+ const FileText = createLucideIcon("file-text", __iconNode$m);
44175
+ const __iconNode$l = [
43809
44176
  ["path", { d: "M20 7h-3a2 2 0 0 1-2-2V2", key: "x099mo" }],
43810
44177
  ["path", { d: "M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z", key: "18t6ie" }],
43811
44178
  ["path", { d: "M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8", key: "1nja0z" }]
43812
44179
  ];
43813
- const Files = createLucideIcon("files", __iconNode$j);
43814
- const __iconNode$i = [
44180
+ const Files = createLucideIcon("files", __iconNode$l);
44181
+ const __iconNode$k = [
43815
44182
  [
43816
44183
  "path",
43817
44184
  {
@@ -43829,8 +44196,8 @@ const __iconNode$i = [
43829
44196
  ["path", { d: "M3 5a2 2 0 0 0 2 2h3", key: "f2jnh7" }],
43830
44197
  ["path", { d: "M3 3v13a2 2 0 0 0 2 2h3", key: "k8epm1" }]
43831
44198
  ];
43832
- const FolderTree = createLucideIcon("folder-tree", __iconNode$i);
43833
- const __iconNode$h = [
44199
+ const FolderTree = createLucideIcon("folder-tree", __iconNode$k);
44200
+ const __iconNode$j = [
43834
44201
  [
43835
44202
  "path",
43836
44203
  {
@@ -43840,8 +44207,8 @@ const __iconNode$h = [
43840
44207
  ],
43841
44208
  ["path", { d: "M9 18c-4.51 2-5-2-7-2", key: "9comsn" }]
43842
44209
  ];
43843
- const Github = createLucideIcon("github", __iconNode$h);
43844
- const __iconNode$g = [
44210
+ const Github = createLucideIcon("github", __iconNode$j);
44211
+ const __iconNode$i = [
43845
44212
  ["path", { d: "m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9", key: "eefl8a" }],
43846
44213
  ["path", { d: "m18 15 4-4", key: "16gjal" }],
43847
44214
  [
@@ -43852,36 +44219,44 @@ const __iconNode$g = [
43852
44219
  }
43853
44220
  ]
43854
44221
  ];
43855
- const Hammer = createLucideIcon("hammer", __iconNode$g);
43856
- const __iconNode$f = [
44222
+ const Hammer = createLucideIcon("hammer", __iconNode$i);
44223
+ const __iconNode$h = [
43857
44224
  ["line", { x1: "4", x2: "20", y1: "9", y2: "9", key: "4lhtct" }],
43858
44225
  ["line", { x1: "4", x2: "20", y1: "15", y2: "15", key: "vyu0kd" }],
43859
44226
  ["line", { x1: "10", x2: "8", y1: "3", y2: "21", key: "1ggp8o" }],
43860
44227
  ["line", { x1: "16", x2: "14", y1: "3", y2: "21", key: "weycgp" }]
43861
44228
  ];
43862
- const Hash = createLucideIcon("hash", __iconNode$f);
43863
- const __iconNode$e = [
44229
+ const Hash = createLucideIcon("hash", __iconNode$h);
44230
+ const __iconNode$g = [
43864
44231
  ["path", { d: "m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4", key: "g0fldk" }],
43865
44232
  ["path", { d: "m21 2-9.6 9.6", key: "1j0ho8" }],
43866
44233
  ["circle", { cx: "7.5", cy: "15.5", r: "5.5", key: "yqb3hr" }]
43867
44234
  ];
43868
- const Key = createLucideIcon("key", __iconNode$e);
43869
- const __iconNode$d = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
43870
- const LoaderCircle = createLucideIcon("loader-circle", __iconNode$d);
43871
- const __iconNode$c = [
44235
+ const Key = createLucideIcon("key", __iconNode$g);
44236
+ const __iconNode$f = [
44237
+ ["rect", { x: "3", y: "5", width: "6", height: "6", rx: "1", key: "1defrl" }],
44238
+ ["path", { d: "m3 17 2 2 4-4", key: "1jhpwq" }],
44239
+ ["path", { d: "M13 6h8", key: "15sg57" }],
44240
+ ["path", { d: "M13 12h8", key: "h98zly" }],
44241
+ ["path", { d: "M13 18h8", key: "oe0vm4" }]
44242
+ ];
44243
+ const ListTodo = createLucideIcon("list-todo", __iconNode$f);
44244
+ const __iconNode$e = [["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]];
44245
+ const LoaderCircle = createLucideIcon("loader-circle", __iconNode$e);
44246
+ const __iconNode$d = [
43872
44247
  ["path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z", key: "1lielz" }]
43873
44248
  ];
43874
- const MessageSquare = createLucideIcon("message-square", __iconNode$c);
43875
- const __iconNode$b = [["path", { d: "M5 12h14", key: "1ays0h" }]];
43876
- const Minus = createLucideIcon("minus", __iconNode$b);
43877
- const __iconNode$a = [["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]];
43878
- const Play = createLucideIcon("play", __iconNode$a);
43879
- const __iconNode$9 = [
44249
+ const MessageSquare = createLucideIcon("message-square", __iconNode$d);
44250
+ const __iconNode$c = [["path", { d: "M5 12h14", key: "1ays0h" }]];
44251
+ const Minus = createLucideIcon("minus", __iconNode$c);
44252
+ const __iconNode$b = [["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]];
44253
+ const Play = createLucideIcon("play", __iconNode$b);
44254
+ const __iconNode$a = [
43880
44255
  ["path", { d: "M5 12h14", key: "1ays0h" }],
43881
44256
  ["path", { d: "M12 5v14", key: "s699le" }]
43882
44257
  ];
43883
- const Plus = createLucideIcon("plus", __iconNode$9);
43884
- const __iconNode$8 = [
44258
+ const Plus = createLucideIcon("plus", __iconNode$a);
44259
+ const __iconNode$9 = [
43885
44260
  ["path", { d: "M21 8L18.74 5.74A9.75 9.75 0 0 0 12 3C11 3 10.03 3.16 9.13 3.47", key: "1krf6h" }],
43886
44261
  ["path", { d: "M8 16H3v5", key: "1cv678" }],
43887
44262
  ["path", { d: "M3 12C3 9.51 4 7.26 5.64 5.64", key: "ruvoct" }],
@@ -43890,20 +44265,20 @@ const __iconNode$8 = [
43890
44265
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
43891
44266
  ["path", { d: "M22 22 2 2", key: "1r8tn9" }]
43892
44267
  ];
43893
- const RefreshCwOff = createLucideIcon("refresh-cw-off", __iconNode$8);
43894
- const __iconNode$7 = [
44268
+ const RefreshCwOff = createLucideIcon("refresh-cw-off", __iconNode$9);
44269
+ const __iconNode$8 = [
43895
44270
  ["path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8", key: "v9h5vc" }],
43896
44271
  ["path", { d: "M21 3v5h-5", key: "1q7to0" }],
43897
44272
  ["path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16", key: "3uifl3" }],
43898
44273
  ["path", { d: "M8 16H3v5", key: "1cv678" }]
43899
44274
  ];
43900
- const RefreshCw = createLucideIcon("refresh-cw", __iconNode$7);
43901
- const __iconNode$6 = [
44275
+ const RefreshCw = createLucideIcon("refresh-cw", __iconNode$8);
44276
+ const __iconNode$7 = [
43902
44277
  ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
43903
44278
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
43904
44279
  ];
43905
- const RotateCcw = createLucideIcon("rotate-ccw", __iconNode$6);
43906
- const __iconNode$5 = [
44280
+ const RotateCcw = createLucideIcon("rotate-ccw", __iconNode$7);
44281
+ const __iconNode$6 = [
43907
44282
  [
43908
44283
  "path",
43909
44284
  {
@@ -43914,13 +44289,13 @@ const __iconNode$5 = [
43914
44289
  ["path", { d: "M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7", key: "1ydtos" }],
43915
44290
  ["path", { d: "M7 3v4a1 1 0 0 0 1 1h7", key: "t51u73" }]
43916
44291
  ];
43917
- const Save = createLucideIcon("save", __iconNode$5);
43918
- const __iconNode$4 = [
44292
+ const Save = createLucideIcon("save", __iconNode$6);
44293
+ const __iconNode$5 = [
43919
44294
  ["path", { d: "m21 21-4.34-4.34", key: "14j7rj" }],
43920
44295
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }]
43921
44296
  ];
43922
- const Search = createLucideIcon("search", __iconNode$4);
43923
- const __iconNode$3 = [
44297
+ const Search = createLucideIcon("search", __iconNode$5);
44298
+ const __iconNode$4 = [
43924
44299
  [
43925
44300
  "path",
43926
44301
  {
@@ -43930,15 +44305,15 @@ const __iconNode$3 = [
43930
44305
  ],
43931
44306
  ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
43932
44307
  ];
43933
- const Send = createLucideIcon("send", __iconNode$3);
43934
- const __iconNode$2 = [
44308
+ const Send = createLucideIcon("send", __iconNode$4);
44309
+ const __iconNode$3 = [
43935
44310
  ["rect", { width: "20", height: "8", x: "2", y: "2", rx: "2", ry: "2", key: "ngkwjq" }],
43936
44311
  ["rect", { width: "20", height: "8", x: "2", y: "14", rx: "2", ry: "2", key: "iecqi9" }],
43937
44312
  ["line", { x1: "6", x2: "6.01", y1: "6", y2: "6", key: "16zg32" }],
43938
44313
  ["line", { x1: "6", x2: "6.01", y1: "18", y2: "18", key: "nzw8ys" }]
43939
44314
  ];
43940
- const Server = createLucideIcon("server", __iconNode$2);
43941
- const __iconNode$1 = [
44315
+ const Server = createLucideIcon("server", __iconNode$3);
44316
+ const __iconNode$2 = [
43942
44317
  [
43943
44318
  "path",
43944
44319
  {
@@ -43948,15 +44323,27 @@ const __iconNode$1 = [
43948
44323
  ],
43949
44324
  ["circle", { cx: "12", cy: "12", r: "3", key: "1v7zrd" }]
43950
44325
  ];
43951
- const Settings = createLucideIcon("settings", __iconNode$1);
43952
- const __iconNode = [
44326
+ const Settings = createLucideIcon("settings", __iconNode$2);
44327
+ const __iconNode$1 = [
43953
44328
  ["path", { d: "M3 6h18", key: "d0wm0j" }],
43954
44329
  ["path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6", key: "4alrt4" }],
43955
44330
  ["path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2", key: "v07s0e" }],
43956
44331
  ["line", { x1: "10", x2: "10", y1: "11", y2: "17", key: "1uufr5" }],
43957
44332
  ["line", { x1: "14", x2: "14", y1: "11", y2: "17", key: "xtxkd" }]
43958
44333
  ];
43959
- const Trash2 = createLucideIcon("trash-2", __iconNode);
44334
+ const Trash2 = createLucideIcon("trash-2", __iconNode$1);
44335
+ const __iconNode = [
44336
+ [
44337
+ "path",
44338
+ {
44339
+ d: "m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",
44340
+ key: "wmoenq"
44341
+ }
44342
+ ],
44343
+ ["path", { d: "M12 9v4", key: "juzpu7" }],
44344
+ ["path", { d: "M12 17h.01", key: "p32p05" }]
44345
+ ];
44346
+ const TriangleAlert = createLucideIcon("triangle-alert", __iconNode);
43960
44347
  const OAuthStepDetails = ({
43961
44348
  label,
43962
44349
  isComplete,
@@ -46109,7 +46496,7 @@ function createSlotClone$2(ownerName) {
46109
46496
  SlotClone.displayName = `${ownerName}.SlotClone`;
46110
46497
  return SlotClone;
46111
46498
  }
46112
- var SLOTTABLE_IDENTIFIER$3 = Symbol("radix.slottable");
46499
+ var SLOTTABLE_IDENTIFIER$3 = /* @__PURE__ */ Symbol("radix.slottable");
46113
46500
  function isSlottable$2(child) {
46114
46501
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$3;
46115
46502
  }
@@ -49116,7 +49503,7 @@ function createSlotClone$1(ownerName) {
49116
49503
  SlotClone.displayName = `${ownerName}.SlotClone`;
49117
49504
  return SlotClone;
49118
49505
  }
49119
- var SLOTTABLE_IDENTIFIER$2 = Symbol("radix.slottable");
49506
+ var SLOTTABLE_IDENTIFIER$2 = /* @__PURE__ */ Symbol("radix.slottable");
49120
49507
  function isSlottable$1(child) {
49121
49508
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$2;
49122
49509
  }
@@ -49557,7 +49944,7 @@ var Primitive = NODES.reduce((primitive, node) => {
49557
49944
  const { asChild, ...primitiveProps } = props;
49558
49945
  const Comp = asChild ? Slot2 : node;
49559
49946
  if (typeof window !== "undefined") {
49560
- window[Symbol.for("radix-ui")] = true;
49947
+ window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
49561
49948
  }
49562
49949
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Comp, { ...primitiveProps, ref: forwardedRef });
49563
49950
  });
@@ -50115,7 +50502,7 @@ class UriTemplate {
50115
50502
  const name2 = part.name;
50116
50503
  switch (part.operator) {
50117
50504
  case "":
50118
- pattern2 = part.exploded ? "([^/]+(?:,[^/]+)*)" : "([^/,]+)";
50505
+ pattern2 = part.exploded ? "([^/,]+(?:,[^/,]+)*)" : "([^/,]+)";
50119
50506
  break;
50120
50507
  case "+":
50121
50508
  case "#":
@@ -50125,7 +50512,7 @@ class UriTemplate {
50125
50512
  pattern2 = "\\.([^/,]+)";
50126
50513
  break;
50127
50514
  case "/":
50128
- pattern2 = "/" + (part.exploded ? "([^/]+(?:,[^/]+)*)" : "([^/,]+)");
50515
+ pattern2 = "/" + (part.exploded ? "([^/,]+(?:,[^/,]+)*)" : "([^/,]+)");
50129
50516
  break;
50130
50517
  default:
50131
50518
  pattern2 = "([^/]+)";
@@ -52310,7 +52697,8 @@ Prism.languages.webmanifest = Prism.languages.json;
52310
52697
  const JsonEditor = ({
52311
52698
  value,
52312
52699
  onChange,
52313
- error: externalError
52700
+ error: externalError,
52701
+ placeholder
52314
52702
  }) => {
52315
52703
  const [editorContent, setEditorContent] = reactExports.useState(value || "");
52316
52704
  const [internalError, setInternalError] = reactExports.useState(
@@ -52337,6 +52725,7 @@ const JsonEditor = ({
52337
52725
  onValueChange: handleEditorChange,
52338
52726
  highlight: (code2) => Prism$1.highlight(code2, Prism$1.languages.json, "json"),
52339
52727
  padding: 10,
52728
+ placeholder,
52340
52729
  style: {
52341
52730
  fontFamily: '"Fira code", "Fira Mono", monospace',
52342
52731
  fontSize: 14,
@@ -52394,7 +52783,22 @@ const getArrayItemDefault = (schema) => {
52394
52783
  };
52395
52784
  const DynamicJsonForm = reactExports.forwardRef(
52396
52785
  ({ schema, value, onChange, maxDepth = 3 }, ref2) => {
52397
- const isOnlyJSON = !isSimpleObject(schema);
52786
+ const canRenderTopLevelForm = (s) => {
52787
+ const primitiveTypes = ["string", "number", "integer", "boolean", "null"];
52788
+ const hasType = Array.isArray(s.type) ? s.type.length > 0 : !!s.type;
52789
+ if (!hasType) return false;
52790
+ const includesType = (t) => Array.isArray(s.type) ? s.type.includes(t) : s.type === t;
52791
+ if (primitiveTypes.some(includesType)) return true;
52792
+ if (includesType("object")) {
52793
+ const keys = Object.keys(s.properties ?? {});
52794
+ return keys.length > 0;
52795
+ }
52796
+ if (includesType("array")) {
52797
+ return !!s.items;
52798
+ }
52799
+ return false;
52800
+ };
52801
+ const isOnlyJSON = !canRenderTopLevelForm(schema);
52398
52802
  const [isJsonMode, setIsJsonMode] = reactExports.useState(isOnlyJSON);
52399
52803
  const [jsonError, setJsonError] = reactExports.useState();
52400
52804
  const [copiedJson, setCopiedJson] = reactExports.useState(false);
@@ -52536,58 +52940,64 @@ const DynamicJsonForm = reactExports.forwardRef(
52536
52940
  }
52537
52941
  switch (fieldType) {
52538
52942
  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
- );
52943
+ const titledOptions = (propSchema.oneOf ?? propSchema.anyOf)?.filter((opt) => "const" in opt);
52944
+ if (titledOptions && titledOptions.length > 0) {
52945
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
52946
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
52947
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
52948
+ "select",
52949
+ {
52950
+ value: currentValue ?? "",
52951
+ onChange: (e) => {
52952
+ const val = e.target.value;
52953
+ if (!val && !isRequired) {
52954
+ handleFieldChange(path, void 0);
52955
+ } else {
52956
+ handleFieldChange(path, val);
52957
+ }
52958
+ },
52959
+ required: isRequired,
52960
+ 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",
52961
+ children: [
52962
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select an option..." }),
52963
+ titledOptions.map((option) => /* @__PURE__ */ jsxRuntimeExports.jsx(
52964
+ "option",
52965
+ {
52966
+ value: String(option.const),
52967
+ children: option.title ?? String(option.const)
52968
+ },
52969
+ String(option.const)
52970
+ ))
52971
+ ]
52972
+ }
52973
+ )
52974
+ ] });
52569
52975
  }
52570
52976
  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
- );
52977
+ const names2 = Array.isArray(propSchema.enumNames) ? propSchema.enumNames : void 0;
52978
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
52979
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
52980
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
52981
+ "select",
52982
+ {
52983
+ value: currentValue ?? "",
52984
+ onChange: (e) => {
52985
+ const val = e.target.value;
52986
+ if (!val && !isRequired) {
52987
+ handleFieldChange(path, void 0);
52988
+ } else {
52989
+ handleFieldChange(path, val);
52990
+ }
52991
+ },
52992
+ required: isRequired,
52993
+ 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",
52994
+ children: [
52995
+ /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select an option..." }),
52996
+ propSchema.enum.map((option, idx) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: option, children: names2?.[idx] ?? option }, option))
52997
+ ]
52998
+ }
52999
+ )
53000
+ ] });
52591
53001
  }
52592
53002
  let inputType = "text";
52593
53003
  switch (propSchema.format) {
@@ -52672,16 +53082,19 @@ const DynamicJsonForm = reactExports.forwardRef(
52672
53082
  }
52673
53083
  );
52674
53084
  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
- );
53085
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
53086
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
53087
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
53088
+ Input,
53089
+ {
53090
+ type: "checkbox",
53091
+ checked: currentValue ?? false,
53092
+ onChange: (e) => handleFieldChange(path, e.target.checked),
53093
+ className: "w-4 h-4",
53094
+ required: isRequired
53095
+ }
53096
+ )
53097
+ ] });
52685
53098
  case "null":
52686
53099
  return null;
52687
53100
  case "object":
@@ -52707,7 +53120,7 @@ const DynamicJsonForm = reactExports.forwardRef(
52707
53120
  }
52708
53121
  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
53122
  /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { className: "block text-sm font-medium mb-1", children: [
52710
- key,
53123
+ subSchema.title ?? key,
52711
53124
  propSchema.required?.includes(key) && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-500 ml-1", children: "*" })
52712
53125
  ] }),
52713
53126
  renderFormFields(
@@ -52722,6 +53135,47 @@ const DynamicJsonForm = reactExports.forwardRef(
52722
53135
  case "array": {
52723
53136
  const arrayValue = Array.isArray(currentValue) ? currentValue : [];
52724
53137
  if (!propSchema.items) return null;
53138
+ const itemSchema = propSchema.items;
53139
+ let multiOptions = null;
53140
+ const titledMulti = (itemSchema.anyOf ?? itemSchema.oneOf)?.filter((opt) => "const" in opt);
53141
+ if (titledMulti && titledMulti.length > 0) {
53142
+ multiOptions = titledMulti.map((o) => ({
53143
+ value: String(o.const),
53144
+ label: o.title ?? String(o.const)
53145
+ }));
53146
+ } else if (itemSchema.enum) {
53147
+ const names2 = Array.isArray(itemSchema.enumNames) ? itemSchema.enumNames : void 0;
53148
+ multiOptions = itemSchema.enum.map((v, i) => ({
53149
+ value: v,
53150
+ label: names2?.[i] ?? v
53151
+ }));
53152
+ }
53153
+ if (multiOptions) {
53154
+ const selectSize = Math.min(Math.max(multiOptions.length, 3), 8);
53155
+ return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
53156
+ propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
53157
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
53158
+ "select",
53159
+ {
53160
+ multiple: true,
53161
+ size: selectSize,
53162
+ value: arrayValue,
53163
+ onChange: (e) => {
53164
+ const selected = Array.from(
53165
+ e.target.selectedOptions
53166
+ ).map((o) => o.value);
53167
+ handleFieldChange(path, selected);
53168
+ },
53169
+ 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",
53170
+ children: multiOptions.map((opt) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: opt.value, children: opt.label }, opt.value))
53171
+ }
53172
+ ),
53173
+ (propSchema.minItems || propSchema.maxItems) && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-xs text-gray-500", children: [
53174
+ propSchema.minItems ? `Select at least ${propSchema.minItems}. ` : "",
53175
+ propSchema.maxItems ? `Select at most ${propSchema.maxItems}.` : ""
53176
+ ] })
53177
+ ] });
53178
+ }
52725
53179
  if (isSimpleObject(propSchema.items)) {
52726
53180
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-4", children: [
52727
53181
  propSchema.description && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-gray-600", children: propSchema.description }),
@@ -52856,7 +53310,8 @@ const DynamicJsonForm = reactExports.forwardRef(
52856
53310
  setRawJsonValue(newValue);
52857
53311
  debouncedUpdateParent(newValue);
52858
53312
  },
52859
- error: jsonError
53313
+ error: jsonError,
53314
+ placeholder: schema.description
52860
53315
  }
52861
53316
  ) : (
52862
53317
  // If schema type is object but value is not an object or is empty, and we have actual JSON data,
@@ -53068,7 +53523,7 @@ function createSlotClone(ownerName) {
53068
53523
  SlotClone.displayName = `${ownerName}.SlotClone`;
53069
53524
  return SlotClone;
53070
53525
  }
53071
- var SLOTTABLE_IDENTIFIER$1 = Symbol("radix.slottable");
53526
+ var SLOTTABLE_IDENTIFIER$1 = /* @__PURE__ */ Symbol("radix.slottable");
53072
53527
  function isSlottable(child) {
53073
53528
  return reactExports.isValidElement(child) && typeof child.type === "function" && "__radixId" in child.type && child.type.__radixId === SLOTTABLE_IDENTIFIER$1;
53074
53529
  }
@@ -54392,8 +54847,8 @@ const useTheme = () => {
54392
54847
  [theme, setThemeWithSideEffect]
54393
54848
  );
54394
54849
  };
54395
- const version = "0.17.5";
54396
- var SLOTTABLE_IDENTIFIER = Symbol("radix.slottable");
54850
+ const version = "0.19.0";
54851
+ var SLOTTABLE_IDENTIFIER = /* @__PURE__ */ Symbol("radix.slottable");
54397
54852
  // @__NO_SIDE_EFFECTS__
54398
54853
  function createSlottable(ownerName) {
54399
54854
  const Slottable2 = ({ children }) => {
@@ -56401,7 +56856,8 @@ const ToolResults = ({
56401
56856
  toolResult,
56402
56857
  selectedTool,
56403
56858
  resourceContent,
56404
- onReadResource
56859
+ onReadResource,
56860
+ isPollingTask
56405
56861
  }) => {
56406
56862
  if (!toolResult) return null;
56407
56863
  if ("content" in toolResult) {
@@ -56416,6 +56872,10 @@ const ToolResults = ({
56416
56872
  }
56417
56873
  const structuredResult = parsedResult.data;
56418
56874
  const isError = structuredResult.isError ?? false;
56875
+ const relatedTask = structuredResult._meta?.["io.modelcontextprotocol/related-task"];
56876
+ const isTaskRunning = isPollingTask || !!relatedTask && structuredResult.content.some(
56877
+ (c) => c.type === "text" && (c.text?.includes("Polling") || c.text?.includes("Task status"))
56878
+ );
56419
56879
  let validationResult = null;
56420
56880
  const toolHasOutputSchema = selectedTool && hasOutputSchema(selectedTool.name);
56421
56881
  if (toolHasOutputSchema) {
@@ -56442,7 +56902,7 @@ const ToolResults = ({
56442
56902
  /* @__PURE__ */ jsxRuntimeExports.jsxs("h4", { className: "font-semibold mb-2", children: [
56443
56903
  "Tool Result:",
56444
56904
  " ",
56445
- isError ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-600 font-semibold", children: "Error" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-green-600 font-semibold", children: "Success" })
56905
+ isError ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-red-600 font-semibold", children: "Error" }) : isTaskRunning ? /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-yellow-600 font-semibold", children: "Task Running" }) : /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-green-600 font-semibold", children: "Success" })
56446
56906
  ] }),
56447
56907
  structuredResult.structuredContent && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4", children: [
56448
56908
  /* @__PURE__ */ jsxRuntimeExports.jsx("h5", { className: "font-semibold mb-2 text-sm", children: "Structured Content:" }),
@@ -56533,12 +56993,14 @@ const ToolsTab = ({
56533
56993
  selectedTool,
56534
56994
  setSelectedTool,
56535
56995
  toolResult,
56996
+ isPollingTask,
56536
56997
  nextCursor,
56537
56998
  error,
56538
56999
  resourceContent,
56539
57000
  onReadResource
56540
57001
  }) => {
56541
57002
  const [params, setParams] = reactExports.useState({});
57003
+ const [runAsTask, setRunAsTask] = reactExports.useState(false);
56542
57004
  const [isToolRunning, setIsToolRunning] = reactExports.useState(false);
56543
57005
  const [isOutputSchemaExpanded, setIsOutputSchemaExpanded] = reactExports.useState(false);
56544
57006
  const [isMetadataExpanded, setIsMetadataExpanded] = reactExports.useState(false);
@@ -56572,6 +57034,7 @@ const ToolsTab = ({
56572
57034
  ];
56573
57035
  });
56574
57036
  setParams(Object.fromEntries(params2));
57037
+ setRunAsTask(false);
56575
57038
  setHasValidationErrors(false);
56576
57039
  formRefs.current = {};
56577
57040
  }, [selectedTool]);
@@ -56596,6 +57059,7 @@ const ToolsTab = ({
56596
57059
  clearItems: () => {
56597
57060
  clearTools();
56598
57061
  setSelectedTool(null);
57062
+ setRunAsTask(false);
56599
57063
  },
56600
57064
  setSelectedItem: setSelectedTool,
56601
57065
  renderItem: (tool) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-start w-full gap-2", children: [
@@ -56985,6 +57449,24 @@ const ToolsTab = ({
56985
57449
  }
56986
57450
  )
56987
57451
  ] }),
57452
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center space-x-2", children: [
57453
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
57454
+ Checkbox,
57455
+ {
57456
+ id: "run-as-task",
57457
+ checked: runAsTask,
57458
+ onCheckedChange: (checked) => setRunAsTask(checked)
57459
+ }
57460
+ ),
57461
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
57462
+ Label$1,
57463
+ {
57464
+ htmlFor: "run-as-task",
57465
+ className: "text-sm font-medium text-gray-700 dark:text-gray-300 cursor-pointer",
57466
+ children: "Run as task"
57467
+ }
57468
+ )
57469
+ ] }),
56988
57470
  /* @__PURE__ */ jsxRuntimeExports.jsx(
56989
57471
  Button,
56990
57472
  {
@@ -57002,16 +57484,17 @@ const ToolsTab = ({
57002
57484
  await callTool(
57003
57485
  selectedTool.name,
57004
57486
  params,
57005
- Object.keys(metadata2).length ? metadata2 : void 0
57487
+ Object.keys(metadata2).length ? metadata2 : void 0,
57488
+ runAsTask
57006
57489
  );
57007
57490
  } finally {
57008
57491
  setIsToolRunning(false);
57009
57492
  }
57010
57493
  },
57011
- disabled: isToolRunning || hasValidationErrors || hasReservedMetadataEntry || hasInvalidMetaPrefixEntry || hasInvalidMetaNameEntry,
57012
- children: isToolRunning ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
57494
+ disabled: isToolRunning || isPollingTask || hasValidationErrors || hasReservedMetadataEntry || hasInvalidMetaPrefixEntry || hasInvalidMetaNameEntry,
57495
+ children: isToolRunning || isPollingTask ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
57013
57496
  /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "w-4 h-4 mr-2 animate-spin" }),
57014
- "Running..."
57497
+ isPollingTask ? "Polling Task..." : "Running..."
57015
57498
  ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
57016
57499
  /* @__PURE__ */ jsxRuntimeExports.jsx(Send, { className: "w-4 h-4 mr-2" }),
57017
57500
  "Run Tool"
@@ -57047,13 +57530,168 @@ const ToolsTab = ({
57047
57530
  toolResult,
57048
57531
  selectedTool,
57049
57532
  resourceContent,
57050
- onReadResource
57533
+ onReadResource,
57534
+ isPollingTask
57051
57535
  }
57052
57536
  )
57053
57537
  ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Alert, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDescription, { children: "Select a tool from the list to view its details and run it" }) }) })
57054
57538
  ] })
57055
57539
  ] }) });
57056
57540
  };
57541
+ const TaskStatusIcon = ({ status }) => {
57542
+ switch (status) {
57543
+ case "working":
57544
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "h-4 w-4 animate-pulse text-blue-500" });
57545
+ case "input_required":
57546
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleAlert, { className: "h-4 w-4 text-yellow-500" });
57547
+ case "completed":
57548
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(CircleCheck, { className: "h-4 w-4 text-green-500" });
57549
+ case "failed":
57550
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(CircleX, { className: "h-4 w-4 text-red-500" });
57551
+ case "cancelled":
57552
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(CircleX, { className: "h-4 w-4 text-gray-500" });
57553
+ default:
57554
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(CirclePlay, { className: "h-4 w-4" });
57555
+ }
57556
+ };
57557
+ const TasksTab = ({
57558
+ tasks,
57559
+ listTasks,
57560
+ clearTasks,
57561
+ cancelTask,
57562
+ selectedTask,
57563
+ setSelectedTask,
57564
+ error,
57565
+ nextCursor
57566
+ }) => {
57567
+ const [isCancelling, setIsCancelling] = reactExports.useState(null);
57568
+ const displayedTask = selectedTask ? tasks.find((t) => t.taskId === selectedTask.taskId) || selectedTask : null;
57569
+ const handleCancel = async (taskId) => {
57570
+ setIsCancelling(taskId);
57571
+ try {
57572
+ await cancelTask(taskId);
57573
+ } finally {
57574
+ setIsCancelling(null);
57575
+ }
57576
+ };
57577
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "tasks", className: "flex-1 overflow-hidden p-0 m-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full overflow-hidden p-4 gap-4", children: [
57578
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-1/3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
57579
+ ListPane,
57580
+ {
57581
+ title: "Tasks",
57582
+ items: tasks,
57583
+ setSelectedItem: setSelectedTask,
57584
+ listItems: listTasks,
57585
+ clearItems: clearTasks,
57586
+ buttonText: nextCursor ? "List More Tasks" : "List Tasks",
57587
+ isButtonDisabled: !nextCursor && tasks.length > 0,
57588
+ renderItem: (task) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2 overflow-hidden w-full", children: [
57589
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TaskStatusIcon, { status: task.status }),
57590
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col overflow-hidden", children: [
57591
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate font-medium", children: task.taskId }),
57592
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "truncate text-xs text-muted-foreground", children: [
57593
+ task.status,
57594
+ " -",
57595
+ " ",
57596
+ new Date(task.lastUpdatedAt).toLocaleString()
57597
+ ] })
57598
+ ] })
57599
+ ] })
57600
+ }
57601
+ ) }),
57602
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 overflow-y-auto p-4 bg-background border border-border rounded-lg", children: [
57603
+ error && /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { variant: "destructive", className: "mb-4", children: [
57604
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CircleAlert, { className: "h-4 w-4" }),
57605
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AlertTitle, { children: "Error" }),
57606
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AlertDescription, { children: error })
57607
+ ] }),
57608
+ displayedTask ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-6", children: [
57609
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between border-b pb-4", children: [
57610
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
57611
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-2xl font-bold tracking-tight", children: "Task Details" }),
57612
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "text-muted-foreground", children: [
57613
+ "ID: ",
57614
+ displayedTask.taskId
57615
+ ] })
57616
+ ] }),
57617
+ (displayedTask.status === "working" || displayedTask.status === "input_required") && /* @__PURE__ */ jsxRuntimeExports.jsxs(
57618
+ Button,
57619
+ {
57620
+ variant: "destructive",
57621
+ size: "sm",
57622
+ "aria-label": `Cancel task ${displayedTask.taskId}`,
57623
+ onClick: () => handleCancel(displayedTask.taskId),
57624
+ disabled: isCancelling === displayedTask.taskId,
57625
+ children: [
57626
+ isCancelling === displayedTask.taskId ? /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(CircleX, { className: "mr-2 h-4 w-4" }),
57627
+ "Cancel Task"
57628
+ ]
57629
+ }
57630
+ )
57631
+ ] }),
57632
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
57633
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border p-3", children: [
57634
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Status" }),
57635
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-2", children: [
57636
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TaskStatusIcon, { status: displayedTask.status }),
57637
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
57638
+ "span",
57639
+ {
57640
+ className: cn(
57641
+ "font-semibold capitalize",
57642
+ displayedTask.status === "working" && "text-blue-500",
57643
+ displayedTask.status === "completed" && "text-green-500",
57644
+ displayedTask.status === "failed" && "text-red-500",
57645
+ displayedTask.status === "cancelled" && "text-gray-500",
57646
+ displayedTask.status === "input_required" && "text-yellow-500"
57647
+ ),
57648
+ children: displayedTask.status.replace("_", " ")
57649
+ }
57650
+ )
57651
+ ] })
57652
+ ] }),
57653
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border p-3", children: [
57654
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Last Updated" }),
57655
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 font-medium", children: new Date(displayedTask.lastUpdatedAt).toLocaleString() })
57656
+ ] }),
57657
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border p-3", children: [
57658
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Created At" }),
57659
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 font-medium", children: new Date(displayedTask.createdAt).toLocaleString() })
57660
+ ] }),
57661
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border p-3", children: [
57662
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "TTL" }),
57663
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 font-medium", children: displayedTask.ttl === null ? "Infinite" : `${displayedTask.ttl}ms` })
57664
+ ] })
57665
+ ] }),
57666
+ displayedTask.statusMessage && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-lg border p-3", children: [
57667
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm font-medium text-muted-foreground", children: "Status Message" }),
57668
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 whitespace-pre-wrap", children: displayedTask.statusMessage })
57669
+ ] }),
57670
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
57671
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-semibold", children: "Full Task Object" }),
57672
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md border", children: /* @__PURE__ */ jsxRuntimeExports.jsx(JsonView, { data: displayedTask }) })
57673
+ ] })
57674
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full items-center justify-center text-muted-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-center", children: [
57675
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Clock, { className: "mx-auto mb-4 h-12 w-12 opacity-20" }),
57676
+ /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: "text-lg font-medium", children: "No Task Selected" }),
57677
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Select a task from the list to view its details." }),
57678
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
57679
+ Button,
57680
+ {
57681
+ variant: "outline",
57682
+ size: "sm",
57683
+ className: "mt-4",
57684
+ onClick: listTasks,
57685
+ children: [
57686
+ /* @__PURE__ */ jsxRuntimeExports.jsx(RefreshCw, { className: "mr-2 h-4 w-4" }),
57687
+ "Refresh Tasks"
57688
+ ]
57689
+ }
57690
+ )
57691
+ ] }) })
57692
+ ] })
57693
+ ] }) });
57694
+ };
57057
57695
  const ElicitationRequest = ({
57058
57696
  request,
57059
57697
  onResolve
@@ -57098,7 +57736,7 @@ const ElicitationRequest = ({
57098
57736
  if (!validateFormData(formData, request.request.requestedSchema)) {
57099
57737
  return;
57100
57738
  }
57101
- const ajv2 = new Ajv();
57739
+ const ajv2 = new Ajv$1();
57102
57740
  const validate2 = ajv2.compile(request.request.requestedSchema);
57103
57741
  const isValid2 = validate2(formData);
57104
57742
  if (!isValid2) {
@@ -57306,11 +57944,13 @@ const App = () => {
57306
57944
  const [prompts, setPrompts] = reactExports.useState([]);
57307
57945
  const [promptContent, setPromptContent] = reactExports.useState("");
57308
57946
  const [tools, setTools] = reactExports.useState([]);
57947
+ const [tasks, setTasks] = reactExports.useState([]);
57309
57948
  const [toolResult, setToolResult] = reactExports.useState(null);
57310
57949
  const [errors2, setErrors] = reactExports.useState({
57311
57950
  resources: null,
57312
57951
  prompts: null,
57313
- tools: null
57952
+ tools: null,
57953
+ tasks: null
57314
57954
  });
57315
57955
  const [command, setCommand] = reactExports.useState(getInitialCommand);
57316
57956
  const [args, setArgs] = reactExports.useState(getInitialArgs);
@@ -57402,10 +58042,13 @@ const App = () => {
57402
58042
  const [resourceSubscriptions, setResourceSubscriptions] = reactExports.useState(/* @__PURE__ */ new Set());
57403
58043
  const [selectedPrompt, setSelectedPrompt] = reactExports.useState(null);
57404
58044
  const [selectedTool, setSelectedTool] = reactExports.useState(null);
58045
+ const [selectedTask, setSelectedTask] = reactExports.useState(null);
58046
+ const [isPollingTask, setIsPollingTask] = reactExports.useState(false);
57405
58047
  const [nextResourceCursor, setNextResourceCursor] = reactExports.useState();
57406
58048
  const [nextResourceTemplateCursor, setNextResourceTemplateCursor] = reactExports.useState();
57407
58049
  const [nextPromptCursor, setNextPromptCursor] = reactExports.useState();
57408
58050
  const [nextToolCursor, setNextToolCursor] = reactExports.useState();
58051
+ const [nextTaskCursor, setNextTaskCursor] = reactExports.useState();
57409
58052
  const progressTokenRef = reactExports.useRef(0);
57410
58053
  const [activeTab, setActiveTab] = reactExports.useState(() => {
57411
58054
  const hash = window.location.hash.slice(1);
@@ -57417,12 +58060,37 @@ const App = () => {
57417
58060
  reactExports.useEffect(() => {
57418
58061
  currentTabRef.current = activeTab;
57419
58062
  }, [activeTab]);
58063
+ const navigateToOriginatingTab = (originatingTab) => {
58064
+ if (!originatingTab) return;
58065
+ const validTabs = [
58066
+ ...serverCapabilities?.resources ? ["resources"] : [],
58067
+ ...serverCapabilities?.prompts ? ["prompts"] : [],
58068
+ ...serverCapabilities?.tools ? ["tools"] : [],
58069
+ ...serverCapabilities?.tasks ? ["tasks"] : [],
58070
+ "ping",
58071
+ "sampling",
58072
+ "elicitations",
58073
+ "roots",
58074
+ "auth"
58075
+ ];
58076
+ if (!validTabs.includes(originatingTab)) return;
58077
+ setActiveTab(originatingTab);
58078
+ window.location.hash = originatingTab;
58079
+ setTimeout(() => {
58080
+ setActiveTab(originatingTab);
58081
+ window.location.hash = originatingTab;
58082
+ }, 100);
58083
+ };
57420
58084
  const { height: historyPaneHeight, handleDragStart } = useDraggablePane(300);
57421
58085
  const {
57422
58086
  width: sidebarWidth,
57423
58087
  isDragging: isSidebarDragging,
57424
58088
  handleDragStart: handleSidebarDragStart
57425
58089
  } = useDraggableSidebar(320);
58090
+ const selectedTaskRef = reactExports.useRef(null);
58091
+ reactExports.useEffect(() => {
58092
+ selectedTaskRef.current = selectedTask;
58093
+ }, [selectedTask]);
57426
58094
  const {
57427
58095
  connectionStatus,
57428
58096
  serverCapabilities,
@@ -57431,6 +58099,8 @@ const App = () => {
57431
58099
  requestHistory,
57432
58100
  clearRequestHistory,
57433
58101
  makeRequest,
58102
+ cancelTask: cancelMcpTask,
58103
+ listTasks: listMcpTasks,
57434
58104
  sendNotification,
57435
58105
  handleCompletion,
57436
58106
  completionsSupported,
@@ -57450,12 +58120,38 @@ const App = () => {
57450
58120
  connectionType,
57451
58121
  onNotification: (notification) => {
57452
58122
  setNotifications((prev) => [...prev, notification]);
58123
+ if (notification.method === "notifications/tasks/list_changed") {
58124
+ void listTasks();
58125
+ }
58126
+ if (notification.method === "notifications/tasks/status") {
58127
+ const task = notification.params;
58128
+ setTasks((prev) => {
58129
+ const exists = prev.some((t) => t.taskId === task.taskId);
58130
+ if (exists) {
58131
+ return prev.map((t) => t.taskId === task.taskId ? task : t);
58132
+ } else {
58133
+ return [task, ...prev];
58134
+ }
58135
+ });
58136
+ if (selectedTaskRef.current?.taskId === task.taskId) {
58137
+ setSelectedTask(task);
58138
+ }
58139
+ }
57453
58140
  },
57454
58141
  onPendingRequest: (request, resolve2, reject) => {
58142
+ const currentTab = lastToolCallOriginTabRef.current;
57455
58143
  setPendingSampleRequests((prev) => [
57456
58144
  ...prev,
57457
- { id: nextRequestId.current++, request, resolve: resolve2, reject }
58145
+ {
58146
+ id: nextRequestId.current++,
58147
+ request,
58148
+ originatingTab: currentTab,
58149
+ resolve: resolve2,
58150
+ reject
58151
+ }
57458
58152
  ]);
58153
+ setActiveTab("sampling");
58154
+ window.location.hash = "sampling";
57459
58155
  },
57460
58156
  onElicitationRequest: (request, resolve2) => {
57461
58157
  const currentTab = lastToolCallOriginTabRef.current;
@@ -57489,6 +58185,7 @@ const App = () => {
57489
58185
  ...serverCapabilities?.resources ? ["resources"] : [],
57490
58186
  ...serverCapabilities?.prompts ? ["prompts"] : [],
57491
58187
  ...serverCapabilities?.tools ? ["tools"] : [],
58188
+ ...serverCapabilities?.tasks ? ["tasks"] : [],
57492
58189
  "ping",
57493
58190
  "sampling",
57494
58191
  "elicitations",
@@ -57497,12 +58194,17 @@ const App = () => {
57497
58194
  ];
57498
58195
  const isValidTab = validTabs.includes(hash);
57499
58196
  if (!isValidTab) {
57500
- const defaultTab = serverCapabilities?.resources ? "resources" : serverCapabilities?.prompts ? "prompts" : serverCapabilities?.tools ? "tools" : "ping";
58197
+ const defaultTab = serverCapabilities?.resources ? "resources" : serverCapabilities?.prompts ? "prompts" : serverCapabilities?.tools ? "tools" : serverCapabilities?.tasks ? "tasks" : "ping";
57501
58198
  setActiveTab(defaultTab);
57502
58199
  window.location.hash = defaultTab;
57503
58200
  }
57504
58201
  }
57505
58202
  }, [serverCapabilities]);
58203
+ reactExports.useEffect(() => {
58204
+ if (mcpClient && activeTab === "tasks") {
58205
+ void listTasks();
58206
+ }
58207
+ }, [mcpClient, activeTab]);
57506
58208
  reactExports.useEffect(() => {
57507
58209
  localStorage.setItem("lastCommand", command);
57508
58210
  }, [command]);
@@ -57677,7 +58379,7 @@ const App = () => {
57677
58379
  }, [roots]);
57678
58380
  reactExports.useEffect(() => {
57679
58381
  if (mcpClient && !window.location.hash) {
57680
- const defaultTab = serverCapabilities?.resources ? "resources" : serverCapabilities?.prompts ? "prompts" : serverCapabilities?.tools ? "tools" : "ping";
58382
+ const defaultTab = serverCapabilities?.resources ? "resources" : serverCapabilities?.prompts ? "prompts" : serverCapabilities?.tools ? "tools" : serverCapabilities?.tasks ? "tasks" : "ping";
57681
58383
  window.location.hash = defaultTab;
57682
58384
  } else if (!mcpClient && window.location.hash) {
57683
58385
  window.history.replaceState(
@@ -57701,6 +58403,7 @@ const App = () => {
57701
58403
  setPendingSampleRequests((prev) => {
57702
58404
  const request = prev.find((r2) => r2.id === id2);
57703
58405
  request?.resolve(result);
58406
+ navigateToOriginatingTab(request?.originatingTab);
57704
58407
  return prev.filter((r2) => r2.id !== id2);
57705
58408
  });
57706
58409
  };
@@ -57708,6 +58411,7 @@ const App = () => {
57708
58411
  setPendingSampleRequests((prev) => {
57709
58412
  const request = prev.find((r2) => r2.id === id2);
57710
58413
  request?.reject(new Error("Sampling request rejected"));
58414
+ navigateToOriginatingTab(request?.originatingTab);
57711
58415
  return prev.filter((r2) => r2.id !== id2);
57712
58416
  });
57713
58417
  };
@@ -57722,6 +58426,7 @@ const App = () => {
57722
58426
  ...serverCapabilities?.resources ? ["resources"] : [],
57723
58427
  ...serverCapabilities?.prompts ? ["prompts"] : [],
57724
58428
  ...serverCapabilities?.tools ? ["tools"] : [],
58429
+ ...serverCapabilities?.tasks ? ["tasks"] : [],
57725
58430
  "ping",
57726
58431
  "sampling",
57727
58432
  "elicitations",
@@ -57872,7 +58577,7 @@ const App = () => {
57872
58577
  setNextToolCursor(response.nextCursor);
57873
58578
  cacheToolOutputSchemas(response.tools);
57874
58579
  };
57875
- const callTool = async (name2, params, toolMetadata) => {
58580
+ const callTool = async (name2, params, toolMetadata, runAsTask) => {
57876
58581
  lastToolCallOriginTabRef.current = currentTabRef.current;
57877
58582
  try {
57878
58583
  const tool = tools.find((t) => t.name === name2);
@@ -57884,19 +58589,119 @@ const App = () => {
57884
58589
  ...toolMetadata
57885
58590
  // Tool-specific metadata
57886
58591
  };
57887
- const response = await sendMCPRequest(
57888
- {
57889
- method: "tools/call",
57890
- params: {
57891
- name: name2,
57892
- arguments: cleanedParams,
57893
- _meta: mergedMetadata
58592
+ const request = {
58593
+ method: "tools/call",
58594
+ params: {
58595
+ name: name2,
58596
+ arguments: cleanedParams,
58597
+ _meta: mergedMetadata
58598
+ }
58599
+ };
58600
+ if (runAsTask) {
58601
+ request.params = {
58602
+ ...request.params,
58603
+ task: {
58604
+ ttl: getMCPTaskTtl(config2)
57894
58605
  }
57895
- },
58606
+ };
58607
+ }
58608
+ const response = await sendMCPRequest(
58609
+ request,
57896
58610
  CompatibilityCallToolResultSchema,
57897
58611
  "tools"
57898
58612
  );
57899
- setToolResult(response);
58613
+ const isTaskResult = (res) => !!res && typeof res === "object" && "task" in res && !!res.task && typeof res.task === "object" && "taskId" in res.task;
58614
+ if (runAsTask && isTaskResult(response)) {
58615
+ const taskId = response.task.taskId;
58616
+ const pollInterval = response.task.pollInterval;
58617
+ setIsPollingTask(true);
58618
+ const initialResponseMeta = response && typeof response === "object" && "_meta" in response ? response._meta ?? {} : void 0;
58619
+ setToolResult({
58620
+ content: [
58621
+ {
58622
+ type: "text",
58623
+ text: `Task created: ${taskId}. Polling for status...`
58624
+ }
58625
+ ],
58626
+ _meta: {
58627
+ ...initialResponseMeta || {},
58628
+ "io.modelcontextprotocol/related-task": { taskId }
58629
+ }
58630
+ });
58631
+ let taskCompleted = false;
58632
+ while (!taskCompleted) {
58633
+ try {
58634
+ await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
58635
+ const taskStatus = await sendMCPRequest(
58636
+ {
58637
+ method: "tasks/get",
58638
+ params: { taskId }
58639
+ },
58640
+ GetTaskResultSchema
58641
+ );
58642
+ if (taskStatus.status === "completed" || taskStatus.status === "failed" || taskStatus.status === "cancelled") {
58643
+ taskCompleted = true;
58644
+ console.log(
58645
+ `Polling complete for task ${taskId}: ${taskStatus.status}`
58646
+ );
58647
+ if (taskStatus.status === "completed") {
58648
+ console.log(`Fetching result for task ${taskId}`);
58649
+ const result = await sendMCPRequest(
58650
+ {
58651
+ method: "tasks/result",
58652
+ params: { taskId }
58653
+ },
58654
+ CompatibilityCallToolResultSchema
58655
+ );
58656
+ console.log(`Result received for task ${taskId}:`, result);
58657
+ setToolResult(result);
58658
+ void listTasks();
58659
+ } else {
58660
+ setToolResult({
58661
+ content: [
58662
+ {
58663
+ type: "text",
58664
+ text: `Task ${taskStatus.status}: ${taskStatus.statusMessage || "No additional information"}`
58665
+ }
58666
+ ],
58667
+ isError: true
58668
+ });
58669
+ void listTasks();
58670
+ }
58671
+ } else {
58672
+ const pollingResponseMeta = response && typeof response === "object" && "_meta" in response ? response._meta ?? {} : void 0;
58673
+ setToolResult({
58674
+ content: [
58675
+ {
58676
+ type: "text",
58677
+ text: `Task status: ${taskStatus.status}${taskStatus.statusMessage ? ` - ${taskStatus.statusMessage}` : ""}. Polling...`
58678
+ }
58679
+ ],
58680
+ _meta: {
58681
+ ...pollingResponseMeta || {},
58682
+ "io.modelcontextprotocol/related-task": { taskId }
58683
+ }
58684
+ });
58685
+ void listTasks();
58686
+ }
58687
+ } catch (pollingError) {
58688
+ console.error("Error polling task status:", pollingError);
58689
+ setToolResult({
58690
+ content: [
58691
+ {
58692
+ type: "text",
58693
+ text: `Error polling task status: ${pollingError instanceof Error ? pollingError.message : String(pollingError)}`
58694
+ }
58695
+ ],
58696
+ isError: true
58697
+ });
58698
+ taskCompleted = true;
58699
+ }
58700
+ }
58701
+ setIsPollingTask(false);
58702
+ } else {
58703
+ setToolResult(response);
58704
+ }
57900
58705
  setErrors((prev) => ({ ...prev, tools: null }));
57901
58706
  } catch (e) {
57902
58707
  const toolResult2 = {
@@ -57912,6 +58717,34 @@ const App = () => {
57912
58717
  setErrors((prev) => ({ ...prev, tools: null }));
57913
58718
  }
57914
58719
  };
58720
+ const listTasks = reactExports.useCallback(async () => {
58721
+ try {
58722
+ const response = await listMcpTasks(nextTaskCursor);
58723
+ setTasks(response.tasks);
58724
+ setNextTaskCursor(response.nextCursor);
58725
+ setErrors((prev) => ({ ...prev, tasks: null }));
58726
+ } catch (e) {
58727
+ setErrors((prev) => ({
58728
+ ...prev,
58729
+ tasks: e.message ?? String(e)
58730
+ }));
58731
+ }
58732
+ }, [listMcpTasks, nextTaskCursor]);
58733
+ const cancelTask = async (taskId) => {
58734
+ try {
58735
+ const response = await cancelMcpTask(taskId);
58736
+ setTasks((prev) => prev.map((t) => t.taskId === taskId ? response : t));
58737
+ if (selectedTask?.taskId === taskId) {
58738
+ setSelectedTask(response);
58739
+ }
58740
+ clearError("tasks");
58741
+ } catch (e) {
58742
+ setErrors((prev) => ({
58743
+ ...prev,
58744
+ tasks: e.message ?? String(e)
58745
+ }));
58746
+ }
58747
+ };
57915
58748
  const handleRootsChange = async () => {
57916
58749
  await sendNotification({ method: "notifications/roots/list_changed" });
57917
58750
  };
@@ -57939,13 +58772,13 @@ const App = () => {
57939
58772
  ) });
57940
58773
  if (window.location.pathname === "/oauth/callback") {
57941
58774
  const OAuthCallback = React.lazy(
57942
- () => __vitePreload(() => import("./OAuthCallback-Bojw9MF2.js"), true ? [] : void 0)
58775
+ () => __vitePreload(() => import("./OAuthCallback-C7u-W3fG.js"), true ? [] : void 0)
57943
58776
  );
57944
58777
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthCallback, { onConnect: onOAuthConnect }) });
57945
58778
  }
57946
58779
  if (window.location.pathname === "/oauth/callback/debug") {
57947
58780
  const OAuthDebugCallback = React.lazy(
57948
- () => __vitePreload(() => import("./OAuthDebugCallback-ms23dRpk.js"), true ? [] : void 0)
58781
+ () => __vitePreload(() => import("./OAuthDebugCallback-CJZOHlWo.js"), true ? [] : void 0)
57949
58782
  );
57950
58783
  return /* @__PURE__ */ jsxRuntimeExports.jsx(reactExports.Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(OAuthDebugCallback, { onConnect: onOAuthDebugConnect }) });
57951
58784
  }
@@ -58061,6 +58894,17 @@ const App = () => {
58061
58894
  ]
58062
58895
  }
58063
58896
  ),
58897
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
58898
+ TabsTrigger,
58899
+ {
58900
+ value: "tasks",
58901
+ disabled: !serverCapabilities?.tasks,
58902
+ children: [
58903
+ /* @__PURE__ */ jsxRuntimeExports.jsx(ListTodo, { className: "w-4 h-4 mr-2" }),
58904
+ "Tasks"
58905
+ ]
58906
+ }
58907
+ ),
58064
58908
  /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "ping", children: [
58065
58909
  /* @__PURE__ */ jsxRuntimeExports.jsx(Bell, { className: "w-4 h-4 mr-2" }),
58066
58910
  "Ping"
@@ -58194,10 +59038,10 @@ const App = () => {
58194
59038
  setNextToolCursor(void 0);
58195
59039
  cacheToolOutputSchemas([]);
58196
59040
  },
58197
- callTool: async (name2, params, metadata22) => {
59041
+ callTool: async (name2, params, metadata22, runAsTask) => {
58198
59042
  clearError("tools");
58199
59043
  setToolResult(null);
58200
- await callTool(name2, params, metadata22);
59044
+ await callTool(name2, params, metadata22, runAsTask);
58201
59045
  },
58202
59046
  selectedTool,
58203
59047
  setSelectedTool: (tool) => {
@@ -58206,6 +59050,7 @@ const App = () => {
58206
59050
  setToolResult(null);
58207
59051
  },
58208
59052
  toolResult,
59053
+ isPollingTask,
58209
59054
  nextCursor: nextToolCursor,
58210
59055
  error: errors2.tools,
58211
59056
  resourceContent: resourceContentMap,
@@ -58215,6 +59060,28 @@ const App = () => {
58215
59060
  }
58216
59061
  }
58217
59062
  ),
59063
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
59064
+ TasksTab,
59065
+ {
59066
+ tasks,
59067
+ listTasks: () => {
59068
+ clearError("tasks");
59069
+ listTasks();
59070
+ },
59071
+ clearTasks: () => {
59072
+ setTasks([]);
59073
+ setNextTaskCursor(void 0);
59074
+ },
59075
+ cancelTask,
59076
+ selectedTask,
59077
+ setSelectedTask: (task) => {
59078
+ clearError("tasks");
59079
+ setSelectedTask(task);
59080
+ },
59081
+ error: errors2.tasks,
59082
+ nextCursor: nextTaskCursor
59083
+ }
59084
+ ),
58218
59085
  /* @__PURE__ */ jsxRuntimeExports.jsx(ConsoleTab, {}),
58219
59086
  /* @__PURE__ */ jsxRuntimeExports.jsx(
58220
59087
  PingTab,