|
| 1 | +# SysMetrics MCP Server |
| 2 | + |
| 3 | +A lightweight MCP (Model Context Protocol) server that exposes Linux system metrics through MCP tools. Works on any Linux system including Raspberry Pi. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- **7 MCP Tools**: System info, CPU, memory, disk, network, processes, and thermal status |
| 8 | +- **Configurable**: CLI arguments for temperature units, process limits, mount points, and interfaces |
| 9 | +- **Cross-Platform**: Works on any Linux system (enhanced metrics for Raspberry Pi) |
| 10 | +- **AI-Ready**: Designed for integration with Claude Desktop, Cursor, or any MCP client |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +### Prerequisites |
| 15 | + |
| 16 | +- Go 1.25.6 or higher |
| 17 | +- Linux system (tested on Ubuntu, Debian, Raspberry Pi OS) |
| 18 | + |
| 19 | +### Build from Source |
| 20 | + |
| 21 | +The project uses a `Makefile` for common tasks. |
| 22 | + |
| 23 | +```bash |
| 24 | +git clone <repository> |
| 25 | +cd sysmetrics-mcp |
| 26 | +make build |
| 27 | +``` |
| 28 | + |
| 29 | +The compiled binary will be located in `bin/sysmetrics-mcp`. |
| 30 | + |
| 31 | +### Install to PATH |
| 32 | + |
| 33 | +```bash |
| 34 | +# Option 1: System-wide (installs to /usr/local/bin) |
| 35 | +sudo make install |
| 36 | + |
| 37 | +# Option 2: User-local |
| 38 | +mkdir -p ~/.local/bin |
| 39 | +cp bin/sysmetrics-mcp ~/.local/bin/ |
| 40 | +# Add to PATH if not already: export PATH="$HOME/.local/bin:$PATH" |
| 41 | +``` |
| 42 | + |
| 43 | +### Verify Installation |
| 44 | + |
| 45 | +```bash |
| 46 | +sysmetrics-mcp --help |
| 47 | +``` |
| 48 | + |
| 49 | +## Configuration |
| 50 | + |
| 51 | +### Local AI Agents (Gemini CLI / Personal Agents) |
| 52 | + |
| 53 | +Add to your agent's configuration file: |
| 54 | + |
| 55 | +```json |
| 56 | +{ |
| 57 | + "sysmetrics": { |
| 58 | + "type": "stdio", |
| 59 | + "command": "sysmetrics-mcp", |
| 60 | + "args": [ |
| 61 | + "--temp-unit", "celsius", |
| 62 | + "--max-processes", "10" |
| 63 | + ] |
| 64 | + } |
| 65 | +} |
| 66 | +``` |
| 67 | + |
| 68 | +### Available CLI Flags |
| 69 | + |
| 70 | +| Flag | Default | Description | |
| 71 | +|------|---------|-------------| |
| 72 | +| `--temp-unit` | `celsius` | Temperature unit: `celsius`, `fahrenheit`, or `kelvin` | |
| 73 | +| `--max-processes` | `10` | Default maximum processes to list (1-50) | |
| 74 | +| `--mount-points` | `""` | Comma-separated mount points (empty = all) | |
| 75 | +| `--interfaces` | `""` | Comma-separated interfaces (empty = all, excludes `lo`) | |
| 76 | +| `--enable-gpu` | `true` | Attempt to read GPU metrics (Raspberry Pi only) | |
| 77 | + |
| 78 | +## MCP Tools |
| 79 | + |
| 80 | +### `get_system_info` |
| 81 | +Returns system information including hostname, OS, uptime, and platform details. |
| 82 | + |
| 83 | +### `get_cpu_metrics` |
| 84 | +Returns CPU usage, temperature, core count, and load average. |
| 85 | + |
| 86 | +**Optional Arguments:** |
| 87 | +- `temp_unit`: Override temperature unit |
| 88 | + |
| 89 | +### `get_memory_metrics` |
| 90 | +Returns RAM and swap usage statistics with both bytes and human-readable formats. |
| 91 | + |
| 92 | +### `get_disk_metrics` |
| 93 | +Returns disk usage for all or specified mount points. |
| 94 | + |
| 95 | +**Optional Arguments:** |
| 96 | +- `mount_points`: Comma-separated mount points to check |
| 97 | +- `human_readable`: Include human-readable sizes (default: true) |
| 98 | + |
| 99 | +### `get_network_metrics` |
| 100 | +Returns network interface statistics including bytes sent/received and IP addresses. |
| 101 | + |
| 102 | +**Optional Arguments:** |
| 103 | +- `interfaces`: Comma-separated interface names to check |
| 104 | + |
| 105 | +### `get_process_list` |
| 106 | +Returns list of running processes sorted by resource usage. |
| 107 | + |
| 108 | +**Optional Arguments:** |
| 109 | +- `limit`: Maximum number of processes (1-50) |
| 110 | +- `sort_by`: Sort by `cpu`, `memory`, or `pid` (default: `cpu`) |
| 111 | + |
| 112 | +### `get_thermal_status` |
| 113 | +Returns thermal status including CPU/GPU temperatures and throttling information (Raspberry Pi). |
| 114 | + |
| 115 | +**Optional Arguments:** |
| 116 | +- `temp_unit`: Override temperature unit |
| 117 | + |
| 118 | +## Example Usage |
| 119 | + |
| 120 | +Once configured, you can ask your AI assistant: |
| 121 | + |
| 122 | +- "What's my CPU temperature?" |
| 123 | +- "Show me disk usage for / and /home" |
| 124 | +- "List the top 5 processes by memory usage" |
| 125 | +- "What's my network usage on eth0?" |
| 126 | +- "Check if my Raspberry Pi is throttling" |
| 127 | + |
| 128 | +## Raspberry Pi Enhancements |
| 129 | + |
| 130 | +On Raspberry Pi systems, the server provides additional metrics: |
| 131 | + |
| 132 | +- **CPU Temperature**: Reads from `/sys/class/thermal/thermal_zone0/temp` |
| 133 | +- **GPU Temperature**: Uses `vcgencmd measure_temp` |
| 134 | +- **Throttling Status**: Uses `vcgencmd get_throttled` to detect: |
| 135 | + - Under-voltage conditions |
| 136 | + - Frequency capping |
| 137 | + - Thermal throttling |
| 138 | + - Soft temperature limits |
| 139 | + |
| 140 | +On non-Pi systems, these metrics return `"not_available"` gracefully. |
| 141 | + |
| 142 | +## Development |
| 143 | + |
| 144 | +Use the included `Makefile` for development tasks: |
| 145 | + |
| 146 | +```bash |
| 147 | +# Run tests |
| 148 | +make test |
| 149 | + |
| 150 | +# Run linter (go vet) |
| 151 | +make lint |
| 152 | + |
| 153 | +# Clean build artifacts |
| 154 | +make clean |
| 155 | + |
| 156 | +# Download and tidy dependencies |
| 157 | +make deps |
| 158 | +``` |
| 159 | + |
| 160 | +## Requirements |
| 161 | + |
| 162 | +- Go 1.25.6+ |
| 163 | +- Linux system |
| 164 | +- For Pi features: Raspberry Pi OS with `vcgencmd` available |
| 165 | + |
| 166 | +## License |
| 167 | + |
| 168 | +MIT |
0 commit comments