@umbraco-cms/mcp-dev 17.6.8 → 17.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -15664,6 +15664,9 @@ var Protocol = class {
15664
15664
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
15665
15665
  const handleTaskResult = async () => {
15666
15666
  const taskId = request.params.taskId;
15667
+ if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
15668
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
15669
+ }
15667
15670
  if (this._taskMessageQueue) {
15668
15671
  let queuedMessage;
15669
15672
  while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
@@ -15694,12 +15697,12 @@ var Protocol = class {
15694
15697
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
15695
15698
  }
15696
15699
  if (!isTerminal(task.status)) {
15697
- await this._waitForTaskUpdate(taskId, extra.signal);
15700
+ await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
15698
15701
  return await handleTaskResult();
15699
15702
  }
15700
15703
  if (isTerminal(task.status)) {
15701
15704
  const result = await this._taskStore.getTaskResult(taskId, extra.sessionId);
15702
- this._clearTaskQueue(taskId);
15705
+ this._clearTaskQueue(taskId, extra.sessionId);
15703
15706
  return {
15704
15707
  ...result,
15705
15708
  _meta: {
@@ -15736,7 +15739,7 @@ var Protocol = class {
15736
15739
  throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
15737
15740
  }
15738
15741
  await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
15739
- this._clearTaskQueue(request.params.taskId);
15742
+ this._clearTaskQueue(request.params.taskId, extra.sessionId);
15740
15743
  const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
15741
15744
  if (!cancelledTask) {
15742
15745
  throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
@@ -15864,6 +15867,19 @@ var Protocol = class {
15864
15867
  const handler = _nullishCoalesce(this._requestHandlers.get(request.method), () => ( this.fallbackRequestHandler));
15865
15868
  const capturedTransport = this._transport;
15866
15869
  const relatedTaskId = _optionalChain([request, 'access', _89 => _89.params, 'optionalAccess', _90 => _90._meta, 'optionalAccess', _91 => _91[RELATED_TASK_META_KEY], 'optionalAccess', _92 => _92.taskId]);
15870
+ const sessionId = _optionalChain([capturedTransport, 'optionalAccess', _93 => _93.sessionId]);
15871
+ const store = this._taskStore;
15872
+ let relatedTaskFound = true;
15873
+ let relatedTaskLookup;
15874
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
15875
+ relatedTaskFound = false;
15876
+ relatedTaskLookup = (async () => {
15877
+ if (!await store.getTask(relatedTaskId, sessionId)) {
15878
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
15879
+ }
15880
+ relatedTaskFound = true;
15881
+ })();
15882
+ }
15867
15883
  if (handler === void 0) {
15868
15884
  const errorResponse = {
15869
15885
  jsonrpc: "2.0",
@@ -15873,25 +15889,28 @@ var Protocol = class {
15873
15889
  message: "Method not found"
15874
15890
  }
15875
15891
  };
15876
- if (relatedTaskId && this._taskMessageQueue) {
15892
+ if (relatedTaskId && relatedTaskLookup) {
15893
+ const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
15894
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => _optionalChain([capturedTransport, 'optionalAccess', _94 => _94.send, 'call', _95 => _95(errorResponse)])).catch((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)));
15895
+ } else if (relatedTaskId && this._taskMessageQueue) {
15877
15896
  this._enqueueTaskMessage(relatedTaskId, {
15878
15897
  type: "error",
15879
15898
  message: errorResponse,
15880
15899
  timestamp: Date.now()
15881
- }, _optionalChain([capturedTransport, 'optionalAccess', _93 => _93.sessionId])).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
15900
+ }, _optionalChain([capturedTransport, 'optionalAccess', _96 => _96.sessionId])).catch((error) => this._onerror(new Error(`Failed to enqueue error response: ${error}`)));
15882
15901
  } else {
15883
- _optionalChain([capturedTransport, 'optionalAccess', _94 => _94.send, 'call', _95 => _95(errorResponse), 'access', _96 => _96.catch, 'call', _97 => _97((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)))]);
15902
+ _optionalChain([capturedTransport, 'optionalAccess', _97 => _97.send, 'call', _98 => _98(errorResponse), 'access', _99 => _99.catch, 'call', _100 => _100((error) => this._onerror(new Error(`Failed to send an error response: ${error}`)))]);
15884
15903
  }
15885
15904
  return;
15886
15905
  }
15887
15906
  const abortController = new AbortController();
15888
15907
  this._requestHandlerAbortControllers.set(request.id, abortController);
15889
15908
  const taskCreationParams = isTaskAugmentedRequestParams(request.params) ? request.params.task : void 0;
15890
- const taskStore = this._taskStore ? this.requestTaskStore(request, _optionalChain([capturedTransport, 'optionalAccess', _98 => _98.sessionId])) : void 0;
15909
+ const taskStore = this._taskStore ? this.requestTaskStore(request, _optionalChain([capturedTransport, 'optionalAccess', _101 => _101.sessionId])) : void 0;
15891
15910
  const fullExtra = {
15892
15911
  signal: abortController.signal,
15893
- sessionId: _optionalChain([capturedTransport, 'optionalAccess', _99 => _99.sessionId]),
15894
- _meta: _optionalChain([request, 'access', _100 => _100.params, 'optionalAccess', _101 => _101._meta]),
15912
+ sessionId: _optionalChain([capturedTransport, 'optionalAccess', _102 => _102.sessionId]),
15913
+ _meta: _optionalChain([request, 'access', _103 => _103.params, 'optionalAccess', _104 => _104._meta]),
15895
15914
  sendNotification: async (notification) => {
15896
15915
  if (abortController.signal.aborted)
15897
15916
  return;
@@ -15909,22 +15928,25 @@ var Protocol = class {
15909
15928
  if (relatedTaskId && !requestOptions.relatedTask) {
15910
15929
  requestOptions.relatedTask = { taskId: relatedTaskId };
15911
15930
  }
15912
- const effectiveTaskId = _nullishCoalesce(_optionalChain([requestOptions, 'access', _102 => _102.relatedTask, 'optionalAccess', _103 => _103.taskId]), () => ( relatedTaskId));
15931
+ const effectiveTaskId = _nullishCoalesce(_optionalChain([requestOptions, 'access', _105 => _105.relatedTask, 'optionalAccess', _106 => _106.taskId]), () => ( relatedTaskId));
15913
15932
  if (effectiveTaskId && taskStore) {
15914
15933
  await taskStore.updateTaskStatus(effectiveTaskId, "input_required");
15915
15934
  }
15916
15935
  return await this.request(r, resultSchema, requestOptions);
15917
15936
  },
15918
- authInfo: _optionalChain([extra, 'optionalAccess', _104 => _104.authInfo]),
15937
+ authInfo: _optionalChain([extra, 'optionalAccess', _107 => _107.authInfo]),
15919
15938
  requestId: request.id,
15920
- requestInfo: _optionalChain([extra, 'optionalAccess', _105 => _105.requestInfo]),
15939
+ requestInfo: _optionalChain([extra, 'optionalAccess', _108 => _108.requestInfo]),
15921
15940
  taskId: relatedTaskId,
15922
15941
  taskStore,
15923
- taskRequestedTtl: _optionalChain([taskCreationParams, 'optionalAccess', _106 => _106.ttl]),
15924
- closeSSEStream: _optionalChain([extra, 'optionalAccess', _107 => _107.closeSSEStream]),
15925
- closeStandaloneSSEStream: _optionalChain([extra, 'optionalAccess', _108 => _108.closeStandaloneSSEStream])
15942
+ taskRequestedTtl: _optionalChain([taskCreationParams, 'optionalAccess', _109 => _109.ttl]),
15943
+ closeSSEStream: _optionalChain([extra, 'optionalAccess', _110 => _110.closeSSEStream]),
15944
+ closeStandaloneSSEStream: _optionalChain([extra, 'optionalAccess', _111 => _111.closeStandaloneSSEStream])
15926
15945
  };
15927
- Promise.resolve().then(() => {
15946
+ (_nullishCoalesce(relatedTaskLookup, () => ( Promise.resolve()))).then(() => {
15947
+ if (relatedTaskLookup && abortController.signal.aborted) {
15948
+ throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
15949
+ }
15928
15950
  if (taskCreationParams) {
15929
15951
  this.assertTaskHandlerCapability(request.method);
15930
15952
  }
@@ -15942,9 +15964,9 @@ var Protocol = class {
15942
15964
  type: "response",
15943
15965
  message: response,
15944
15966
  timestamp: Date.now()
15945
- }, _optionalChain([capturedTransport, 'optionalAccess', _109 => _109.sessionId]));
15967
+ }, _optionalChain([capturedTransport, 'optionalAccess', _112 => _112.sessionId]));
15946
15968
  } else {
15947
- await _optionalChain([capturedTransport, 'optionalAccess', _110 => _110.send, 'call', _111 => _111(response)]);
15969
+ await _optionalChain([capturedTransport, 'optionalAccess', _113 => _113.send, 'call', _114 => _114(response)]);
15948
15970
  }
15949
15971
  }, async (error) => {
15950
15972
  if (abortController.signal.aborted) {
@@ -15959,14 +15981,14 @@ var Protocol = class {
15959
15981
  ...error["data"] !== void 0 && { data: error["data"] }
15960
15982
  }
15961
15983
  };
15962
- if (relatedTaskId && this._taskMessageQueue) {
15984
+ if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
15963
15985
  await this._enqueueTaskMessage(relatedTaskId, {
15964
15986
  type: "error",
15965
15987
  message: errorResponse,
15966
15988
  timestamp: Date.now()
15967
- }, _optionalChain([capturedTransport, 'optionalAccess', _112 => _112.sessionId]));
15989
+ }, _optionalChain([capturedTransport, 'optionalAccess', _115 => _115.sessionId]));
15968
15990
  } else {
15969
- await _optionalChain([capturedTransport, 'optionalAccess', _113 => _113.send, 'call', _114 => _114(errorResponse)]);
15991
+ await _optionalChain([capturedTransport, 'optionalAccess', _116 => _116.send, 'call', _117 => _117(errorResponse)]);
15970
15992
  }
15971
15993
  }).catch((error) => this._onerror(new Error(`Failed to send response: ${error}`))).finally(() => {
15972
15994
  if (this._requestHandlerAbortControllers.get(request.id) === abortController) {
@@ -16045,7 +16067,7 @@ var Protocol = class {
16045
16067
  * Closes the connection.
16046
16068
  */
16047
16069
  async close() {
16048
- await _optionalChain([this, 'access', _115 => _115._transport, 'optionalAccess', _116 => _116.close, 'call', _117 => _117()]);
16070
+ await _optionalChain([this, 'access', _118 => _118._transport, 'optionalAccess', _119 => _119.close, 'call', _120 => _120()]);
16049
16071
  }
16050
16072
  /**
16051
16073
  * Sends a request and returns an AsyncGenerator that yields response messages.
@@ -16122,9 +16144,9 @@ var Protocol = class {
16122
16144
  yield { type: "result", result };
16123
16145
  return;
16124
16146
  }
16125
- const pollInterval = _nullishCoalesce(_nullishCoalesce(task2.pollInterval, () => ( _optionalChain([this, 'access', _118 => _118._options, 'optionalAccess', _119 => _119.defaultTaskPollInterval]))), () => ( 1e3));
16147
+ const pollInterval = _nullishCoalesce(_nullishCoalesce(task2.pollInterval, () => ( _optionalChain([this, 'access', _121 => _121._options, 'optionalAccess', _122 => _122.defaultTaskPollInterval]))), () => ( 1e3));
16126
16148
  await new Promise((resolve) => setTimeout(resolve, pollInterval));
16127
- _optionalChain([options, 'optionalAccess', _120 => _120.signal, 'optionalAccess', _121 => _121.throwIfAborted, 'call', _122 => _122()]);
16149
+ _optionalChain([options, 'optionalAccess', _123 => _123.signal, 'optionalAccess', _124 => _124.throwIfAborted, 'call', _125 => _125()]);
16128
16150
  }
16129
16151
  } catch (error) {
16130
16152
  yield {
@@ -16148,7 +16170,7 @@ var Protocol = class {
16148
16170
  earlyReject(new Error("Not connected"));
16149
16171
  return;
16150
16172
  }
16151
- if (_optionalChain([this, 'access', _123 => _123._options, 'optionalAccess', _124 => _124.enforceStrictCapabilities]) === true) {
16173
+ if (_optionalChain([this, 'access', _126 => _126._options, 'optionalAccess', _127 => _127.enforceStrictCapabilities]) === true) {
16152
16174
  try {
16153
16175
  this.assertCapabilityForMethod(request.method);
16154
16176
  if (task) {
@@ -16159,19 +16181,19 @@ var Protocol = class {
16159
16181
  return;
16160
16182
  }
16161
16183
  }
16162
- _optionalChain([options, 'optionalAccess', _125 => _125.signal, 'optionalAccess', _126 => _126.throwIfAborted, 'call', _127 => _127()]);
16184
+ _optionalChain([options, 'optionalAccess', _128 => _128.signal, 'optionalAccess', _129 => _129.throwIfAborted, 'call', _130 => _130()]);
16163
16185
  const messageId = this._requestMessageId++;
16164
16186
  const jsonrpcRequest = {
16165
16187
  ...request,
16166
16188
  jsonrpc: "2.0",
16167
16189
  id: messageId
16168
16190
  };
16169
- if (_optionalChain([options, 'optionalAccess', _128 => _128.onprogress])) {
16191
+ if (_optionalChain([options, 'optionalAccess', _131 => _131.onprogress])) {
16170
16192
  this._progressHandlers.set(messageId, options.onprogress);
16171
16193
  jsonrpcRequest.params = {
16172
16194
  ...request.params,
16173
16195
  _meta: {
16174
- ..._optionalChain([request, 'access', _129 => _129.params, 'optionalAccess', _130 => _130._meta]) || {},
16196
+ ..._optionalChain([request, 'access', _132 => _132.params, 'optionalAccess', _133 => _133._meta]) || {},
16175
16197
  progressToken: messageId
16176
16198
  }
16177
16199
  };
@@ -16186,7 +16208,7 @@ var Protocol = class {
16186
16208
  jsonrpcRequest.params = {
16187
16209
  ...jsonrpcRequest.params,
16188
16210
  _meta: {
16189
- ..._optionalChain([jsonrpcRequest, 'access', _131 => _131.params, 'optionalAccess', _132 => _132._meta]) || {},
16211
+ ..._optionalChain([jsonrpcRequest, 'access', _134 => _134.params, 'optionalAccess', _135 => _135._meta]) || {},
16190
16212
  [RELATED_TASK_META_KEY]: relatedTask
16191
16213
  }
16192
16214
  };
@@ -16195,19 +16217,19 @@ var Protocol = class {
16195
16217
  this._responseHandlers.delete(messageId);
16196
16218
  this._progressHandlers.delete(messageId);
16197
16219
  this._cleanupTimeout(messageId);
16198
- _optionalChain([this, 'access', _133 => _133._transport, 'optionalAccess', _134 => _134.send, 'call', _135 => _135({
16220
+ _optionalChain([this, 'access', _136 => _136._transport, 'optionalAccess', _137 => _137.send, 'call', _138 => _138({
16199
16221
  jsonrpc: "2.0",
16200
16222
  method: "notifications/cancelled",
16201
16223
  params: {
16202
16224
  requestId: messageId,
16203
16225
  reason: String(reason)
16204
16226
  }
16205
- }, { relatedRequestId, resumptionToken, onresumptiontoken }), 'access', _136 => _136.catch, 'call', _137 => _137((error2) => this._onerror(new Error(`Failed to send cancellation: ${error2}`)))]);
16227
+ }, { relatedRequestId, resumptionToken, onresumptiontoken }), 'access', _139 => _139.catch, 'call', _140 => _140((error2) => this._onerror(new Error(`Failed to send cancellation: ${error2}`)))]);
16206
16228
  const error = reason instanceof McpError ? reason : new McpError(ErrorCode.RequestTimeout, String(reason));
16207
16229
  reject(error);
16208
16230
  };
16209
16231
  this._responseHandlers.set(messageId, (response) => {
16210
- if (_optionalChain([options, 'optionalAccess', _138 => _138.signal, 'optionalAccess', _139 => _139.aborted])) {
16232
+ if (_optionalChain([options, 'optionalAccess', _141 => _141.signal, 'optionalAccess', _142 => _142.aborted])) {
16211
16233
  return;
16212
16234
  }
16213
16235
  if (response instanceof Error) {
@@ -16224,13 +16246,13 @@ var Protocol = class {
16224
16246
  reject(error);
16225
16247
  }
16226
16248
  });
16227
- _optionalChain([options, 'optionalAccess', _140 => _140.signal, 'optionalAccess', _141 => _141.addEventListener, 'call', _142 => _142("abort", () => {
16228
- cancel(_optionalChain([options, 'optionalAccess', _143 => _143.signal, 'optionalAccess', _144 => _144.reason]));
16249
+ _optionalChain([options, 'optionalAccess', _143 => _143.signal, 'optionalAccess', _144 => _144.addEventListener, 'call', _145 => _145("abort", () => {
16250
+ cancel(_optionalChain([options, 'optionalAccess', _146 => _146.signal, 'optionalAccess', _147 => _147.reason]));
16229
16251
  })]);
16230
- const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _145 => _145.timeout]), () => ( DEFAULT_REQUEST_TIMEOUT_MSEC));
16252
+ const timeout = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _148 => _148.timeout]), () => ( DEFAULT_REQUEST_TIMEOUT_MSEC));
16231
16253
  const timeoutHandler = () => cancel(McpError.fromError(ErrorCode.RequestTimeout, "Request timed out", { timeout }));
16232
- this._setupTimeout(messageId, timeout, _optionalChain([options, 'optionalAccess', _146 => _146.maxTotalTimeout]), timeoutHandler, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _147 => _147.resetTimeoutOnProgress]), () => ( false)));
16233
- const relatedTaskId = _optionalChain([relatedTask, 'optionalAccess', _148 => _148.taskId]);
16254
+ this._setupTimeout(messageId, timeout, _optionalChain([options, 'optionalAccess', _149 => _149.maxTotalTimeout]), timeoutHandler, _nullishCoalesce(_optionalChain([options, 'optionalAccess', _150 => _150.resetTimeoutOnProgress]), () => ( false)));
16255
+ const relatedTaskId = _optionalChain([relatedTask, 'optionalAccess', _151 => _151.taskId]);
16234
16256
  if (relatedTaskId) {
16235
16257
  const responseResolver = (response) => {
16236
16258
  const handler = this._responseHandlers.get(messageId);
@@ -16297,7 +16319,7 @@ var Protocol = class {
16297
16319
  throw new Error("Not connected");
16298
16320
  }
16299
16321
  this.assertNotificationCapability(notification.method);
16300
- const relatedTaskId = _optionalChain([options, 'optionalAccess', _149 => _149.relatedTask, 'optionalAccess', _150 => _150.taskId]);
16322
+ const relatedTaskId = _optionalChain([options, 'optionalAccess', _152 => _152.relatedTask, 'optionalAccess', _153 => _153.taskId]);
16301
16323
  if (relatedTaskId) {
16302
16324
  const jsonrpcNotification2 = {
16303
16325
  ...notification,
@@ -16305,7 +16327,7 @@ var Protocol = class {
16305
16327
  params: {
16306
16328
  ...notification.params,
16307
16329
  _meta: {
16308
- ..._optionalChain([notification, 'access', _151 => _151.params, 'optionalAccess', _152 => _152._meta]) || {},
16330
+ ..._optionalChain([notification, 'access', _154 => _154.params, 'optionalAccess', _155 => _155._meta]) || {},
16309
16331
  [RELATED_TASK_META_KEY]: options.relatedTask
16310
16332
  }
16311
16333
  }
@@ -16317,8 +16339,8 @@ var Protocol = class {
16317
16339
  });
16318
16340
  return;
16319
16341
  }
16320
- const debouncedMethods = _nullishCoalesce(_optionalChain([this, 'access', _153 => _153._options, 'optionalAccess', _154 => _154.debouncedNotificationMethods]), () => ( []));
16321
- const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !_optionalChain([options, 'optionalAccess', _155 => _155.relatedRequestId]) && !_optionalChain([options, 'optionalAccess', _156 => _156.relatedTask]);
16342
+ const debouncedMethods = _nullishCoalesce(_optionalChain([this, 'access', _156 => _156._options, 'optionalAccess', _157 => _157.debouncedNotificationMethods]), () => ( []));
16343
+ const canDebounce = debouncedMethods.includes(notification.method) && !notification.params && !_optionalChain([options, 'optionalAccess', _158 => _158.relatedRequestId]) && !_optionalChain([options, 'optionalAccess', _159 => _159.relatedTask]);
16322
16344
  if (canDebounce) {
16323
16345
  if (this._pendingDebouncedNotifications.has(notification.method)) {
16324
16346
  return;
@@ -16333,19 +16355,19 @@ var Protocol = class {
16333
16355
  ...notification,
16334
16356
  jsonrpc: "2.0"
16335
16357
  };
16336
- if (_optionalChain([options, 'optionalAccess', _157 => _157.relatedTask])) {
16358
+ if (_optionalChain([options, 'optionalAccess', _160 => _160.relatedTask])) {
16337
16359
  jsonrpcNotification2 = {
16338
16360
  ...jsonrpcNotification2,
16339
16361
  params: {
16340
16362
  ...jsonrpcNotification2.params,
16341
16363
  _meta: {
16342
- ..._optionalChain([jsonrpcNotification2, 'access', _158 => _158.params, 'optionalAccess', _159 => _159._meta]) || {},
16364
+ ..._optionalChain([jsonrpcNotification2, 'access', _161 => _161.params, 'optionalAccess', _162 => _162._meta]) || {},
16343
16365
  [RELATED_TASK_META_KEY]: options.relatedTask
16344
16366
  }
16345
16367
  }
16346
16368
  };
16347
16369
  }
16348
- _optionalChain([this, 'access', _160 => _160._transport, 'optionalAccess', _161 => _161.send, 'call', _162 => _162(jsonrpcNotification2, options), 'access', _163 => _163.catch, 'call', _164 => _164((error) => this._onerror(error))]);
16370
+ _optionalChain([this, 'access', _163 => _163._transport, 'optionalAccess', _164 => _164.send, 'call', _165 => _165(jsonrpcNotification2, options), 'access', _166 => _166.catch, 'call', _167 => _167((error) => this._onerror(error))]);
16349
16371
  });
16350
16372
  return;
16351
16373
  }
@@ -16353,13 +16375,13 @@ var Protocol = class {
16353
16375
  ...notification,
16354
16376
  jsonrpc: "2.0"
16355
16377
  };
16356
- if (_optionalChain([options, 'optionalAccess', _165 => _165.relatedTask])) {
16378
+ if (_optionalChain([options, 'optionalAccess', _168 => _168.relatedTask])) {
16357
16379
  jsonrpcNotification = {
16358
16380
  ...jsonrpcNotification,
16359
16381
  params: {
16360
16382
  ...jsonrpcNotification.params,
16361
16383
  _meta: {
16362
- ..._optionalChain([jsonrpcNotification, 'access', _166 => _166.params, 'optionalAccess', _167 => _167._meta]) || {},
16384
+ ..._optionalChain([jsonrpcNotification, 'access', _169 => _169.params, 'optionalAccess', _170 => _170._meta]) || {},
16363
16385
  [RELATED_TASK_META_KEY]: options.relatedTask
16364
16386
  }
16365
16387
  }
@@ -16438,8 +16460,8 @@ var Protocol = class {
16438
16460
  if (!this._taskStore || !this._taskMessageQueue) {
16439
16461
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
16440
16462
  }
16441
- const maxQueueSize = _optionalChain([this, 'access', _168 => _168._options, 'optionalAccess', _169 => _169.maxTaskQueueSize]);
16442
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
16463
+ const maxQueueSize = _optionalChain([this, 'access', _171 => _171._options, 'optionalAccess', _172 => _172.maxTaskQueueSize]);
16464
+ await this._taskMessageQueue.enqueue(taskId, message, _nullishCoalesce(sessionId, () => ( _optionalChain([this, 'access', _173 => _173._transport, 'optionalAccess', _174 => _174.sessionId]))), maxQueueSize);
16443
16465
  }
16444
16466
  /**
16445
16467
  * Clears the message queue for a task and rejects any pending request resolvers.
@@ -16468,13 +16490,14 @@ var Protocol = class {
16468
16490
  * Uses polling to check for updates at the task's configured poll interval.
16469
16491
  * @param taskId The task ID to wait for
16470
16492
  * @param signal Abort signal to cancel the wait
16493
+ * @param sessionId Session of the request that waits, passed to the task store
16471
16494
  * @returns Promise that resolves when an update occurs or rejects if aborted
16472
16495
  */
16473
- async _waitForTaskUpdate(taskId, signal) {
16474
- let interval = _nullishCoalesce(_optionalChain([this, 'access', _170 => _170._options, 'optionalAccess', _171 => _171.defaultTaskPollInterval]), () => ( 1e3));
16496
+ async _waitForTaskUpdate(taskId, signal, sessionId) {
16497
+ let interval = _nullishCoalesce(_optionalChain([this, 'access', _175 => _175._options, 'optionalAccess', _176 => _176.defaultTaskPollInterval]), () => ( 1e3));
16475
16498
  try {
16476
- const task = await _optionalChain([this, 'access', _172 => _172._taskStore, 'optionalAccess', _173 => _173.getTask, 'call', _174 => _174(taskId)]);
16477
- if (_optionalChain([task, 'optionalAccess', _175 => _175.pollInterval])) {
16499
+ const task = await _optionalChain([this, 'access', _177 => _177._taskStore, 'optionalAccess', _178 => _178.getTask, 'call', _179 => _179(taskId, sessionId)]);
16500
+ if (_optionalChain([task, 'optionalAccess', _180 => _180.pollInterval])) {
16478
16501
  interval = task.pollInterval;
16479
16502
  }
16480
16503
  } catch (e8) {
@@ -16712,7 +16735,7 @@ var ExperimentalServerTasks = class {
16712
16735
  */
16713
16736
  createMessageStream(params, options) {
16714
16737
  const clientCapabilities = this._server.getClientCapabilities();
16715
- if ((params.tools || params.toolChoice) && !_optionalChain([clientCapabilities, 'optionalAccess', _176 => _176.sampling, 'optionalAccess', _177 => _177.tools])) {
16738
+ if ((params.tools || params.toolChoice) && !_optionalChain([clientCapabilities, 'optionalAccess', _181 => _181.sampling, 'optionalAccess', _182 => _182.tools])) {
16716
16739
  throw new Error("Client does not support sampling tools capability.");
16717
16740
  }
16718
16741
  if (params.messages.length > 0) {
@@ -16790,13 +16813,13 @@ var ExperimentalServerTasks = class {
16790
16813
  const mode = _nullishCoalesce(params.mode, () => ( "form"));
16791
16814
  switch (mode) {
16792
16815
  case "url": {
16793
- if (!_optionalChain([clientCapabilities, 'optionalAccess', _178 => _178.elicitation, 'optionalAccess', _179 => _179.url])) {
16816
+ if (!_optionalChain([clientCapabilities, 'optionalAccess', _183 => _183.elicitation, 'optionalAccess', _184 => _184.url])) {
16794
16817
  throw new Error("Client does not support url elicitation.");
16795
16818
  }
16796
16819
  break;
16797
16820
  }
16798
16821
  case "form": {
16799
- if (!_optionalChain([clientCapabilities, 'optionalAccess', _180 => _180.elicitation, 'optionalAccess', _181 => _181.form])) {
16822
+ if (!_optionalChain([clientCapabilities, 'optionalAccess', _185 => _185.elicitation, 'optionalAccess', _186 => _186.form])) {
16800
16823
  throw new Error("Client does not support form elicitation.");
16801
16824
  }
16802
16825
  break;
@@ -16865,7 +16888,7 @@ function assertToolsCallTaskCapability(requests, method, entityName) {
16865
16888
  }
16866
16889
  switch (method) {
16867
16890
  case "tools/call":
16868
- if (!_optionalChain([requests, 'access', _182 => _182.tools, 'optionalAccess', _183 => _183.call])) {
16891
+ if (!_optionalChain([requests, 'access', _187 => _187.tools, 'optionalAccess', _188 => _188.call])) {
16869
16892
  throw new Error(`${entityName} does not support task creation for tools/call (required for ${method})`);
16870
16893
  }
16871
16894
  break;
@@ -16879,12 +16902,12 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
16879
16902
  }
16880
16903
  switch (method) {
16881
16904
  case "sampling/createMessage":
16882
- if (!_optionalChain([requests, 'access', _184 => _184.sampling, 'optionalAccess', _185 => _185.createMessage])) {
16905
+ if (!_optionalChain([requests, 'access', _189 => _189.sampling, 'optionalAccess', _190 => _190.createMessage])) {
16883
16906
  throw new Error(`${entityName} does not support task creation for sampling/createMessage (required for ${method})`);
16884
16907
  }
16885
16908
  break;
16886
16909
  case "elicitation/create":
16887
- if (!_optionalChain([requests, 'access', _186 => _186.elicitation, 'optionalAccess', _187 => _187.create])) {
16910
+ if (!_optionalChain([requests, 'access', _191 => _191.elicitation, 'optionalAccess', _192 => _192.create])) {
16888
16911
  throw new Error(`${entityName} does not support task creation for elicitation/create (required for ${method})`);
16889
16912
  }
16890
16913
  break;
@@ -16907,14 +16930,14 @@ var Server = class extends Protocol {
16907
16930
  const currentLevel = this._loggingLevels.get(sessionId);
16908
16931
  return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
16909
16932
  };
16910
- this._capabilities = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _188 => _188.capabilities]), () => ( {}));
16911
- this._instructions = _optionalChain([options, 'optionalAccess', _189 => _189.instructions]);
16912
- this._jsonSchemaValidator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _190 => _190.jsonSchemaValidator]), () => ( new AjvJsonSchemaValidator()));
16933
+ this._capabilities = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _193 => _193.capabilities]), () => ( {}));
16934
+ this._instructions = _optionalChain([options, 'optionalAccess', _194 => _194.instructions]);
16935
+ this._jsonSchemaValidator = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _195 => _195.jsonSchemaValidator]), () => ( new AjvJsonSchemaValidator()));
16913
16936
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
16914
- this.setNotificationHandler(InitializedNotificationSchema, () => _optionalChain([this, 'access', _191 => _191.oninitialized, 'optionalCall', _192 => _192()]));
16937
+ this.setNotificationHandler(InitializedNotificationSchema, () => _optionalChain([this, 'access', _196 => _196.oninitialized, 'optionalCall', _197 => _197()]));
16915
16938
  if (this._capabilities.logging) {
16916
16939
  this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
16917
- const transportSessionId = extra.sessionId || _optionalChain([extra, 'access', _193 => _193.requestInfo, 'optionalAccess', _194 => _194.headers, 'access', _195 => _195["mcp-session-id"]]) || void 0;
16940
+ const transportSessionId = extra.sessionId || _optionalChain([extra, 'access', _198 => _198.requestInfo, 'optionalAccess', _199 => _199.headers, 'access', _200 => _200["mcp-session-id"]]) || void 0;
16918
16941
  const { level } = request.params;
16919
16942
  const parseResult = LoggingLevelSchema.safeParse(level);
16920
16943
  if (parseResult.success) {
@@ -16955,7 +16978,7 @@ var Server = class extends Protocol {
16955
16978
  */
16956
16979
  setRequestHandler(requestSchema, handler) {
16957
16980
  const shape = getObjectShape(requestSchema);
16958
- const methodSchema = _optionalChain([shape, 'optionalAccess', _196 => _196.method]);
16981
+ const methodSchema = _optionalChain([shape, 'optionalAccess', _201 => _201.method]);
16959
16982
  if (!methodSchema) {
16960
16983
  throw new Error("Schema is missing a method literal");
16961
16984
  }
@@ -16995,17 +17018,17 @@ var Server = class extends Protocol {
16995
17018
  assertCapabilityForMethod(method) {
16996
17019
  switch (method) {
16997
17020
  case "sampling/createMessage":
16998
- if (!_optionalChain([this, 'access', _197 => _197._clientCapabilities, 'optionalAccess', _198 => _198.sampling])) {
17021
+ if (!_optionalChain([this, 'access', _202 => _202._clientCapabilities, 'optionalAccess', _203 => _203.sampling])) {
16999
17022
  throw new Error(`Client does not support sampling (required for ${method})`);
17000
17023
  }
17001
17024
  break;
17002
17025
  case "elicitation/create":
17003
- if (!_optionalChain([this, 'access', _199 => _199._clientCapabilities, 'optionalAccess', _200 => _200.elicitation])) {
17026
+ if (!_optionalChain([this, 'access', _204 => _204._clientCapabilities, 'optionalAccess', _205 => _205.elicitation])) {
17004
17027
  throw new Error(`Client does not support elicitation (required for ${method})`);
17005
17028
  }
17006
17029
  break;
17007
17030
  case "roots/list":
17008
- if (!_optionalChain([this, 'access', _201 => _201._clientCapabilities, 'optionalAccess', _202 => _202.roots])) {
17031
+ if (!_optionalChain([this, 'access', _206 => _206._clientCapabilities, 'optionalAccess', _207 => _207.roots])) {
17009
17032
  throw new Error(`Client does not support listing roots (required for ${method})`);
17010
17033
  }
17011
17034
  break;
@@ -17037,7 +17060,7 @@ var Server = class extends Protocol {
17037
17060
  }
17038
17061
  break;
17039
17062
  case "notifications/elicitation/complete":
17040
- if (!_optionalChain([this, 'access', _203 => _203._clientCapabilities, 'optionalAccess', _204 => _204.elicitation, 'optionalAccess', _205 => _205.url])) {
17063
+ if (!_optionalChain([this, 'access', _208 => _208._clientCapabilities, 'optionalAccess', _209 => _209.elicitation, 'optionalAccess', _210 => _210.url])) {
17041
17064
  throw new Error(`Client does not support URL elicitation (required for ${method})`);
17042
17065
  }
17043
17066
  break;
@@ -17095,13 +17118,13 @@ var Server = class extends Protocol {
17095
17118
  }
17096
17119
  }
17097
17120
  assertTaskCapability(method) {
17098
- assertClientRequestTaskCapability(_optionalChain([this, 'access', _206 => _206._clientCapabilities, 'optionalAccess', _207 => _207.tasks, 'optionalAccess', _208 => _208.requests]), method, "Client");
17121
+ assertClientRequestTaskCapability(_optionalChain([this, 'access', _211 => _211._clientCapabilities, 'optionalAccess', _212 => _212.tasks, 'optionalAccess', _213 => _213.requests]), method, "Client");
17099
17122
  }
17100
17123
  assertTaskHandlerCapability(method) {
17101
17124
  if (!this._capabilities) {
17102
17125
  return;
17103
17126
  }
17104
- assertToolsCallTaskCapability(_optionalChain([this, 'access', _209 => _209._capabilities, 'access', _210 => _210.tasks, 'optionalAccess', _211 => _211.requests]), method, "Server");
17127
+ assertToolsCallTaskCapability(_optionalChain([this, 'access', _214 => _214._capabilities, 'access', _215 => _215.tasks, 'optionalAccess', _216 => _216.requests]), method, "Server");
17105
17128
  }
17106
17129
  async _oninitialize(request) {
17107
17130
  const requestedVersion = request.params.protocolVersion;
@@ -17136,7 +17159,7 @@ var Server = class extends Protocol {
17136
17159
  // Implementation
17137
17160
  async createMessage(params, options) {
17138
17161
  if (params.tools || params.toolChoice) {
17139
- if (!_optionalChain([this, 'access', _212 => _212._clientCapabilities, 'optionalAccess', _213 => _213.sampling, 'optionalAccess', _214 => _214.tools])) {
17162
+ if (!_optionalChain([this, 'access', _217 => _217._clientCapabilities, 'optionalAccess', _218 => _218.sampling, 'optionalAccess', _219 => _219.tools])) {
17140
17163
  throw new Error("Client does not support sampling tools capability.");
17141
17164
  }
17142
17165
  }
@@ -17179,14 +17202,14 @@ var Server = class extends Protocol {
17179
17202
  const mode = _nullishCoalesce(params.mode, () => ( "form"));
17180
17203
  switch (mode) {
17181
17204
  case "url": {
17182
- if (!_optionalChain([this, 'access', _215 => _215._clientCapabilities, 'optionalAccess', _216 => _216.elicitation, 'optionalAccess', _217 => _217.url])) {
17205
+ if (!_optionalChain([this, 'access', _220 => _220._clientCapabilities, 'optionalAccess', _221 => _221.elicitation, 'optionalAccess', _222 => _222.url])) {
17183
17206
  throw new Error("Client does not support url elicitation.");
17184
17207
  }
17185
17208
  const urlParams = params;
17186
17209
  return this.request({ method: "elicitation/create", params: urlParams }, ElicitResultSchema, options);
17187
17210
  }
17188
17211
  case "form": {
17189
- if (!_optionalChain([this, 'access', _218 => _218._clientCapabilities, 'optionalAccess', _219 => _219.elicitation, 'optionalAccess', _220 => _220.form])) {
17212
+ if (!_optionalChain([this, 'access', _223 => _223._clientCapabilities, 'optionalAccess', _224 => _224.elicitation, 'optionalAccess', _225 => _225.form])) {
17190
17213
  throw new Error("Client does not support form elicitation.");
17191
17214
  }
17192
17215
  const formParams = params.mode === "form" ? params : { ...params, mode: "form" };
@@ -17218,7 +17241,7 @@ var Server = class extends Protocol {
17218
17241
  * @returns A function that emits the completion notification when awaited.
17219
17242
  */
17220
17243
  createElicitationCompletionNotifier(elicitationId, options) {
17221
- if (!_optionalChain([this, 'access', _221 => _221._clientCapabilities, 'optionalAccess', _222 => _222.elicitation, 'optionalAccess', _223 => _223.url])) {
17244
+ if (!_optionalChain([this, 'access', _226 => _226._clientCapabilities, 'optionalAccess', _227 => _227.elicitation, 'optionalAccess', _228 => _228.url])) {
17222
17245
  throw new Error("Client does not support URL elicitation (required for notifications/elicitation/complete)");
17223
17246
  }
17224
17247
  return () => this.notification({
@@ -17271,7 +17294,7 @@ function isCompletable(schema) {
17271
17294
  }
17272
17295
  function getCompleter(schema) {
17273
17296
  const meta = schema[COMPLETABLE_SYMBOL];
17274
- return _optionalChain([meta, 'optionalAccess', _224 => _224.complete]);
17297
+ return _optionalChain([meta, 'optionalAccess', _229 => _229.complete]);
17275
17298
  }
17276
17299
  var McpZodTypeKind;
17277
17300
  (function(McpZodTypeKind2) {
@@ -17353,6 +17376,42 @@ var ExperimentalMcpServerTasks = class {
17353
17376
 
17354
17377
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
17355
17378
  var _zod2 = require('zod');
17379
+ function toolInputElementCount(value, max) {
17380
+ let count = 0;
17381
+ const stack = [value];
17382
+ while (stack.length > 0) {
17383
+ const node = stack.pop();
17384
+ if (node === null || typeof node !== "object")
17385
+ continue;
17386
+ if (Array.isArray(node)) {
17387
+ for (const child of node) {
17388
+ if (++count > max)
17389
+ return count;
17390
+ if (child !== null && typeof child === "object")
17391
+ stack.push(child);
17392
+ }
17393
+ } else {
17394
+ for (const key in node) {
17395
+ if (!Object.prototype.hasOwnProperty.call(node, key))
17396
+ continue;
17397
+ if (++count > max)
17398
+ return count;
17399
+ const child = node[key];
17400
+ if (child !== null && typeof child === "object")
17401
+ stack.push(child);
17402
+ }
17403
+ }
17404
+ }
17405
+ return count;
17406
+ }
17407
+ function resolveMaxToolInputElements(value) {
17408
+ if (value === void 0 || value === Infinity)
17409
+ return void 0;
17410
+ if (typeof value !== "number" || Number.isNaN(value) || value < 1) {
17411
+ throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
17412
+ }
17413
+ return value;
17414
+ }
17356
17415
  var McpServer = class {
17357
17416
  constructor(serverInfo, options) {
17358
17417
  this._registeredResources = {};
@@ -17364,6 +17423,7 @@ var McpServer = class {
17364
17423
  this._resourceHandlersInitialized = false;
17365
17424
  this._promptHandlersInitialized = false;
17366
17425
  this.server = new Server(serverInfo, options);
17426
+ this._maxToolInputElements = resolveMaxToolInputElements(_optionalChain([options, 'optionalAccess', _230 => _230.maxToolInputElements]));
17367
17427
  }
17368
17428
  /**
17369
17429
  * Access experimental features.
@@ -17444,7 +17504,7 @@ var McpServer = class {
17444
17504
  throw new McpError(ErrorCode.InvalidParams, `Tool ${request.params.name} disabled`);
17445
17505
  }
17446
17506
  const isTaskRequest = !!request.params.task;
17447
- const taskSupport = _optionalChain([tool, 'access', _225 => _225.execution, 'optionalAccess', _226 => _226.taskSupport]);
17507
+ const taskSupport = _optionalChain([tool, 'access', _231 => _231.execution, 'optionalAccess', _232 => _232.taskSupport]);
17448
17508
  const isTaskHandler = "createTask" in tool.handler;
17449
17509
  if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
17450
17510
  throw new McpError(ErrorCode.InternalError, `Tool ${request.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
@@ -17494,12 +17554,15 @@ var McpServer = class {
17494
17554
  * Validates tool input arguments against the tool's input schema.
17495
17555
  */
17496
17556
  async validateToolInput(tool, args, toolName) {
17557
+ if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) {
17558
+ throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
17559
+ }
17497
17560
  if (!tool.inputSchema) {
17498
17561
  return void 0;
17499
17562
  }
17500
17563
  const inputObj = normalizeObjectSchema(tool.inputSchema);
17501
17564
  const schemaToParse = _nullishCoalesce(inputObj, () => ( tool.inputSchema));
17502
- const parseResult = await safeParseAsync2(schemaToParse, args);
17565
+ const parseResult = await safeParseAsync2(schemaToParse, _nullishCoalesce(args, () => ( {})));
17503
17566
  if (!parseResult.success) {
17504
17567
  const error = "error" in parseResult ? parseResult.error : "Unknown error";
17505
17568
  const errorMessage = getParseErrorMessage(error);
@@ -17619,7 +17682,7 @@ var McpServer = class {
17619
17682
  return EMPTY_COMPLETION_RESULT;
17620
17683
  }
17621
17684
  const promptShape = getObjectShape(prompt.argsSchema);
17622
- const field = _optionalChain([promptShape, 'optionalAccess', _227 => _227[request.params.argument.name]]);
17685
+ const field = _optionalChain([promptShape, 'optionalAccess', _233 => _233[request.params.argument.name]]);
17623
17686
  if (!isCompletable(field)) {
17624
17687
  return EMPTY_COMPLETION_RESULT;
17625
17688
  }
@@ -17737,7 +17800,7 @@ var McpServer = class {
17737
17800
  }
17738
17801
  if (prompt.argsSchema) {
17739
17802
  const argsObj = normalizeObjectSchema(prompt.argsSchema);
17740
- const parseResult = await safeParseAsync2(argsObj, request.params.arguments);
17803
+ const parseResult = await safeParseAsync2(argsObj, _nullishCoalesce(request.params.arguments, () => ( {})));
17741
17804
  if (!parseResult.success) {
17742
17805
  const error = "error" in parseResult ? parseResult.error : "Unknown error";
17743
17806
  const errorMessage = getParseErrorMessage(error);
@@ -17897,7 +17960,7 @@ var McpServer = class {
17897
17960
  this._registeredPrompts[name] = registeredPrompt;
17898
17961
  if (argsSchema) {
17899
17962
  const hasCompletable = Object.values(argsSchema).some((field) => {
17900
- const inner = field instanceof _zod2.ZodOptional ? _optionalChain([field, 'access', _228 => _228._def, 'optionalAccess', _229 => _229.innerType]) : field;
17963
+ const inner = field instanceof _zod2.ZodOptional ? _optionalChain([field, 'access', _234 => _234._def, 'optionalAccess', _235 => _235.innerType]) : field;
17901
17964
  return isCompletable(inner);
17902
17965
  });
17903
17966
  if (hasCompletable) {
@@ -18118,7 +18181,7 @@ function promptArgumentsFromSchema(schema) {
18118
18181
  }
18119
18182
  function getMethodValue(schema) {
18120
18183
  const shape = getObjectShape(schema);
18121
- const methodSchema = _optionalChain([shape, 'optionalAccess', _230 => _230.method]);
18184
+ const methodSchema = _optionalChain([shape, 'optionalAccess', _236 => _236.method]);
18122
18185
  if (!methodSchema) {
18123
18186
  throw new Error("Schema is missing a method literal");
18124
18187
  }
@@ -18151,10 +18214,10 @@ var _process = require('process'); var _process2 = _interopRequireDefault(_proce
18151
18214
  var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
18152
18215
  var ReadBuffer = class {
18153
18216
  constructor(options) {
18154
- this._maxBufferSize = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _231 => _231.maxBufferSize]), () => ( STDIO_DEFAULT_MAX_BUFFER_SIZE));
18217
+ this._maxBufferSize = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _237 => _237.maxBufferSize]), () => ( STDIO_DEFAULT_MAX_BUFFER_SIZE));
18155
18218
  }
18156
18219
  append(chunk) {
18157
- const newSize = (_nullishCoalesce(_optionalChain([this, 'access', _232 => _232._buffer, 'optionalAccess', _233 => _233.length]), () => ( 0))) + chunk.length;
18220
+ const newSize = (_nullishCoalesce(_optionalChain([this, 'access', _238 => _238._buffer, 'optionalAccess', _239 => _239.length]), () => ( 0))) + chunk.length;
18158
18221
  if (newSize > this._maxBufferSize) {
18159
18222
  this.clear();
18160
18223
  throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
@@ -18195,15 +18258,15 @@ var StdioServerTransport = class {
18195
18258
  this._readBuffer.append(chunk);
18196
18259
  this.processReadBuffer();
18197
18260
  } catch (error) {
18198
- _optionalChain([this, 'access', _234 => _234.onerror, 'optionalCall', _235 => _235(error)]);
18261
+ _optionalChain([this, 'access', _240 => _240.onerror, 'optionalCall', _241 => _241(error)]);
18199
18262
  this.close().catch(() => {
18200
18263
  });
18201
18264
  }
18202
18265
  };
18203
18266
  this._onerror = (error) => {
18204
- _optionalChain([this, 'access', _236 => _236.onerror, 'optionalCall', _237 => _237(error)]);
18267
+ _optionalChain([this, 'access', _242 => _242.onerror, 'optionalCall', _243 => _243(error)]);
18205
18268
  };
18206
- this._readBuffer = new ReadBuffer({ maxBufferSize: _optionalChain([options, 'optionalAccess', _238 => _238.maxBufferSize]) });
18269
+ this._readBuffer = new ReadBuffer({ maxBufferSize: _optionalChain([options, 'optionalAccess', _244 => _244.maxBufferSize]) });
18207
18270
  }
18208
18271
  /**
18209
18272
  * Starts listening for messages on stdin.
@@ -18223,9 +18286,9 @@ var StdioServerTransport = class {
18223
18286
  if (message === null) {
18224
18287
  break;
18225
18288
  }
18226
- _optionalChain([this, 'access', _239 => _239.onmessage, 'optionalCall', _240 => _240(message)]);
18289
+ _optionalChain([this, 'access', _245 => _245.onmessage, 'optionalCall', _246 => _246(message)]);
18227
18290
  } catch (error) {
18228
- _optionalChain([this, 'access', _241 => _241.onerror, 'optionalCall', _242 => _242(error)]);
18291
+ _optionalChain([this, 'access', _247 => _247.onerror, 'optionalCall', _248 => _248(error)]);
18229
18292
  }
18230
18293
  }
18231
18294
  }
@@ -18237,7 +18300,7 @@ var StdioServerTransport = class {
18237
18300
  this._stdin.pause();
18238
18301
  }
18239
18302
  this._readBuffer.clear();
18240
- _optionalChain([this, 'access', _243 => _243.onclose, 'optionalCall', _244 => _244()]);
18303
+ _optionalChain([this, 'access', _249 => _249.onclose, 'optionalCall', _250 => _250()]);
18241
18304
  }
18242
18305
  send(message) {
18243
18306
  return new Promise((resolve) => {
@@ -18254,7 +18317,7 @@ var StdioServerTransport = class {
18254
18317
  // package.json
18255
18318
  var package_default = {
18256
18319
  name: "@umbraco-cms/mcp-dev",
18257
- version: "17.6.8",
18320
+ version: "17.6.9",
18258
18321
  type: "module",
18259
18322
  description: "A model context protocol (MCP) server for Umbraco CMS",
18260
18323
  main: "dist/index.js",
@@ -18325,8 +18388,8 @@ var package_default = {
18325
18388
  "@modelcontextprotocol/sdk": "^1.28.0",
18326
18389
  "@types/uuid": "^10.0.0",
18327
18390
  "@types/yargs": "^17.0.33",
18328
- "@umbraco-cms/mcp-hosted": "^1.0.0-beta.41",
18329
- "@umbraco-cms/mcp-server-sdk": "^1.0.0-beta.41",
18391
+ "@umbraco-cms/mcp-hosted": "^1.0.0-beta.45",
18392
+ "@umbraco-cms/mcp-server-sdk": "^1.0.0-beta.45",
18330
18393
  dotenv: "^16.5.0",
18331
18394
  "form-data": "^4.0.4",
18332
18395
  "mime-types": "^3.0.1",
@@ -18420,7 +18483,7 @@ var CollectionResolver = {
18420
18483
  const collectionMap = new Map(collections.map((c) => [c.metadata.name, c]));
18421
18484
  function addDependencies(collectionName) {
18422
18485
  const collection = collectionMap.get(collectionName);
18423
- if (_optionalChain([collection, 'optionalAccess', _245 => _245.metadata, 'access', _246 => _246.dependencies])) {
18486
+ if (_optionalChain([collection, 'optionalAccess', _251 => _251.metadata, 'access', _252 => _252.dependencies])) {
18424
18487
  collection.metadata.dependencies.forEach((dep) => {
18425
18488
  if (!result.has(dep)) {
18426
18489
  result.add(dep);
@@ -18481,7 +18544,7 @@ var ToolRegistrar = {
18481
18544
  tools.forEach((tool) => {
18482
18545
  const userHasPermission = tool.enabled === void 0 || tool.enabled(user);
18483
18546
  if (!userHasPermission) return;
18484
- const readOnlyHint = _nullishCoalesce(_optionalChain([tool, 'access', _247 => _247.annotations, 'optionalAccess', _248 => _248.readOnlyHint]), () => ( false));
18547
+ const readOnlyHint = _nullishCoalesce(_optionalChain([tool, 'access', _253 => _253.annotations, 'optionalAccess', _254 => _254.readOnlyHint]), () => ( false));
18485
18548
  if (readonlyMode && !readOnlyHint) {
18486
18549
  filteredTools.push(tool.name);
18487
18550
  return;
@@ -18489,8 +18552,8 @@ var ToolRegistrar = {
18489
18552
  if (!ToolRegistrar.isToolAllowedBySlices(tool.slices, config.enabledSlices, config.disabledSlices)) {
18490
18553
  return;
18491
18554
  }
18492
- if (_optionalChain([config, 'access', _249 => _249.disabledTools, 'optionalAccess', _250 => _250.includes, 'call', _251 => _251(tool.name)])) return;
18493
- if (_optionalChain([config, 'access', _252 => _252.enabledTools, 'optionalAccess', _253 => _253.length]) && !config.enabledTools.includes(tool.name)) return;
18555
+ if (_optionalChain([config, 'access', _255 => _255.disabledTools, 'optionalAccess', _256 => _256.includes, 'call', _257 => _257(tool.name)])) return;
18556
+ if (_optionalChain([config, 'access', _258 => _258.enabledTools, 'optionalAccess', _259 => _259.length]) && !config.enabledTools.includes(tool.name)) return;
18494
18557
  const annotations = _mcpserversdk.createToolAnnotations.call(void 0, tool);
18495
18558
  server.registerTool(tool.name, {
18496
18559
  description: tool.description,
@@ -18565,7 +18628,7 @@ var main = async () => {
18565
18628
  // client was generated against. Override to point at a different major.
18566
18629
  // (`?.trim() ||`, not `??`: an env var set to an empty string must still
18567
18630
  // fall back, or the check silently no-ops with no log output at all.)
18568
- expectedUmbracoMajor: _optionalChain([process, 'access', _254 => _254.env, 'access', _255 => _255.UMBRACO_EXPECTED_MAJOR, 'optionalAccess', _256 => _256.trim, 'call', _257 => _257()]) || UMBRACO_TARGET_MAJOR,
18631
+ expectedUmbracoMajor: _optionalChain([process, 'access', _260 => _260.env, 'access', _261 => _261.UMBRACO_EXPECTED_MAJOR, 'optionalAccess', _262 => _262.trim, 'call', _263 => _263()]) || UMBRACO_TARGET_MAJOR,
18569
18632
  client: { getServerInformation: async () => serverInfo }
18570
18633
  });
18571
18634
  _mcpserversdk.configureVersionCheckHook.call(void 0, );