@opentiny/next-sdk 0.1.15-beta.4 → 0.1.15-beta.5

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.
@@ -6847,9 +6847,8 @@ const string$1 = (params) => {
6847
6847
  return new RegExp(`^${regex}$`);
6848
6848
  };
6849
6849
  const integer = /^\d+$/;
6850
- const number$2 = /^-?\d+(?:\.\d+)?/i;
6850
+ const number$1 = /^-?\d+(?:\.\d+)?/i;
6851
6851
  const boolean$1 = /true|false/i;
6852
- const _null$2 = /null/i;
6853
6852
  const lowercase = /^[^A-Z]*$/;
6854
6853
  const uppercase = /^[^a-z]*$/;
6855
6854
  const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
@@ -7659,7 +7658,7 @@ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
7659
7658
  });
7660
7659
  const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
7661
7660
  $ZodType.init(inst, def);
7662
- inst._zod.pattern = inst._zod.bag.pattern ?? number$2;
7661
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
7663
7662
  inst._zod.parse = (payload, _ctx) => {
7664
7663
  if (def.coerce)
7665
7664
  try {
@@ -7706,23 +7705,6 @@ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
7706
7705
  return payload;
7707
7706
  };
7708
7707
  });
7709
- const $ZodNull = /* @__PURE__ */ $constructor("$ZodNull", (inst, def) => {
7710
- $ZodType.init(inst, def);
7711
- inst._zod.pattern = _null$2;
7712
- inst._zod.values = /* @__PURE__ */ new Set([null]);
7713
- inst._zod.parse = (payload, _ctx) => {
7714
- const input = payload.value;
7715
- if (input === null)
7716
- return payload;
7717
- payload.issues.push({
7718
- expected: "null",
7719
- code: "invalid_type",
7720
- input,
7721
- inst
7722
- });
7723
- return payload;
7724
- };
7725
- });
7726
7708
  const $ZodAny = /* @__PURE__ */ $constructor("$ZodAny", (inst, def) => {
7727
7709
  $ZodType.init(inst, def);
7728
7710
  inst._zod.parse = (payload) => payload;
@@ -8810,14 +8792,6 @@ function _number(Class, params) {
8810
8792
  ...normalizeParams(params)
8811
8793
  });
8812
8794
  }
