meshcentral-mcp
# meshcentral-mcp
An [MCP](https://modelcontextprotocol.io) server for [MeshCentral](https://meshcentral.com), so Claude (or any MCP client) can list your machines, run commands, show messages and **gracefully reboot** them. It wraps MeshCentral's own `meshctrl` client.
> Unofficial community project. Not affiliated with or endorsed by MeshCentral or Intel. Apache-2.0.
## Safe by default
Reading is always allowed. Anything that changes a machine is **off** until the operator turns it on with an environment variable:
| Variable | Enables |
|---|---|
| `MESH_MCP_ALLOW_COMMANDS=1` | `mesh_run_command` (the agent usually runs as root/SYSTEM, so this is full control) |
| `MESH_MCP_ALLOW_POWER=1` | `mesh_graceful_reboot`, `mesh_cancel_reboot`, `mesh_power` |
| `MESH_MCP_ALLOW_NOTIFY=1` | `mesh_device_message`, `mesh_device_toast` |
| `MESH_MCP_ALLOW_ALL=1` | all of the above |
| `MESH_MCP_DEVICE_ALLOWLIST=omen,lab-*` | restrict write tools to these device names / node ids (globs allowed) |
Other safeguards: write tools refuse offline devices instead of queueing, ambiguous names are rejected, every write is logged as JSON to stderr (never including credentials), and commands run with no shell between the server and `meshctrl`.
## Tools
| Tool | Type | What it does |
|---|---|---|
| `mesh_server_info` | read | MeshCentral server version/settings |
| `mesh_list_device_groups` | read | device groups the account can see |
| `mesh_list_devices` | read | id, name, group, online, OS, user; optional `filter`, `group`, `online_only` |
| `mesh_device_info` | read | details for one device (name or node id) |
| `mesh_run_command` | write | run a command via the agent and return the output |
| `mesh_graceful_reboot` | write | `shutdown /r` (Windows) or `shutdown -r` (Linux/macOS) with a delay and a message |
| `mesh_cancel_reboot` | write | `shutdown /a` / `shutdown -c` |
| `mesh_power` | write | wake / sleep / reset / off through MeshCentral (reset and off are **not** graceful) |
| `mesh_device_message`, `mesh_device_toast` | write | message box / toast for the logged-in user |
## Setup
```bash
git clone https://github.com/klepsydra/meshcentral-mcp
cd meshcentral-mcp
npm install && npm run build
```
Create a login key on the MeshCentral server (this lets the account sign in without a password, and is revocable by regenerating it):
```bash
cd /path/to/meshcentral && node node_modules/meshcentral --logintokenkey # prints a hex key
install -m 600 /dev/stdin ~/.meshcentral-login.key <<< "<the hex key>"
```
Use a dedicated MeshCentral user with only the device groups you want exposed. Passwords work too (`MESHCENTRAL_PASSWORD`), but the value is visible to local `ps` while a call runs, so prefer the key file.
### Environment
| Variable | Notes |
|---|---|
| `MESHCENTRAL_URL` | e.g. `wss://mesh.example.com` |
| `MESHCENTRAL_USER` | MeshCentral username |
| `MESHCENTRAL_LOGIN_KEY_FILE` | path to the key file (recommended), or `MESHCENTRAL_LOGIN_KEY` |
| `MESHCENTRAL_PASSWORD`, `MESHCENTRAL_TOKEN` | password / 2FA token alternative |
| `MESHCENTRAL_DOMAIN` | for multi-domain servers |
| `MESHCTRL_PATH` | use an existing `meshctrl.js` instead of the bundled `meshcentral` dependency |
### Claude Code
```bash
claude mcp add meshcentral \
--env MESHCENTRAL_URL=wss://mesh.example.com \
--env MESHCENTRAL_USER=mcp \
--env MESHCENTRAL_LOGIN_KEY_FILE=$HOME/.meshcentral-login.key \
--env MESH_MCP_ALLOW_POWER=1 \
-- node /path/to/meshcentral-mcp/dist/index.js
```
### Claude Desktop
```json
{
"mcpServers": {
"meshcentral": {
"command": "node",
"args": ["/path/to/meshcentral-mcp/dist/index.js"],
"env": {
"MESHCENTRAL_URL": "wss://mesh.example.com",
"MESHCENTRAL_USER": "mcp",
"MESHCENTRAL_LOGIN_KEY_FILE": "/home/you/.meshcentral-login.key",
"MESH_MCP_ALLOW_POWER": "1"
}
}
}
}
```
Then ask: "Which machines are online?" or "Reboot omen in 2 minutes and warn whoever is logged in."
## Sample client
`examples/sample-client.mjs` starts the server over stdio, lists tools and devices, and with `--reboot <device>` schedules a graceful reboot and cancels it (needs `MESH_MCP_ALLOW_POWER=1`). It is also a minimal template for calling the tools from your own code.
## Development
```bash
npm test # builds, then runs the tests with a fake meshctrl (no server needed)
```
Ideas and contributions welcome, especially an HTTP transport for remote connectors, file upload/download, and a pure-WebSocket backend that drops the `meshctrl` subprocess.
TDQS
Scored across 10 tools
Most tools are clearly separated by target and action (list devices, device info, run command, reboot, cancel reboot). The main overlap is mesh_graceful_reboot versus mesh_power, and mesh_device_message versus mesh_device_toast, but the descriptions explain when to prefer each.
All tools share a consistent mesh_ prefix, which makes the set predictable. However, the suffix style is mixed: mostly verb_noun (list_devices, run_command), but also noun-style names like server_info and device_info.
Ten tools is well-scoped for a MeshCentral remote-management server. Each tool corresponds to a distinct operational need: discovery, inspection, command execution, power control, and user notification.
The core remote-management lifecycle is covered: server and device discovery, device inspection, command execution, reboot/power management, and user messaging. Minor gaps remain around file transfer, device/group administration, or event/audit history, but common workflows are supported.