computer-vitals 0.1.0 → 0.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 +10 -8
- package/package.json +1 -1
- package/src/data/os-support.json +1 -1
- package/src/lib/diagnose.js +5 -3
- package/src/lib/gather.js +14 -2
- package/src/lib/safety.js +3 -1
- package/src/win/computer.ps1 +17 -10
- package/src/win/safety.ps1 +14 -7
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Computer Vitals
|
|
2
2
|
|
|
3
|
+
[](https://glama.ai/mcp/servers/getlarkwright/computer-vitals)
|
|
4
|
+
|
|
3
5
|
Ask your AI assistant "why is my computer slow?" and get a real answer.
|
|
4
6
|
|
|
5
7
|
Computer Vitals is an [MCP](https://modelcontextprotocol.io) server. It takes a few quick readings on
|
|
@@ -58,7 +60,7 @@ whoever helps you with the computer.
|
|
|
58
60
|
|
|
59
61
|
## Install
|
|
60
62
|
|
|
61
|
-
**Claude Desktop, the easy way:** download `computer-vitals-0.1.
|
|
63
|
+
**Claude Desktop, the easy way:** download `computer-vitals-0.1.1.mcpb` from the
|
|
62
64
|
[latest release](https://github.com/getlarkwright/computer-vitals/releases/latest) and open it. Nothing
|
|
63
65
|
else to install.
|
|
64
66
|
|
|
@@ -67,7 +69,7 @@ For everything else you need [Node.js](https://nodejs.org) 20 or newer.
|
|
|
67
69
|
**Claude Code**
|
|
68
70
|
|
|
69
71
|
```bash
|
|
70
|
-
claude mcp add computer-vitals -- npx -y computer-vitals@0.1.
|
|
72
|
+
claude mcp add computer-vitals -- npx -y computer-vitals@0.1.1
|
|
71
73
|
```
|
|
72
74
|
|
|
73
75
|
**Cursor, VS Code and other MCP apps**: add this to the app's MCP settings:
|
|
@@ -77,7 +79,7 @@ claude mcp add computer-vitals -- npx -y computer-vitals@0.1.0
|
|
|
77
79
|
"mcpServers": {
|
|
78
80
|
"computer-vitals": {
|
|
79
81
|
"command": "npx",
|
|
80
|
-
"args": ["-y", "computer-vitals@0.1.
|
|
82
|
+
"args": ["-y", "computer-vitals@0.1.1"]
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|
|
@@ -86,11 +88,11 @@ claude mcp add computer-vitals -- npx -y computer-vitals@0.1.0
|
|
|
86
88
|
**Without an AI app**, in a terminal:
|
|
87
89
|
|
|
88
90
|
```bash
|
|
89
|
-
npx -y computer-vitals@0.1.
|
|
90
|
-
npx -y computer-vitals@0.1.
|
|
91
|
-
npx -y computer-vitals@0.1.
|
|
92
|
-
npx -y computer-vitals@0.1.
|
|
93
|
-
npx -y computer-vitals@0.1.
|
|
91
|
+
npx -y computer-vitals@0.1.1 check # why is this computer slow? about 5 seconds
|
|
92
|
+
npx -y computer-vitals@0.1.1 disk # what is using the disk space? up to 20 seconds
|
|
93
|
+
npx -y computer-vitals@0.1.1 files downloads # the biggest files in one standard folder
|
|
94
|
+
npx -y computer-vitals@0.1.1 startup # what starts with the computer?
|
|
95
|
+
npx -y computer-vitals@0.1.1 safety # is this computer safe?
|
|
94
96
|
```
|
|
95
97
|
|
|
96
98
|
## The five tools
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "computer-vitals",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Ask your AI why your computer is slow, what is filling the disk, and whether the computer is safe. Read-only checks on your own computer, explained in plain words. No admin rights, no telemetry, nothing sent to the internet.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Larkwright LLC",
|
package/src/data/os-support.json
CHANGED
package/src/lib/diagnose.js
CHANGED
|
@@ -156,8 +156,9 @@ export function diagnose(f) {
|
|
|
156
156
|
} else add("note", "disk", "I could not read the free space on the system drive.");
|
|
157
157
|
const isHdd = d.kind === "hdd" && !d.virtual;
|
|
158
158
|
if (isHdd) add("warning", "drive", "This computer runs from a spinning hard drive. Those are far slower than the solid-state drives (SSDs) in computers today, and are the most common reason an older computer feels slow at everything.");
|
|
159
|
-
|
|
160
|
-
else if (d.
|
|
159
|
+
// In a virtual machine the "drive" is a file the host provides, so its type and health say nothing.
|
|
160
|
+
else if (!d.virtual && d.kind === "ssd" && d.health !== "failing" && d.health !== "warn") add("ok", "drive", `The system drive is a solid-state drive (SSD)${d.health === "ok" ? " and reports good health" : ""}.`);
|
|
161
|
+
else if (!d.virtual && d.health === "ok") add("ok", "drive", "The system drive reports good health.");
|
|
161
162
|
if (d.virtual) add("note", "drive", "This is a virtual machine, so the drive type, drive health and temperature cannot be read from inside it.");
|
|
162
163
|
const diskBusy = d.busyPct !== null && d.busyPct !== undefined && d.busyPct >= LIMITS.diskBusyPct;
|
|
163
164
|
if (diskBusy) add("problem", "diskbusy", `The disk was working flat out during the check (${Math.round(d.busyPct)}% busy). While that goes on, everything that needs the disk has to wait.`);
|
|
@@ -195,7 +196,8 @@ export function diagnose(f) {
|
|
|
195
196
|
if (worn) add("warning", "battery", `The battery is worn${b.healthPct !== null && b.healthPct !== undefined ? `: it holds about ${b.healthPct}% of what it did when new` : ""}${b.cycles ? ` (${b.cycles} charge cycles)` : ""}.`);
|
|
196
197
|
else if (b.present && b.healthPct !== null && b.healthPct !== undefined) add("ok", "battery", `The battery is in good shape: about ${b.healthPct}% of its original capacity${b.cycles ? `, ${b.cycles} charge cycles` : ""}.`);
|
|
197
198
|
|
|
198
|
-
if (f.
|
|
199
|
+
if (f.wmiRefused) add("note", "check", "Windows did not answer some of my questions (its management service, WMI, refused or is not working), so this check is less complete than usual. Restarting the computer usually fixes this.");
|
|
200
|
+
else if (f.incomplete) add("note", "check", "Some readings were not available on this computer, so this check is less complete than usual.");
|
|
199
201
|
|
|
200
202
|
// ---- the verdict: the first of these that applies ----
|
|
201
203
|
let verdict;
|
package/src/lib/gather.js
CHANGED
|
@@ -268,6 +268,15 @@ async function macFacts() {
|
|
|
268
268
|
const POWER_SAVER_SCHEME = "a1841308-3541-4fab-bc81-f71556f20b4a";
|
|
269
269
|
const EFFICIENCY_OVERLAY = "961cc777-2547-4f9d-8174-7d86181b8a7a";
|
|
270
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Memory as Windows itself counts it (GlobalMemoryStatusEx, which Node reads): total and available.
|
|
273
|
+
* It needs no WMI, so it is there when WMI refuses or is broken. Windows only: on a Mac, "free" is
|
|
274
|
+
* far below what is really available.
|
|
275
|
+
*/
|
|
276
|
+
export function winMemoryFallback(total = os.totalmem(), available = os.freemem()) {
|
|
277
|
+
return { total, available, swapTotal: null, swapUsed: null, waitPct: null, pressure: null, commitPct: null };
|
|
278
|
+
}
|
|
279
|
+
|
|
271
280
|
/** The JSON from src/win/computer.ps1 -> the same shape the other systems produce. */
|
|
272
281
|
export function normalizeWinComputer(j, systemDrive = process.env.SystemDrive || "C:") {
|
|
273
282
|
if (!j) return null;
|
|
@@ -316,11 +325,14 @@ export function normalizeWinComputer(j, systemDrive = process.env.SystemDrive ||
|
|
|
316
325
|
efficiencyMode: overlay ? String(overlay).toLowerCase() === EFFICIENCY_OVERLAY : null,
|
|
317
326
|
},
|
|
318
327
|
thermal: { speedLimit: null, throttledNow: null },
|
|
328
|
+
wmiRefused: j.wmi === false,
|
|
319
329
|
};
|
|
320
330
|
}
|
|
321
331
|
|
|
322
332
|
async function winFacts() {
|
|
323
|
-
|
|
333
|
+
const f = normalizeWinComputer(await runWinScript("computer"));
|
|
334
|
+
if (f && !f.memory) f.memory = winMemoryFallback();
|
|
335
|
+
return f;
|
|
324
336
|
}
|
|
325
337
|
|
|
326
338
|
// ---------- everything ------------------------------------------------------------------------
|
|
@@ -329,7 +341,7 @@ export async function gatherComputer() {
|
|
|
329
341
|
const t0 = performance.now();
|
|
330
342
|
const specific = PLATFORM === "linux" ? linuxFacts() : PLATFORM === "darwin" ? macFacts() : PLATFORM === "win32" ? winFacts() : Promise.resolve(null);
|
|
331
343
|
const [cpu, f, startup] = await Promise.all([sampleCpu(), specific.catch(() => null), gatherStartup().catch(() => null)]);
|
|
332
|
-
const facts = f || { osName: PLATFORM, procs: [], memory: null, drive: driveSpace(os.homedir()) || {}, restart: { pending: null }, battery: { present: false }, power: {}, thermal: {} };
|
|
344
|
+
const facts = f || { osName: PLATFORM, procs: [], memory: PLATFORM === "win32" ? winMemoryFallback() : null, drive: driveSpace(os.homedir()) || {}, restart: { pending: null }, battery: { present: false }, power: {}, thermal: {} };
|
|
333
345
|
const { procs, ...rest } = facts;
|
|
334
346
|
return {
|
|
335
347
|
platform: PLATFORM,
|
package/src/lib/safety.js
CHANGED
|
@@ -77,7 +77,7 @@ const HOME_EDITION = /^(Core|CoreN|CoreSingleLanguage|CoreCountrySpecific|Profes
|
|
|
77
77
|
/** The JSON from src/win/safety.ps1 -> facts in the shape assess() takes. */
|
|
78
78
|
export function normalizeWinSafety(j, { support = SUPPORT, today = iso(Date.now()) } = {}) {
|
|
79
79
|
if (!j) return null;
|
|
80
|
-
const f = { platform: "win32", today, laptop: j.laptop === null || j.laptop === undefined ? null : Boolean(j.laptop) };
|
|
80
|
+
const f = { platform: "win32", today, laptop: j.laptop === null || j.laptop === undefined ? null : Boolean(j.laptop), wmiRefused: j.wmi === false };
|
|
81
81
|
const build = Number(j.version?.build);
|
|
82
82
|
const isServer = /server/i.test(j.version?.type || "");
|
|
83
83
|
const major = Number.isFinite(build) ? (build >= 22000 ? 11 : 10) : null;
|
|
@@ -413,6 +413,8 @@ export function assess(f, { support = SUPPORT } = {}) {
|
|
|
413
413
|
for (const r of f.remote) add("note", "remote", `${r.what} is turned on. That lets other devices on your network try to connect to this computer. Fine if you use it; if not, turn it off (${r.off}).`);
|
|
414
414
|
} else if (f.remoteKnown) add("ok", "remote", "No remote-access features are turned on.");
|
|
415
415
|
|
|
416
|
+
if (f.wmiRefused) add("note", "check", "Windows did not answer some of my questions (its management service, WMI, refused or is not working), so this check is less complete than usual. Restarting the computer usually fixes this.");
|
|
417
|
+
|
|
416
418
|
return { findings, steps, asOf };
|
|
417
419
|
}
|
|
418
420
|
|
package/src/win/computer.ps1
CHANGED
|
@@ -6,26 +6,33 @@ $ErrorActionPreference = 'Stop'
|
|
|
6
6
|
$ProgressPreference = 'SilentlyContinue'
|
|
7
7
|
$r = @{}
|
|
8
8
|
function Step([string]$name, [scriptblock]$block) { try { $script:r[$name] = & $block } catch { $script:r[$name] = $null } }
|
|
9
|
+
# When WMI refuses or is broken, every WMI question takes seconds to fail, and enough of them run
|
|
10
|
+
# past the time limit, which loses the readings that do work. So ask once, and if WMI does not
|
|
11
|
+
# answer, skip the WMI questions (CimStep) and keep the rest.
|
|
12
|
+
$cim = $true
|
|
13
|
+
try { $null = Get-CimInstance -ClassName Win32_OperatingSystem -Property Caption } catch { $cim = $false }
|
|
14
|
+
$r['wmi'] = $cim
|
|
15
|
+
function CimStep([string]$name, [scriptblock]$block) { if ($script:cim) { Step $name $block } else { $script:r[$name] = $null } }
|
|
9
16
|
|
|
10
17
|
# Two readings of every program's processor time, about 1.5 seconds apart. The gap is filled
|
|
11
18
|
# with the other questions below.
|
|
12
19
|
$pq = 'SELECT Name,IDProcess,PercentProcessorTime,Timestamp_Sys100NS,WorkingSetPrivate FROM Win32_PerfRawData_PerfProc_Process'
|
|
13
20
|
$dq = 'SELECT Name,PercentIdleTime,Timestamp_Sys100NS FROM Win32_PerfRawData_PerfDisk_PhysicalDisk'
|
|
14
21
|
$p1 = @(); $d1 = @()
|
|
15
|
-
try { $p1 = @(Get-CimInstance -Query $pq) } catch { }
|
|
16
|
-
try { $d1 = @(Get-CimInstance -Query $dq) } catch { }
|
|
22
|
+
if ($cim) { try { $p1 = @(Get-CimInstance -Query $pq) } catch { } }
|
|
23
|
+
if ($cim) { try { $d1 = @(Get-CimInstance -Query $dq) } catch { } }
|
|
17
24
|
$clock = [Diagnostics.Stopwatch]::StartNew()
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
CimStep 'os' {
|
|
20
27
|
$o = Get-CimInstance Win32_OperatingSystem
|
|
21
28
|
@{ caption = [string]$o.Caption; build = [string]$o.BuildNumber; totalKb = [double]$o.TotalVisibleMemorySize; freeKb = [double]$o.FreePhysicalMemory; commitLimitKb = [double]$o.TotalVirtualMemorySize; commitFreeKb = [double]$o.FreeVirtualMemory; boot = $o.LastBootUpTime.ToUniversalTime().ToString('o') }
|
|
22
29
|
}
|
|
23
|
-
|
|
24
|
-
|
|
30
|
+
CimStep 'model' { [string](Get-CimInstance Win32_ComputerSystem).Model }
|
|
31
|
+
CimStep 'disks' {
|
|
25
32
|
@(Get-CimInstance -Namespace root/Microsoft/Windows/Storage -ClassName MSFT_PhysicalDisk | ForEach-Object { @{ id = [string]$_.DeviceId; media = [int]$_.MediaType; health = [int]$_.HealthStatus; bus = [int]$_.BusType } })
|
|
26
33
|
}
|
|
27
|
-
|
|
28
|
-
|
|
34
|
+
CimStep 'drives' { @(Get-CimInstance Win32_DiskDrive | ForEach-Object { @{ index = [int]$_.Index; status = [string]$_.Status } }) }
|
|
35
|
+
CimStep 'sysDisk' {
|
|
29
36
|
$ld = Get-CimInstance Win32_LogicalDisk -Filter ('DeviceID=''' + $env:SystemDrive + '''')
|
|
30
37
|
$p = Get-CimAssociatedInstance -InputObject $ld -ResultClassName Win32_DiskPartition | Select-Object -First 1
|
|
31
38
|
[int]$p.DiskIndex
|
|
@@ -33,7 +40,7 @@ Step 'sysDisk' {
|
|
|
33
40
|
Step 'restartUpdate' { Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired' }
|
|
34
41
|
Step 'restartServicing' { Test-Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending' }
|
|
35
42
|
Step 'fastStartup' { [int](Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power').HiberbootEnabled }
|
|
36
|
-
|
|
43
|
+
CimStep 'battery' {
|
|
37
44
|
$b = Get-CimInstance Win32_Battery | Select-Object -First 1
|
|
38
45
|
if ($null -eq $b) { return @{ present = $false } }
|
|
39
46
|
$out = @{ present = $true; percent = [int]$b.EstimatedChargeRemaining; status = [int]$b.BatteryStatus }
|
|
@@ -54,7 +61,7 @@ Step 'energySaver' {
|
|
|
54
61
|
$wait = 1500 - $clock.ElapsedMilliseconds
|
|
55
62
|
if ($wait -gt 0) { Start-Sleep -Milliseconds $wait }
|
|
56
63
|
|
|
57
|
-
|
|
64
|
+
CimStep 'procs' {
|
|
58
65
|
$p2 = @(Get-CimInstance -Query $pq)
|
|
59
66
|
$prev = @{}
|
|
60
67
|
foreach ($p in $p1) { $prev[[string]$p.IDProcess + '|' + $p.Name] = $p }
|
|
@@ -69,7 +76,7 @@ Step 'procs' {
|
|
|
69
76
|
@{ n = [string]$p.Name; c = $c; m = [double]$p.WorkingSetPrivate }
|
|
70
77
|
})
|
|
71
78
|
}
|
|
72
|
-
|
|
79
|
+
CimStep 'diskBusy' {
|
|
73
80
|
$d2 = @(Get-CimInstance -Query $dq)
|
|
74
81
|
$want = '* ' + $env:SystemDrive + '*'
|
|
75
82
|
$a = $d1 | Where-Object { $_.Name -like $want } | Select-Object -First 1
|
package/src/win/safety.ps1
CHANGED
|
@@ -5,14 +5,21 @@ $ErrorActionPreference = 'Stop'
|
|
|
5
5
|
$ProgressPreference = 'SilentlyContinue'
|
|
6
6
|
$r = @{}
|
|
7
7
|
function Step([string]$name, [scriptblock]$block) { try { $script:r[$name] = & $block } catch { $script:r[$name] = $null } }
|
|
8
|
+
# When WMI refuses or is broken, every WMI question takes seconds to fail, and enough of them run
|
|
9
|
+
# past the time limit, which loses the readings that do work. So ask once, and if WMI does not
|
|
10
|
+
# answer, skip the WMI questions (CimStep) and keep the rest.
|
|
11
|
+
$cim = $true
|
|
12
|
+
try { $null = Get-CimInstance -ClassName Win32_OperatingSystem -Property Caption } catch { $cim = $false }
|
|
13
|
+
$r['wmi'] = $cim
|
|
14
|
+
function CimStep([string]$name, [scriptblock]$block) { if ($script:cim) { Step $name $block } else { $script:r[$name] = $null } }
|
|
8
15
|
|
|
9
16
|
Step 'firewall' {
|
|
10
17
|
$base = 'HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\'
|
|
11
18
|
@{ domain = [int](Get-ItemProperty ($base + 'DomainProfile')).EnableFirewall; private = [int](Get-ItemProperty ($base + 'StandardProfile')).EnableFirewall; public = [int](Get-ItemProperty ($base + 'PublicProfile')).EnableFirewall }
|
|
12
19
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
CimStep 'firewallProducts' { @(Get-CimInstance -Namespace root/SecurityCenter2 -ClassName FirewallProduct | ForEach-Object { @{ name = [string]$_.displayName; state = [double]$_.productState } }) }
|
|
21
|
+
CimStep 'antivirus' { @(Get-CimInstance -Namespace root/SecurityCenter2 -ClassName AntiVirusProduct | ForEach-Object { @{ name = [string]$_.displayName; state = [double]$_.productState } }) }
|
|
22
|
+
CimStep 'defender' {
|
|
16
23
|
$d = Get-CimInstance -Namespace root/Microsoft/Windows/Defender -ClassName MSFT_MpComputerStatus
|
|
17
24
|
@{ enabled = [bool]$d.AntivirusEnabled; realtime = [bool]$d.RealTimeProtectionEnabled; signatureAgeDays = [double]$d.AntivirusSignatureAge }
|
|
18
25
|
}
|
|
@@ -25,7 +32,7 @@ Step 'version' {
|
|
|
25
32
|
$v = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'
|
|
26
33
|
@{ display = [string]$v.DisplayVersion; build = [string]$v.CurrentBuild; ubr = [int]$v.UBR; edition = [string]$v.EditionID; type = [string]$v.InstallationType }
|
|
27
34
|
}
|
|
28
|
-
|
|
35
|
+
CimStep 'lastUpdate' {
|
|
29
36
|
$d = Get-CimInstance Win32_QuickFixEngineering | Where-Object { $_.InstalledOn } | Sort-Object InstalledOn | Select-Object -Last 1
|
|
30
37
|
if ($null -eq $d) { return $null }
|
|
31
38
|
$d.InstalledOn.ToString('yyyy-MM-dd')
|
|
@@ -41,9 +48,9 @@ Step 'sshServer' {
|
|
|
41
48
|
[string]$s.Status -eq 'Running'
|
|
42
49
|
}
|
|
43
50
|
# Folders shared from this computer. Only the count is reported, never their names.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
51
|
+
CimStep 'sharedFolders' { @(Get-CimInstance Win32_Share | Where-Object { $_.Type -eq 0 }).Count }
|
|
52
|
+
CimStep 'networkCategory' { @(Get-CimInstance -Namespace root/StandardCimv2 -ClassName MSFT_NetConnectionProfile | ForEach-Object { [int]$_.NetworkCategory }) }
|
|
53
|
+
CimStep 'laptop' { [bool](Get-CimInstance Win32_Battery | Select-Object -First 1) }
|
|
47
54
|
Step 'backup' {
|
|
48
55
|
$docs = [Environment]::GetFolderPath('MyDocuments')
|
|
49
56
|
$roots = @($env:OneDrive, $env:OneDriveConsumer, $env:OneDriveCommercial) | Where-Object { $_ }
|