8813
- function _coercedNumber(Class, params) {
8814
- return new Class({
8815
- type: "number",
8816
- coerce: true,
8817
- checks: [],
8818
- ...normalizeParams(params)
8819
- });
8820
- }
8821
8795
  function _int(Class, params) {
8822
8796
  return new Class({
8823
8797
  type: "number",
@@ -8833,12 +8807,6 @@ function _boolean(Class, params) {
8833
8807
  ...normalizeParams(params)
8834
8808
  });
8835
8809
  }
8836
- function _null$1(Class, params) {
8837
- return new Class({
8838
- type: "null",
8839
- ...normalizeParams(params)
8840
- });
8841
- }
8842
8810
  function _any(Class) {
8843
8811
  return new Class({
8844
8812
  type: "any"
@@ -10062,7 +10030,7 @@ const ZodNumber$1 = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
10062
10030
  inst.isFinite = true;
10063
10031
  inst.format = bag.format ?? null;
10064
10032
  });
10065
- function number$1(params) {
10033
+ function number(params) {
10066
10034
  return _number(ZodNumber$1, params);
10067
10035
  }
10068
10036
  const ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
@@ -10079,13 +10047,6 @@ const ZodBoolean$1 = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
10079
10047
  function boolean(params) {
10080
10048
  return _boolean(ZodBoolean$1, params);
10081
10049
  }
10082
- const ZodNull$1 = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
10083
- $ZodNull.init(inst, def);
10084
- ZodType$1.init(inst, def);
10085
- });
10086
- function _null(params) {
10087
- return _null$1(ZodNull$1, params);
10088
- }
10089
10050
  const ZodAny$1 = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
10090
10051
  $ZodAny.init(inst, def);
10091
10052
  ZodType$1.init(inst, def);
@@ -10454,47 +10415,20 @@ function preprocess(fn, schema) {
10454
10415
  const ZodIssueCode$1 = {
10455
10416
  custom: "custom"
10456
10417
  };
10457
- function number(params) {
10458
- return _coercedNumber(ZodNumber$1, params);
10459
- }
10460
- const LATEST_PROTOCOL_VERSION = "2025-11-25";
10418
+ const LATEST_PROTOCOL_VERSION = "2025-06-18";
10461
10419
  const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
10462
- const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
10463
- const RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
10420
+ const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
10464
10421
  const JSONRPC_VERSION = "2.0";
10465
10422
  const AssertObjectSchema = custom((v) => v !== null && (typeof v === "object" || typeof v === "function"));
10466
- const ProgressTokenSchema = union([string(), number$1().int()]);
10423
+ const ProgressTokenSchema = union([string(), number().int()]);
10467
10424
  const CursorSchema = string();
10468
- const TaskCreationParamsSchema = looseObject({
10469
- /**
10470
- * Time in milliseconds to keep task results available after completion.
10471
- * If null, the task has unlimited lifetime until manually cleaned up.
10472
- */
10473
- ttl: union([number$1(), _null()]).optional(),
10474
- /**
10475
- * Time in milliseconds to wait between task status requests.
10476
- */
10477
- pollInterval: number$1().optional()
10478
- });
10479
- const RelatedTaskMetadataSchema = looseObject({
10480
- taskId: string()
10481
- });
10482
10425
  const RequestMetaSchema = looseObject({
10483
10426
  /**
10484
10427
  * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.
10485
10428
  */
10486
- progressToken: ProgressTokenSchema.optional(),
10487
- /**
10488
- * If specified, this request is related to the provided task.
10489
- */
10490
- [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
10429
+ progressToken: ProgressTokenSchema.optional()
10491
10430
  });
10492
10431
  const BaseRequestParamsSchema = looseObject({
10493
- /**
10494
- * If specified, the caller is requesting that the receiver create a task to represent the request.
10495
- * Task creation parameters are now at the top level instead of in _meta.
10496
- */
10497
- task: TaskCreationParamsSchema.optional(),
10498
10432
  /**
10499
10433
  * See [General fields: `_meta`](/specification/draft/basic/index#meta) for notes on `_meta` usage.
10500
10434
  */
@@ -10509,12 +10443,7 @@ const NotificationsParamsSchema = looseObject({
10509
10443
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
10510
10444
  * for notes on _meta usage.
10511
10445
  */
10512
- _meta: object$1({
10513
- /**
10514
- * If specified, this notification is related to the provided task.
10515
- */
10516
- [RELATED_TASK_META_KEY]: optional(RelatedTaskMetadataSchema)
10517
- }).passthrough().optional()
10446
+ _meta: record(string(), unknown()).optional()
10518
10447
  });
10519
10448
  const NotificationSchema = object$1({
10520
10449
  method: string(),
@@ -10525,14 +10454,9 @@ const ResultSchema = looseObject({
10525
10454
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
10526
10455
  * for notes on _meta usage.
10527
10456
  */
10528
- _meta: looseObject({
10529
- /**
10530
- * If specified, this result is related to the provided task.
10531
- */
10532
- [RELATED_TASK_META_KEY]: RelatedTaskMetadataSchema.optional()
10533
- }).optional()
10457
+ _meta: record(string(), unknown()).optional()
10534
10458
  });
10535
- const RequestIdSchema = union([string(), number$1().int()]);
10459
+ const RequestIdSchema = union([string(), number().int()]);
10536
10460
  const JSONRPCRequestSchema = object$1({
10537
10461
  jsonrpc: literal(JSONRPC_VERSION),
10538
10462
  id: RequestIdSchema,
@@ -10568,7 +10492,7 @@ const JSONRPCErrorSchema = object$1({
10568
10492
  /**
10569
10493
  * The error type that occurred.
10570
10494
  */
10571
- code: number$1().int(),
10495
+ code: number().int(),
10572
10496
  /**
10573
10497
  * A short description of the error. The message SHOULD be limited to a concise single sentence.
10574
10498
  */
@@ -10665,54 +10589,6 @@ const ElicitationCapabilitySchema = preprocess((value) => {
10665
10589
  form: FormElicitationCapabilitySchema.optional(),
10666
10590
  url: AssertObjectSchema.optional()
10667
10591
  }), record(string(), unknown()).optional()));
10668
- const ClientTasksCapabilitySchema = object$1({
10669
- /**
10670
- * Present if the client supports listing tasks.
10671
- */
10672
- list: optional(object$1({}).passthrough()),
10673
- /**
10674
- * Present if the client supports cancelling tasks.
10675
- */
10676
- cancel: optional(object$1({}).passthrough()),
10677
- /**
10678
- * Capabilities for task creation on specific request types.
10679
- */
10680
- requests: optional(object$1({
10681
- /**
10682
- * Task support for sampling requests.
10683
- */
10684
- sampling: optional(object$1({
10685
- createMessage: optional(object$1({}).passthrough())
10686
- }).passthrough()),
10687
- /**
10688
- * Task support for elicitation requests.
10689
- */
10690
- elicitation: optional(object$1({
10691
- create: optional(object$1({}).passthrough())
10692
- }).passthrough())
10693
- }).passthrough())
10694
- }).passthrough();
10695
- const ServerTasksCapabilitySchema = object$1({
10696
- /**
10697
- * Present if the server supports listing tasks.
10698
- */
10699
- list: optional(object$1({}).passthrough()),
10700
- /**
10701
- * Present if the server supports cancelling tasks.
10702
- */
10703
- cancel: optional(object$1({}).passthrough()),
10704
- /**
10705
- * Capabilities for task creation on specific request types.
10706
- */
10707
- requests: optional(object$1({
10708
- /**
10709
- * Task support for tool requests.
10710
- */
10711
- tools: optional(object$1({
10712
- call: optional(object$1({}).passthrough())
10713
- }).passthrough())
10714
- }).passthrough())
10715
- }).passthrough();
10716
10592
  const ClientCapabilitiesSchema = object$1({
10717
10593
  /**
10718
10594
  * Experimental, non-standard capabilities that the client supports.
@@ -10744,11 +10620,7 @@ const ClientCapabilitiesSchema = object$1({
10744
10620
  * Whether the client supports issuing notifications for changes to the roots list.
10745
10621
  */
10746
10622
  listChanged: boolean().optional()
10747
- }).optional(),
10748
- /**
10749
- * Present if the client supports task creation.
10750
- */
10751
- tasks: optional(ClientTasksCapabilitySchema)
10623
+ }).optional()
10752
10624
  });
10753
10625
  const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
10754
10626
  /**
@@ -10806,12 +10678,8 @@ const ServerCapabilitiesSchema = object$1({
10806
10678
  * Whether this server supports issuing notifications for changes to the tool list.
10807
10679
  */
10808
10680
  listChanged: boolean().optional()
10809
- }).optional(),
10810
- /**
10811
- * Present if the server supports task creation.
10812
- */
10813
- tasks: optional(ServerTasksCapabilitySchema)
10814
- }).passthrough();
10681
+ }).optional()
10682
+ });
10815
10683
  const InitializeResultSchema = ResultSchema.extend({
10816
10684
  /**
10817
10685
  * 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.
@@ -10837,11 +10705,11 @@ const ProgressSchema = object$1({
10837
10705
  /**
10838
10706
  * The progress thus far. This should increase every time progress is made, even if the total is unknown.
10839
10707
  */
10840
- progress: number$1(),
10708
+ progress: number(),
10841
10709
  /**
10842
10710
  * Total number of items to process (or total progress required), if known.
10843
10711
  */
10844
- total: optional(number$1()),
10712
+ total: optional(number()),
10845
10713
  /**
10846
10714
  * An optional message describing the current progress.
10847
10715
  */
@@ -10876,62 +10744,6 @@ const PaginatedResultSchema = ResultSchema.extend({
10876
10744
  */
10877
10745
  nextCursor: optional(CursorSchema)
10878
10746
  });
10879
- const TaskSchema = object$1({
10880
- taskId: string(),
10881
- status: _enum(["working", "input_required", "completed", "failed", "cancelled"]),
10882
- /**
10883
- * Time in milliseconds to keep task results available after completion.
10884
- * If null, the task has unlimited lifetime until manually cleaned up.
10885
- */
10886
- ttl: union([number$1(), _null()]),
10887
- /**
10888
- * ISO 8601 timestamp when the task was created.
10889
- */
10890
- createdAt: string(),
10891
- /**
10892
- * ISO 8601 timestamp when the task was last updated.
10893
- */
10894
- lastUpdatedAt: string(),
10895
- pollInterval: optional(number$1()),
10896
- /**
10897
- * Optional diagnostic message for failed tasks or other status information.
10898
- */
10899
- statusMessage: optional(string())
10900
- });
10901
- const CreateTaskResultSchema = ResultSchema.extend({
10902
- task: TaskSchema
10903
- });
10904
- const TaskStatusNotificationParamsSchema = NotificationsParamsSchema.merge(TaskSchema);
10905
- const TaskStatusNotificationSchema = NotificationSchema.extend({
10906
- method: literal("notifications/tasks/status"),
10907
- params: TaskStatusNotificationParamsSchema
10908
- });
10909
- const GetTaskRequestSchema = RequestSchema.extend({
10910
- method: literal("tasks/get"),
10911
- params: BaseRequestParamsSchema.extend({
10912
- taskId: string()
10913
- })
10914
- });
10915
- const GetTaskResultSchema = ResultSchema.merge(TaskSchema);
10916
- const GetTaskPayloadRequestSchema = RequestSchema.extend({
10917
- method: literal("tasks/result"),
10918
- params: BaseRequestParamsSchema.extend({
10919
- taskId: string()
10920
- })
10921
- });
10922
- const ListTasksRequestSchema = PaginatedRequestSchema.extend({
10923
- method: literal("tasks/list")
10924
- });
10925
- const ListTasksResultSchema = PaginatedResultSchema.extend({
10926
- tasks: array(TaskSchema)
10927
- });
10928
- const CancelTaskRequestSchema = RequestSchema.extend({
10929
- method: literal("tasks/cancel"),
10930
- params: BaseRequestParamsSchema.extend({
10931
- taskId: string()
10932
- })
10933
- });
10934
- const CancelTaskResultSchema = ResultSchema.merge(TaskSchema);
10935
10747
  const ResourceContentsSchema = object$1({
10936
10748
  /**
10937
10749
  * The URI of this resource.
@@ -10967,20 +10779,6 @@ const BlobResourceContentsSchema = ResourceContentsSchema.extend({
10967
10779
  */
10968
10780
  blob: Base64Schema
10969
10781
  });
10970
- const AnnotationsSchema = object$1({
10971
- /**
10972
- * Intended audience(s) for the resource.
10973
- */
10974
- audience: array(_enum(["user", "assistant"])).optional(),
10975
- /**
10976
- * Importance hint for the resource, from 0 (least) to 1 (most).
10977
- */
10978
- priority: number$1().min(0).max(1).optional(),
10979
- /**
10980
- * ISO 8601 timestamp for the most recent modification.
10981
- */
10982
- lastModified: datetime({ offset: true }).optional()
10983
- });
10984
10782
  const ResourceSchema = object$1({
10985
10783
  ...BaseMetadataSchema.shape,
10986
10784
  ...IconsSchema.shape,
@@ -10998,10 +10796,6 @@ const ResourceSchema = object$1({
10998
10796
  * The MIME type of this resource, if known.
10999
10797
  */
11000
10798
  mimeType: optional(string()),
11001
- /**
11002
- * Optional annotations for the client.
11003
- */
11004
- annotations: AnnotationsSchema.optional(),
11005
10799
  /**
11006
10800
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11007
10801
  * for notes on _meta usage.
@@ -11025,10 +10819,6 @@ const ResourceTemplateSchema = object$1({
11025
10819
  * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.
11026
10820
  */
11027
10821
  mimeType: optional(string()),
11028
- /**
11029
- * Optional annotations for the client.
11030
- */
11031
- annotations: AnnotationsSchema.optional(),
11032
10822
  /**
11033
10823
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11034
10824
  * for notes on _meta usage.
@@ -11143,10 +10933,6 @@ const TextContentSchema = object$1({
11143
10933
  * The text content of the message.
11144
10934
  */
11145
10935
  text: string(),
11146
- /**
11147
- * Optional annotations for the client.
11148
- */
11149
- annotations: AnnotationsSchema.optional(),
11150
10936
  /**
11151
10937
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11152
10938
  * for notes on _meta usage.
@@ -11163,10 +10949,6 @@ const ImageContentSchema = object$1({
11163
10949
  * The MIME type of the image. Different providers may support different image types.
11164
10950
  */
11165
10951
  mimeType: string(),
11166
- /**
11167
- * Optional annotations for the client.
11168
- */
11169
- annotations: AnnotationsSchema.optional(),
11170
10952
  /**
11171
10953
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11172
10954
  * for notes on _meta usage.
@@ -11183,10 +10965,6 @@ const AudioContentSchema = object$1({
11183
10965
  * The MIME type of the audio. Different providers may support different audio types.
11184
10966
  */
11185
10967
  mimeType: string(),
11186
- /**
11187
- * Optional annotations for the client.
11188
- */
11189
- annotations: AnnotationsSchema.optional(),
11190
10968
  /**
11191
10969
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11192
10970
  * for notes on _meta usage.
@@ -11219,10 +10997,6 @@ const ToolUseContentSchema = object$1({
11219
10997
  const EmbeddedResourceSchema = object$1({
11220
10998
  type: literal("resource"),
11221
10999
  resource: union([TextResourceContentsSchema, BlobResourceContentsSchema]),
11222
- /**
11223
- * Optional annotations for the client.
11224
- */
11225
- annotations: AnnotationsSchema.optional(),
11226
11000
  /**
11227
11001
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11228
11002
  * for notes on _meta usage.
@@ -11292,17 +11066,6 @@ const ToolAnnotationsSchema = object$1({
11292
11066
  */
11293
11067
  openWorldHint: boolean().optional()
11294
11068
  });
11295
- const ToolExecutionSchema = object$1({
11296
- /**
11297
- * Indicates the tool's preference for task-augmented execution.
11298
- * - "required": Clients MUST invoke the tool as a task
11299
- * - "optional": Clients MAY invoke the tool as a task or normal request
11300
- * - "forbidden": Clients MUST NOT attempt to invoke the tool as a task
11301
- *
11302
- * If not present, defaults to "forbidden".
11303
- */
11304
- taskSupport: _enum(["required", "optional", "forbidden"]).optional()
11305
- });
11306
11069
  const ToolSchema = object$1({
11307
11070
  ...BaseMetadataSchema.shape,
11308
11071
  ...IconsSchema.shape,
@@ -11333,10 +11096,6 @@ const ToolSchema = object$1({
11333
11096
  * Optional additional tool information.
11334
11097
  */
11335
11098
  annotations: optional(ToolAnnotationsSchema),
11336
- /**
11337
- * Execution-related properties for this tool.
11338
- */
11339
- execution: optional(ToolExecutionSchema),
11340
11099
  /**
11341
11100
  * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
11342
11101
  * for notes on _meta usage.
@@ -11442,15 +11201,15 @@ const ModelPreferencesSchema = object$1({
11442
11201
  /**
11443
11202
  * How much to prioritize cost when selecting a model.
11444
11203
  */
11445
- costPriority: optional(number$1().min(0).max(1)),
11204
+ costPriority: optional(number().min(0).max(1)),
11446
11205
  /**
11447
11206
  * How much to prioritize sampling speed (latency) when selecting a model.
11448
11207
  */
11449
- speedPriority: optional(number$1().min(0).max(1)),
11208
+ speedPriority: optional(number().min(0).max(1)),
11450
11209
  /**
11451
11210
  * How much to prioritize intelligence and capabilities when selecting a model.
11452
11211
  */
11453
- intelligencePriority: optional(number$1().min(0).max(1))
11212
+ intelligencePriority: optional(number().min(0).max(1))
11454
11213
  });
11455
11214
  const ToolChoiceSchema = object$1({
11456
11215
  /**
@@ -11473,7 +11232,6 @@ const ToolResultContentSchema = object$1({
11473
11232
  */
11474
11233
  _meta: optional(object$1({}).passthrough())
11475
11234
  }).passthrough();
11476
- const SamplingContentSchema = discriminatedUnion("type", [TextContentSchema, ImageContentSchema, AudioContentSchema]);
11477
11235
  const SamplingMessageContentBlockSchema = discriminatedUnion("type", [
11478
11236
  TextContentSchema,
11479
11237
  ImageContentSchema,
@@ -11508,13 +11266,13 @@ const CreateMessageRequestParamsSchema = BaseRequestParamsSchema.extend({
11508
11266
  * declares ClientCapabilities.sampling.context. These values may be removed in future spec releases.
11509
11267
  */
11510
11268
  includeContext: _enum(["none", "thisServer", "allServers"]).optional(),
11511
- temperature: number$1().optional(),
11269
+ temperature: number().optional(),
11512
11270
  /**
11513
11271
  * The requested maximum number of tokens to sample (to prevent runaway completions).
11514
11272
  *
11515
11273
  * The client MAY choose to sample fewer tokens than the requested maximum.
11516
11274
  */
11517
- maxTokens: number$1().int(),
11275
+ maxTokens: number().int(),
11518
11276
  stopSequences: array(string()).optional(),
11519
11277
  /**
11520
11278
  * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.
@@ -11537,28 +11295,6 @@ const CreateMessageRequestSchema = RequestSchema.extend({
11537
11295
  params: CreateMessageRequestParamsSchema
11538
11296
  });
11539
11297
  const CreateMessageResultSchema = ResultSchema.extend({
11540
- /**
11541
- * The name of the model that generated the message.
11542
- */
11543
- model: string(),
11544
- /**
11545
- * The reason why sampling stopped, if known.
11546
- *
11547
- * Standard values:
11548
- * - "endTurn": Natural end of the assistant's turn
11549
- * - "stopSequence": A stop sequence was encountered
11550
- * - "maxTokens": Maximum token limit was reached
11551
- *
11552
- * This field is an open string to allow for provider-specific stop reasons.
11553
- */
11554
- stopReason: optional(_enum(["endTurn", "stopSequence", "maxTokens"]).or(string())),
11555
- role: _enum(["user", "assistant"]),
11556
- /**
11557
- * Response content. Single content block (text, image, or audio).
11558
- */
11559
- content: SamplingContentSchema
11560
- });
11561
- const CreateMessageResultWithToolsSchema = ResultSchema.extend({
11562
11298
  /**
11563
11299
  * The name of the model that generated the message.
11564
11300
  */
@@ -11577,7 +11313,7 @@ const CreateMessageResultWithToolsSchema = ResultSchema.extend({
11577
11313
  stopReason: optional(_enum(["endTurn", "stopSequence", "maxTokens", "toolUse"]).or(string())),
11578
11314
  role: _enum(["user", "assistant"]),
11579
11315
  /**
11580
- * Response content. May be a single block or array. May include ToolUseContent if stopReason is "toolUse".
11316
+ * Response content. May be ToolUseContent if stopReason is "toolUse".
11581
11317
  */
11582
11318
  content: union([SamplingMessageContentBlockSchema, array(SamplingMessageContentBlockSchema)])
11583
11319
  });
@@ -11591,8 +11327,8 @@ const StringSchemaSchema = object$1({
11591
11327
  type: literal("string"),
11592
11328
  title: string().optional(),
11593
11329
  description: string().optional(),
11594
- minLength: number$1().optional(),
11595
- maxLength: number$1().optional(),
11330
+ minLength: number().optional(),
11331
+ maxLength: number().optional(),
11596
11332
  format: _enum(["email", "uri", "date", "date-time"]).optional(),
11597
11333
  default: string().optional()
11598
11334
  });
@@ -11600,9 +11336,9 @@ const NumberSchemaSchema = object$1({
11600
11336
  type: _enum(["number", "integer"]),
11601
11337
  title: string().optional(),
11602
11338
  description: string().optional(),
11603
- minimum: number$1().optional(),
11604
- maximum: number$1().optional(),
11605
- default: number$1().optional()
11339
+ minimum: number().optional(),
11340
+ maximum: number().optional(),
11341
+ default: number().optional()
11606
11342
  });
11607
11343
  const UntitledSingleSelectEnumSchemaSchema = object$1({
11608
11344
  type: literal("string"),
@@ -11634,8 +11370,8 @@ const UntitledMultiSelectEnumSchemaSchema = object$1({
11634
11370
  type: literal("array"),
11635
11371
  title: string().optional(),
11636
11372
  description: string().optional(),
11637
- minItems: number$1().optional(),
11638
- maxItems: number$1().optional(),
11373
+ minItems: number().optional(),
11374
+ maxItems: number().optional(),
11639
11375
  items: object$1({
11640
11376
  type: literal("string"),
11641
11377
  enum: array(string())
@@ -11646,8 +11382,8 @@ const TitledMultiSelectEnumSchemaSchema = object$1({
11646
11382
  type: literal("array"),
11647
11383
  title: string().optional(),
11648
11384
  description: string().optional(),
11649
- minItems: number$1().optional(),
11650
- maxItems: number$1().optional(),
11385
+ minItems: number().optional(),
11386
+ maxItems: number().optional(),
11651
11387
  items: object$1({
11652
11388
  anyOf: array(object$1({
11653
11389
  const: string(),
@@ -11725,10 +11461,8 @@ const ElicitResultSchema = ResultSchema.extend({
11725
11461
  /**
11726
11462
  * The submitted form data, only present when action is "accept".
11727
11463
  * Contains values matching the requested schema.
11728
- * Per MCP spec, content is "typically omitted" for decline/cancel actions.
11729
- * We normalize null to undefined for leniency while maintaining type compatibility.
11730
11464
  */
11731
- content: preprocess((val) => val === null ? void 0 : val, record(string(), union([string(), number$1(), boolean(), array(string())])).optional())
11465
+ content: record(string(), union([string(), number(), boolean(), array(string())])).optional()
11732
11466
  });
11733
11467
  const ResourceTemplateReferenceSchema = object$1({
11734
11468
  type: literal("ref/resource"),
@@ -11790,7 +11524,7 @@ const CompleteResultSchema = ResultSchema.extend({
11790
11524
  /**
11791
11525
  * The total number of completion options available. This can exceed the number of values actually sent in the response.
11792
11526
  */
11793
- total: optional(number$1().int()),
11527
+ total: optional(number().int()),
11794
11528
  /**
11795
11529
  * Indicates whether there are additional completion options beyond those provided in the current response, even if the exact total is unknown.
11796
11530
  */
@@ -11834,37 +11568,16 @@ const ClientRequestSchema = union([
11834
11568
  SubscribeRequestSchema,
11835
11569
  UnsubscribeRequestSchema,
11836
11570
  CallToolRequestSchema,
11837
- ListToolsRequestSchema,
11838
- GetTaskRequestSchema,
11839
- GetTaskPayloadRequestSchema,
11840
- ListTasksRequestSchema
11571
+ ListToolsRequestSchema
11841
11572
  ]);
11842
11573
  const ClientNotificationSchema = union([
11843
11574
  CancelledNotificationSchema,
11844
11575
  ProgressNotificationSchema,
11845
11576
  InitializedNotificationSchema,
11846
- RootsListChangedNotificationSchema,
11847
- TaskStatusNotificationSchema
11848
- ]);
11849
- const ClientResultSchema = union([
11850
- EmptyResultSchema,
11851
- CreateMessageResultSchema,
11852
- CreateMessageResultWithToolsSchema,
11853
- ElicitResultSchema,
11854
- ListRootsResultSchema,
11855
- GetTaskResultSchema,
11856
- ListTasksResultSchema,
11857
- CreateTaskResultSchema
11858
- ]);
11859
- const ServerRequestSchema = union([
11860
- PingRequestSchema,
11861
- CreateMessageRequestSchema,
11862
- ElicitRequestSchema,
11863
- ListRootsRequestSchema,
11864
- GetTaskRequestSchema,
11865
- GetTaskPayloadRequestSchema,
11866
- ListTasksRequestSchema
11577
+ RootsListChangedNotificationSchema
11867
11578
  ]);
11579
+ const ClientResultSchema = union([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
11580
+ const ServerRequestSchema = union([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
11868
11581
  const ServerNotificationSchema = union([
11869
11582
  CancelledNotificationSchema,
11870
11583
  ProgressNotificationSchema,
@@ -11873,7 +11586,6 @@ const ServerNotificationSchema = union([
11873
11586
  ResourceListChangedNotificationSchema,
11874
11587
  ToolListChangedNotificationSchema,
11875
11588
  PromptListChangedNotificationSchema,
11876
- TaskStatusNotificationSchema,
11877
11589
  ElicitationCompleteNotificationSchema
11878
11590
  ]);
11879
11591
  const ServerResultSchema = union([
@@ -11886,10 +11598,7 @@ const ServerResultSchema = union([
11886
11598
  ListResourceTemplatesResultSchema,
11887
11599
  ReadResourceResultSchema,
11888
11600
  CallToolResultSchema,
11889
- ListToolsResultSchema,
11890
- GetTaskResultSchema,
11891
- ListTasksResultSchema,
11892
- CreateTaskResultSchema
11601
+ ListToolsResultSchema
11893
11602
  ]);
11894
11603
  class McpError extends Error {
11895
11604
  constructor(code2, message, data) {
@@ -12171,7 +11880,7 @@ function getDisplayName(metadata2) {
12171
11880
  if (metadata2.title !== void 0 && metadata2.title !== "") {
12172
11881
  return metadata2.title;
12173
11882
  }
12174
- if ("annotations" in metadata2 && ((_a = metadata2.annotations) === null || _a === void 0 ? void 0 : _a.title)) {
11883
+ if ((_a = metadata2.annotations) === null || _a === void 0 ? void 0 : _a.title) {
12175
11884
  return metadata2.annotations.title;
12176
11885
  }
12177
11886
  return metadata2.name;
@@ -15863,7 +15572,7 @@ function normalizeObjectSchema(schema) {
15863
15572
  if (isZ4Schema(schema)) {
15864
15573
  const v4Schema = schema;
15865
15574
  const def = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
15866
- if (def && (def.type === "object" || def.shape !== void 0)) {
15575
+ if (def && (def.typeName === "object" || def.shape !== void 0)) {
15867
15576
  return schema;
15868
15577
  }
15869
15578
  } else {
@@ -15906,7 +15615,7 @@ function isSchemaOptional(schema) {
15906
15615
  var _a, _b, _c;
15907
15616
  if (isZ4Schema(schema)) {
15908
15617
  const v4Schema = schema;
15909
- return ((_b = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def) === null || _b === void 0 ? void 0 : _b.type) === "optional";
15618
+ return ((_b = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def) === null || _b === void 0 ? void 0 : _b.typeName) === "ZodOptional";
15910
15619
  }
15911
15620
  const v3Schema = schema;
15912
15621
  if (typeof schema.isOptional === "function") {
@@ -15941,9 +15650,6 @@ function getLiteralValue(schema) {
15941
15650
  return directValue;
15942
15651
  return void 0;
15943
15652
  }
15944
- function isTerminal(status) {
15945
- return status === "completed" || status === "failed" || status === "cancelled";
15946
- }
15947
15653
  const ignoreOverride = Symbol("Let zodToJsonSchema decide on which parser to use");
15948
15654
  const defaultOptions = {
15949
15655
  name: void 0,
@@ -17200,10 +16906,9 @@ class Protocol {
17200
16906
  this._progressHandlers = /* @__PURE__ */ new Map();
17201
16907
  this._timeoutInfo = /* @__PURE__ */ new Map();
17202
16908
  this._pendingDebouncedNotifications = /* @__PURE__ */ new Set();
17203
- this._taskProgressTokens = /* @__PURE__ */ new Map();
17204
- this._requestResolvers = /* @__PURE__ */ new Map();
17205
16909
  this.setNotificationHandler(CancelledNotificationSchema, (notification) => {
17206
- this._oncancel(notification);
16910
+ const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
16911
+ controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
17207
16912
  });
17208
16913
  this.setNotificationHandler(ProgressNotificationSchema, (notification) => {
17209
16914
  this._onprogress(notification);
@@ -17213,116 +16918,6 @@ class Protocol {
17213
16918
  // Automatic pong by default.
17214
16919
  (_request) => ({})
17215
16920
  );
17216
- this._taskStore = _options === null || _options === void 0 ? void 0 : _options.taskStore;
17217
- this._taskMessageQueue = _options === null || _options === void 0 ? void 0 : _options.taskMessageQueue;
17218
- if (this._taskStore) {
17219
- this.setRequestHandler(GetTaskRequestSchema, async (request, extra) => {
17220
- const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
17221
- if (!task) {
17222
- throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
17223
- }
17224
- return {
17225
- ...task
17226
- };
17227
- });
17228
- this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
17229
- const handleTaskResult = async () => {
17230
- var _a;
17231
- const taskId = request.params.taskId;
17232
- if (this._taskMessageQueue) {
17233
- let queuedMessage;
17234
- while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
17235
- if (queuedMessage.type === "response" || queuedMessage.type === "error") {
17236
- const message = queuedMessage.message;
17237
- const requestId = message.id;
17238
- const resolver = this._requestResolvers.get(requestId);
17239
- if (resolver) {
17240
- this._requestResolvers.delete(requestId);
17241
- if (queuedMessage.type === "response") {
17242
- resolver(message);
17243
- } else {
17244
- const errorMessage = message;
17245
- const error = new McpError(errorMessage.error.code, errorMessage.error.message, errorMessage.error.data);
17246
- resolver(error);
17247
- }
17248
- } else {
17249
- const messageType = queuedMessage.type === "response" ? "Response" : "Error";
17250
- this._onerror(new Error(`${messageType} handler missing for request ${requestId}`));
17251
- }
17252
- continue;
17253
- }
17254
- await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.send(queuedMessage.message, { relatedRequestId: extra.requestId }));
17255
- }
17256
- }
17257
- const task = await this._taskStore.getTask(taskId, extra.sessionId);
17258
- if (!task) {
17259
- throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
17260
- }
17261
- if (!isTerminal(task.status)) {
17262
- await this._waitForTaskUpdate(taskId, extra.signal);
17263
- return await handleTaskResult();
17264
- }
17265
- if (isTerminal(task.status)) {
17266
- const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
17267
- this._clearTaskQueue(taskId);
17268
- return {
17269
- ...result,
17270
- _meta: {
17271
- ...result._meta,
17272
- [RELATED_TASK_META_KEY]: {
17273
- taskId
17274
- }
17275
- }
17276
- };
17277
- }
17278
- return await handleTaskResult();
17279
- };
17280
- return await handleTaskResult();
17281
- });
17282
- this.setRequestHandler(ListTasksRequestSchema, async (request, extra) => {
17283
- var _a;
17284
- try {
17285
- const { tasks, nextCursor } = await this._taskStore.listTasks((_a = request.params) === null || _a === void 0 ? void 0 : _a.cursor, extra.sessionId);
17286
- return {
17287
- tasks,
17288
- nextCursor,
17289
- _meta: {}
17290
- };
17291
- } catch (error) {
17292
- throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error instanceof Error ? error.message : String(error)}`);
17293
- }
17294
- });
17295
- this.setRequestHandler(CancelTaskRequestSchema, async (request, extra) => {
17296
- try {
17297
- const task = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
17298
- if (!task) {
17299
- throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request.params.taskId}`);
17300
- }
17301
- if (isTerminal(task.status)) {
17302
- throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
17303
- }
17304
- await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
17305
- this._clearTaskQueue(request.params.taskId);
17306
- const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
17307
- if (!cancelledTask) {
17308
- throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
17309
- }
17310
- return {
17311
- _meta: {},
17312
- ...cancelledTask
17313
- };
17314
- } catch (error) {
17315
- if (error instanceof McpError) {
17316
- throw error;
17317
- }
17318
- throw new McpError(ErrorCode.InvalidRequest, `Failed to cancel task: ${error instanceof Error ? error.message : String(error)}`);
17319
- }
17320
- });
17321
- }
17322
- }
17323
- async _oncancel(notification) {
17324
- const controller = this._requestHandlerAbortControllers.get(notification.params.requestId);
17325
- controller === null || controller === void 0 ? void 0 : controller.abort(notification.params.reason);
17326
16921
  }
17327
16922
  _setupTimeout(messageId, timeout, maxTotalTimeout, onTimeout, resetTimeoutOnProgress = false) {
17328
16923
  this._timeoutInfo.set(messageId, {
@@ -17395,11 +16990,10 @@ class Protocol {
17395
16990
  const responseHandlers = this._responseHandlers;
17396
16991
  this._responseHandlers = /* @__PURE__ */ new Map();
17397
16992
  this._progressHandlers.clear();
17398
- this._taskProgressTokens.clear();
17399
16993
  this._pendingDebouncedNotifications.clear();
17400
- const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
17401
16994
  this._transport = void 0;
17402
16995
  (_a = this.onclose) === null || _a === void 0 ? void 0 : _a.call(this);
16996
+ const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
17403
16997
  for (const handler of responseHandlers.values()) {
17404
16998
  handler(error);
17405
16999
  }
@@ -17417,94 +17011,47 @@ class Protocol {
17417
17011
  Promise.resolve().then(() => handler(notification)).catch((error) => this._onerror(new Error(`Uncaught error in notification handler: ${error}`)));
17418
17012
  }
17419
17013
  _onrequest(request, extra) {
17420
- var _a, _b, _c, _d, _e, _f;
17014
+ var _a, _b;
17421
17015
  const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
17422
17016
  const capturedTransport = this._transport;
17423
- 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;
17424
17017
  if (handler === void 0) {
17425
- const errorResponse = {
17018
+ capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
17426
17019
  jsonrpc: "2.0",
17427
17020
  id: request.id,
17428
17021
  error: {
17429
17022
  code: ErrorCode.MethodNotFound,
17430
17023
  message: "Method not found"
17431
17024
  }
17432
- };
17433
- if (relatedTaskId && this._taskMessageQueue) {
17434
- this._enqueueTaskMessage(relatedTaskId, {
17435
- type: "error",
17436
- message: errorResponse,
17437
- timestamp: Date.now()
17438
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
17439
- } else {
17440
- capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
17441
- }
17025
+ }).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
17442
17026
  return;
17443
17027
  }
17444
17028
  const abortController = new AbortController();
17445
17029
  this._requestHandlerAbortControllers.set(request.id, abortController);
17446
- const taskCreationParams = (_e = request.params) === null || _e === void 0 ? void 0 : _e.task;
17447
- const taskStore = this._taskStore ? this.requestTaskStore(request, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId) : void 0;
17448
17030
  const fullExtra = {
17449
17031
  signal: abortController.signal,
17450
17032
  sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
17451
- _meta: (_f = request.params) === null || _f === void 0 ? void 0 : _f._meta,
17452
- sendNotification: async (notification) => {
17453
- const notificationOptions = { relatedRequestId: request.id };
17454
- if (relatedTaskId) {
17455
- notificationOptions.relatedTask = { taskId: relatedTaskId };
17456
- }
17457
- await this.notification(notification, notificationOptions);
17458
- },
17459
- sendRequest: async (r, resultSchema, options) => {
17460
- var _a2, _b2;
17461
- const requestOptions = { ...options, relatedRequestId: request.id };
17462
- if (relatedTaskId && !requestOptions.relatedTask) {
17463
- requestOptions.relatedTask = { taskId: relatedTaskId };
17464
- }
17465
- const effectiveTaskId = (_b2 = (_a2 = requestOptions.relatedTask) === null || _a2 === void 0 ? void 0 : _a2.taskId) !== null && _b2 !== void 0 ? _b2 : relatedTaskId;
17466
- if (effectiveTaskId && taskStore) {
17467
- await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
17468
- }
17469
- return await this.request(r, resultSchema, requestOptions);
17470
- },
17033
+ _meta: (_b = request.params) === null || _b === void 0 ? void 0 : _b._meta,
17034
+ sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
17035
+ sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
17471
17036
  authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
17472
17037
  requestId: request.id,
17473
- requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo,
17474
- taskId: relatedTaskId,
17475
- taskStore,
17476
- taskRequestedTtl: taskCreationParams === null || taskCreationParams === void 0 ? void 0 : taskCreationParams.ttl,
17477
- closeSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeSSEStream,
17478
- closeStandaloneSSEStream: extra === null || extra === void 0 ? void 0 : extra.closeStandaloneSSEStream
17038
+ requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
17479
17039
  };
17480
- Promise.resolve().then(() => {
17481
- if (taskCreationParams) {
17482
- this.assertTaskHandlerCapability(request.method);
17483
- }
17484
- }).then(() => handler(request, fullExtra)).then(async (result) => {
17040
+ Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
17485
17041
  if (abortController.signal.aborted) {
17486
17042
  return;
17487
17043
  }
17488
- const response = {
17044
+ return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
17489
17045
  result,
17490
17046
  jsonrpc: "2.0",
17491
17047
  id: request.id
17492
- };
17493
- if (relatedTaskId && this._taskMessageQueue) {
17494
- await this._enqueueTaskMessage(relatedTaskId, {
17495
- type: "response",
17496
- message: response,
17497
- timestamp: Date.now()
17498
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
17499
- } else {
17500
- await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(response));
17501
- }
17502
- }, async (error) => {
17048
+ });
17049
+ }, (error) => {
17503
17050
  var _a2;
17504
17051
  if (abortController.signal.aborted) {
17505
17052
  return;
17506
17053
  }
17507
- const errorResponse = {
17054
+ return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
17508
17055
  jsonrpc: "2.0",
17509
17056
  id: request.id,
17510
17057
  error: {
@@ -17512,16 +17059,7 @@ class Protocol {
17512
17059
  message: (_a2 = error.message) !== null && _a2 !== void 0 ? _a2 : "Internal error",
17513
17060
  ...error["data"] !== void 0 && { data: error["data"] }
17514
17061
  }
17515
- };
17516
- if (relatedTaskId && this._taskMessageQueue) {
17517
- await this._enqueueTaskMessage(relatedTaskId, {
17518
- type: "error",
17519
- message: errorResponse,
17520
- timestamp: Date.now()
17521
- }, capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId);
17522
- } else {
17523
- await (capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send(errorResponse));
17524
- }
17062
+ });
17525
17063
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
17526
17064
  this._requestHandlerAbortControllers.delete(request.id);
17527
17065
  });
@@ -17540,9 +17078,6 @@ class Protocol {
17540
17078
  try {
17541
17079
  this._resetTimeout(messageId);
17542
17080
  } catch (error) {
17543
- this._responseHandlers.delete(messageId);
17544
- this._progressHandlers.delete(messageId);
17545
- this._cleanupTimeout(messageId);
17546
17081
  responseHandler(error);
17547
17082
  return;
17548
17083
  }
@@ -17551,38 +17086,14 @@ class Protocol {
17551
17086
  }
17552
17087
  _onresponse(response) {
17553
17088
  const messageId = Number(response.id);
17554
- const resolver = this._requestResolvers.get(messageId);
17555
- if (resolver) {
17556
- this._requestResolvers.delete(messageId);
17557
- if (isJSONRPCResponse(response)) {
17558
- resolver(response);
17559
- } else {
17560
- const error = new McpError(response.error.code, response.error.message, response.error.data);
17561
- resolver(error);
17562
- }
17563
- return;
17564
- }
17565
17089
  const handler = this._responseHandlers.get(messageId);
17566
17090
  if (handler === void 0) {
17567
17091
  this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(response)}`));
17568
17092
  return;
17569
17093
  }
17570
17094
  this._responseHandlers.delete(messageId);
17095
+ this._progressHandlers.delete(messageId);
17571
17096
  this._cleanupTimeout(messageId);
17572
- let isTaskResponse = false;
17573
- if (isJSONRPCResponse(response) && response.result && typeof response.result === "object") {
17574
- const result = response.result;
17575
- if (result.task && typeof result.task === "object") {
17576
- const task = result.task;
17577
- if (typeof task.taskId === "string") {
17578
- isTaskResponse = true;
17579
- this._taskProgressTokens.set(task.taskId, messageId);
17580
- }
17581
- }
17582
- }
17583
- if (!isTaskResponse) {
17584
- this._progressHandlers.delete(messageId);
17585
- }
17586
17097
  if (isJSONRPCResponse(response)) {
17587
17098
  handler(response);
17588
17099
  } else {
@@ -17601,118 +17112,20 @@ class Protocol {
17601
17112
  await ((_a = this._transport) === null || _a === void 0 ? void 0 : _a.close());
17602
17113
  }
17603
17114
  /**
17604
- * Sends a request and returns an AsyncGenerator that yields response messages.
17605
- * The generator is guaranteed to end with either a 'result' or 'error' message.
17606
- *
17607
- * @example
17608
- * ```typescript
17609
- * const stream = protocol.requestStream(request, resultSchema, options);
17610
- * for await (const message of stream) {
17611
- * switch (message.type) {
17612
- * case 'taskCreated':
17613
- * console.log('Task created:', message.task.taskId);
17614
- * break;
17615
- * case 'taskStatus':
17616
- * console.log('Task status:', message.task.status);
17617
- * break;
17618
- * case 'result':
17619
- * console.log('Final result:', message.result);
17620
- * break;
17621
- * case 'error':
17622
- * console.error('Error:', message.error);
17623
- * break;
17624
- * }
17625
- * }
17626
- * ```
17627
- *
17628
- * @experimental Use `client.experimental.tasks.requestStream()` to access this method.
17629
- */
17630
- async *requestStream(request, resultSchema, options) {
17631
- var _a, _b, _c, _d;
17632
- const { task } = options !== null && options !== void 0 ? options : {};
17633
- if (!task) {
17634
- try {
17635
- const result = await this.request(request, resultSchema, options);
17636
- yield { type: "result", result };
17637
- } catch (error) {
17638
- yield {
17639
- type: "error",
17640
- error: error instanceof McpError ? error : new McpError(ErrorCode.InternalError, String(error))
17641
- };
17642
- }
17643
- return;
17644
- }
17645
- let taskId;
17646
- try {
17647
- const createResult = await this.request(request, CreateTaskResultSchema, options);
17648
- if (createResult.task) {
17649
- taskId = createResult.task.taskId;
17650
- yield { type: "taskCreated", task: createResult.task };
17651
- } else {
17652
- throw new McpError(ErrorCode.InternalError, "Task creation did not return a task");
17653
- }
17654
- while (true) {
17655
- const task2 = await this.getTask({ taskId }, options);
17656
- yield { type: "taskStatus", task: task2 };
17657
- if (isTerminal(task2.status)) {
17658
- if (task2.status === "completed") {
17659
- const result = await this.getTaskResult({ taskId }, resultSchema, options);
17660
- yield { type: "result", result };
17661
- } else if (task2.status === "failed") {
17662
- yield {
17663
- type: "error",
17664
- error: new McpError(ErrorCode.InternalError, `Task ${taskId} failed`)
17665
- };
17666
- } else if (task2.status === "cancelled") {
17667
- yield {
17668
- type: "error",
17669
- error: new McpError(ErrorCode.InternalError, `Task ${taskId} was cancelled`)
17670
- };
17671
- }
17672
- return;
17673
- }
17674
- if (task2.status === "input_required") {
17675
- const result = await this.getTaskResult({ taskId }, resultSchema, options);
17676
- yield { type: "result", result };
17677
- return;
17678
- }
17679
- 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;
17680
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
17681
- (_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.throwIfAborted();
17682
- }
17683
- } catch (error) {
17684
- yield {
17685
- type: "error",
17686
- error: error instanceof McpError ? error : new McpError(ErrorCode.InternalError, String(error))
17687
- };
17688
- }
17689
- }
17690
- /**
17691
- * Sends a request and waits for a response.
17115
+ * Sends a request and wait for a response.
17692
17116
  *
17693
17117
  * Do not use this method to emit notifications! Use notification() instead.
17694
17118
  */
17695
17119
  request(request, resultSchema, options) {
17696
- const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options !== null && options !== void 0 ? options : {};
17120
+ const { relatedRequestId, resumptionToken, onresumptiontoken } = options !== null && options !== void 0 ? options : {};
17697
17121
  return new Promise((resolve2, reject) => {
17698
- var _a, _b, _c, _d, _e, _f, _g;
17699
- const earlyReject = (error) => {
17700
- reject(error);
17701
- };
17122
+ var _a, _b, _c, _d, _e, _f;
17702
17123
  if (!this._transport) {
17703
- earlyReject(new Error("Not connected"));
17124
+ reject(new Error("Not connected"));
17704
17125
  return;
17705
17126
  }
17706
17127
  if (((_a = this._options) === null || _a === void 0 ? void 0 : _a.enforceStrictCapabilities) === true) {
17707
- try {
17708
- this.assertCapabilityForMethod(request.method);
17709
- if (task) {
17710
- this.assertTaskCapability(request.method);
17711
- }
17712
- } catch (e) {
17713
- earlyReject(e);
17714
- return;
17715
- }
17128
+ this.assertCapabilityForMethod(request.method);
17716
17129
  }
17717
17130
  (_b = options === null || options === void 0 ? void 0 : options.signal) === null || _b === void 0 ? void 0 : _b.throwIfAborted();
17718
17131
  const messageId = this._requestMessageId++;
@@ -17731,21 +17144,6 @@ class Protocol {
17731
17144
  }
17732
17145
  };
17733
17146
  }
17734
- if (task) {
17735
- jsonrpcRequest.params = {
17736
- ...jsonrpcRequest.params,
17737
- task
17738
- };
17739
- }
17740
- if (relatedTask) {
17741
- jsonrpcRequest.params = {
17742
- ...jsonrpcRequest.params,
17743
- _meta: {
17744
- ...((_d = jsonrpcRequest.params) === null || _d === void 0 ? void 0 : _d._meta) || {},
17745
- [RELATED_TASK_META_KEY]: relatedTask
17746
- }
17747
- };
17748
- }
17749
17147
  const cancel = (reason) => {
17750
17148
  var _a2;
17751
17149
  this._responseHandlers.delete(messageId);
@@ -17758,9 +17156,8 @@ class Protocol {
17758
17156
  requestId: messageId,
17759
17157
  reason: String(reason)
17760
17158
  }
17761
- }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error2) => this._onerror(new Error(`Failed to send cancellation: ${error2}`)));
17762
- const error = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
17763
- reject(error);
17159
+ }, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => this._onerror(new Error(`Failed to send cancellation: ${error}`)));
17160
+ reject(reason);
17764
17161
  };
17765
17162
  this._responseHandlers.set(messageId, (response) => {
17766
17163
  var _a2;
@@ -17781,150 +17178,53 @@ class Protocol {
17781
17178
  reject(error);
17782
17179
  }
17783
17180
  });
17784
- (_e = options === null || options === void 0 ? void 0 : options.signal) === null || _e === void 0 ? void 0 : _e.addEventListener("abort", () => {
17181
+ (_d = options === null || options === void 0 ? void 0 : options.signal) === null || _d === void 0 ? void 0 : _d.addEventListener("abort", () => {
17785
17182
  var _a2;
17786
17183
  cancel((_a2 = options === null || options === void 0 ? void 0 : options.signal) === null || _a2 === void 0 ? void 0 : _a2.reason);
17787
17184
  });
17788
- const timeout = (_f = options === null || options === void 0 ? void 0 : options.timeout) !== null && _f !== void 0 ? _f : DEFAULT_REQUEST_TIMEOUT_MSEC;
17185
+ const timeout = (_e = options === null || options === void 0 ? void 0 : options.timeout) !== null && _e !== void 0 ? _e : DEFAULT_REQUEST_TIMEOUT_MSEC;
17789
17186
  const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
17790
- 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);
17791
- const relatedTaskId = relatedTask === null || relatedTask === void 0 ? void 0 : relatedTask.taskId;
17792
- if (relatedTaskId) {
17793
- const responseResolver = (response) => {
17794
- const handler = this._responseHandlers.get(messageId);
17795
- if (handler) {
17796
- handler(response);
17797
- } else {
17798
- this._onerror(new Error(`Response handler missing for side-channeled request ${messageId}`));
17799
- }
17800
- };
17801
- this._requestResolvers.set(messageId, responseResolver);
17802
- this._enqueueTaskMessage(relatedTaskId, {
17803
- type: "request",
17804
- message: jsonrpcRequest,
17805
- timestamp: Date.now()
17806
- }).catch((error) => {
17807
- this._cleanupTimeout(messageId);
17808
- reject(error);
17809
- });
17810
- } else {
17811
- this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => {
17812
- this._cleanupTimeout(messageId);
17813
- reject(error);
17814
- });
17815
- }
17187
+ this._setupTimeout(messageId, timeout, options === null || options === void 0 ? void 0 : options.maxTotalTimeout, timeoutHandler, (_f = options === null || options === void 0 ? void 0 : options.resetTimeoutOnProgress) !== null && _f !== void 0 ? _f : false);
17188
+ this._transport.send(jsonrpcRequest, { relatedRequestId, resumptionToken, onresumptiontoken }).catch((error) => {
17189
+ this._cleanupTimeout(messageId);
17190
+ reject(error);
17191
+ });
17816
17192
  });
17817
17193
  }
17818
- /**
17819
- * Gets the current status of a task.
17820
- *
17821
- * @experimental Use `client.experimental.tasks.getTask()` to access this method.
17822
- */
17823
- async getTask(params, options) {
17824
- return this.request({ method: "tasks/get", params }, GetTaskResultSchema, options);
17825
- }
17826
- /**
17827
- * Retrieves the result of a completed task.
17828
- *
17829
- * @experimental Use `client.experimental.tasks.getTaskResult()` to access this method.
17830
- */
17831
- async getTaskResult(params, resultSchema, options) {
17832
- return this.request({ method: "tasks/result", params }, resultSchema, options);
17833
- }
17834
- /**
17835
- * Lists tasks, optionally starting from a pagination cursor.
17836
- *
17837
- * @experimental Use `client.experimental.tasks.listTasks()` to access this method.
17838
- */
17839
- async listTasks(params, options) {
17840
- return this.request({ method: "tasks/list", params }, ListTasksResultSchema, options);
17841
- }
17842
- /**
17843
- * Cancels a specific task.
17844
- *
17845
- * @experimental Use `client.experimental.tasks.cancelTask()` to access this method.
17846
- */
17847
- async cancelTask(params, options) {
17848
- return this.request({ method: "tasks/cancel", params }, CancelTaskResultSchema, options);
17849
- }
17850
17194
  /**
17851
17195
  * Emits a notification, which is a one-way message that does not expect a response.
17852
17196
  */
17853
17197
  async notification(notification, options) {
17854
- var _a, _b, _c, _d, _e;
17198
+ var _a, _b;
17855
17199
  if (!this._transport) {
17856
17200
  throw new Error("Not connected");
17857
17201
  }
17858
17202
  this.assertNotificationCapability(notification.method);
17859
- const relatedTaskId = (_a = options === null || options === void 0 ? void 0 : options.relatedTask) === null || _a === void 0 ? void 0 : _a.taskId;
17860
- if (relatedTaskId) {
17861
- const jsonrpcNotification2 = {
17862
- ...notification,
17863
- jsonrpc: "2.0",
17864
- params: {
17865
- ...notification.params,
17866
- _meta: {
17867
- ...((_b = notification.params) === null || _b === void 0 ? void 0 : _b._meta) || {},
17868
- [RELATED_TASK_META_KEY]: options.relatedTask
17869
- }
17870
- }
17871
- };
17872
- await this._enqueueTaskMessage(relatedTaskId, {
17873
- type: "notification",
17874
- message: jsonrpcNotification2,
17875
- timestamp: Date.now()
17876
- });
17877
- return;
17878
- }
17879
- const debouncedMethods = (_d = (_c = this._options) === null || _c === void 0 ? void 0 : _c.debouncedNotificationMethods) !== null && _d !== void 0 ? _d : [];
17880
- 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);
17203
+ const debouncedMethods = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.debouncedNotificationMethods) !== null && _b !== void 0 ? _b : [];
17204
+ const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !(options === null || options === void 0 ? void 0 : options.relatedRequestId);
17881
17205
  if (canDebounce) {
17882
17206
  if (this._pendingDebouncedNotifications.has(notification.method)) {
17883
17207
  return;
17884
17208
  }
17885
17209
  this._pendingDebouncedNotifications.add(notification.method);
17886
17210
  Promise.resolve().then(() => {
17887
- var _a2, _b2;
17211
+ var _a2;
17888
17212
  this._pendingDebouncedNotifications.delete(notification.method);
17889
17213
  if (!this._transport) {
17890
17214
  return;
17891
17215
  }
17892
- let jsonrpcNotification2 = {
17216
+ const jsonrpcNotification2 = {
17893
17217
  ...notification,
17894
17218
  jsonrpc: "2.0"
17895
17219
  };
17896
- if (options === null || options === void 0 ? void 0 : options.relatedTask) {
17897
- jsonrpcNotification2 = {
17898
- ...jsonrpcNotification2,
17899
- params: {
17900
- ...jsonrpcNotification2.params,
17901
- _meta: {
17902
- ...((_a2 = jsonrpcNotification2.params) === null || _a2 === void 0 ? void 0 : _a2._meta) || {},
17903
- [RELATED_TASK_META_KEY]: options.relatedTask
17904
- }
17905
- }
17906
- };
17907
- }
17908
- (_b2 = this._transport) === null || _b2 === void 0 ? void 0 : _b2.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
17220
+ (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send(jsonrpcNotification2, options).catch((error) => this._onerror(error));
17909
17221
  });
17910
17222
  return;
17911
17223
  }
17912
- let jsonrpcNotification = {
17224
+ const jsonrpcNotification = {
17913
17225
  ...notification,
17914
17226
  jsonrpc: "2.0"
17915
17227
  };
17916
- if (options === null || options === void 0 ? void 0 : options.relatedTask) {
17917
- jsonrpcNotification = {
17918
- ...jsonrpcNotification,
17919
- params: {
17920
- ...jsonrpcNotification.params,
17921
- _meta: {
17922
- ...((_e = jsonrpcNotification.params) === null || _e === void 0 ? void 0 : _e._meta) || {},
17923
- [RELATED_TASK_META_KEY]: options.relatedTask
17924
- }
17925
- }
17926
- };
17927
- }
17928
17228
  await this._transport.send(jsonrpcNotification, options);
17929
17229
  }
17930
17230
  /**
@@ -17972,152 +17272,6 @@ class Protocol {
17972
17272
  removeNotificationHandler(method) {
17973
17273
  this._notificationHandlers.delete(method);
17974
17274
  }
17975
- /**
17976
- * Cleans up the progress handler associated with a task.
17977
- * This should be called when a task reaches a terminal status.
17978
- */
17979
- _cleanupTaskProgressHandler(taskId) {
17980
- const progressToken = this._taskProgressTokens.get(taskId);
17981
- if (progressToken !== void 0) {
17982
- this._progressHandlers.delete(progressToken);
17983
- this._taskProgressTokens.delete(taskId);
17984
- }
17985
- }
17986
- /**
17987
- * Enqueues a task-related message for side-channel delivery via tasks/result.
17988
- * @param taskId The task ID to associate the message with
17989
- * @param message The message to enqueue
17990
- * @param sessionId Optional session ID for binding the operation to a specific session
17991
- * @throws Error if taskStore is not configured or if enqueue fails (e.g., queue overflow)
17992
- *
17993
- * Note: If enqueue fails, it's the TaskMessageQueue implementation's responsibility to handle
17994
- * the error appropriately (e.g., by failing the task, logging, etc.). The Protocol layer
17995
- * simply propagates the error.
17996
- */
17997
- async _enqueueTaskMessage(taskId, message, sessionId) {
17998
- var _a;
17999
- if (!this._taskStore || !this._taskMessageQueue) {
18000
- throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
18001
- }
18002
- const maxQueueSize = (_a = this._options) === null || _a === void 0 ? void 0 : _a.maxTaskQueueSize;
18003
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
18004
- }
18005
- /**
18006
- * Clears the message queue for a task and rejects any pending request resolvers.
18007
- * @param taskId The task ID whose queue should be cleared
18008
- * @param sessionId Optional session ID for binding the operation to a specific session
18009
- */
18010
- async _clearTaskQueue(taskId, sessionId) {
18011
- if (this._taskMessageQueue) {
18012
- const messages = await this._taskMessageQueue.dequeueAll(taskId, sessionId);
18013
- for (const message of messages) {
18014
- if (message.type === "request" && isJSONRPCRequest(message.message)) {
18015
- const requestId = message.message.id;
18016
- const resolver = this._requestResolvers.get(requestId);
18017
- if (resolver) {
18018
- resolver(new McpError(ErrorCode.InternalError, "Task cancelled or completed"));
18019
- this._requestResolvers.delete(requestId);
18020
- } else {
18021
- this._onerror(new Error(`Resolver missing for request ${requestId} during task ${taskId} cleanup`));
18022
- }
18023
- }
18024
- }
18025
- }
18026
- }
18027
- /**
18028
- * Waits for a task update (new messages or status change) with abort signal support.
18029
- * Uses polling to check for updates at the task's configured poll interval.
18030
- * @param taskId The task ID to wait for
18031
- * @param signal Abort signal to cancel the wait
18032
- * @returns Promise that resolves when an update occurs or rejects if aborted
18033
- */
18034
- async _waitForTaskUpdate(taskId, signal) {
18035
- var _a, _b, _c;
18036
- let interval = (_b = (_a = this._options) === null || _a === void 0 ? void 0 : _a.defaultTaskPollInterval) !== null && _b !== void 0 ? _b : 1e3;
18037
- try {
18038
- const task = await ((_c = this._taskStore) === null || _c === void 0 ? void 0 : _c.getTask(taskId));
18039
- if (task === null || task === void 0 ? void 0 : task.pollInterval) {
18040
- interval = task.pollInterval;
18041
- }
18042
- } catch (_d) {
18043
- }
18044
- return new Promise((resolve2, reject) => {
18045
- if (signal.aborted) {
18046
- reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
18047
- return;
18048
- }
18049
- const timeoutId = setTimeout(resolve2, interval);
18050
- signal.addEventListener("abort", () => {
18051
- clearTimeout(timeoutId);
18052
- reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
18053
- }, { once: true });
18054
- });
18055
- }
18056
- requestTaskStore(request, sessionId) {
18057
- const taskStore = this._taskStore;
18058
- if (!taskStore) {
18059
- throw new Error("No task store configured");
18060
- }
18061
- return {
18062
- createTask: async (taskParams) => {
18063
- if (!request) {
18064
- throw new Error("No request provided");
18065
- }
18066
- return await taskStore.createTask(taskParams, request.id, {
18067
- method: request.method,
18068
- params: request.params
18069
- }, sessionId);
18070
- },
18071
- getTask: async (taskId) => {
18072
- const task = await taskStore.getTask(taskId, sessionId);
18073
- if (!task) {
18074
- throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
18075
- }
18076
- return task;
18077
- },
18078
- storeTaskResult: async (taskId, status, result) => {
18079
- await taskStore.storeTaskResult(taskId, status, result, sessionId);
18080
- const task = await taskStore.getTask(taskId, sessionId);
18081
- if (task) {
18082
- const notification = TaskStatusNotificationSchema.parse({
18083
- method: "notifications/tasks/status",
18084
- params: task
18085
- });
18086
- await this.notification(notification);
18087
- if (isTerminal(task.status)) {
18088
- this._cleanupTaskProgressHandler(taskId);
18089
- }
18090
- }
18091
- },
18092
- getTaskResult: (taskId) => {
18093
- return taskStore.getTaskResult(taskId, sessionId);
18094
- },
18095
- updateTaskStatus: async (taskId, status, statusMessage) => {
18096
- const task = await taskStore.getTask(taskId, sessionId);
18097
- if (!task) {
18098
- throw new McpError(ErrorCode.InvalidParams, `Task "${taskId}" not found - it may have been cleaned up`);
18099
- }
18100
- if (isTerminal(task.status)) {
18101
- throw new McpError(ErrorCode.InvalidParams, `Cannot update task "${taskId}" from terminal status "${task.status}" to "${status}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);
18102
- }
18103
- await taskStore.updateTaskStatus(taskId, status, statusMessage, sessionId);
18104
- const updatedTask = await taskStore.getTask(taskId, sessionId);
18105
- if (updatedTask) {
18106
- const notification = TaskStatusNotificationSchema.parse({
18107
- method: "notifications/tasks/status",
18108
- params: updatedTask
18109
- });
18110
- await this.notification(notification);
18111
- if (isTerminal(updatedTask.status)) {
18112
- this._cleanupTaskProgressHandler(taskId);
18113
- }
18114
- }
18115
- },
18116
- listTasks: (cursor) => {
18117
- return taskStore.listTasks(cursor, sessionId);
18118
- }
18119
- };
18120
- }
18121
17275
  }
18122
17276
  function isPlainObject(value) {
18123
17277
  return value !== null && typeof value === "object" && !Array.isArray(value);
@@ -18528,190 +17682,6 @@ class AjvJsonSchemaValidator {
18528
17682
  };
18529
17683
  }
18530
17684
  }
18531
- class ExperimentalClientTasks {
18532
- constructor(_client) {
18533
- this._client = _client;
18534
- }
18535
- /**
18536
- * Calls a tool and returns an AsyncGenerator that yields response messages.
18537
- * The generator is guaranteed to end with either a 'result' or 'error' message.
18538
- *
18539
- * This method provides streaming access to tool execution, allowing you to
18540
- * observe intermediate task status updates for long-running tool calls.
18541
- * Automatically validates structured output if the tool has an outputSchema.
18542
- *
18543
- * @example
18544
- * ```typescript
18545
- * const stream = client.experimental.tasks.callToolStream({ name: 'myTool', arguments: {} });
18546
- * for await (const message of stream) {
18547
- * switch (message.type) {
18548
- * case 'taskCreated':
18549
- * console.log('Tool execution started:', message.task.taskId);
18550
- * break;
18551
- * case 'taskStatus':
18552
- * console.log('Tool status:', message.task.status);
18553
- * break;
18554
- * case 'result':
18555
- * console.log('Tool result:', message.result);
18556
- * break;
18557
- * case 'error':
18558
- * console.error('Tool error:', message.error);
18559
- * break;
18560
- * }
18561
- * }
18562
- * ```
18563
- *
18564
- * @param params - Tool call parameters (name and arguments)
18565
- * @param resultSchema - Zod schema for validating the result (defaults to CallToolResultSchema)
18566
- * @param options - Optional request options (timeout, signal, task creation params, etc.)
18567
- * @returns AsyncGenerator that yields ResponseMessage objects
18568
- *
18569
- * @experimental
18570
- */
18571
- async *callToolStream(params, resultSchema = CallToolResultSchema, options) {
18572
- var _a;
18573
- const clientInternal = this._client;
18574
- const optionsWithTask = {
18575
- ...options,
18576
- // We check if the tool is known to be a task during auto-configuration, but assume
18577
- // the caller knows what they're doing if they pass this explicitly
18578
- task: (_a = options === null || options === void 0 ? void 0 : options.task) !== null && _a !== void 0 ? _a : clientInternal.isToolTask(params.name) ? {} : void 0
18579
- };
18580
- const stream = clientInternal.requestStream({ method: "tools/call", params }, resultSchema, optionsWithTask);
18581
- const validator = clientInternal.getToolOutputValidator(params.name);
18582
- for await (const message of stream) {
18583
- if (message.type === "result" && validator) {
18584
- const result = message.result;
18585
- if (!result.structuredContent && !result.isError) {
18586
- yield {
18587
- type: "error",
18588
- error: new McpError(ErrorCode.InvalidRequest, `Tool ${params.name} has an output schema but did not return structured content`)
18589
- };
18590
- return;
18591
- }
18592
- if (result.structuredContent) {
18593
- try {
18594
- const validationResult = validator(result.structuredContent);
18595
- if (!validationResult.valid) {
18596
- yield {
18597
- type: "error",
18598
- error: new McpError(ErrorCode.InvalidParams, `Structured content does not match the tool's output schema: ${validationResult.errorMessage}`)
18599
- };
18600
- return;
18601
- }
18602
- } catch (error) {
18603
- if (error instanceof McpError) {
18604
- yield { type: "error", error };
18605
- return;
18606
- }
18607
- yield {
18608
- type: "error",
18609
- error: new McpError(ErrorCode.InvalidParams, `Failed to validate structured content: ${error instanceof Error ? error.message : String(error)}`)
18610
- };
18611
- return;
18612
- }
18613
- }
18614
- }
18615
- yield message;
18616
- }
18617
- }
18618
- /**
18619
- * Gets the current status of a task.
18620
- *
18621
- * @param taskId - The task identifier
18622
- * @param options - Optional request options
18623
- * @returns The task status
18624
- *
18625
- * @experimental
18626
- */
18627
- async getTask(taskId, options) {
18628
- return this._client.getTask({ taskId }, options);
18629
- }
18630
- /**
18631
- * Retrieves the result of a completed task.
18632
- *
18633
- * @param taskId - The task identifier
18634
- * @param resultSchema - Zod schema for validating the result
18635
- * @param options - Optional request options
18636
- * @returns The task result
18637
- *
18638
- * @experimental
18639
- */
18640
- async getTaskResult(taskId, resultSchema, options) {
18641
- return this._client.getTaskResult({ taskId }, resultSchema, options);
18642
- }
18643
- /**
18644
- * Lists tasks with optional pagination.
18645
- *
18646
- * @param cursor - Optional pagination cursor
18647
- * @param options - Optional request options
18648
- * @returns List of tasks with optional next cursor
18649
- *
18650
- * @experimental
18651
- */
18652
- async listTasks(cursor, options) {
18653
- return this._client.listTasks(cursor ? { cursor } : void 0, options);
18654
- }
18655
- /**
18656
- * Cancels a running task.
18657
- *
18658
- * @param taskId - The task identifier
18659
- * @param options - Optional request options
18660
- *
18661
- * @experimental
18662
- */
18663
- async cancelTask(taskId, options) {
18664
- return this._client.cancelTask({ taskId }, options);
18665
- }
18666
- /**
18667
- * Sends a request and returns an AsyncGenerator that yields response messages.
18668
- * The generator is guaranteed to end with either a 'result' or 'error' message.
18669
- *
18670
- * This method provides streaming access to request processing, allowing you to
18671
- * observe intermediate task status updates for task-augmented requests.
18672
- *
18673
- * @param request - The request to send
18674
- * @param resultSchema - Zod schema for validating the result
18675
- * @param options - Optional request options (timeout, signal, task creation params, etc.)
18676
- * @returns AsyncGenerator that yields ResponseMessage objects
18677
- *
18678
- * @experimental
18679
- */
18680
- requestStream(request, resultSchema, options) {
18681
- return this._client.requestStream(request, resultSchema, options);
18682
- }
18683
- }
18684
- function assertToolsCallTaskCapability(requests, method, entityName) {
18685
- var _a;
18686
- if (!requests) {
18687
- throw new Error(`${entityName} does not support task creation (required for ${method})`);
18688
- }
18689
- switch (method) {
18690
- case "tools/call":
18691
- if (!((_a = requests.tools) === null || _a === void 0 ? void 0 : _a.call)) {
18692
- throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
18693
- }
18694
- break;
18695
- }
18696
- }
18697
- function assertClientRequestTaskCapability(requests, method, entityName) {
18698
- var _a, _b;
18699
- if (!requests) {
18700
- throw new Error(`${entityName} does not support task creation (required for ${method})`);
18701
- }
18702
- switch (method) {
18703
- case "sampling/createMessage":
18704
- if (!((_a = requests.sampling) === null || _a === void 0 ? void 0 : _a.createMessage)) {
18705
- throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
18706
- }
18707
- break;
18708
- case "elicitation/create":
18709
- if (!((_b = requests.elicitation) === null || _b === void 0 ? void 0 : _b.create)) {
18710
- throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
18711
- }
18712
- break;
18713
- }
18714
- }
18715
17685
  function applyElicitationDefaults(schema, data) {
18716
17686
  if (!schema || data === null || typeof data !== "object")
18717
17687
  return;
@@ -18758,26 +17728,9 @@ class Client extends Protocol {
18758
17728
  super(options);
18759
17729
  this._clientInfo = _clientInfo;
18760
17730
  this._cachedToolOutputValidators = /* @__PURE__ */ new Map();
18761
- this._cachedKnownTaskTools = /* @__PURE__ */ new Set();
18762
- this._cachedRequiredTaskTools = /* @__PURE__ */ new Set();
18763
17731
  this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
18764
17732
  this._jsonSchemaValidator = (_b = options === null || options === void 0 ? void 0 : options.jsonSchemaValidator) !== null && _b !== void 0 ? _b : new AjvJsonSchemaValidator();
18765
17733
  }
18766
- /**
18767
- * Access experimental features.
18768
- *
18769
- * WARNING: These APIs are experimental and may change without notice.
18770
- *
18771
- * @experimental
18772
- */
18773
- get experimental() {
18774
- if (!this._experimental) {
18775
- this._experimental = {
18776
- tasks: new ExperimentalClientTasks(this)
18777
- };
18778
- }
18779
- return this._experimental;
18780
- }
18781
17734
  /**
18782
17735
  * Registers new capabilities. This can only be called before connecting to a transport.
18783
17736
  *
@@ -18831,14 +17784,6 @@ class Client extends Protocol {
18831
17784
  throw new McpError(ErrorCode.InvalidParams, "Client does not support URL-mode elicitation requests");
18832
17785
  }
18833
17786
  const result = await Promise.resolve(handler(request, extra));
18834
- if (params.task) {
18835
- const taskValidationResult = safeParse(CreateTaskResultSchema, result);
18836
- if (!taskValidationResult.success) {
18837
- const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
18838
- throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
18839
- }
18840
- return taskValidationResult.data;
18841
- }
18842
17787
  const validationResult = safeParse(ElicitResultSchema, result);
18843
17788
  if (!validationResult.success) {
18844
17789
  const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
@@ -18858,32 +17803,6 @@ class Client extends Protocol {
18858
17803
  };
18859
17804
  return super.setRequestHandler(requestSchema, wrappedHandler);
18860
17805
  }
18861
- if (method === "sampling/createMessage") {
18862
- const wrappedHandler = async (request, extra) => {
18863
- const validatedRequest = safeParse(CreateMessageRequestSchema, request);
18864
- if (!validatedRequest.success) {
18865
- const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
18866
- throw new McpError(ErrorCode.InvalidParams, `Invalid sampling request: ${errorMessage}`);
18867
- }
18868
- const { params } = validatedRequest.data;
18869
- const result = await Promise.resolve(handler(request, extra));
18870
- if (params.task) {
18871
- const taskValidationResult = safeParse(CreateTaskResultSchema, result);
18872
- if (!taskValidationResult.success) {
18873
- const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
18874
- throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
18875
- }
18876
- return taskValidationResult.data;
18877
- }
18878
- const validationResult = safeParse(CreateMessageResultSchema, result);
18879
- if (!validationResult.success) {
18880
- const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
18881
- throw new McpError(ErrorCode.InvalidParams, `Invalid sampling result: ${errorMessage}`);
18882
- }
18883
- return validationResult.data;
18884
- };
18885
- return super.setRequestHandler(requestSchema, wrappedHandler);
18886
- }
18887
17806
  return super.setRequestHandler(requestSchema, handler);
18888
17807
  }
18889
17808
  assertCapability(capability, method) {
@@ -18994,9 +17913,6 @@ class Client extends Protocol {
18994
17913
  }
18995
17914
  }
18996
17915
  assertRequestHandlerCapability(method) {
18997
- if (!this._capabilities) {
18998
- return;
18999
- }
19000
17916
  switch (method) {
19001
17917
  case "sampling/createMessage":
19002
17918
  if (!this._capabilities.sampling) {
@@ -19013,26 +17929,7 @@ class Client extends Protocol {
19013
17929
  throw new Error(`Client does not support roots capability (required for ${method})`);
19014
17930
  }
19015
17931
  break;
19016
- case "tasks/get":
19017
- case "tasks/list":
19018
- case "tasks/result":
19019
- case "tasks/cancel":
19020
- if (!this._capabilities.tasks) {
19021
- throw new Error(`Client does not support tasks capability (required for ${method})`);
19022
- }
19023
- break;
19024
- }
19025
- }
19026
- assertTaskCapability(method) {
19027
- var _a, _b;
19028
- assertToolsCallTaskCapability((_b = (_a = this._serverCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Server");
19029
- }
19030
- assertTaskHandlerCapability(method) {
19031
- var _a;
19032
- if (!this._capabilities) {
19033
- return;
19034
17932
  }
19035
- assertClientRequestTaskCapability((_a = this._capabilities.tasks) === null || _a === void 0 ? void 0 : _a.requests, method, "Client");
19036
17933
  }
19037
17934
  async ping(options) {
19038
17935
  return this.request({ method: "ping" }, EmptyResultSchema, options);
@@ -19064,15 +17961,7 @@ class Client extends Protocol {
19064
17961
  async unsubscribeResource(params, options) {
19065
17962
  return this.request({ method: "resources/unsubscribe", params }, EmptyResultSchema, options);
19066
17963
  }
19067
- /**
19068
- * Calls a tool and waits for the result. Automatically validates structured output if the tool has an outputSchema.
19069
- *
19070
- * For task-based execution with streaming behavior, use client.experimental.tasks.callToolStream() instead.
19071
- */
19072
17964
  async callTool(params, resultSchema = CallToolResultSchema, options) {
19073
- if (this.isToolTaskRequired(params.name)) {
19074
- throw new McpError(ErrorCode.InvalidRequest, `Tool "${params.name}" requires task-based execution. Use client.experimental.tasks.callToolStream() instead.`);
19075
- }
19076
17965
  const result = await this.request({ method: "tools/call", params }, resultSchema, options);
19077
17966
  const validator = this.getToolOutputValidator(params.name);
19078
17967
  if (validator) {
@@ -19095,41 +17984,17 @@ class Client extends Protocol {
19095
17984
  }
19096
17985
  return result;
19097
17986
  }
19098
- isToolTask(toolName) {
19099
- var _a, _b, _c, _d;
19100
- 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)) {
19101
- return false;
19102
- }
19103
- return this._cachedKnownTaskTools.has(toolName);
19104
- }
19105
- /**
19106
- * Check if a tool requires task-based execution.
19107
- * Unlike isToolTask which includes 'optional' tools, this only checks for 'required'.
19108
- */
19109
- isToolTaskRequired(toolName) {
19110
- return this._cachedRequiredTaskTools.has(toolName);
19111
- }
19112
17987
  /**
19113
17988
  * Cache validators for tool output schemas.
19114
17989
  * Called after listTools() to pre-compile validators for better performance.
19115
17990
  */
19116
- cacheToolMetadata(tools) {
19117
- var _a;
17991
+ cacheToolOutputSchemas(tools) {
19118
17992
  this._cachedToolOutputValidators.clear();
19119
- this._cachedKnownTaskTools.clear();
19120
- this._cachedRequiredTaskTools.clear();
19121
17993
  for (const tool of tools) {
19122
17994
  if (tool.outputSchema) {
19123
17995
  const toolValidator = this._jsonSchemaValidator.getValidator(tool.outputSchema);
19124
17996
  this._cachedToolOutputValidators.set(tool.name, toolValidator);
19125
17997
  }
19126
- const taskSupport = (_a = tool.execution) === null || _a === void 0 ? void 0 : _a.taskSupport;
19127
- if (taskSupport === "required" || taskSupport === "optional") {
19128
- this._cachedKnownTaskTools.add(tool.name);
19129
- }
19130
- if (taskSupport === "required") {
19131
- this._cachedRequiredTaskTools.add(tool.name);
19132
- }
19133
17998
  }
19134
17999
  }
19135
18000
  /**
@@ -19140,7 +18005,7 @@ class Client extends Protocol {
19140
18005
  }
19141
18006
  async listTools(params, options) {
19142
18007
  const result = await this.request({ method: "tools/list", params }, ListToolsResultSchema, options);
19143
- this.cacheToolMetadata(result.tools);
18008
+ this.cacheToolOutputSchemas(result.tools);
19144
18009
  return result;
19145
18010
  }
19146
18011
  async sendRootsListChanged() {
@@ -19316,8 +18181,8 @@ const OAuthClientMetadataSchema = object$1({
19316
18181
  const OAuthClientInformationSchema = object$1({
19317
18182
  client_id: string(),
19318
18183
  client_secret: string().optional(),
19319
- client_id_issued_at: number$1().optional(),
19320
- client_secret_expires_at: number$1().optional()
18184
+ client_id_issued_at: number().optional(),
18185
+ client_secret_expires_at: number().optional()
19321
18186
  }).strip();
19322
18187
  const OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
19323
18188
  object$1({
@@ -19417,9 +18282,6 @@ InvalidClientMetadataError.errorCode = "invalid_client_metadata";
19417
18282
  class InsufficientScopeError extends OAuthError {
19418
18283
  }
19419
18284
  InsufficientScopeError.errorCode = "insufficient_scope";
19420
- class InvalidTargetError extends OAuthError {
19421
- }
19422
- InvalidTargetError.errorCode = "invalid_target";
19423
18285
  const OAUTH_ERRORS = {
19424
18286
  [InvalidRequestError.errorCode]: InvalidRequestError,
19425
18287
  [InvalidClientError.errorCode]: InvalidClientError,
@@ -19436,8 +18298,7 @@ const OAUTH_ERRORS = {
19436
18298
  [MethodNotAllowedError.errorCode]: MethodNotAllowedError,
19437
18299
  [TooManyRequestsError.errorCode]: TooManyRequestsError,
19438
18300
  [InvalidClientMetadataError.errorCode]: InvalidClientMetadataError,
19439
- [InsufficientScopeError.errorCode]: InsufficientScopeError,
19440
- [InvalidTargetError.errorCode]: InvalidTargetError
18301
+ [InsufficientScopeError.errorCode]: InsufficientScopeError
19441
18302
  };
19442
18303
  class UnauthorizedError extends Error {
19443
18304
  constructor(message) {
@@ -19575,12 +18436,16 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
19575
18436
  clientInformation = fullInformation;
19576
18437
  }
19577
18438
  }
19578
- const nonInteractiveFlow = !provider.redirectUrl;
19579
- if (authorizationCode !== void 0 || nonInteractiveFlow) {
19580
- const tokens2 = await fetchToken(provider, authorizationServerUrl, {
18439
+ if (authorizationCode !== void 0) {
18440
+ const codeVerifier2 = await provider.codeVerifier();
18441
+ const tokens2 = await exchangeAuthorization(authorizationServerUrl, {
19581
18442
  metadata: metadata2,
19582
- resource,
18443
+ clientInformation,
19583
18444
  authorizationCode,
18445
+ codeVerifier: codeVerifier2,
18446
+ redirectUri: provider.redirectUrl,
18447
+ resource,
18448
+ addClientAuthentication: provider.addClientAuthentication,
19584
18449
  fetchFn
19585
18450
  });
19586
18451
  await provider.saveTokens(tokens2);
@@ -19700,17 +18565,14 @@ function extractResourceMetadataUrl(res) {
19700
18565
  }
19701
18566
  }
19702
18567
  async function discoverOAuthProtectedResourceMetadata(serverUrl, opts, fetchFn = fetch) {
19703
- var _a, _b;
19704
18568
  const response = await discoverMetadataWithFallback(serverUrl, "oauth-protected-resource", fetchFn, {
19705
18569
  protocolVersion: opts === null || opts === void 0 ? void 0 : opts.protocolVersion,
19706
18570
  metadataUrl: opts === null || opts === void 0 ? void 0 : opts.resourceMetadataUrl
19707
18571
  });
19708
18572
  if (!response || response.status === 404) {
19709
- await ((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.cancel());
19710
18573
  throw new Error(`Resource server does not implement OAuth 2.0 Protected Resource Metadata.`);
19711
18574
  }
19712
18575
  if (!response.ok) {
19713
- await ((_b = response.body) === null || _b === void 0 ? void 0 : _b.cancel());
19714
18576
  throw new Error(`HTTP ${response.status} trying to load well-known OAuth protected resource metadata.`);
19715
18577
  }
19716
18578
  return OAuthProtectedResourceMetadataSchema.parse(await response.json());
@@ -19764,7 +18626,6 @@ async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, o
19764
18626
  return response;
19765
18627
  }
19766
18628
  async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolVersion } = {}, fetchFn = fetch) {
19767
- var _a, _b;
19768
18629
  if (typeof issuer === "string") {
19769
18630
  issuer = new URL(issuer);
19770
18631
  }
@@ -19780,11 +18641,9 @@ async function discoverOAuthMetadata(issuer, { authorizationServerUrl, protocolV
19780
18641
  metadataServerUrl: authorizationServerUrl
19781
18642
  });
19782
18643
  if (!response || response.status === 404) {
19783
- await ((_a = response === null || response === void 0 ? void 0 : response.body) === null || _a === void 0 ? void 0 : _a.cancel());
19784
18644
  return void 0;
19785
18645
  }
19786
18646
  if (!response.ok) {
19787
- await ((_b = response.body) === null || _b === void 0 ? void 0 : _b.cancel());
19788
18647
  throw new Error(`HTTP ${response.status} trying to load well-known OAuth metadata`);
19789
18648
  }
19790
18649
  return OAuthMetadataSchema.parse(await response.json());
@@ -19823,7 +18682,6 @@ function buildDiscoveryUrls(authorizationServerUrl) {
19823
18682
  return urlsToTry;
19824
18683
  }
19825
18684
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
19826
- var _a;
19827
18685
  const headers = {
19828
18686
  "MCP-Protocol-Version": protocolVersion,
19829
18687
  Accept: "application/json"
@@ -19835,7 +18693,6 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
19835
18693
  continue;
19836
18694
  }
19837
18695
  if (!response.ok) {
19838
- await ((_a = response.body) === null || _a === void 0 ? void 0 : _a.cancel());
19839
18696
  if (response.status >= 400 && response.status < 500) {
19840
18697
  continue;
19841
18698
  }
@@ -19884,92 +18741,81 @@ async function startAuthorization(authorizationServerUrl, { metadata: metadata2,
19884
18741
  }
19885
18742
  return { authorizationUrl, codeVerifier };
19886
18743
  }
19887
- function prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri) {
19888
- return new URLSearchParams({
19889
- grant_type: "authorization_code",
19890
- code: authorizationCode,
19891
- code_verifier: codeVerifier,
19892
- redirect_uri: String(redirectUri)
19893
- });
19894
- }
19895
- async function executeTokenRequest(authorizationServerUrl, { metadata: metadata2, tokenRequestParams, clientInformation, addClientAuthentication, resource, fetchFn }) {
18744
+ async function exchangeAuthorization(authorizationServerUrl, { metadata: metadata2, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn }) {
19896
18745
  var _a;
18746
+ const grantType = "authorization_code";
19897
18747
  const tokenUrl = (metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.token_endpoint) ? new URL(metadata2.token_endpoint) : new URL("/token", authorizationServerUrl);
18748
+ if ((metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.grant_types_supported) && !metadata2.grant_types_supported.includes(grantType)) {
18749
+ throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);
18750
+ }
19898
18751
  const headers = new Headers({
19899
18752
  "Content-Type": "application/x-www-form-urlencoded",
19900
18753
  Accept: "application/json"
19901
18754
  });
19902
- if (resource) {
19903
- tokenRequestParams.set("resource", resource.href);
19904
- }
18755
+ const params = new URLSearchParams({
18756
+ grant_type: grantType,
18757
+ code: authorizationCode,
18758
+ code_verifier: codeVerifier,
18759
+ redirect_uri: String(redirectUri)
18760
+ });
19905
18761
  if (addClientAuthentication) {
19906
- await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata2);
19907
- } else if (clientInformation) {
18762
+ addClientAuthentication(headers, params, authorizationServerUrl, metadata2);
18763
+ } else {
19908
18764
  const supportedMethods = (_a = metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];
19909
18765
  const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
19910
- applyClientAuthentication(authMethod, clientInformation, headers, tokenRequestParams);
18766
+ applyClientAuthentication(authMethod, clientInformation, headers, params);
18767
+ }
18768
+ if (resource) {
18769
+ params.set("resource", resource.href);
19911
18770
  }
19912
18771
  const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {
19913
18772
  method: "POST",
19914
18773
  headers,
19915
- body: tokenRequestParams
18774
+ body: params
19916
18775
  });
19917
18776
  if (!response.ok) {
19918
18777
  throw await parseErrorResponse(response);
19919
18778
  }
19920
18779
  return OAuthTokensSchema.parse(await response.json());
19921
18780
  }
19922
- async function exchangeAuthorization(authorizationServerUrl, { metadata: metadata2, clientInformation, authorizationCode, codeVerifier, redirectUri, resource, addClientAuthentication, fetchFn }) {
19923
- const tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, redirectUri);
19924
- return executeTokenRequest(authorizationServerUrl, {
19925
- metadata: metadata2,
19926
- tokenRequestParams,
19927
- clientInformation,
19928
- addClientAuthentication,
19929
- resource,
19930
- fetchFn
19931
- });
19932
- }
19933
18781
  async function refreshAuthorization(authorizationServerUrl, { metadata: metadata2, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
19934
- const tokenRequestParams = new URLSearchParams({
19935
- grant_type: "refresh_token",
19936
- refresh_token: refreshToken
18782
+ var _a;
18783
+ const grantType = "refresh_token";
18784
+ let tokenUrl;
18785
+ if (metadata2) {
18786
+ tokenUrl = new URL(metadata2.token_endpoint);
18787
+ if (metadata2.grant_types_supported && !metadata2.grant_types_supported.includes(grantType)) {
18788
+ throw new Error(`Incompatible auth server: does not support grant type ${grantType}`);
18789
+ }
18790
+ } else {
18791
+ tokenUrl = new URL("/token", authorizationServerUrl);
18792
+ }
18793
+ const headers = new Headers({
18794
+ "Content-Type": "application/x-www-form-urlencoded"
19937
18795
  });
19938
- const tokens = await executeTokenRequest(authorizationServerUrl, {
19939
- metadata: metadata2,
19940
- tokenRequestParams,
19941
- clientInformation,
19942
- addClientAuthentication,
19943
- resource,
19944
- fetchFn
18796
+ const params = new URLSearchParams({
18797
+ grant_type: grantType,
18798
+ refresh_token: refreshToken
19945
18799
  });
19946
- return { refresh_token: refreshToken, ...tokens };
19947
- }
19948
- async function fetchToken(provider, authorizationServerUrl, { metadata: metadata2, resource, authorizationCode, fetchFn } = {}) {
19949
- const scope2 = provider.clientMetadata.scope;
19950
- let tokenRequestParams;
19951
- if (provider.prepareTokenRequest) {
19952
- tokenRequestParams = await provider.prepareTokenRequest(scope2);
18800
+ if (addClientAuthentication) {
18801
+ addClientAuthentication(headers, params, authorizationServerUrl, metadata2);
18802
+ } else {
18803
+ const supportedMethods = (_a = metadata2 === null || metadata2 === void 0 ? void 0 : metadata2.token_endpoint_auth_methods_supported) !== null && _a !== void 0 ? _a : [];
18804
+ const authMethod = selectClientAuthMethod(clientInformation, supportedMethods);
18805
+ applyClientAuthentication(authMethod, clientInformation, headers, params);
19953
18806
  }
19954
- if (!tokenRequestParams) {
19955
- if (!authorizationCode) {
19956
- throw new Error("Either provider.prepareTokenRequest() or authorizationCode is required");
19957
- }
19958
- if (!provider.redirectUrl) {
19959
- throw new Error("redirectUrl is required for authorization_code flow");
19960
- }
19961
- const codeVerifier = await provider.codeVerifier();
19962
- tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
18807
+ if (resource) {
18808
+ params.set("resource", resource.href);
19963
18809
  }
19964
- const clientInformation = await provider.clientInformation();
19965
- return executeTokenRequest(authorizationServerUrl, {
19966
- metadata: metadata2,
19967
- tokenRequestParams,
19968
- clientInformation: clientInformation !== null && clientInformation !== void 0 ? clientInformation : void 0,
19969
- addClientAuthentication: provider.addClientAuthentication,
19970
- resource,
19971
- fetchFn
18810
+ const response = await (fetchFn !== null && fetchFn !== void 0 ? fetchFn : fetch)(tokenUrl, {
18811
+ method: "POST",
18812
+ headers,
18813
+ body: params
19972
18814
  });
18815
+ if (!response.ok) {
18816
+ throw await parseErrorResponse(response);
18817
+ }
18818
+ return OAuthTokensSchema.parse({ refresh_token: refreshToken, ...await response.json() });
19973
18819
  }
19974
18820
  async function registerClient(authorizationServerUrl, { metadata: metadata2, clientMetadata, fetchFn }) {
19975
18821
  let registrationUrl;
@@ -20438,11 +19284,7 @@ class SSEClientTransport {
20438
19284
  if (this._protocolVersion) {
20439
19285
  headers["mcp-protocol-version"] = this._protocolVersion;
20440
19286
  }
20441
- const extraHeaders = normalizeHeaders((_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers);
20442
- return new Headers({
20443
- ...headers,
20444
- ...extraHeaders
20445
- });
19287
+ return new Headers({ ...headers, ...(_a = this._requestInit) === null || _a === void 0 ? void 0 : _a.headers });
20446
19288
  }
20447
19289
  _startOrAuth() {
20448
19290
  var _a, _b, _c;
@@ -20539,7 +19381,7 @@ class SSEClientTransport {
20539
19381
  (_c = this.onclose) === null || _c === void 0 ? void 0 : _c.call(this);
20540
19382
  }
20541
19383
  async send(message) {
20542
- var _a, _b, _c, _d;
19384
+ var _a, _b, _c;
20543
19385
  if (!this._endpoint) {
20544
19386
  throw new Error("Not connected");
20545
19387
  }
@@ -20555,7 +19397,6 @@ class SSEClientTransport {
20555
19397
  };
20556
19398
  const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._endpoint, init);
20557
19399
  if (!response.ok) {
20558
- const text = await response.text().catch(() => null);
20559
19400
  if (response.status === 401 && this._authProvider) {
20560
19401
  const { resourceMetadataUrl, scope: scope2 } = extractWWWAuthenticateParams(response);
20561
19402
  this._resourceMetadataUrl = resourceMetadataUrl;
@@ -20571,11 +19412,11 @@ class SSEClientTransport {
20571
19412
  }
20572
19413
  return this.send(message);
20573
19414
  }
19415
+ const text = await response.text().catch(() => null);
20574
19416
  throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
20575
19417
  }
20576
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
20577
19418
  } catch (error) {
20578
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
19419
+ (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
20579
19420
  throw error;
20580
19421
  }
20581
19422
  }
@@ -20675,7 +19516,7 @@ class StreamableHTTPClientTransport {
20675
19516
  });
20676
19517
  }
20677
19518
  async _startOrAuthSse(options) {
20678
- var _a, _b, _c, _d;
19519
+ var _a, _b, _c;
20679
19520
  const { resumptionToken } = options;
20680
19521
  try {
20681
19522
  const headers = await this._commonHeaders();
@@ -20689,7 +19530,6 @@ class StreamableHTTPClientTransport {
20689
19530
  signal: (_b = this._abortController) === null || _b === void 0 ? void 0 : _b.signal
20690
19531
  });
20691
19532
  if (!response.ok) {
20692
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
20693
19533
  if (response.status === 401 && this._authProvider) {
20694
19534
  return await this._authThenStart();
20695
19535
  }
@@ -20700,7 +19540,7 @@ class StreamableHTTPClientTransport {
20700
19540
  }
20701
19541
  this._handleSseStream(response.body, options, true);
20702
19542
  } catch (error) {
20703
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
19543
+ (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
20704
19544
  throw error;
20705
19545
  }
20706
19546
  }
@@ -20728,12 +19568,12 @@ class StreamableHTTPClientTransport {
20728
19568
  _scheduleReconnection(options, attemptCount = 0) {
20729
19569
  var _a;
20730
19570
  const maxRetries = this._reconnectionOptions.maxRetries;
20731
- if (attemptCount >= maxRetries) {
19571
+ if (maxRetries > 0 && attemptCount >= maxRetries) {
20732
19572
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, new Error(`Maximum reconnection attempts (${maxRetries}) exceeded.`));
20733
19573
  return;
20734
19574
  }
20735
19575
  const delay = this._getNextReconnectionDelay(attemptCount);
20736
- this._reconnectionTimeout = setTimeout(() => {
19576
+ setTimeout(() => {
20737
19577
  this._startOrAuthSse(options).catch((error) => {
20738
19578
  var _a2;
20739
19579
  (_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)}`));
@@ -20748,7 +19588,6 @@ class StreamableHTTPClientTransport {
20748
19588
  const { onresumptiontoken, replayMessageId } = options;
20749
19589
  let lastEventId;
20750
19590
  let hasPrimingEvent = false;
20751
- let receivedResponse = false;
20752
19591
  const processStream = async () => {
20753
19592
  var _a, _b, _c, _d;
20754
19593
  try {
@@ -20767,17 +19606,11 @@ class StreamableHTTPClientTransport {
20767
19606
  hasPrimingEvent = true;
20768
19607
  onresumptiontoken === null || onresumptiontoken === void 0 ? void 0 : onresumptiontoken(event.id);
20769
19608
  }
20770
- if (!event.data) {
20771
- continue;
20772
- }
20773
19609
  if (!event.event || event.event === "message") {
20774
19610
  try {
20775
19611
  const message = JSONRPCMessageSchema.parse(JSON.parse(event.data));
20776
- if (isJSONRPCResponse(message)) {
20777
- receivedResponse = true;
20778
- if (replayMessageId !== void 0) {
20779
- message.id = replayMessageId;
20780
- }
19612
+ if (replayMessageId !== void 0 && isJSONRPCResponse(message)) {
19613
+ message.id = replayMessageId;
20781
19614
  }
20782
19615
  (_a = this.onmessage) === null || _a === void 0 ? void 0 : _a.call(this, message);
20783
19616
  } catch (error) {
@@ -20786,8 +19619,7 @@ class StreamableHTTPClientTransport {
20786
19619
  }
20787
19620
  }
20788
19621
  const canResume = isReconnectable || hasPrimingEvent;
20789
- const needsReconnect = canResume && !receivedResponse;
20790
- if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
19622
+ if (canResume && this._abortController && !this._abortController.signal.aborted) {
20791
19623
  this._scheduleReconnection({
20792
19624
  resumptionToken: lastEventId,
20793
19625
  onresumptiontoken,
@@ -20797,8 +19629,7 @@ class StreamableHTTPClientTransport {
20797
19629
  } catch (error) {
20798
19630
  (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, new Error(`SSE stream disconnected: ${error}`));
20799
19631
  const canResume = isReconnectable || hasPrimingEvent;
20800
- const needsReconnect = canResume && !receivedResponse;
20801
- if (needsReconnect && this._abortController && !this._abortController.signal.aborted) {
19632
+ if (canResume && this._abortController && !this._abortController.signal.aborted) {
20802
19633
  try {
20803
19634
  this._scheduleReconnection({
20804
19635
  resumptionToken: lastEventId,
@@ -20839,15 +19670,11 @@ class StreamableHTTPClientTransport {
20839
19670
  }
20840
19671
  async close() {
20841
19672
  var _a, _b;
20842
- if (this._reconnectionTimeout) {
20843
- clearTimeout(this._reconnectionTimeout);
20844
- this._reconnectionTimeout = void 0;
20845
- }
20846
19673
  (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.abort();
20847
19674
  (_b = this.onclose) === null || _b === void 0 ? void 0 : _b.call(this);
20848
19675
  }
20849
19676
  async send(message, options) {
20850
- var _a, _b, _c, _d, _e, _f, _g;
19677
+ var _a, _b, _c, _d;
20851
19678
  try {
20852
19679
  const { resumptionToken, onresumptiontoken } = options || {};
20853
19680
  if (resumptionToken) {
@@ -20873,7 +19700,6 @@ class StreamableHTTPClientTransport {
20873
19700
  this._sessionId = sessionId;
20874
19701
  }
20875
19702
  if (!response.ok) {
20876
- const text = await response.text().catch(() => null);
20877
19703
  if (response.status === 401 && this._authProvider) {
20878
19704
  if (this._hasCompletedAuthFlow) {
20879
19705
  throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
@@ -20919,12 +19745,12 @@ class StreamableHTTPClientTransport {
20919
19745
  return this.send(message);
20920
19746
  }
20921
19747
  }
20922
- throw new StreamableHTTPError(response.status, `Error POSTing to endpoint: ${text}`);
19748
+ const text = await response.text().catch(() => null);
19749
+ throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
20923
19750
  }
20924
19751
  this._hasCompletedAuthFlow = false;
20925
19752
  this._lastUpscopingHeader = void 0;
20926
19753
  if (response.status === 202) {
20927
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
20928
19754
  if (isInitializedNotification(message)) {
20929
19755
  this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => {
20930
19756
  var _a2;
@@ -20943,17 +19769,14 @@ class StreamableHTTPClientTransport {
20943
19769
  const data = await response.json();
20944
19770
  const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
20945
19771
  for (const msg of responseMessages) {
20946
- (_d = this.onmessage) === null || _d === void 0 ? void 0 : _d.call(this, msg);
19772
+ (_c = this.onmessage) === null || _c === void 0 ? void 0 : _c.call(this, msg);
20947
19773
  }
20948
19774
  } else {
20949
- await ((_e = response.body) === null || _e === void 0 ? void 0 : _e.cancel());
20950
19775
  throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType}`);
20951
19776
  }
20952
- } else {
20953
- await ((_f = response.body) === null || _f === void 0 ? void 0 : _f.cancel());
20954
19777
  }
20955
19778
  } catch (error) {
20956
- (_g = this.onerror) === null || _g === void 0 ? void 0 : _g.call(this, error);
19779
+ (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
20957
19780
  throw error;
20958
19781
  }
20959
19782
  }
@@ -20972,7 +19795,7 @@ class StreamableHTTPClientTransport {
20972
19795
  * the server does not allow clients to terminate sessions.
20973
19796
  */
20974
19797
  async terminateSession() {
20975
- var _a, _b, _c, _d;
19798
+ var _a, _b, _c;
20976
19799
  if (!this._sessionId) {
20977
19800
  return;
20978
19801
  }
@@ -20985,13 +19808,12 @@ class StreamableHTTPClientTransport {
20985
19808
  signal: (_a = this._abortController) === null || _a === void 0 ? void 0 : _a.signal
20986
19809
  };
20987
19810
  const response = await ((_b = this._fetch) !== null && _b !== void 0 ? _b : fetch)(this._url, init);
20988
- await ((_c = response.body) === null || _c === void 0 ? void 0 : _c.cancel());
20989
19811
  if (!response.ok && response.status !== 405) {
20990
19812
  throw new StreamableHTTPError(response.status, `Failed to terminate session: ${response.statusText}`);
20991
19813
  }
20992
19814
  this._sessionId = void 0;
20993
19815
  } catch (error) {
20994
- (_d = this.onerror) === null || _d === void 0 ? void 0 : _d.call(this, error);
19816
+ (_c = this.onerror) === null || _c === void 0 ? void 0 : _c.call(this, error);
20995
19817
  throw error;
20996
19818
  }
20997
19819
  }
@@ -21015,76 +19837,6 @@ class StreamableHTTPClientTransport {
21015
19837
  });
21016
19838
  }
21017
19839
  }
21018
- class ExperimentalServerTasks {
21019
- constructor(_server) {
21020
- this._server = _server;
21021
- }
21022
- /**
21023
- * Sends a request and returns an AsyncGenerator that yields response messages.
21024
- * The generator is guaranteed to end with either a 'result' or 'error' message.
21025
- *
21026
- * This method provides streaming access to request processing, allowing you to
21027
- * observe intermediate task status updates for task-augmented requests.
21028
- *
21029
- * @param request - The request to send
21030
- * @param resultSchema - Zod schema for validating the result
21031
- * @param options - Optional request options (timeout, signal, task creation params, etc.)
21032
- * @returns AsyncGenerator that yields ResponseMessage objects
21033
- *
21034
- * @experimental
21035
- */
21036
- requestStream(request, resultSchema, options) {
21037
- return this._server.requestStream(request, resultSchema, options);
21038
- }
21039
- /**
21040
- * Gets the current status of a task.
21041
- *
21042
- * @param taskId - The task identifier
21043
- * @param options - Optional request options
21044
- * @returns The task status
21045
- *
21046
- * @experimental
21047
- */
21048
- async getTask(taskId, options) {
21049
- return this._server.getTask({ taskId }, options);
21050
- }
21051
- /**
21052
- * Retrieves the result of a completed task.
21053
- *
21054
- * @param taskId - The task identifier
21055
- * @param resultSchema - Zod schema for validating the result
21056
- * @param options - Optional request options
21057
- * @returns The task result
21058
- *
21059
- * @experimental
21060
- */
21061
- async getTaskResult(taskId, resultSchema, options) {
21062
- return this._server.getTaskResult({ taskId }, resultSchema, options);
21063
- }
21064
- /**
21065
- * Lists tasks with optional pagination.
21066
- *
21067
- * @param cursor - Optional pagination cursor
21068
- * @param options - Optional request options
21069
- * @returns List of tasks with optional next cursor
21070
- *
21071
- * @experimental
21072
- */
21073
- async listTasks(cursor, options) {
21074
- return this._server.listTasks(cursor ? { cursor } : void 0, options);
21075
- }
21076
- /**
21077
- * Cancels a running task.
21078
- *
21079
- * @param taskId - The task identifier
21080
- * @param options - Optional request options
21081
- *
21082
- * @experimental
21083
- */
21084
- async cancelTask(taskId, options) {
21085
- return this._server.cancelTask({ taskId }, options);
21086
- }
21087
- }
21088
19840
  class Server extends Protocol {
21089
19841
  /**
21090
19842
  * Initializes this server with the given name and version information.
@@ -21120,21 +19872,6 @@ class Server extends Protocol {
21120
19872
  });
21121
19873
  }
21122
19874
  }
21123
- /**
21124
- * Access experimental features.
21125
- *
21126
- * WARNING: These APIs are experimental and may change without notice.
21127
- *
21128
- * @experimental
21129
- */
21130
- get experimental() {
21131
- if (!this._experimental) {
21132
- this._experimental = {
21133
- tasks: new ExperimentalServerTasks(this)
21134
- };
21135
- }
21136
- return this._experimental;
21137
- }
21138
19875
  /**
21139
19876
  * Registers new capabilities. This can only be called before connecting to a transport.
21140
19877
  *
@@ -21146,58 +19883,6 @@ class Server extends Protocol {
21146
19883
  }
21147
19884
  this._capabilities = mergeCapabilities(this._capabilities, capabilities);
21148
19885
  }
21149
- /**
21150
- * Override request handler registration to enforce server-side validation for tools/call.
21151
- */
21152
- setRequestHandler(requestSchema, handler) {
21153
- var _a, _b, _c;
21154
- const shape = getObjectShape(requestSchema);
21155
- const methodSchema = shape === null || shape === void 0 ? void 0 : shape.method;
21156
- if (!methodSchema) {
21157
- throw new Error("Schema is missing a method literal");
21158
- }
21159
- let methodValue;
21160
- if (isZ4Schema(methodSchema)) {
21161
- const v4Schema = methodSchema;
21162
- const v4Def = (_a = v4Schema._zod) === null || _a === void 0 ? void 0 : _a.def;
21163
- methodValue = (_b = v4Def === null || v4Def === void 0 ? void 0 : v4Def.value) !== null && _b !== void 0 ? _b : v4Schema.value;
21164
- } else {
21165
- const v3Schema = methodSchema;
21166
- const legacyDef = v3Schema._def;
21167
- methodValue = (_c = legacyDef === null || legacyDef === void 0 ? void 0 : legacyDef.value) !== null && _c !== void 0 ? _c : v3Schema.value;
21168
- }
21169
- if (typeof methodValue !== "string") {
21170
- throw new Error("Schema method literal must be a string");
21171
- }
21172
- const method = methodValue;
21173
- if (method === "tools/call") {
21174
- const wrappedHandler = async (request, extra) => {
21175
- const validatedRequest = safeParse(CallToolRequestSchema, request);
21176
- if (!validatedRequest.success) {
21177
- const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
21178
- throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
21179
- }
21180
- const { params } = validatedRequest.data;
21181
- const result = await Promise.resolve(handler(request, extra));
21182
- if (params.task) {
21183
- const taskValidationResult = safeParse(CreateTaskResultSchema, result);
21184
- if (!taskValidationResult.success) {
21185
- const errorMessage = taskValidationResult.error instanceof Error ? taskValidationResult.error.message : String(taskValidationResult.error);
21186
- throw new McpError(ErrorCode.InvalidParams, `Invalid task creation result: ${errorMessage}`);
21187
- }
21188
- return taskValidationResult.data;
21189
- }
21190
- const validationResult = safeParse(CallToolResultSchema, result);
21191
- if (!validationResult.success) {
21192
- const errorMessage = validationResult.error instanceof Error ? validationResult.error.message : String(validationResult.error);
21193
- throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call result: ${errorMessage}`);
21194
- }
21195
- return validationResult.data;
21196
- };
21197
- return super.setRequestHandler(requestSchema, wrappedHandler);
21198
- }
21199
- return super.setRequestHandler(requestSchema, handler);
21200
- }
21201
19886
  assertCapabilityForMethod(method) {
21202
19887
  var _a, _b, _c;
21203
19888
  switch (method) {
@@ -21250,9 +19935,6 @@ class Server extends Protocol {
21250
19935
  }
21251
19936
  }
21252
19937
  assertRequestHandlerCapability(method) {
21253
- if (!this._capabilities) {
21254
- return;
21255
- }
21256
19938
  switch (method) {
21257
19939
  case "completion/complete":
21258
19940
  if (!this._capabilities.completions) {
@@ -21283,26 +19965,7 @@ class Server extends Protocol {
21283
19965
  throw new Error(`Server does not support tools (required for ${method})`);
21284
19966
  }
21285
19967
  break;
21286
- case "tasks/get":
21287
- case "tasks/list":
21288
- case "tasks/result":
21289
- case "tasks/cancel":
21290
- if (!this._capabilities.tasks) {
21291
- throw new Error(`Server does not support tasks capability (required for ${method})`);
21292
- }
21293
- break;
21294
- }
21295
- }
21296
- assertTaskCapability(method) {
21297
- var _a, _b;
21298
- assertClientRequestTaskCapability((_b = (_a = this._clientCapabilities) === null || _a === void 0 ? void 0 : _a.tasks) === null || _b === void 0 ? void 0 : _b.requests, method, "Client");
21299
- }
21300
- assertTaskHandlerCapability(method) {
21301
- var _a;
21302
- if (!this._capabilities) {
21303
- return;
21304
19968
  }
21305
- assertToolsCallTaskCapability((_a = this._capabilities.tasks) === null || _a === void 0 ? void 0 : _a.requests, method, "Server");
21306
19969
  }
21307
19970
  async _oninitialize(request) {
21308
19971
  const requestedVersion = request.params.protocolVersion;
@@ -21334,7 +19997,6 @@ class Server extends Protocol {
21334
19997
  async ping() {
21335
19998
  return this.request({ method: "ping" }, EmptyResultSchema);
21336
19999
  }
21337
- // Implementation
21338
20000
  async createMessage(params, options) {
21339
20001
  var _a, _b;
21340
20002
  if (params.tools || params.toolChoice) {
@@ -21365,9 +20027,6 @@ class Server extends Protocol {
21365
20027
  }
21366
20028
  }
21367
20029
  }
21368
- if (params.tools) {
21369
- return this.request({ method: "sampling/createMessage", params }, CreateMessageResultWithToolsSchema, options);
21370
- }
21371
20030
  return this.request({ method: "sampling/createMessage", params }, CreateMessageResultSchema, options);
21372
20031
  }
21373
20032
  /**
@@ -21523,19 +20182,6 @@ function validateAndWarnToolName(name) {
21523
20182
  issueToolNameWarning(name, result.warnings);
21524
20183
  return result.isValid;
21525
20184
  }
21526
- class ExperimentalMcpServerTasks {
21527
- constructor(_mcpServer) {
21528
- this._mcpServer = _mcpServer;
21529
- }
21530
- registerToolTask(name, config2, handler) {
21531
- const execution = { taskSupport: "required", ...config2.execution };
21532
- if (execution.taskSupport === "forbidden") {
21533
- throw new Error(`Cannot register task-based tool '${name}' with taskSupport 'forbidden'. Use registerTool() instead.`);
21534
- }
21535
- const mcpServerInternal = this._mcpServer;
21536
- return mcpServerInternal._createRegisteredTool(name, config2.title, config2.description, config2.inputSchema, config2.outputSchema, config2.annotations, execution, config2._meta, handler);
21537
- }
21538
- }
21539
20185
  class McpServer {
21540
20186
  constructor(serverInfo, options) {
21541
20187
  this._registeredResources = {};
@@ -21548,21 +20194,6 @@ class McpServer {
21548
20194
  this._promptHandlersInitialized = false;
21549
20195
  this.server = new Server(serverInfo, options);
21550
20196
  }
21551
- /**
21552
- * Access experimental features.
21553
- *
21554
- * WARNING: These APIs are experimental and may change without notice.
21555
- *
21556
- * @experimental
21557
- */
21558
- get experimental() {
21559
- if (!this._experimental) {
21560
- this._experimental = {
21561
- tasks: new ExperimentalMcpServerTasks(this)
21562
- };
21563
- }
21564
- return this._experimental;
21565
- }
21566
20197
  /**
21567
20198
  * Attaches to the given transport, starts it, and starts listening for messages.
21568
20199
  *
@@ -21602,7 +20233,6 @@ class McpServer {
21602
20233
  }) : EMPTY_OBJECT_JSON_SCHEMA;
21603
20234
  })(),
21604
20235
  annotations: tool.annotations,
21605
- execution: tool.execution,
21606
20236
  _meta: tool._meta
21607
20237
  };
21608
20238
  if (tool.outputSchema) {
@@ -21618,34 +20248,39 @@ class McpServer {
21618
20248
  })
21619
20249
  }));
21620
20250
  this.server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
21621
- var _a;
20251
+ const tool = this._registeredTools[request.params.name];
20252
+ let result;
21622
20253
  try {
21623
- const tool = this._registeredTools[request.params.name];
21624
20254
  if (!tool) {
21625
20255
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} not found`);
21626
20256
  }
21627
20257
  if (!tool.enabled) {
21628
20258
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
21629
20259
  }
21630
- const isTaskRequest = !!request.params.task;
21631
- const taskSupport = (_a = tool.execution) === null || _a === void 0 ? void 0 : _a.taskSupport;
21632
- const isTaskHandler = "createTask" in tool.handler;
21633
- if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
21634
- throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
21635
- }
21636
- if (taskSupport === "required" && !isTaskRequest) {
21637
- throw new McpError(ErrorCode.MethodNotFound, `Tool ${request.params.name} requires task augmentation (taskSupport: 'required')`);
21638
- }
21639
- if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
21640
- return await this.handleAutomaticTaskPolling(tool, request, extra);
20260
+ if (tool.inputSchema) {
20261
+ const cb = tool.callback;
20262
+ const inputObj = normalizeObjectSchema(tool.inputSchema);
20263
+ const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
20264
+ const parseResult = await safeParseAsync(schemaToParse, request.params.arguments);
20265
+ if (!parseResult.success) {
20266
+ throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
20267
+ }
20268
+ const args = parseResult.data;
20269
+ result = await Promise.resolve(cb(args, extra));
20270
+ } else {
20271
+ const cb = tool.callback;
20272
+ result = await Promise.resolve(cb(extra));
21641
20273
  }
21642
- const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
21643
- const result = await this.executeToolHandler(tool, args, extra);
21644
- if (isTaskRequest) {
21645
- return result;
20274
+ if (tool.outputSchema && !result.isError) {
20275
+ if (!result.structuredContent) {
20276
+ throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${request.params.name} has an output schema but no structured content was provided`);
20277
+ }
20278
+ const outputObj = normalizeObjectSchema(tool.outputSchema);
20279
+ const parseResult = await safeParseAsync(outputObj, result.structuredContent);
20280
+ if (!parseResult.success) {
20281
+ throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
20282
+ }
21646
20283
  }
21647
- await this.validateToolOutput(tool, result, request.params.name);
21648
- return result;
21649
20284
  } catch (error) {
21650
20285
  if (error instanceof McpError) {
21651
20286
  if (error.code === ErrorCode.UrlElicitationRequired) {
@@ -21654,6 +20289,7 @@ class McpServer {
21654
20289
  }
21655
20290
  return this.createToolError(error instanceof Error ? error.message : String(error));
21656
20291
  }
20292
+ return result;
21657
20293
  });
21658
20294
  this._toolHandlersInitialized = true;
21659
20295
  }
@@ -21674,102 +20310,6 @@ class McpServer {
21674
20310
  isError: true
21675
20311
  };
21676
20312
  }
21677
- /**
21678
- * Validates tool input arguments against the tool's input schema.
21679
- */
21680
- async validateToolInput(tool, args, toolName) {
21681
- if (!tool.inputSchema) {
21682
- return void 0;
21683
- }
21684
- const inputObj = normalizeObjectSchema(tool.inputSchema);
21685
- const schemaToParse = inputObj !== null && inputObj !== void 0 ? inputObj : tool.inputSchema;
21686
- const parseResult = await safeParseAsync(schemaToParse, args);
21687
- if (!parseResult.success) {
21688
- const error = "error" in parseResult ? parseResult.error : "Unknown error";
21689
- const errorMessage = getParseErrorMessage(error);
21690
- throw new McpError(ErrorCode.InvalidParams, `Input validation error: Invalid arguments for tool ${toolName}: ${errorMessage}`);
21691
- }
21692
- return parseResult.data;
21693
- }
21694
- /**
21695
- * Validates tool output against the tool's output schema.
21696
- */
21697
- async validateToolOutput(tool, result, toolName) {
21698
- if (!tool.outputSchema) {
21699
- return;
21700
- }
21701
- if (!("content" in result)) {
21702
- return;
21703
- }
21704
- if (result.isError) {
21705
- return;
21706
- }
21707
- if (!result.structuredContent) {
21708
- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Tool ${toolName} has an output schema but no structured content was provided`);
21709
- }
21710
- const outputObj = normalizeObjectSchema(tool.outputSchema);
21711
- const parseResult = await safeParseAsync(outputObj, result.structuredContent);
21712
- if (!parseResult.success) {
21713
- const error = "error" in parseResult ? parseResult.error : "Unknown error";
21714
- const errorMessage = getParseErrorMessage(error);
21715
- throw new McpError(ErrorCode.InvalidParams, `Output validation error: Invalid structured content for tool ${toolName}: ${errorMessage}`);
21716
- }
21717
- }
21718
- /**
21719
- * Executes a tool handler (either regular or task-based).
21720
- */
21721
- async executeToolHandler(tool, args, extra) {
21722
- const handler = tool.handler;
21723
- const isTaskHandler = "createTask" in handler;
21724
- if (isTaskHandler) {
21725
- if (!extra.taskStore) {
21726
- throw new Error("No task store provided.");
21727
- }
21728
- const taskExtra = { ...extra, taskStore: extra.taskStore };
21729
- if (tool.inputSchema) {
21730
- const typedHandler = handler;
21731
- return await Promise.resolve(typedHandler.createTask(args, taskExtra));
21732
- } else {
21733
- const typedHandler = handler;
21734
- return await Promise.resolve(typedHandler.createTask(taskExtra));
21735
- }
21736
- }
21737
- if (tool.inputSchema) {
21738
- const typedHandler = handler;
21739
- return await Promise.resolve(typedHandler(args, extra));
21740
- } else {
21741
- const typedHandler = handler;
21742
- return await Promise.resolve(typedHandler(extra));
21743
- }
21744
- }
21745
- /**
21746
- * Handles automatic task polling for tools with taskSupport 'optional'.
21747
- */
21748
- async handleAutomaticTaskPolling(tool, request, extra) {
21749
- var _a;
21750
- if (!extra.taskStore) {
21751
- throw new Error("No task store provided for task-capable tool.");
21752
- }
21753
- const args = await this.validateToolInput(tool, request.params.arguments, request.params.name);
21754
- const handler = tool.handler;
21755
- const taskExtra = { ...extra, taskStore: extra.taskStore };
21756
- const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : (
21757
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
21758
- await Promise.resolve(handler.createTask(taskExtra))
21759
- );
21760
- const taskId = createTaskResult.task.taskId;
21761
- let task = createTaskResult.task;
21762
- const pollInterval = (_a = task.pollInterval) !== null && _a !== void 0 ? _a : 5e3;
21763
- while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
21764
- await new Promise((resolve2) => setTimeout(resolve2, pollInterval));
21765
- const updatedTask = await extra.taskStore.getTask(taskId);
21766
- if (!updatedTask) {
21767
- throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
21768
- }
21769
- task = updatedTask;
21770
- }
21771
- return await extra.taskStore.getTaskResult(taskId);
21772
- }
21773
20313
  setCompletionRequestHandler() {
21774
20314
  if (this._completionHandlerInitialized) {
21775
20315
  return;
@@ -21925,9 +20465,7 @@ class McpServer {
21925
20465
  const argsObj = normalizeObjectSchema(prompt.argsSchema);
21926
20466
  const parseResult = await safeParseAsync(argsObj, request.params.arguments);
21927
20467
  if (!parseResult.success) {
21928
- const error = "error" in parseResult ? parseResult.error : "Unknown error";
21929
- const errorMessage = getParseErrorMessage(error);
21930
- throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${errorMessage}`);
20468
+ throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request.params.name}: ${getParseErrorMessage(parseResult.error)}`);
21931
20469
  }
21932
20470
  const args = parseResult.data;
21933
20471
  const cb = prompt.callback;
@@ -22079,7 +20617,7 @@ class McpServer {
22079
20617
  this._registeredPrompts[name] = registeredPrompt;
22080
20618
  return registeredPrompt;
22081
20619
  }
22082
- _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, execution, _meta, handler) {
20620
+ _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, callback) {
22083
20621
  validateAndWarnToolName(name);
22084
20622
  const registeredTool = {
22085
20623
  title: title2,
@@ -22087,9 +20625,8 @@ class McpServer {
22087
20625
  inputSchema: getZodSchemaObject(inputSchema),
22088
20626
  outputSchema: getZodSchemaObject(outputSchema),
22089
20627
  annotations,
22090
- execution,
22091
20628
  _meta,
22092
- handler,
20629
+ callback,
22093
20630
  enabled: true,
22094
20631
  disable: () => registeredTool.update({ enabled: false }),
22095
20632
  enable: () => registeredTool.update({ enabled: true }),
@@ -22110,7 +20647,7 @@ class McpServer {
22110
20647
  if (typeof updates.paramsSchema !== "undefined")
22111
20648
  registeredTool.inputSchema = objectFromShape(updates.paramsSchema);
22112
20649
  if (typeof updates.callback !== "undefined")
22113
- registeredTool.handler = updates.callback;
20650
+ registeredTool.callback = updates.callback;
22114
20651
  if (typeof updates.annotations !== "undefined")
22115
20652
  registeredTool.annotations = updates.annotations;
22116
20653
  if (typeof updates._meta !== "undefined")
@@ -22141,9 +20678,9 @@ class McpServer {
22141
20678
  }
22142
20679
  if (rest.length > 1) {
22143
20680
  const firstArg = rest[0];
22144
- if (isZodRawShapeCompat(firstArg)) {
20681
+ if (isZodRawShape(firstArg)) {
22145
20682
  inputSchema = rest.shift();
22146
- if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) {
20683
+ if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShape(rest[0])) {
22147
20684
  annotations = rest.shift();
22148
20685
  }
22149
20686
  } else if (typeof firstArg === "object" && firstArg !== null) {
@@ -22151,7 +20688,7 @@ class McpServer {
22151
20688
  }
22152
20689
  }
22153
20690
  const callback = rest[0];
22154
- return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
20691
+ return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, void 0, callback);
22155
20692
  }
22156
20693
  /**
22157
20694
  * Registers a tool with a config object and callback.
@@ -22161,7 +20698,7 @@ class McpServer {
22161
20698
  throw new Error(`Tool ${name} is already registered`);
22162
20699
  }
22163
20700
  const { title: title2, description: description2, inputSchema, outputSchema, annotations, _meta } = config2;
22164
- return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, _meta, cb);
20701
+ return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, cb);
22165
20702
  }
22166
20703
  prompt(name, ...rest) {
22167
20704
  if (this._registeredPrompts[name]) {
@@ -22265,29 +20802,20 @@ const EMPTY_OBJECT_JSON_SCHEMA = {
22265
20802
  type: "object",
22266
20803
  properties: {}
22267
20804
  };
20805
+ function isZodRawShape(obj) {
20806
+ if (typeof obj !== "object" || obj === null)
20807
+ return false;
20808
+ const isEmptyObject = Object.keys(obj).length === 0;
20809
+ return isEmptyObject || Object.values(obj).some(isZodTypeLike);
20810
+ }
22268
20811
  function isZodTypeLike(value) {
22269
20812
  return value !== null && typeof value === "object" && "parse" in value && typeof value.parse === "function" && "safeParse" in value && typeof value.safeParse === "function";
22270
20813
  }
22271
- function isZodSchemaInstance(obj) {
22272
- return "_def" in obj || "_zod" in obj || isZodTypeLike(obj);
22273
- }
22274
- function isZodRawShapeCompat(obj) {
22275
- if (typeof obj !== "object" || obj === null) {
22276
- return false;
22277
- }
22278
- if (isZodSchemaInstance(obj)) {
22279
- return false;
22280
- }
22281
- if (Object.keys(obj).length === 0) {
22282
- return true;
22283
- }
22284
- return Object.values(obj).some(isZodTypeLike);
22285
- }
22286
20814
  function getZodSchemaObject(schema) {
22287
20815
  if (!schema) {
22288
20816
  return void 0;
22289
20817
  }
22290
- if (isZodRawShapeCompat(schema)) {
20818
+ if (isZodRawShape(schema)) {
22291
20819
  return objectFromShape(schema);
22292
20820
  }
22293
20821
  return schema;
@@ -22335,7 +20863,6 @@ const EMPTY_COMPLETION_RESULT = {
22335
20863
  };
22336
20864
  export {
22337
20865
  ajv as Ajv,
22338
- AnnotationsSchema,
22339
20866
  AudioContentSchema,
22340
20867
  BaseMetadataSchema,
22341
20868
  BlobResourceContentsSchema,
@@ -22344,8 +20871,6 @@ export {
22344
20871
  CallToolRequestParamsSchema,
22345
20872
  CallToolRequestSchema,
22346
20873
  CallToolResultSchema,
22347
- CancelTaskRequestSchema,
22348
- CancelTaskResultSchema,
22349
20874
  CancelledNotificationParamsSchema,
22350
20875
  CancelledNotificationSchema,
22351
20876
  Client,
@@ -22353,7 +20878,6 @@ export {
22353
20878
  ClientNotificationSchema,
22354
20879
  ClientRequestSchema,
22355
20880
  ClientResultSchema,
22356
- ClientTasksCapabilitySchema,
22357
20881
  CompatibilityCallToolResultSchema,
22358
20882
  CompleteRequestParamsSchema,
22359
20883
  CompleteRequestSchema,
@@ -22362,8 +20886,6 @@ export {
22362
20886
  CreateMessageRequestParamsSchema,
22363
20887
  CreateMessageRequestSchema,
22364
20888
  CreateMessageResultSchema,
22365
- CreateMessageResultWithToolsSchema,
22366
- CreateTaskResultSchema,
22367
20889
  CursorSchema,
22368
20890
  DEFAULT_NEGOTIATED_PROTOCOL_VERSION,
22369
20891
  DEFAULT_REQUEST_TIMEOUT_MSEC,
@@ -22381,9 +20903,6 @@ export {
22381
20903
  GetPromptRequestParamsSchema,
22382
20904
  GetPromptRequestSchema,
22383
20905
  GetPromptResultSchema,
22384
- GetTaskPayloadRequestSchema,
22385
- GetTaskRequestSchema,
22386
- GetTaskResultSchema,
22387
20906
  IconSchema,
22388
20907
  IconsSchema,
22389
20908
  ImageContentSchema,
@@ -22408,8 +20927,6 @@ export {
22408
20927
  ListResourcesResultSchema,
22409
20928
  ListRootsRequestSchema,
22410
20929
  ListRootsResultSchema,
22411
- ListTasksRequestSchema,
22412
- ListTasksResultSchema,
22413
20930
  ListToolsRequestSchema,
22414
20931
  ListToolsResultSchema,
22415
20932
  LoggingLevelSchema,
@@ -22438,11 +20955,9 @@ export {
22438
20955
  PromptReferenceSchema,
22439
20956
  PromptSchema,
22440
20957
  Protocol,
22441
- RELATED_TASK_META_KEY,
22442
20958
  ReadResourceRequestParamsSchema,
22443
20959
  ReadResourceRequestSchema,
22444
20960
  ReadResourceResultSchema,
22445
- RelatedTaskMetadataSchema,
22446
20961
  RequestIdSchema,
22447
20962
  RequestSchema,
22448
20963
  ResourceContentsSchema,
@@ -22461,14 +20976,12 @@ export {
22461
20976
  RootsListChangedNotificationSchema,
22462
20977
  SSEClientTransport,
22463
20978
  SUPPORTED_PROTOCOL_VERSIONS,
22464
- SamplingContentSchema,
22465
20979
  SamplingMessageContentBlockSchema,
22466
20980
  SamplingMessageSchema,
22467
20981
  ServerCapabilitiesSchema,
22468
20982
  ServerNotificationSchema,
22469
20983
  ServerRequestSchema,
22470
20984
  ServerResultSchema,
22471
- ServerTasksCapabilitySchema,
22472
20985
  SetLevelRequestParamsSchema,
22473
20986
  SetLevelRequestSchema,
22474
20987
  SingleSelectEnumSchemaSchema,
@@ -22478,17 +20991,12 @@ export {
22478
20991
  StringSchemaSchema,
22479
20992
  SubscribeRequestParamsSchema,
22480
20993
  SubscribeRequestSchema,
22481
- TaskCreationParamsSchema,
22482
- TaskSchema,
22483
- TaskStatusNotificationParamsSchema,
22484
- TaskStatusNotificationSchema,
22485
20994
  TextContentSchema,
22486
20995
  TextResourceContentsSchema,
22487
20996
  TitledMultiSelectEnumSchemaSchema,
22488
20997
  TitledSingleSelectEnumSchemaSchema,
22489
20998
  ToolAnnotationsSchema,
22490
20999
  ToolChoiceSchema,
22491
- ToolExecutionSchema,
22492
21000
  ToolListChangedNotificationSchema,
22493
21001
  ToolResultContentSchema,
22494
21002
  ToolSchema,
@@ -22512,7 +21020,6 @@ export {
22512
21020
  exchangeAuthorization,
22513
21021
  extractResourceMetadataUrl,
22514
21022
  extractWWWAuthenticateParams,
22515
- fetchToken,
22516
21023
  getCompleter,
22517
21024
  getDisplayName,
22518
21025
  getSupportedElicitationModes,
@@ -22527,7 +21034,6 @@ export {
22527
21034
  mergeCapabilities,
22528
21035
  normalizeHeaders,
22529
21036
  parseErrorResponse,
22530
- prepareAuthorizationCodeRequest,
22531
21037
  refreshAuthorization,
22532
21038
  registerClient,
22533
21039
  selectClientAuthMethod,