@moor-sh/mcp 0.8.0 → 0.9.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/package.json +1 -1
- package/src/index.ts +44 -6
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -491,7 +491,8 @@ server.registerTool(
|
|
|
491
491
|
"moor_stats",
|
|
492
492
|
{
|
|
493
493
|
title: "Server Stats",
|
|
494
|
-
description:
|
|
494
|
+
description:
|
|
495
|
+
"Get server resource usage: load, memory, root disk, Docker disk by category (images/containers/volumes/build cache) with reclaimable bytes, and container counts. Note: cpu.percent is load-derived (load avg ÷ cores), not instantaneous CPU; use the `load` field for the same signal with explicit naming.",
|
|
495
496
|
},
|
|
496
497
|
async () => {
|
|
497
498
|
const res = await apiGet("/api/server/stats");
|
|
@@ -501,23 +502,60 @@ server.registerTool(
|
|
|
501
502
|
os: string;
|
|
502
503
|
uptime: string;
|
|
503
504
|
cpu: { percent: number; cores: number };
|
|
505
|
+
load?: { one_min: number; cores: number; normalized_percent: number };
|
|
504
506
|
memory: { total: string; used: string; percent: number };
|
|
505
507
|
disk: { total: string; used: string; percent: number };
|
|
506
508
|
containers: { running: number; total: number };
|
|
509
|
+
docker?: {
|
|
510
|
+
images: { bytes: number; reclaimable_bytes: number; count: number; unused_count: number };
|
|
511
|
+
containers: {
|
|
512
|
+
bytes: number;
|
|
513
|
+
reclaimable_bytes: number;
|
|
514
|
+
count: number;
|
|
515
|
+
stopped_count: number;
|
|
516
|
+
};
|
|
517
|
+
volumes: { bytes: number; reclaimable_bytes: number; count: number; unused_count: number };
|
|
518
|
+
build_cache: { bytes: number; reclaimable_bytes: number; count: number };
|
|
519
|
+
} | null;
|
|
507
520
|
};
|
|
508
|
-
const
|
|
521
|
+
const lines = [
|
|
509
522
|
`Host: ${s.hostname}`,
|
|
510
523
|
`OS: ${s.os}`,
|
|
511
524
|
`Uptime: ${s.uptime}`,
|
|
512
|
-
`CPU: ${s.cpu.percent}% (${s.cpu.cores} cores)`,
|
|
525
|
+
`CPU: ${s.cpu.percent}% (${s.cpu.cores} cores) — load-derived, not instantaneous`,
|
|
526
|
+
];
|
|
527
|
+
if (s.load) {
|
|
528
|
+
lines.push(
|
|
529
|
+
`Load (1m): ${s.load.one_min.toFixed(2)} on ${s.load.cores} cores (${s.load.normalized_percent}%)`,
|
|
530
|
+
);
|
|
531
|
+
}
|
|
532
|
+
lines.push(
|
|
513
533
|
`Memory: ${s.memory.used} / ${s.memory.total} (${s.memory.percent}%)`,
|
|
514
|
-
`Disk: ${s.disk.used} / ${s.disk.total} (${s.disk.percent}%)`,
|
|
534
|
+
`Disk (root /): ${s.disk.used} / ${s.disk.total} (${s.disk.percent}%)`,
|
|
515
535
|
`Containers: ${s.containers.running} running / ${s.containers.total} total`,
|
|
516
|
-
|
|
517
|
-
|
|
536
|
+
);
|
|
537
|
+
if (s.docker) {
|
|
538
|
+
const d = s.docker;
|
|
539
|
+
lines.push(
|
|
540
|
+
"Docker disk:",
|
|
541
|
+
` Images: ${formatBytes(d.images.bytes)} (${formatBytes(d.images.reclaimable_bytes)} reclaimable, ${d.images.unused_count}/${d.images.count} unused)`,
|
|
542
|
+
` Containers: ${formatBytes(d.containers.bytes)} (${formatBytes(d.containers.reclaimable_bytes)} reclaimable, ${d.containers.stopped_count}/${d.containers.count} stopped)`,
|
|
543
|
+
` Volumes: ${formatBytes(d.volumes.bytes)} (${formatBytes(d.volumes.reclaimable_bytes)} reclaimable, ${d.volumes.unused_count}/${d.volumes.count} unused)`,
|
|
544
|
+
` Build cache: ${formatBytes(d.build_cache.bytes)} (${formatBytes(d.build_cache.reclaimable_bytes)} reclaimable, ${d.build_cache.count} entries)`,
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
518
548
|
},
|
|
519
549
|
);
|
|
520
550
|
|
|
551
|
+
function formatBytes(bytes: number): string {
|
|
552
|
+
if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
|
|
553
|
+
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
554
|
+
const i = Math.min(units.length - 1, Math.floor(Math.log(bytes) / Math.log(1024)));
|
|
555
|
+
const val = bytes / 1024 ** i;
|
|
556
|
+
return `${val.toFixed(val < 10 ? 1 : 0)} ${units[i]}`;
|
|
557
|
+
}
|
|
558
|
+
|
|
521
559
|
server.registerTool(
|
|
522
560
|
"moor_project_get",
|
|
523
561
|
{
|