@modelcontextprotocol/server-system-monitor 0.4.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 +57 -0
- package/dist/index.js +30583 -0
- package/dist/mcp-app.html +177 -0
- package/dist/server.d.ts +2 -0
- package/dist/server.js +54107 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Example: System Monitor App
|
|
2
|
+
|
|
3
|
+
A demo MCP App that displays real-time OS metrics with a stacked area chart for per-core CPU usage and a bar gauge for memory.
|
|
4
|
+
|
|
5
|
+
<table>
|
|
6
|
+
<tr>
|
|
7
|
+
<td><a href="https://modelcontextprotocol.github.io/ext-apps/screenshots/system-monitor-server/01-initial-state.png"><img src="https://modelcontextprotocol.github.io/ext-apps/screenshots/system-monitor-server/01-initial-state.png" alt="Initial state" width="100%"></a></td>
|
|
8
|
+
<td><a href="https://modelcontextprotocol.github.io/ext-apps/screenshots/system-monitor-server/02-cpu-data-accumulated.png"><img src="https://modelcontextprotocol.github.io/ext-apps/screenshots/system-monitor-server/02-cpu-data-accumulated.png" alt="CPU data accumulated" width="100%"></a></td>
|
|
9
|
+
<td><a href="https://modelcontextprotocol.github.io/ext-apps/screenshots/system-monitor-server/03-extended-cpu-history.png"><img src="https://modelcontextprotocol.github.io/ext-apps/screenshots/system-monitor-server/03-extended-cpu-history.png" alt="Extended CPU history" width="100%"></a></td>
|
|
10
|
+
</tr>
|
|
11
|
+
</table>
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Per-Core CPU Monitoring**: Stacked area chart showing individual CPU core utilization over a 1-minute sliding window
|
|
16
|
+
- **Memory Usage**: Horizontal bar gauge with color-coded thresholds (green/yellow/red)
|
|
17
|
+
- **System Info**: Hostname, platform, and uptime display
|
|
18
|
+
- **Auto-Polling**: Automatically starts monitoring on load with 2-second refresh interval
|
|
19
|
+
- **Theme Support**: Adapts to light/dark mode preferences
|
|
20
|
+
|
|
21
|
+
## Running
|
|
22
|
+
|
|
23
|
+
1. Install dependencies:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npm install
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
2. Build and start the server:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npm run start:http # for Streamable HTTP transport
|
|
33
|
+
# OR
|
|
34
|
+
npm run start:stdio # for stdio transport
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
3. View using the [`basic-host`](https://github.com/modelcontextprotocol/ext-apps/tree/main/examples/basic-host) example or another MCP Apps-compatible host.
|
|
38
|
+
|
|
39
|
+
## Architecture
|
|
40
|
+
|
|
41
|
+
### Server (`server.ts`)
|
|
42
|
+
|
|
43
|
+
Exposes a single `get-system-stats` tool that returns:
|
|
44
|
+
|
|
45
|
+
- Raw per-core CPU timing data (idle/total counters)
|
|
46
|
+
- Memory usage (used/total/percentage)
|
|
47
|
+
- System info (hostname, platform, uptime)
|
|
48
|
+
|
|
49
|
+
The tool is linked to a UI resource via `_meta.ui.resourceUri`.
|
|
50
|
+
|
|
51
|
+
### App (`src/mcp-app.ts`)
|
|
52
|
+
|
|
53
|
+
- Uses Chart.js for the stacked area chart visualization
|
|
54
|
+
- Polls the server tool every 2 seconds
|
|
55
|
+
- Computes CPU usage percentages client-side from timing deltas
|
|
56
|
+
- Maintains a 30-point history (1 minute at 2s intervals)
|
|
57
|
+
- Updates all UI elements on each poll
|