@usex/mikrotik-mcp 5.11.0 → 5.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -30223,7 +30223,7 @@ var cache2 = null;
30223
30223
  async function gateway() {
30224
30224
  if (cache2)
30225
30225
  return cache2;
30226
- const { moduleCatalog } = await import("./shared/cli-m947aqb2.js");
30226
+ const { moduleCatalog } = await import("./shared/cli-e879nc0x.js");
30227
30227
  const forIndex = [];
30228
30228
  const byName = new Map;
30229
30229
  for (const mod of moduleCatalog) {
@@ -52449,7 +52449,7 @@ var riskByTool = null;
52449
52449
  async function riskIndex() {
52450
52450
  if (riskByTool)
52451
52451
  return riskByTool;
52452
- const { moduleCatalog } = await import("./shared/cli-m947aqb2.js");
52452
+ const { moduleCatalog } = await import("./shared/cli-e879nc0x.js");
52453
52453
  const index = new Map;
52454
52454
  for (const mod of moduleCatalog) {
52455
52455
  for (const tool of mod.tools)
@@ -67322,6 +67322,50 @@ function isJsonContentType(header) {
67322
67322
  return mediaTypeEssence(header) === "application/json";
67323
67323
  }
67324
67324
 
67325
+ // node_modules/@modelcontextprotocol/sdk/dist/esm/server/requestBody.js
67326
+ var DEFAULT_MAX_REQUEST_BODY_SIZE = 4 * 1024 * 1024;
67327
+ var MAX_BATCH_SIZE = 100;
67328
+ function requestBodyTooLargeMessage(maxBytes) {
67329
+ return `Payload Too Large: Request body must not exceed ${maxBytes} bytes`;
67330
+ }
67331
+ function resolveMaxRequestBodySize(value) {
67332
+ if (value === undefined) {
67333
+ return DEFAULT_MAX_REQUEST_BODY_SIZE;
67334
+ }
67335
+ if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
67336
+ throw new RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(value)}`);
67337
+ }
67338
+ return value;
67339
+ }
67340
+ async function readRequestBody(request, maxBytes = DEFAULT_MAX_REQUEST_BODY_SIZE) {
67341
+ if (Number(request.headers.get("content-length")) > maxBytes) {
67342
+ return { tooLarge: true };
67343
+ }
67344
+ if (request.body === null) {
67345
+ return { tooLarge: false, text: "" };
67346
+ }
67347
+ const reader = request.body.getReader();
67348
+ const decoder = new TextDecoder;
67349
+ let received = 0;
67350
+ let text = "";
67351
+ try {
67352
+ for (;; ) {
67353
+ const { done, value } = await reader.read();
67354
+ if (done) {
67355
+ break;
67356
+ }
67357
+ received += value.byteLength;
67358
+ if (received > maxBytes) {
67359
+ return { tooLarge: true };
67360
+ }
67361
+ text += decoder.decode(value, { stream: true });
67362
+ }
67363
+ } finally {
67364
+ reader.releaseLock();
67365
+ }
67366
+ return { tooLarge: false, text: text + decoder.decode() };
67367
+ }
67368
+
67325
67369
  // node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js
67326
67370
  var DEFAULT_SSE_KEEP_ALIVE_MS = 15000;
67327
67371
  var MAX_TIMER_DELAY_MS = 2 ** 31 - 1;
@@ -68203,6 +68247,7 @@ class WebStandardStreamableHTTPServerTransport {
68203
68247
  this._enableDnsRebindingProtection = options.enableDnsRebindingProtection ?? false;
68204
68248
  this._retryInterval = options.retryInterval;
68205
68249
  this._keepAliveMs = options.keepAliveMs ?? DEFAULT_SSE_KEEP_ALIVE_MS;
68250
+ this._maxRequestBodySize = resolveMaxRequestBodySize(options.maxRequestBodySize);
68206
68251
  }
68207
68252
  startKeepAlive(controller, encoder) {
68208
68253
  if (this._closed)
@@ -68519,12 +68564,22 @@ data:
68519
68564
  rawMessage = options.parsedBody;
68520
68565
  } else {
68521
68566
  try {
68522
- rawMessage = await req.json();
68567
+ const body = await readRequestBody(req, this._maxRequestBodySize);
68568
+ if (body.tooLarge) {
68569
+ const message = requestBodyTooLargeMessage(this._maxRequestBodySize);
68570
+ this.onerror?.(new Error(message));
68571
+ return this.createJsonErrorResponse(413, -32000, message);
68572
+ }
68573
+ rawMessage = JSON.parse(body.text);
68523
68574
  } catch {
68524
68575
  this.onerror?.(new Error("Parse error: Invalid JSON"));
68525
68576
  return this.createJsonErrorResponse(400, -32700, "Parse error: Invalid JSON");
68526
68577
  }
68527
68578
  }
68579
+ if (Array.isArray(rawMessage) && rawMessage.length > MAX_BATCH_SIZE) {
68580
+ this.onerror?.(new Error(`Invalid Request: Batch must not exceed ${MAX_BATCH_SIZE} messages`));
68581
+ return this.createJsonErrorResponse(400, -32600, `Invalid Request: Batch must not exceed ${MAX_BATCH_SIZE} messages`);
68582
+ }
68528
68583
  let messages;
68529
68584
  try {
68530
68585
  if (Array.isArray(rawMessage)) {