@inerrata-corporation/errata 2.0.23-dev.5035 → 2.0.23-dev.5081

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.
@@ -22742,7 +22742,7 @@ function object(shape, params) {
22742
22742
  return new ZodMiniObject(def);
22743
22743
  }
22744
22744
 
22745
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
22745
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
22746
22746
  function isZ4Schema(s) {
22747
22747
  const schema = s;
22748
22748
  return !!schema._zod;
@@ -22826,17 +22826,33 @@ function normalizeObjectSchema(schema) {
22826
22826
  }
22827
22827
  return void 0;
22828
22828
  }
22829
+ function getDotPath(path) {
22830
+ if (path.length === 0) {
22831
+ return "object root";
22832
+ }
22833
+ return path.reduce((acc, seg, index) => {
22834
+ if (index === 0) {
22835
+ return String(seg);
22836
+ }
22837
+ if (typeof seg === "number") {
22838
+ return `${acc}[${seg}]`;
22839
+ }
22840
+ return `${acc}.${seg}`;
22841
+ }, "");
22842
+ }
22829
22843
  function getParseErrorMessage(error48) {
22830
22844
  if (error48 && typeof error48 === "object") {
22845
+ if ("issues" in error48 && Array.isArray(error48.issues) && error48.issues.length > 0) {
22846
+ return error48.issues.map((i) => {
22847
+ if (!i.path?.length) {
22848
+ return i.message;
22849
+ }
22850
+ return `${i.message} at ${getDotPath(i.path)}`;
22851
+ }).join("\n");
22852
+ }
22831
22853
  if ("message" in error48 && typeof error48.message === "string") {
22832
22854
  return error48.message;
22833
22855
  }
22834
- if ("issues" in error48 && Array.isArray(error48.issues) && error48.issues.length > 0) {
22835
- const firstIssue = error48.issues[0];
22836
- if (firstIssue && typeof firstIssue === "object" && "message" in firstIssue) {
22837
- return String(firstIssue.message);
22838
- }
22839
- }
22840
22856
  try {
22841
22857
  return JSON.stringify(error48);
22842
22858
  } catch {
@@ -25032,7 +25048,7 @@ function date4(params) {
25032
25048
  // ../../node_modules/.pnpm/zod@4.3.6/node_modules/zod/v4/classic/external.js
25033
25049
  config(en_default2());
25034
25050
 
25035
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25051
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
25036
25052
  var LATEST_PROTOCOL_VERSION = "2025-11-25";
25037
25053
  var SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-06-18", "2025-03-26", "2024-11-05", "2024-10-07"];
25038
25054
  var RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -26563,7 +26579,7 @@ var UrlElicitationRequiredError = class extends McpError {
26563
26579
  }
26564
26580
  };
26565
26581
 
26566
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
26582
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/interfaces.js
26567
26583
  function isTerminal(status) {
26568
26584
  return status === "completed" || status === "failed" || status === "cancelled";
26569
26585
  }
@@ -27852,7 +27868,7 @@ var zodToJsonSchema = (schema, options) => {
27852
27868
  return combined;
27853
27869
  };
27854
27870
 
27855
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
27871
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-json-schema-compat.js
27856
27872
  function mapMiniTarget(t) {
27857
27873
  if (!t)
27858
27874
  return "draft-7";
@@ -27894,7 +27910,7 @@ function parseWithCompat(schema, data) {
27894
27910
  return result2.data;
27895
27911
  }
27896
27912
 
27897
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
27913
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
27898
27914
  var DEFAULT_REQUEST_TIMEOUT_MSEC = 6e4;
27899
27915
  var Protocol = class {
27900
27916
  constructor(_options) {
@@ -27935,6 +27951,9 @@ var Protocol = class {
27935
27951
  this.setRequestHandler(GetTaskPayloadRequestSchema, async (request, extra) => {
27936
27952
  const handleTaskResult = async () => {
27937
27953
  const taskId = request.params.taskId;
27954
+ if (!await this._taskStore.getTask(taskId, extra.sessionId)) {
27955
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
27956
+ }
27938
27957
  if (this._taskMessageQueue) {
27939
27958
  let queuedMessage;
27940
27959
  while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
@@ -27965,12 +27984,12 @@ var Protocol = class {
27965
27984
  throw new McpError(ErrorCode.InvalidParams, `Task not found: ${taskId}`);
27966
27985
  }
27967
27986
  if (!isTerminal(task.status)) {
27968
- await this._waitForTaskUpdate(taskId, extra.signal);
27987
+ await this._waitForTaskUpdate(taskId, extra.signal, extra.sessionId);
27969
27988
  return await handleTaskResult();
27970
27989
  }
27971
27990
  if (isTerminal(task.status)) {
27972
27991
  const result2 = await this._taskStore.getTaskResult(taskId, extra.sessionId);
27973
- this._clearTaskQueue(taskId);
27992
+ this._clearTaskQueue(taskId, extra.sessionId);
27974
27993
  return {
27975
27994
  ...result2,
27976
27995
  _meta: {
@@ -28007,7 +28026,7 @@ var Protocol = class {
28007
28026
  throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
28008
28027
  }
28009
28028
  await this._taskStore.updateTaskStatus(request.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
28010
- this._clearTaskQueue(request.params.taskId);
28029
+ this._clearTaskQueue(request.params.taskId, extra.sessionId);
28011
28030
  const cancelledTask = await this._taskStore.getTask(request.params.taskId, extra.sessionId);
28012
28031
  if (!cancelledTask) {
28013
28032
  throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request.params.taskId}`);
@@ -28135,6 +28154,19 @@ var Protocol = class {
28135
28154
  const handler = this._requestHandlers.get(request.method) ?? this.fallbackRequestHandler;
28136
28155
  const capturedTransport = this._transport;
28137
28156
  const relatedTaskId = request.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
28157
+ const sessionId = capturedTransport?.sessionId;
28158
+ const store = this._taskStore;
28159
+ let relatedTaskFound = true;
28160
+ let relatedTaskLookup;
28161
+ if (relatedTaskId && store && this._taskMessageQueue && sessionId !== void 0) {
28162
+ relatedTaskFound = false;
28163
+ relatedTaskLookup = (async () => {
28164
+ if (!await store.getTask(relatedTaskId, sessionId)) {
28165
+ throw new McpError(ErrorCode.InvalidParams, `Task not found: ${relatedTaskId}`);
28166
+ }
28167
+ relatedTaskFound = true;
28168
+ })();
28169
+ }
28138
28170
  if (handler === void 0) {
28139
28171
  const errorResponse = {
28140
28172
  jsonrpc: "2.0",
@@ -28144,7 +28176,10 @@ var Protocol = class {
28144
28176
  message: "Method not found"
28145
28177
  }
28146
28178
  };
28147
- if (relatedTaskId && this._taskMessageQueue) {
28179
+ if (relatedTaskId && relatedTaskLookup) {
28180
+ const queuedError = { type: "error", message: errorResponse, timestamp: Date.now() };
28181
+ relatedTaskLookup.then(() => this._enqueueTaskMessage(relatedTaskId, queuedError, sessionId), () => capturedTransport?.send(errorResponse)).catch((error48) => this._onerror(new Error(`Failed to send an error response: ${error48}`)));
28182
+ } else if (relatedTaskId && this._taskMessageQueue) {
28148
28183
  this._enqueueTaskMessage(relatedTaskId, {
28149
28184
  type: "error",
28150
28185
  message: errorResponse,
@@ -28195,7 +28230,10 @@ var Protocol = class {
28195
28230
  closeSSEStream: extra?.closeSSEStream,
28196
28231
  closeStandaloneSSEStream: extra?.closeStandaloneSSEStream
28197
28232
  };
28198
- Promise.resolve().then(() => {
28233
+ (relatedTaskLookup ?? Promise.resolve()).then(() => {
28234
+ if (relatedTaskLookup && abortController.signal.aborted) {
28235
+ throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
28236
+ }
28199
28237
  if (taskCreationParams) {
28200
28238
  this.assertTaskHandlerCapability(request.method);
28201
28239
  }
@@ -28230,7 +28268,7 @@ var Protocol = class {
28230
28268
  ...error48["data"] !== void 0 && { data: error48["data"] }
28231
28269
  }
28232
28270
  };
28233
- if (relatedTaskId && this._taskMessageQueue) {
28271
+ if (relatedTaskId && this._taskMessageQueue && relatedTaskFound) {
28234
28272
  await this._enqueueTaskMessage(relatedTaskId, {
28235
28273
  type: "error",
28236
28274
  message: errorResponse,
@@ -28710,7 +28748,7 @@ var Protocol = class {
28710
28748
  throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");
28711
28749
  }
28712
28750
  const maxQueueSize = this._options?.maxTaskQueueSize;
28713
- await this._taskMessageQueue.enqueue(taskId, message, sessionId, maxQueueSize);
28751
+ await this._taskMessageQueue.enqueue(taskId, message, sessionId ?? this._transport?.sessionId, maxQueueSize);
28714
28752
  }
28715
28753
  /**
28716
28754
  * Clears the message queue for a task and rejects any pending request resolvers.
@@ -28739,12 +28777,13 @@ var Protocol = class {
28739
28777
  * Uses polling to check for updates at the task's configured poll interval.
28740
28778
  * @param taskId The task ID to wait for
28741
28779
  * @param signal Abort signal to cancel the wait
28780
+ * @param sessionId Session of the request that waits, passed to the task store
28742
28781
  * @returns Promise that resolves when an update occurs or rejects if aborted
28743
28782
  */
28744
- async _waitForTaskUpdate(taskId, signal) {
28783
+ async _waitForTaskUpdate(taskId, signal, sessionId) {
28745
28784
  let interval = this._options?.defaultTaskPollInterval ?? 1e3;
28746
28785
  try {
28747
- const task = await this._taskStore?.getTask(taskId);
28786
+ const task = await this._taskStore?.getTask(taskId, sessionId);
28748
28787
  if (task?.pollInterval) {
28749
28788
  interval = task.pollInterval;
28750
28789
  }
@@ -28848,7 +28887,7 @@ function mergeCapabilities(base, additional) {
28848
28887
  return result2;
28849
28888
  }
28850
28889
 
28851
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
28890
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/validation/ajv-provider.js
28852
28891
  var import_ajv = __toESM(require_ajv(), 1);
28853
28892
  var import_ajv_formats = __toESM(require_dist(), 1);
28854
28893
  function createDefaultAjvInstance() {
@@ -28916,7 +28955,7 @@ var AjvJsonSchemaValidator = class {
28916
28955
  }
28917
28956
  };
28918
28957
 
28919
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
28958
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/server.js
28920
28959
  var ExperimentalServerTasks = class {
28921
28960
  constructor(_server) {
28922
28961
  this._server = _server;
@@ -29129,7 +29168,7 @@ var ExperimentalServerTasks = class {
29129
29168
  }
29130
29169
  };
29131
29170
 
29132
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
29171
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/helpers.js
29133
29172
  function assertToolsCallTaskCapability(requests, method, entityName) {
29134
29173
  if (!requests) {
29135
29174
  throw new Error(`${entityName} does not support task creation (required for ${method})`);
@@ -29164,7 +29203,7 @@ function assertClientRequestTaskCapability(requests, method, entityName) {
29164
29203
  }
29165
29204
  }
29166
29205
 
29167
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
29206
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
29168
29207
  var Server = class extends Protocol {
29169
29208
  /**
29170
29209
  * Initializes this server with the given name and version information.
@@ -29230,16 +29269,7 @@ var Server = class extends Protocol {
29230
29269
  if (!methodSchema) {
29231
29270
  throw new Error("Schema is missing a method literal");
29232
29271
  }
29233
- let methodValue;
29234
- if (isZ4Schema(methodSchema)) {
29235
- const v4Schema = methodSchema;
29236
- const v4Def = v4Schema._zod?.def;
29237
- methodValue = v4Def?.value ?? v4Schema.value;
29238
- } else {
29239
- const v3Schema = methodSchema;
29240
- const legacyDef = v3Schema._def;
29241
- methodValue = legacyDef?.value ?? v3Schema.value;
29242
- }
29272
+ const methodValue = getLiteralValue(methodSchema);
29243
29273
  if (typeof methodValue !== "string") {
29244
29274
  throw new Error("Schema method literal must be a string");
29245
29275
  }
@@ -29544,7 +29574,7 @@ var Server = class extends Protocol {
29544
29574
  }
29545
29575
  };
29546
29576
 
29547
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
29577
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/completable.js
29548
29578
  var COMPLETABLE_SYMBOL = /* @__PURE__ */ Symbol.for("mcp.completable");
29549
29579
  function isCompletable(schema) {
29550
29580
  return !!schema && typeof schema === "object" && COMPLETABLE_SYMBOL in schema;
@@ -29558,7 +29588,7 @@ var McpZodTypeKind;
29558
29588
  McpZodTypeKind2["Completable"] = "McpCompletable";
29559
29589
  })(McpZodTypeKind || (McpZodTypeKind = {}));
29560
29590
 
29561
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
29591
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/toolNameValidation.js
29562
29592
  var TOOL_NAME_REGEX = /^[A-Za-z0-9._-]{1,128}$/;
29563
29593
  function validateToolName(name) {
29564
29594
  const warnings = [];
@@ -29616,7 +29646,7 @@ function validateAndWarnToolName(name) {
29616
29646
  return result2.isValid;
29617
29647
  }
29618
29648
 
29619
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
29649
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/experimental/tasks/mcp-server.js
29620
29650
  var ExperimentalMcpServerTasks = class {
29621
29651
  constructor(_mcpServer) {
29622
29652
  this._mcpServer = _mcpServer;
@@ -29631,7 +29661,43 @@ var ExperimentalMcpServerTasks = class {
29631
29661
  }
29632
29662
  };
29633
29663
 
29634
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
29664
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/mcp.js
29665
+ function toolInputElementCount(value, max) {
29666
+ let count = 0;
29667
+ const stack = [value];
29668
+ while (stack.length > 0) {
29669
+ const node = stack.pop();
29670
+ if (node === null || typeof node !== "object")
29671
+ continue;
29672
+ if (Array.isArray(node)) {
29673
+ for (const child of node) {
29674
+ if (++count > max)
29675
+ return count;
29676
+ if (child !== null && typeof child === "object")
29677
+ stack.push(child);
29678
+ }
29679
+ } else {
29680
+ for (const key in node) {
29681
+ if (!Object.prototype.hasOwnProperty.call(node, key))
29682
+ continue;
29683
+ if (++count > max)
29684
+ return count;
29685
+ const child = node[key];
29686
+ if (child !== null && typeof child === "object")
29687
+ stack.push(child);
29688
+ }
29689
+ }
29690
+ }
29691
+ return count;
29692
+ }
29693
+ function resolveMaxToolInputElements(value) {
29694
+ if (value === void 0 || value === Infinity)
29695
+ return void 0;
29696
+ if (typeof value !== "number" || Number.isNaN(value) || value < 1) {
29697
+ throw new RangeError(`maxToolInputElements must be a number of at least 1, or Infinity, got ${String(value)}`);
29698
+ }
29699
+ return value;
29700
+ }
29635
29701
  var McpServer = class {
29636
29702
  constructor(serverInfo, options) {
29637
29703
  this._registeredResources = {};
@@ -29643,6 +29709,16 @@ var McpServer = class {
29643
29709
  this._resourceHandlersInitialized = false;
29644
29710
  this._promptHandlersInitialized = false;
29645
29711
  this.server = new Server(serverInfo, options);
29712
+ this._maxToolInputElements = resolveMaxToolInputElements(options?.maxToolInputElements);
29713
+ if (options?.capabilities?.tools) {
29714
+ this.setToolRequestHandlers();
29715
+ }
29716
+ if (options?.capabilities?.resources) {
29717
+ this.setResourceRequestHandlers();
29718
+ }
29719
+ if (options?.capabilities?.prompts) {
29720
+ this.setPromptRequestHandlers();
29721
+ }
29646
29722
  }
29647
29723
  /**
29648
29724
  * Access experimental features.
@@ -29773,12 +29849,15 @@ var McpServer = class {
29773
29849
  * Validates tool input arguments against the tool's input schema.
29774
29850
  */
29775
29851
  async validateToolInput(tool, args, toolName) {
29852
+ if (this._maxToolInputElements !== void 0 && toolInputElementCount(args, this._maxToolInputElements) > this._maxToolInputElements) {
29853
+ throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for tool ${toolName}: arguments contain more than the maximum of ${this._maxToolInputElements} elements`);
29854
+ }
29776
29855
  if (!tool.inputSchema) {
29777
29856
  return void 0;
29778
29857
  }
29779
29858
  const inputObj = normalizeObjectSchema(tool.inputSchema);
29780
29859
  const schemaToParse = inputObj ?? tool.inputSchema;
29781
- const parseResult = await safeParseAsync2(schemaToParse, args);
29860
+ const parseResult = await safeParseAsync2(schemaToParse, args ?? {});
29782
29861
  if (!parseResult.success) {
29783
29862
  const error48 = "error" in parseResult ? parseResult.error : "Unknown error";
29784
29863
  const errorMessage = getParseErrorMessage(error48);
@@ -30016,7 +30095,7 @@ var McpServer = class {
30016
30095
  }
30017
30096
  if (prompt.argsSchema) {
30018
30097
  const argsObj = normalizeObjectSchema(prompt.argsSchema);
30019
- const parseResult = await safeParseAsync2(argsObj, request.params.arguments);
30098
+ const parseResult = await safeParseAsync2(argsObj, request.params.arguments ?? {});
30020
30099
  if (!parseResult.success) {
30021
30100
  const error48 = "error" in parseResult ? parseResult.error : "Unknown error";
30022
30101
  const errorMessage = getParseErrorMessage(error48);
@@ -30423,12 +30502,21 @@ var EMPTY_COMPLETION_RESULT = {
30423
30502
  }
30424
30503
  };
30425
30504
 
30426
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30505
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30427
30506
  import process3 from "node:process";
30428
30507
 
30429
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
30508
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
30509
+ var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
30430
30510
  var ReadBuffer = class {
30511
+ constructor(options) {
30512
+ this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
30513
+ }
30431
30514
  append(chunk) {
30515
+ const newSize = (this._buffer?.length ?? 0) + chunk.length;
30516
+ if (newSize > this._maxBufferSize) {
30517
+ this.clear();
30518
+ throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
30519
+ }
30432
30520
  this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
30433
30521
  }
30434
30522
  readMessage() {
@@ -30454,20 +30542,26 @@ function serializeMessage(message) {
30454
30542
  return JSON.stringify(message) + "\n";
30455
30543
  }
30456
30544
 
30457
- // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.29.0_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30545
+ // ../../node_modules/.pnpm/@modelcontextprotocol+sdk@1.32.2_@cfworker+json-schema@4.1.1_zod@4.3.6/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
30458
30546
  var StdioServerTransport = class {
30459
- constructor(_stdin = process3.stdin, _stdout = process3.stdout) {
30547
+ constructor(_stdin = process3.stdin, _stdout = process3.stdout, options) {
30460
30548
  this._stdin = _stdin;
30461
30549
  this._stdout = _stdout;
30462
- this._readBuffer = new ReadBuffer();
30463
30550
  this._started = false;
30464
30551
  this._ondata = (chunk) => {
30465
- this._readBuffer.append(chunk);
30466
- this.processReadBuffer();
30552
+ try {
30553
+ this._readBuffer.append(chunk);
30554
+ this.processReadBuffer();
30555
+ } catch (error48) {
30556
+ this.onerror?.(error48);
30557
+ this.close().catch(() => {
30558
+ });
30559
+ }
30467
30560
  };
30468
30561
  this._onerror = (error48) => {
30469
30562
  this.onerror?.(error48);
30470
30563
  };
30564
+ this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
30471
30565
  }
30472
30566
  /**
30473
30567
  * Starts listening for messages on stdin.