proxmox-mcp
by NotYourGuy
README.md
# proxmox-mcp
An [MCP](https://modelcontextprotocol.io) server for Proxmox VE and Proxmox Backup Server (PBS).
It gives an MCP client (Claude Code, Claude Desktop, ...) read access to your cluster and backups,
a health check that finds what needs attention, and, only if you turn them on, a small set of
guarded write tools (power, snapshots, backup, migrate). The same health check ships as a
command, `proxmox-mcp-check`, that can run on a schedule and send notifications to
[ntfy](https://ntfy.sh).
## Features
- 18 read-only tools: cluster, node, guest, storage, backup and task information for Proxmox VE,
datastore, snapshot and task information for PBS, plus `api_get` / `pbs_api_get` for any other
`GET` endpoint.
- A health check that reports problems worst first: quorum, node and storage usage, stale or
failed backups, guests missing from backup jobs, failed tasks, expiring certificates, PBS
datastore state.
- Six write tools (`guest_power`, `create_snapshot`, `rollback_snapshot`, `delete_snapshot`,
`backup_guest`, `migrate_guest`), absent unless explicitly enabled.
- `proxmox-mcp-check`: the health check as a CLI with exit codes and ntfy notifications.
- Authentication with API tokens only; token secrets are read from a file, never from the
environment or the command line.
- No dependencies beyond the `mcp` SDK; the HTTPS client uses the standard library.
## Safety model
Read-only is the default. The write tools are designed so that enabling them still leaves a small
blast radius:
- **Opt-in.** The write tools are registered only when `PROXMOX_ALLOW_WRITES=true`. Otherwise the
server does not expose them and the HTTP client refuses every `POST`, `PUT` and `DELETE` before
anything is sent, whatever the API token is allowed to do.
- **Fixed set of operations.** There is deliberately no tool that deletes a guest, edits a
guest's configuration or sends an arbitrary write to the API. `api_get` and `pbs_api_get` only
issue `GET`.
- **Reads stay outside guests and backups.** `api_get` and `pbs_api_get` refuse `GET` endpoints
that return data from inside a guest or a backup, secrets, or open a console (guest-agent
`file-read` and `exec-status`, file-restore, cloud-init dumps, backup downloads, file lists and
catalogs, console and migration websockets, TFA settings, configs extracted from backups) and
endpoints that make the server contact another host (any `query-*` endpoint, storage `scan`,
ACME `meta`/`tos`, and any request whose parameters contain a URL),
whatever the token would allow. Node logs (`journal`, `syslog`) stay readable for
troubleshooting; they need the separate `Sys.Syslog` privilege, which `PVEAuditor` does not
grant. This is defence in depth: the token's roles remain the real boundary.
- **PBS is read-only.** The PBS client is never created with write access.
- **Checked before acting.** Each write tool looks up the guest first and checks its live
status (for example it will not start a running guest, shut down a stopped one, or act on a
template), validates snapshot names and node names, and for rollback and delete confirms the
snapshot exists. Migration targets must be online nodes of the cluster.
- **One call, then the task.** Each tool sends a single API call, then waits up to
`wait_seconds` (at most 300) for the resulting task and reports its outcome or its log tail on
failure. Long tasks are reported as still running; follow them with `task_log`.
- **Annotated.** Destructive tools (`guest_power`, `rollback_snapshot`, `delete_snapshot`,
`migrate_guest`) carry the MCP destructive-tool hint so clients can ask for confirmation.
- **Least privilege on the Proxmox side.** Use a dedicated API token with only the roles
listed below. Proxmox enforces those permissions regardless of this server.
- **TLS is always verified.** There is no switch to disable verification; use a CA file or a
pinned fingerprint for private certificates.
- **Token handling.** The token secret file must not be readable by group or others (the server
refuses to use it otherwise), and error messages never contain the token.
- **The scheduled checker only reads**, whatever `PROXMOX_ALLOW_WRITES` says.
## Tools
| Tool | What it returns |
|---|---|
| `health_check` | Everything that needs attention, worst first (see below) |
| `backup_summary` | Each guest's backup count and newest backup; backups of guests that are gone |
| `cluster_overview` | Quorum, each node's CPU and memory, guest counts |
| `node_details` | Versions, hardware, load and memory of one node |
| `list_guests` | VMs and containers, filterable by node, kind, status, name |
| `guest_details` | State and full configuration of one VM or container |
| `list_snapshots` | Snapshots of one VM or container |
| `list_storage` | Storage pools with usage |
| `list_backups` | Backup archives, newest first, filterable by guest or storage |
| `backup_coverage` | Backup jobs, and guests not covered by any job |
| `list_tasks` | Recent cluster tasks, optionally only failures |
| `task_log` | Status and log tail of one task |
| `api_get` | Any other `GET` path of the Proxmox VE API |
| `pbs_datastores` | PBS datastores with usage |
| `pbs_snapshots` | Backup snapshots in a datastore, with verification state |
| `pbs_tasks` | Recent PBS tasks |
| `pbs_task_log` | The log of one PBS task, optionally only matching lines |
| `pbs_api_get` | Any other `GET` path of the PBS API |
The `pbs_*` tools are registered only when `PBS_URL` is set.
### Write tools
Registered only when `PROXMOX_ALLOW_WRITES=true`:
| Tool | What it does |
|---|---|
| `guest_power` | Start, shut down, reboot or hard-stop a VM or container |
| `create_snapshot` | Take a snapshot, optionally including a VM's memory |
| `rollback_snapshot` | Roll back to a snapshot (changes since then are lost) |
| `delete_snapshot` | Delete one snapshot |
| `backup_guest` | Back up one guest now |
| `migrate_guest` | Move a guest to another node, with its local disks |
Each one checks the guest first, sends a single API call, then waits up to `wait_seconds` for
the task and reports its result. There is deliberately no tool that deletes a guest, edits its
configuration, or sends an arbitrary write to the API.
## Health check
`health_check` (and the `proxmox-mcp-check` command) looks at:
| Check | Critical | Warning |
|---|---|---|
| Cluster | No quorum, node offline | |
| Nodes | Root filesystem 90% full | Memory 90% used, root filesystem 80% full |
| Storage | Not available, 90% full | 80% full |
| Guest locks | | Locked with no task running |
| Backups | Guest with no backup, newest older than 72 h, newest failed verification, backup storage unreadable | Newest older than 36 h, guest in no backup job |
| Tasks | Backup job failed in the last 24 h | Other task failed in the last 24 h |
| Certificates | Expired | Expires within 14 days |
| Backup server | Unreachable, datastore error or 90% full, backup/verify/GC task failed | 80% full, estimated full within 30 days |
A failed task is not reported once the same task has succeeded again, and a failed backup job is
settled once every guest on that node has a backup made since the job started. The backup age
limits are a setting (36 h by default; critical at twice that). Long node uptime is listed as
information and never changes the status.
### Running it on a schedule
```sh
proxmox-mcp-check # print the report
proxmox-mcp-check --notify # also notify when problems appear, change or clear
proxmox-mcp-check --env-file /path/to/settings.env --notify --quiet
```
The exit status is 0 when healthy, 1 with warnings, 2 when critical and 3 if the check could not
run or notify. The checker only reads, whatever `PROXMOX_ALLOW_WRITES` says.
With `--notify` it posts to an [ntfy](https://ntfy.sh) topic. To avoid repeating itself it
remembers what it last reported: it notifies when the set of problems changes, once when
everything clears, and again as a reminder if the same problems are still open after 24 hours
(`--remind-hours`).
| Variable | Meaning |
|---|---|
| `PROXMOX_NOTIFY_URL` | ntfy topic URL, e.g. `https://ntfy.example.com/proxmox` |
| `PROXMOX_NOTIFY_TOKEN_FILE` | Optional file with an ntfy access token |
| `PROXMOX_STATE_DIR` | Where to remember the last report (default `~/.local/state/proxmox-mcp`) |
## Install
Requires Python 3.11+ and [uv](https://docs.astral.sh/uv/).
```sh
git clone https://github.com/NotYourGuy/proxmox-mcp.git proxmox-mcp
cd proxmox-mcp
uv sync
```
Put the token secret in a file only you can read:
```sh
mkdir -p ~/.config/proxmox-mcp
printf '%s' 'YOUR-TOKEN-SECRET' > ~/.config/proxmox-mcp/pve_token
chmod 600 ~/.config/proxmox-mcp/pve_token
```
## Configuration
All settings are environment variables. See [`.env.example`](.env.example) for a template. The MCP
server reads its own environment (set the variables in your MCP client config); only
`proxmox-mcp-check` can also read a `KEY=VALUE` file via `--env-file`.
| Variable | Required | Meaning |
|---|---|---|
| `PROXMOX_URL` | yes | `https://host:8006`, no path |
| `PROXMOX_TOKEN_ID` | yes | `user@realm!tokenname` |
| `PROXMOX_TOKEN_FILE` | yes | File containing only the token secret; must be `chmod 600` |
| `PROXMOX_TLS_FINGERPRINT` | no | SHA-256 fingerprint of the server certificate (see TLS) |
| `PROXMOX_CA_FILE` | no | CA bundle, for a private CA |
| `PROXMOX_TIMEOUT` | no | Request timeout in seconds, 1 to 300 (default 30) |
| `PROXMOX_ALLOW_WRITES` | no | `true` to register the write tools (default `false`) |
| `PBS_URL` | no | `https://host:8007`; setting it enables the `pbs_*` tools |
| `PBS_TOKEN_ID`, `PBS_TOKEN_FILE`, `PBS_TLS_FINGERPRINT`, `PBS_CA_FILE`, `PBS_TIMEOUT` | with `PBS_URL` | The same as above, for PBS; PBS needs its own token |
| `PROXMOX_NOTIFY_URL` | for `--notify` | ntfy topic URL, e.g. `https://ntfy.example.com/proxmox` |
| `PROXMOX_NOTIFY_TOKEN_FILE` | no | File with an ntfy access token |
| `PROXMOX_STATE_DIR` | no | Where the checker remembers its last report (default `~/.local/state/proxmox-mcp`) |
### API tokens
Create a dedicated token with only the roles it needs, not a root token:
- Proxmox VE, read-only: role `PVEAuditor` on `/`.
- Proxmox VE, with the write tools: `PVEAuditor` plus a role holding `VM.PowerMgmt`,
`VM.Snapshot`, `VM.Snapshot.Rollback`, `VM.Backup`, `VM.Migrate` and `Datastore.AllocateSpace`:
```sh
pveum role add MCPOperator --privs "VM.PowerMgmt VM.Snapshot VM.Snapshot.Rollback VM.Backup VM.Migrate Datastore.AllocateSpace"
pveum acl modify / --tokens 'mcp@pve!mcp' --roles PVEAuditor,MCPOperator
```
This only takes effect for a token created with privilege separation on.
- Proxmox Backup Server: role `Audit` on `/` (or `DatastoreAudit` on the datastores).
### TLS
Certificates are verified against the system CA store by default and there is no switch to turn
verification off. If the server's certificate is self-signed or expired, pin it instead: set
`PROXMOX_TLS_FINGERPRINT` to the SHA-256 fingerprint shown in the web UI under
*node → System → Certificates*. The pin is checked before the token is sent, and must be
updated whenever the certificate is renewed.
## MCP client configuration
Claude Code:
```sh
claude mcp add proxmox --scope user \
--env PROXMOX_URL=https://pve.example.com:8006 \
--env 'PROXMOX_TOKEN_ID=mcp@pve!mcp' \
--env PROXMOX_TOKEN_FILE=$HOME/.config/proxmox-mcp/pve_token \
-- uv run --directory /path/to/proxmox-mcp proxmox-mcp
```
Claude Desktop (`claude_desktop_config.json`) or any client that takes an `mcpServers` block:
```json
{
"mcpServers": {
"proxmox": {
"command": "uv",
"args": ["run", "--directory", "/path/to/proxmox-mcp", "proxmox-mcp"],
"env": {
"PROXMOX_URL": "https://pve.example.com:8006",
"PROXMOX_TOKEN_ID": "mcp@pve!mcp",
"PROXMOX_TOKEN_FILE": "/home/user/.config/proxmox-mcp/pve_token",
"PBS_URL": "https://pbs.example.com:8007",
"PBS_TOKEN_ID": "mcp@pbs!mcp",
"PBS_TOKEN_FILE": "/home/user/.config/proxmox-mcp/pbs_token"
}
}
}
}
```
Omit the `PBS_*` variables if you have no Backup Server. Add `"PROXMOX_ALLOW_WRITES": "true"` only
when you want the write tools.
## Layout
| Module | Role |
|---|---|
| `client.py` | HTTPS client: token auth, TLS, read-only unless writes are allowed |
| `config.py` | Settings from environment variables |
| `cluster.py` | Cluster queries shared by tools and checks |
| `formatting.py` | Raw API values to small results |
| `health.py` | The health checks and backup summary |
| `check.py` | The `proxmox-mcp-check` command and notifications |
| `tools/` | MCP tools: `health`, `read`, `write`, `pbs`, and what they share in `common` |
| `server.py` | Assembles the MCP server |
## Development
```sh
uv sync
uv run pytest
```
The tests are fully mocked: they use fake API responses and, for the transport tests, a local
HTTPS server on `127.0.0.1` with a throwaway certificate. No Proxmox server is needed.
## Limitations
- Stdio transport only; there is no HTTP/SSE mode.
- Authentication is by API token only (no ticket or password login).
- The write tools cover guests (VMs and containers) only. There are no tools for storage,
network, users, firewall or cluster configuration, and none for PBS writes.
- Task waiting is capped at 300 seconds; longer tasks must be followed with `task_log`.
- The health check thresholds (80/90% usage, 14-day certificate expiry, backup age) are
fixed in code apart from the backup age limit.
- The tests use mocked API responses; the code has not been verified against every Proxmox VE or
PBS version.
## License
MIT, see [LICENSE](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues