@modelcontextprotocol/server-system-monitor 1.6.0 → 1.7.1

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.js CHANGED
@@ -33071,7 +33071,7 @@ function createMcpExpressApp(options = {}) {
33071
33071
  }
33072
33072
 
33073
33073
  // ../../node_modules/@hono/node-server/dist/index.mjs
33074
- import { Http2ServerRequest as Http2ServerRequest2 } from "http2";
33074
+ import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
33075
33075
  import { Http2ServerRequest } from "http2";
33076
33076
  import { Readable } from "stream";
33077
33077
  import crypto2 from "crypto";
@@ -33211,6 +33211,17 @@ var requestPrototype = {
33211
33211
  }
33212
33212
  });
33213
33213
  });
33214
+ Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), {
33215
+ value: function(depth, options, inspectFn) {
33216
+ const props = {
33217
+ method: this.method,
33218
+ url: this.url,
33219
+ headers: this.headers,
33220
+ nativeRequest: this[requestCache]
33221
+ };
33222
+ return `Request (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
33223
+ }
33224
+ });
33214
33225
  Object.setPrototypeOf(requestPrototype, Request.prototype);
33215
33226
  var newRequest = (incoming, defaultHostname) => {
33216
33227
  const req = Object.create(requestPrototype);
@@ -33311,6 +33322,17 @@ var Response2 = class _Response {
33311
33322
  }
33312
33323
  });
33313
33324
  });
33325
+ Object.defineProperty(Response2.prototype, Symbol.for("nodejs.util.inspect.custom"), {
33326
+ value: function(depth, options, inspectFn) {
33327
+ const props = {
33328
+ status: this.status,
33329
+ headers: this.headers,
33330
+ ok: this.ok,
33331
+ nativeResponse: this[responseCache]
33332
+ };
33333
+ return `Response (lightweight) ${inspectFn(props, { ...options, depth: depth == null ? null : depth - 1 })}`;
33334
+ }
33335
+ });
33314
33336
  Object.setPrototypeOf(Response2, GlobalResponse);
33315
33337
  Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
33316
33338
  async function readWithoutBlocking(readPromise) {
@@ -33381,6 +33403,48 @@ if (typeof global.crypto === "undefined") {
33381
33403
  global.crypto = crypto2;
33382
33404
  }
33383
33405
  var outgoingEnded = Symbol("outgoingEnded");
33406
+ var incomingDraining = Symbol("incomingDraining");
33407
+ var DRAIN_TIMEOUT_MS = 500;
33408
+ var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
33409
+ var drainIncoming = (incoming) => {
33410
+ const incomingWithDrainState = incoming;
33411
+ if (incoming.destroyed || incomingWithDrainState[incomingDraining]) {
33412
+ return;
33413
+ }
33414
+ incomingWithDrainState[incomingDraining] = true;
33415
+ if (incoming instanceof Http2ServerRequest2) {
33416
+ try {
33417
+ incoming.stream?.close?.(h2constants.NGHTTP2_NO_ERROR);
33418
+ } catch {}
33419
+ return;
33420
+ }
33421
+ let bytesRead = 0;
33422
+ const cleanup = () => {
33423
+ clearTimeout(timer);
33424
+ incoming.off("data", onData);
33425
+ incoming.off("end", cleanup);
33426
+ incoming.off("error", cleanup);
33427
+ };
33428
+ const forceClose = () => {
33429
+ cleanup();
33430
+ const socket = incoming.socket;
33431
+ if (socket && !socket.destroyed) {
33432
+ socket.destroySoon();
33433
+ }
33434
+ };
33435
+ const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
33436
+ timer.unref?.();
33437
+ const onData = (chunk) => {
33438
+ bytesRead += chunk.length;
33439
+ if (bytesRead > MAX_DRAIN_BYTES) {
33440
+ forceClose();
33441
+ }
33442
+ };
33443
+ incoming.on("data", onData);
33444
+ incoming.on("end", cleanup);
33445
+ incoming.on("error", cleanup);
33446
+ incoming.resume();
33447
+ };
33384
33448
  var handleRequestError = () => new Response(null, {
33385
33449
  status: 400
33386
33450
  });
@@ -33544,14 +33608,18 @@ var getRequestListener = (fetchCallback, options = {}) => {
33544
33608
  setTimeout(() => {
33545
33609
  if (!incomingEnded) {
33546
33610
  setTimeout(() => {
33547
- incoming.destroy();
33548
- outgoing.destroy();
33611
+ drainIncoming(incoming);
33549
33612
  });
33550
33613
  }
33551
33614
  });
33552
33615
  }
33553
33616
  };
33554
33617
  }
33618
+ outgoing.on("finish", () => {
33619
+ if (!incomingEnded) {
33620
+ drainIncoming(incoming);
33621
+ }
33622
+ });
33555
33623
  }
33556
33624
  outgoing.on("close", () => {
33557
33625
  const abortController = req[abortControllerKey];
@@ -33566,7 +33634,7 @@ var getRequestListener = (fetchCallback, options = {}) => {
33566
33634
  setTimeout(() => {
33567
33635
  if (!incomingEnded) {
33568
33636
  setTimeout(() => {
33569
- incoming.destroy();
33637
+ drainIncoming(incoming);
33570
33638
  });
33571
33639
  }
33572
33640
  });