@modelcontextprotocol/server-system-monitor 1.0.1 → 1.1.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/README.md +13 -7
- package/dist/mcp-app.html +15 -15
- package/dist/server.js +61 -84
- package/package.json +2 -2
package/dist/server.js
CHANGED
|
@@ -53958,37 +53958,52 @@ var import_systeminformation = __toESM(require_lib(), 1);
|
|
|
53958
53958
|
import fs from "node:fs/promises";
|
|
53959
53959
|
import os from "node:os";
|
|
53960
53960
|
import path from "node:path";
|
|
53961
|
-
var
|
|
53962
|
-
idle: exports_external.number(),
|
|
53963
|
-
total: exports_external.number()
|
|
53964
|
-
});
|
|
53965
|
-
var CpuStatsSchema = exports_external.object({
|
|
53966
|
-
cores: exports_external.array(CpuCoreSchema),
|
|
53967
|
-
model: exports_external.string(),
|
|
53968
|
-
count: exports_external.number()
|
|
53969
|
-
});
|
|
53970
|
-
var MemoryStatsSchema = exports_external.object({
|
|
53971
|
-
usedBytes: exports_external.number(),
|
|
53972
|
-
totalBytes: exports_external.number(),
|
|
53973
|
-
usedPercent: exports_external.number(),
|
|
53974
|
-
freeBytes: exports_external.number(),
|
|
53975
|
-
usedFormatted: exports_external.string(),
|
|
53976
|
-
totalFormatted: exports_external.string()
|
|
53977
|
-
});
|
|
53961
|
+
var DIST_DIR = import.meta.filename.endsWith(".ts") ? path.join(import.meta.dirname, "dist") : import.meta.dirname;
|
|
53978
53962
|
var SystemInfoSchema = exports_external.object({
|
|
53979
53963
|
hostname: exports_external.string(),
|
|
53980
53964
|
platform: exports_external.string(),
|
|
53981
53965
|
arch: exports_external.string(),
|
|
53982
|
-
|
|
53983
|
-
|
|
53966
|
+
cpu: exports_external.object({
|
|
53967
|
+
model: exports_external.string(),
|
|
53968
|
+
count: exports_external.number()
|
|
53969
|
+
}),
|
|
53970
|
+
memory: exports_external.object({
|
|
53971
|
+
totalBytes: exports_external.number()
|
|
53972
|
+
})
|
|
53984
53973
|
});
|
|
53985
|
-
var
|
|
53986
|
-
|
|
53987
|
-
|
|
53988
|
-
|
|
53974
|
+
var CpuCoreSchema = exports_external.object({
|
|
53975
|
+
idle: exports_external.number(),
|
|
53976
|
+
total: exports_external.number()
|
|
53977
|
+
});
|
|
53978
|
+
var PollStatsSchema = exports_external.object({
|
|
53979
|
+
cpu: exports_external.object({
|
|
53980
|
+
cores: exports_external.array(CpuCoreSchema)
|
|
53981
|
+
}),
|
|
53982
|
+
memory: exports_external.object({
|
|
53983
|
+
usedBytes: exports_external.number(),
|
|
53984
|
+
usedPercent: exports_external.number(),
|
|
53985
|
+
freeBytes: exports_external.number()
|
|
53986
|
+
}),
|
|
53987
|
+
uptime: exports_external.object({
|
|
53988
|
+
seconds: exports_external.number()
|
|
53989
|
+
}),
|
|
53989
53990
|
timestamp: exports_external.string()
|
|
53990
53991
|
});
|
|
53991
|
-
|
|
53992
|
+
function getSystemInfo() {
|
|
53993
|
+
const cpuInfo = os.cpus()[0];
|
|
53994
|
+
return {
|
|
53995
|
+
hostname: os.hostname(),
|
|
53996
|
+
platform: `${os.platform()} ${os.arch()}`,
|
|
53997
|
+
arch: os.arch(),
|
|
53998
|
+
cpu: {
|
|
53999
|
+
model: cpuInfo?.model ?? "Unknown",
|
|
54000
|
+
count: os.cpus().length
|
|
54001
|
+
},
|
|
54002
|
+
memory: {
|
|
54003
|
+
totalBytes: os.totalmem()
|
|
54004
|
+
}
|
|
54005
|
+
};
|
|
54006
|
+
}
|
|
53992
54007
|
function getCpuSnapshots() {
|
|
53993
54008
|
return os.cpus().map((cpu) => {
|
|
53994
54009
|
const times = cpu.times;
|
|
@@ -53997,58 +54012,20 @@ function getCpuSnapshots() {
|
|
|
53997
54012
|
return { idle, total };
|
|
53998
54013
|
});
|
|
53999
54014
|
}
|
|
54000
|
-
function
|
|
54001
|
-
const days = Math.floor(seconds / 86400);
|
|
54002
|
-
const hours = Math.floor(seconds % 86400 / 3600);
|
|
54003
|
-
const minutes = Math.floor(seconds % 3600 / 60);
|
|
54004
|
-
const parts = [];
|
|
54005
|
-
if (days > 0)
|
|
54006
|
-
parts.push(`${days}d`);
|
|
54007
|
-
if (hours > 0)
|
|
54008
|
-
parts.push(`${hours}h`);
|
|
54009
|
-
if (minutes > 0)
|
|
54010
|
-
parts.push(`${minutes}m`);
|
|
54011
|
-
return parts.length > 0 ? parts.join(" ") : "< 1m";
|
|
54012
|
-
}
|
|
54013
|
-
function formatBytes(bytes) {
|
|
54014
|
-
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
54015
|
-
let value = bytes;
|
|
54016
|
-
let unitIndex = 0;
|
|
54017
|
-
while (value >= 1024 && unitIndex < units.length - 1) {
|
|
54018
|
-
value /= 1024;
|
|
54019
|
-
unitIndex++;
|
|
54020
|
-
}
|
|
54021
|
-
return `${value.toFixed(1)} ${units[unitIndex]}`;
|
|
54022
|
-
}
|
|
54023
|
-
async function getMemoryStats() {
|
|
54015
|
+
async function getPollStats() {
|
|
54024
54016
|
const mem = await import_systeminformation.default.mem();
|
|
54025
|
-
return {
|
|
54026
|
-
usedBytes: mem.active,
|
|
54027
|
-
totalBytes: mem.total,
|
|
54028
|
-
usedPercent: Math.round(mem.active / mem.total * 100),
|
|
54029
|
-
freeBytes: mem.available,
|
|
54030
|
-
usedFormatted: formatBytes(mem.active),
|
|
54031
|
-
totalFormatted: formatBytes(mem.total)
|
|
54032
|
-
};
|
|
54033
|
-
}
|
|
54034
|
-
async function getStats() {
|
|
54035
|
-
const cpuSnapshots = getCpuSnapshots();
|
|
54036
|
-
const cpuInfo = os.cpus()[0];
|
|
54037
|
-
const memory = await getMemoryStats();
|
|
54038
54017
|
const uptimeSeconds = os.uptime();
|
|
54039
54018
|
return {
|
|
54040
54019
|
cpu: {
|
|
54041
|
-
cores:
|
|
54042
|
-
model: cpuInfo?.model ?? "Unknown",
|
|
54043
|
-
count: os.cpus().length
|
|
54020
|
+
cores: getCpuSnapshots()
|
|
54044
54021
|
},
|
|
54045
|
-
memory
|
|
54046
|
-
|
|
54047
|
-
|
|
54048
|
-
|
|
54049
|
-
|
|
54050
|
-
|
|
54051
|
-
|
|
54022
|
+
memory: {
|
|
54023
|
+
usedBytes: mem.active,
|
|
54024
|
+
usedPercent: Math.round(mem.active / mem.total * 100),
|
|
54025
|
+
freeBytes: mem.available
|
|
54026
|
+
},
|
|
54027
|
+
uptime: {
|
|
54028
|
+
seconds: uptimeSeconds
|
|
54052
54029
|
},
|
|
54053
54030
|
timestamp: new Date().toISOString()
|
|
54054
54031
|
};
|
|
@@ -54059,27 +54036,27 @@ function createServer() {
|
|
|
54059
54036
|
version: "1.0.0"
|
|
54060
54037
|
});
|
|
54061
54038
|
const resourceUri = "ui://system-monitor/mcp-app.html";
|
|
54062
|
-
hk(server, "get-system-
|
|
54063
|
-
title: "Get System
|
|
54064
|
-
description: "Returns
|
|
54039
|
+
hk(server, "get-system-info", {
|
|
54040
|
+
title: "Get System Info",
|
|
54041
|
+
description: "Returns system information, including hostname, platform, CPU info, and memory.",
|
|
54065
54042
|
inputSchema: {},
|
|
54066
|
-
outputSchema:
|
|
54043
|
+
outputSchema: SystemInfoSchema.shape,
|
|
54067
54044
|
_meta: { ui: { resourceUri } }
|
|
54068
|
-
},
|
|
54069
|
-
const
|
|
54045
|
+
}, () => {
|
|
54046
|
+
const info = getSystemInfo();
|
|
54070
54047
|
return {
|
|
54071
|
-
content: [{ type: "text", text: JSON.stringify(
|
|
54072
|
-
structuredContent:
|
|
54048
|
+
content: [{ type: "text", text: JSON.stringify(info) }],
|
|
54049
|
+
structuredContent: info
|
|
54073
54050
|
};
|
|
54074
54051
|
});
|
|
54075
|
-
hk(server, "
|
|
54076
|
-
title: "
|
|
54077
|
-
description: "
|
|
54052
|
+
hk(server, "poll-system-stats", {
|
|
54053
|
+
title: "Poll System Stats",
|
|
54054
|
+
description: "Returns dynamic system metrics for polling: per-core CPU timing, memory usage, and uptime. App-only.",
|
|
54078
54055
|
inputSchema: {},
|
|
54079
|
-
outputSchema:
|
|
54056
|
+
outputSchema: PollStatsSchema.shape,
|
|
54080
54057
|
_meta: { ui: { visibility: ["app"] } }
|
|
54081
54058
|
}, async () => {
|
|
54082
|
-
const stats = await
|
|
54059
|
+
const stats = await getPollStats();
|
|
54083
54060
|
return {
|
|
54084
54061
|
content: [{ type: "text", text: JSON.stringify(stats) }],
|
|
54085
54062
|
structuredContent: stats
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelcontextprotocol/server-system-monitor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "System monitor MCP App Server with real-time stats",
|
|
6
6
|
"repository": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"start": "npm run start:http",
|
|
22
22
|
"start:http": "cross-env NODE_ENV=development npm run build && npm run serve:http",
|
|
23
23
|
"start:stdio": "cross-env NODE_ENV=development npm run build && npm run serve:stdio",
|
|
24
|
-
"dev": "cross-env NODE_ENV=development concurrently
|
|
24
|
+
"dev": "cross-env NODE_ENV=development concurrently \"npm run watch\" \"npm run serve:http\"",
|
|
25
25
|
"prepublishOnly": "npm run build",
|
|
26
26
|
"serve": "bun --watch main.ts"
|
|
27
27
|
},
|