@samik081/mcp-pve 0.1.0
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/LICENSE +21 -0
- package/README.md +368 -0
- package/dist/core/client.d.ts +43 -0
- package/dist/core/client.js +143 -0
- package/dist/core/config.d.ts +15 -0
- package/dist/core/config.js +68 -0
- package/dist/core/errors.d.ts +24 -0
- package/dist/core/errors.js +43 -0
- package/dist/core/logger.d.ts +15 -0
- package/dist/core/logger.js +26 -0
- package/dist/core/server.d.ts +15 -0
- package/dist/core/server.js +30 -0
- package/dist/core/tools.d.ts +29 -0
- package/dist/core/tools.js +64 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +51 -0
- package/dist/tools/access.d.ts +7 -0
- package/dist/tools/access.js +234 -0
- package/dist/tools/backup.d.ts +7 -0
- package/dist/tools/backup.js +176 -0
- package/dist/tools/cluster.d.ts +7 -0
- package/dist/tools/cluster.js +150 -0
- package/dist/tools/firewall.d.ts +7 -0
- package/dist/tools/firewall.js +215 -0
- package/dist/tools/ha.d.ts +9 -0
- package/dist/tools/ha.js +138 -0
- package/dist/tools/index.d.ts +10 -0
- package/dist/tools/index.js +32 -0
- package/dist/tools/lxc.d.ts +7 -0
- package/dist/tools/lxc.js +371 -0
- package/dist/tools/network.d.ts +7 -0
- package/dist/tools/network.js +157 -0
- package/dist/tools/nodes.d.ts +7 -0
- package/dist/tools/nodes.js +131 -0
- package/dist/tools/pools.d.ts +7 -0
- package/dist/tools/pools.js +98 -0
- package/dist/tools/qemu.d.ts +7 -0
- package/dist/tools/qemu.js +394 -0
- package/dist/tools/storage.d.ts +7 -0
- package/dist/tools/storage.js +216 -0
- package/dist/tools/tasks.d.ts +7 -0
- package/dist/tools/tasks.js +106 -0
- package/dist/types/index.d.ts +25 -0
- package/dist/types/index.js +17 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Proxmox VE MCP Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
[](https://www.npmjs.com/package/@samik081/mcp-pve)
|
|
2
|
+
[](https://opensource.org/licenses/MIT)
|
|
3
|
+
[](https://nodejs.org)
|
|
4
|
+
|
|
5
|
+
# MCP PVE
|
|
6
|
+
|
|
7
|
+
MCP server for [Proxmox VE](https://www.proxmox.com/en/proxmox-virtual-environment/overview). Manage virtual machines, containers, storage, networking, and clusters through natural language in Cursor, Claude Code, and Claude Desktop.
|
|
8
|
+
|
|
9
|
+
> **Disclaimer:** Most of this code has been AI-generated and has not been fully tested yet. I created this project for my own needs and plan to continue improving its quality, but it may be buggy in the early stages. If you find a bug, feel free to [open an issue](https://github.com/Samik081/mcp-pve/issues) -- I'll try to work on it in my spare time.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- **105 tools** across **12 categories** covering the Proxmox VE REST API
|
|
14
|
+
- **Three access tiers** (`read-only`, `read-execute`, `full`) for granular control
|
|
15
|
+
- **Category filtering** via `PVE_CATEGORIES` to expose only the tools you need
|
|
16
|
+
- **Zero HTTP dependencies** -- uses native `fetch` (Node 18+)
|
|
17
|
+
- **Self-signed cert support** via `PVE_VERIFY_SSL=false`
|
|
18
|
+
- **TypeScript/ESM** with full type safety
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
Run the server directly with npx:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
PVE_BASE_URL="https://pve.example.com:8006" \
|
|
26
|
+
PVE_TOKEN_ID="root@pam!mcp" \
|
|
27
|
+
PVE_TOKEN_SECRET="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" \
|
|
28
|
+
npx -y @samik081/mcp-pve
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The server validates your PVE connection on startup and fails immediately with a clear error if credentials are missing or invalid.
|
|
32
|
+
|
|
33
|
+
## Configuration
|
|
34
|
+
|
|
35
|
+
**Claude Code CLI (recommended):**
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
claude mcp add --transport stdio pve \
|
|
39
|
+
--env PVE_BASE_URL=https://pve.example.com:8006 \
|
|
40
|
+
--env PVE_TOKEN_ID=root@pam!mcp \
|
|
41
|
+
--env PVE_TOKEN_SECRET=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
|
|
42
|
+
--env PVE_VERIFY_SSL=false \
|
|
43
|
+
-- npx -y @samik081/mcp-pve
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
**JSON config** (works with Claude Code `.mcp.json`, Claude Desktop `claude_desktop_config.json`, Cursor `.cursor/mcp.json`):
|
|
47
|
+
|
|
48
|
+
```json
|
|
49
|
+
{
|
|
50
|
+
"mcpServers": {
|
|
51
|
+
"pve": {
|
|
52
|
+
"command": "npx",
|
|
53
|
+
"args": ["-y", "@samik081/mcp-pve"],
|
|
54
|
+
"env": {
|
|
55
|
+
"PVE_BASE_URL": "https://pve.example.com:8006",
|
|
56
|
+
"PVE_TOKEN_ID": "root@pam!mcp",
|
|
57
|
+
"PVE_TOKEN_SECRET": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
|
|
58
|
+
"PVE_VERIFY_SSL": "false"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Access Tiers
|
|
66
|
+
|
|
67
|
+
Control which tools are available using the `PVE_ACCESS_TIER` environment variable:
|
|
68
|
+
|
|
69
|
+
| Tier | Tools | Description |
|
|
70
|
+
|------|-------|-------------|
|
|
71
|
+
| `full` (default) | 105 | Read, execute, and write -- full control |
|
|
72
|
+
| `read-execute` | 68 | Read and execute -- no resource creation/deletion |
|
|
73
|
+
| `read-only` | 51 | Read only -- safe for exploration, no state changes |
|
|
74
|
+
|
|
75
|
+
**Tier details:**
|
|
76
|
+
|
|
77
|
+
- **full**: All 105 tools. Includes creating/deleting VMs, containers, storage, users, firewall rules, and more.
|
|
78
|
+
- **read-execute**: 68 tools. All read tools plus power actions (start, stop, migrate), backup execution, and task management.
|
|
79
|
+
- **read-only**: 51 tools. List, get, status, and log tools only. No state changes.
|
|
80
|
+
|
|
81
|
+
Tools that are not available in your tier are not registered with the MCP server. They will not appear in your AI tool's tool list, keeping the context clean.
|
|
82
|
+
|
|
83
|
+
## Environment Variables
|
|
84
|
+
|
|
85
|
+
| Variable | Required | Default | Description |
|
|
86
|
+
|----------|----------|---------|-------------|
|
|
87
|
+
| `PVE_BASE_URL` | Yes | — | URL of your PVE instance (e.g. `https://pve:8006`) |
|
|
88
|
+
| `PVE_TOKEN_ID` | Yes | — | API token ID (`user@realm!tokenname`) |
|
|
89
|
+
| `PVE_TOKEN_SECRET` | Yes | — | API token UUID secret |
|
|
90
|
+
| `PVE_ACCESS_TIER` | No | `full` | `read-only`, `read-execute`, or `full` |
|
|
91
|
+
| `PVE_CATEGORIES` | No | all | Comma-separated category allowlist |
|
|
92
|
+
| `PVE_VERIFY_SSL` | No | `true` | Set `false` for self-signed certs |
|
|
93
|
+
| `DEBUG` | No | — | Set to any value to enable debug logging to stderr |
|
|
94
|
+
|
|
95
|
+
Create API tokens in the PVE UI under **Datacenter > Permissions > API Tokens**. Make sure to uncheck "Privilege Separation" if you want the token to inherit the user's full permissions.
|
|
96
|
+
|
|
97
|
+
### Available Categories
|
|
98
|
+
|
|
99
|
+
`nodes`, `qemu`, `lxc`, `storage`, `cluster`, `access`, `pools`, `network`, `firewall`, `backup`, `tasks`, `ha`
|
|
100
|
+
|
|
101
|
+
## Tools
|
|
102
|
+
|
|
103
|
+
mcp-pve provides 105 tools organized by category. Each tool's Access column shows the minimum tier required: `read-only` (available in all tiers), `read-execute` (requires `read-execute` or `full`), or `full` (requires `full` tier only).
|
|
104
|
+
|
|
105
|
+
<details>
|
|
106
|
+
<summary>Nodes (8 tools)</summary>
|
|
107
|
+
|
|
108
|
+
| Tool | Description | Access |
|
|
109
|
+
|------|-------------|--------|
|
|
110
|
+
| `pve_list_nodes` | List all nodes in the cluster | read-only |
|
|
111
|
+
| `pve_get_node_status` | Get detailed node status (CPU, memory, uptime, load) | read-only |
|
|
112
|
+
| `pve_get_node_version` | Get PVE version info for a node | read-only |
|
|
113
|
+
| `pve_get_node_dns` | Get DNS settings for a node | read-only |
|
|
114
|
+
| `pve_get_node_time` | Get time and timezone info for a node | read-only |
|
|
115
|
+
| `pve_get_node_syslog` | Get system log entries from a node | read-only |
|
|
116
|
+
| `pve_list_node_services` | List all system services on a node | read-only |
|
|
117
|
+
| `pve_manage_node_service` | Start, stop, restart, or reload a node service | read-execute |
|
|
118
|
+
|
|
119
|
+
</details>
|
|
120
|
+
|
|
121
|
+
<details>
|
|
122
|
+
<summary>QEMU Virtual Machines (20 tools)</summary>
|
|
123
|
+
|
|
124
|
+
| Tool | Description | Access |
|
|
125
|
+
|------|-------------|--------|
|
|
126
|
+
| `pve_list_qemu_vms` | List all QEMU VMs on a node | read-only |
|
|
127
|
+
| `pve_get_qemu_status` | Get current VM status (CPU, memory, disk, network) | read-only |
|
|
128
|
+
| `pve_get_qemu_config` | Get VM configuration | read-only |
|
|
129
|
+
| `pve_get_qemu_rrddata` | Get RRD statistics over a time period | read-only |
|
|
130
|
+
| `pve_list_qemu_snapshots` | List all VM snapshots | read-only |
|
|
131
|
+
| `pve_start_qemu_vm` | Start a VM | read-execute |
|
|
132
|
+
| `pve_stop_qemu_vm` | Stop a VM (immediate) | read-execute |
|
|
133
|
+
| `pve_shutdown_qemu_vm` | Gracefully shut down a VM | read-execute |
|
|
134
|
+
| `pve_reboot_qemu_vm` | Reboot a VM | read-execute |
|
|
135
|
+
| `pve_suspend_qemu_vm` | Suspend a VM | read-execute |
|
|
136
|
+
| `pve_resume_qemu_vm` | Resume a suspended VM | read-execute |
|
|
137
|
+
| `pve_reset_qemu_vm` | Reset a VM (hard) | read-execute |
|
|
138
|
+
| `pve_migrate_qemu_vm` | Migrate a VM to another node | read-execute |
|
|
139
|
+
| `pve_create_qemu_vm` | Create a new VM | full |
|
|
140
|
+
| `pve_delete_qemu_vm` | Delete a VM and all its data | full |
|
|
141
|
+
| `pve_update_qemu_config` | Update VM configuration | full |
|
|
142
|
+
| `pve_clone_qemu_vm` | Clone a VM | full |
|
|
143
|
+
| `pve_create_qemu_snapshot` | Create a VM snapshot | full |
|
|
144
|
+
| `pve_delete_qemu_snapshot` | Delete a VM snapshot | full |
|
|
145
|
+
| `pve_rollback_qemu_snapshot` | Rollback a VM to a snapshot | full |
|
|
146
|
+
|
|
147
|
+
</details>
|
|
148
|
+
|
|
149
|
+
<details>
|
|
150
|
+
<summary>LXC Containers (18 tools)</summary>
|
|
151
|
+
|
|
152
|
+
| Tool | Description | Access |
|
|
153
|
+
|------|-------------|--------|
|
|
154
|
+
| `pve_list_lxc_containers` | List all LXC containers on a node | read-only |
|
|
155
|
+
| `pve_get_lxc_status` | Get current container status | read-only |
|
|
156
|
+
| `pve_get_lxc_config` | Get container configuration | read-only |
|
|
157
|
+
| `pve_get_lxc_rrddata` | Get RRD statistics over a time period | read-only |
|
|
158
|
+
| `pve_list_lxc_snapshots` | List all container snapshots | read-only |
|
|
159
|
+
| `pve_start_lxc_container` | Start a container | read-execute |
|
|
160
|
+
| `pve_stop_lxc_container` | Stop a container (immediate) | read-execute |
|
|
161
|
+
| `pve_shutdown_lxc_container` | Gracefully shut down a container | read-execute |
|
|
162
|
+
| `pve_reboot_lxc_container` | Reboot a container | read-execute |
|
|
163
|
+
| `pve_suspend_lxc_container` | Suspend (freeze) a container | read-execute |
|
|
164
|
+
| `pve_resume_lxc_container` | Resume (unfreeze) a container | read-execute |
|
|
165
|
+
| `pve_create_lxc_container` | Create a new container | full |
|
|
166
|
+
| `pve_delete_lxc_container` | Delete a container and all its data | full |
|
|
167
|
+
| `pve_update_lxc_config` | Update container configuration | full |
|
|
168
|
+
| `pve_clone_lxc_container` | Clone a container | full |
|
|
169
|
+
| `pve_create_lxc_snapshot` | Create a container snapshot | full |
|
|
170
|
+
| `pve_delete_lxc_snapshot` | Delete a container snapshot | full |
|
|
171
|
+
| `pve_rollback_lxc_snapshot` | Rollback a container to a snapshot | full |
|
|
172
|
+
|
|
173
|
+
</details>
|
|
174
|
+
|
|
175
|
+
<details>
|
|
176
|
+
<summary>Storage (8 tools)</summary>
|
|
177
|
+
|
|
178
|
+
| Tool | Description | Access |
|
|
179
|
+
|------|-------------|--------|
|
|
180
|
+
| `pve_list_storage` | List all configured storage backends | read-only |
|
|
181
|
+
| `pve_get_storage_config` | Get storage backend configuration | read-only |
|
|
182
|
+
| `pve_list_node_storage` | List available storage on a node with usage info | read-only |
|
|
183
|
+
| `pve_get_storage_status` | Get storage status and usage on a node | read-only |
|
|
184
|
+
| `pve_list_storage_content` | List storage content (images, ISOs, backups) | read-only |
|
|
185
|
+
| `pve_create_storage` | Create a new storage backend | full |
|
|
186
|
+
| `pve_update_storage` | Update storage configuration | full |
|
|
187
|
+
| `pve_delete_storage` | Delete a storage backend | full |
|
|
188
|
+
|
|
189
|
+
</details>
|
|
190
|
+
|
|
191
|
+
<details>
|
|
192
|
+
<summary>Cluster (9 tools)</summary>
|
|
193
|
+
|
|
194
|
+
| Tool | Description | Access |
|
|
195
|
+
|------|-------------|--------|
|
|
196
|
+
| `pve_get_cluster_status` | Get cluster status (membership, quorum) | read-only |
|
|
197
|
+
| `pve_list_cluster_resources` | List all cluster resources with optional type filter | read-only |
|
|
198
|
+
| `pve_get_next_vmid` | Get the next available VMID | read-only |
|
|
199
|
+
| `pve_get_cluster_log` | Get recent cluster log entries | read-only |
|
|
200
|
+
| `pve_get_cluster_options` | Get datacenter options | read-only |
|
|
201
|
+
| `pve_list_cluster_backup_info` | List guests not covered by backup jobs | read-only |
|
|
202
|
+
| `pve_get_cluster_ha_status` | Get HA manager status | read-only |
|
|
203
|
+
| `pve_list_cluster_replication` | List all replication jobs | read-only |
|
|
204
|
+
| `pve_update_cluster_options` | Update datacenter options | full |
|
|
205
|
+
|
|
206
|
+
</details>
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
<summary>Access Control (10 tools)</summary>
|
|
210
|
+
|
|
211
|
+
| Tool | Description | Access |
|
|
212
|
+
|------|-------------|--------|
|
|
213
|
+
| `pve_list_users` | List all users | read-only |
|
|
214
|
+
| `pve_get_user` | Get user details | read-only |
|
|
215
|
+
| `pve_list_roles` | List all roles and privileges | read-only |
|
|
216
|
+
| `pve_list_groups` | List all user groups | read-only |
|
|
217
|
+
| `pve_list_acls` | List all ACL entries | read-only |
|
|
218
|
+
| `pve_list_domains` | List authentication domains/realms | read-only |
|
|
219
|
+
| `pve_create_user` | Create a new user | full |
|
|
220
|
+
| `pve_update_user` | Update user properties | full |
|
|
221
|
+
| `pve_delete_user` | Delete a user | full |
|
|
222
|
+
| `pve_update_acl` | Grant or revoke ACL permissions | full |
|
|
223
|
+
|
|
224
|
+
</details>
|
|
225
|
+
|
|
226
|
+
<details>
|
|
227
|
+
<summary>Pools (5 tools)</summary>
|
|
228
|
+
|
|
229
|
+
| Tool | Description | Access |
|
|
230
|
+
|------|-------------|--------|
|
|
231
|
+
| `pve_list_pools` | List all resource pools | read-only |
|
|
232
|
+
| `pve_get_pool` | Get pool details and members | read-only |
|
|
233
|
+
| `pve_create_pool` | Create a resource pool | full |
|
|
234
|
+
| `pve_update_pool` | Update pool members and settings | full |
|
|
235
|
+
| `pve_delete_pool` | Delete a resource pool | full |
|
|
236
|
+
|
|
237
|
+
</details>
|
|
238
|
+
|
|
239
|
+
<details>
|
|
240
|
+
<summary>Network (5 tools)</summary>
|
|
241
|
+
|
|
242
|
+
| Tool | Description | Access |
|
|
243
|
+
|------|-------------|--------|
|
|
244
|
+
| `pve_list_networks` | List all network interfaces on a node | read-only |
|
|
245
|
+
| `pve_get_network` | Get network interface configuration | read-only |
|
|
246
|
+
| `pve_create_network` | Create a network interface | full |
|
|
247
|
+
| `pve_update_network` | Update network interface configuration | full |
|
|
248
|
+
| `pve_delete_network` | Delete a network interface | full |
|
|
249
|
+
|
|
250
|
+
</details>
|
|
251
|
+
|
|
252
|
+
<details>
|
|
253
|
+
<summary>Firewall (8 tools)</summary>
|
|
254
|
+
|
|
255
|
+
| Tool | Description | Access |
|
|
256
|
+
|------|-------------|--------|
|
|
257
|
+
| `pve_get_firewall_options` | Get cluster firewall options | read-only |
|
|
258
|
+
| `pve_list_firewall_rules` | List cluster firewall rules | read-only |
|
|
259
|
+
| `pve_list_firewall_aliases` | List firewall aliases | read-only |
|
|
260
|
+
| `pve_list_firewall_ipsets` | List firewall IP sets | read-only |
|
|
261
|
+
| `pve_update_firewall_options` | Update cluster firewall options | full |
|
|
262
|
+
| `pve_create_firewall_rule` | Create a firewall rule | full |
|
|
263
|
+
| `pve_update_firewall_rule` | Update a firewall rule | full |
|
|
264
|
+
| `pve_delete_firewall_rule` | Delete a firewall rule | full |
|
|
265
|
+
|
|
266
|
+
</details>
|
|
267
|
+
|
|
268
|
+
<details>
|
|
269
|
+
<summary>Backup (5 tools)</summary>
|
|
270
|
+
|
|
271
|
+
| Tool | Description | Access |
|
|
272
|
+
|------|-------------|--------|
|
|
273
|
+
| `pve_list_backup_jobs` | List all scheduled backup jobs | read-only |
|
|
274
|
+
| `pve_get_backup_job` | Get backup job configuration | read-only |
|
|
275
|
+
| `pve_run_backup` | Run an immediate backup (vzdump) | read-execute |
|
|
276
|
+
| `pve_create_backup_job` | Create a scheduled backup job | full |
|
|
277
|
+
| `pve_delete_backup_job` | Delete a scheduled backup job | full |
|
|
278
|
+
|
|
279
|
+
</details>
|
|
280
|
+
|
|
281
|
+
<details>
|
|
282
|
+
<summary>Tasks (4 tools)</summary>
|
|
283
|
+
|
|
284
|
+
| Tool | Description | Access |
|
|
285
|
+
|------|-------------|--------|
|
|
286
|
+
| `pve_list_tasks` | List recent tasks on a node | read-only |
|
|
287
|
+
| `pve_get_task_status` | Get task status by UPID | read-only |
|
|
288
|
+
| `pve_get_task_log` | Get task log output by UPID | read-only |
|
|
289
|
+
| `pve_stop_task` | Stop a running task | read-execute |
|
|
290
|
+
|
|
291
|
+
</details>
|
|
292
|
+
|
|
293
|
+
<details>
|
|
294
|
+
<summary>High Availability (5 tools)</summary>
|
|
295
|
+
|
|
296
|
+
| Tool | Description | Access |
|
|
297
|
+
|------|-------------|--------|
|
|
298
|
+
| `pve_list_ha_resources` | List all HA-managed resources | read-only |
|
|
299
|
+
| `pve_get_ha_resource` | Get HA configuration for a resource | read-only |
|
|
300
|
+
| `pve_create_ha_resource` | Add a VM/container to HA management | full |
|
|
301
|
+
| `pve_update_ha_resource` | Update HA resource configuration | full |
|
|
302
|
+
| `pve_delete_ha_resource` | Remove a resource from HA management | full |
|
|
303
|
+
|
|
304
|
+
</details>
|
|
305
|
+
|
|
306
|
+
## Verify It Works
|
|
307
|
+
|
|
308
|
+
After configuring your MCP client, ask your AI assistant:
|
|
309
|
+
|
|
310
|
+
> "What nodes are in my Proxmox cluster?"
|
|
311
|
+
|
|
312
|
+
If the connection is working, the assistant will call `pve_list_nodes` and return your nodes with their current status.
|
|
313
|
+
|
|
314
|
+
## Usage Examples
|
|
315
|
+
|
|
316
|
+
Once configured, ask your AI tool questions in natural language:
|
|
317
|
+
|
|
318
|
+
- **"List all VMs on node pve1"** -- calls `pve_list_qemu_vms` to show VMs with their status, CPU, and memory usage.
|
|
319
|
+
|
|
320
|
+
- **"What's the status of VM 100?"** -- calls `pve_get_qemu_status` to show real-time resource utilization.
|
|
321
|
+
|
|
322
|
+
- **"Start container 200 on pve1"** -- calls `pve_start_lxc_container` to start the container and returns the task UPID.
|
|
323
|
+
|
|
324
|
+
- **"Create a snapshot of VM 100 called pre-upgrade"** -- calls `pve_create_qemu_snapshot` to create a snapshot before changes.
|
|
325
|
+
|
|
326
|
+
- **"Show me the cluster resources"** -- calls `pve_list_cluster_resources` to show all VMs, containers, storage, and nodes.
|
|
327
|
+
|
|
328
|
+
- **"Migrate VM 100 to node pve2"** -- calls `pve_migrate_qemu_vm` to live-migrate the VM to another node.
|
|
329
|
+
|
|
330
|
+
## Troubleshooting
|
|
331
|
+
|
|
332
|
+
**Connection refused / ECONNREFUSED**
|
|
333
|
+
Check that `PVE_BASE_URL` is correct and includes the port (default: 8006). Ensure the PVE host is reachable from where the MCP server is running.
|
|
334
|
+
|
|
335
|
+
**SSL certificate errors**
|
|
336
|
+
If your PVE instance uses a self-signed certificate, set `PVE_VERIFY_SSL=false`. This disables TLS verification for all requests.
|
|
337
|
+
|
|
338
|
+
**Invalid credentials / 401 Unauthorized**
|
|
339
|
+
Verify your API token ID and secret are correct. The token ID format is `user@realm!tokenname` (e.g. `root@pam!mcp`). Check that "Privilege Separation" is unchecked if you need full user permissions.
|
|
340
|
+
|
|
341
|
+
**Tools not showing up in your AI tool**
|
|
342
|
+
Check your access tier setting. In `read-only` mode, only 51 tools are registered. In `read-execute` mode, 68 tools are registered. Use `full` (or omit `PVE_ACCESS_TIER`) for all 105 tools. Check `PVE_CATEGORIES` -- only tools in listed categories are registered. Also verify the server started without errors by checking stderr output.
|
|
343
|
+
|
|
344
|
+
**Node.js version errors**
|
|
345
|
+
mcp-pve requires Node.js >= 18.0.0. Check your version with `node --version`.
|
|
346
|
+
|
|
347
|
+
**Parse errors or "invalid JSON" in MCP client**
|
|
348
|
+
This typically means something is writing to stdout besides the MCP server. Ensure no other tools, shell profiles, or startup scripts print to stdout when launching the server. The MCP protocol uses stdout for JSON-RPC communication. All mcp-pve logging goes to stderr.
|
|
349
|
+
|
|
350
|
+
## Development
|
|
351
|
+
|
|
352
|
+
```bash
|
|
353
|
+
# Install dependencies
|
|
354
|
+
npm install
|
|
355
|
+
|
|
356
|
+
# Build the project
|
|
357
|
+
npm run build
|
|
358
|
+
|
|
359
|
+
# Run in development mode (auto-reload)
|
|
360
|
+
npm run dev
|
|
361
|
+
|
|
362
|
+
# Open the MCP Inspector for interactive testing
|
|
363
|
+
npm run inspect
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## License
|
|
367
|
+
|
|
368
|
+
MIT
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for Proxmox VE API.
|
|
3
|
+
*
|
|
4
|
+
* Uses native fetch (Node 18+) with PVE API Token authentication.
|
|
5
|
+
* All PVE JSON responses are wrapped in {"data": ...} — this client
|
|
6
|
+
* unwraps them so callers get clean data.
|
|
7
|
+
*/
|
|
8
|
+
import type { AppConfig } from "../types/index.js";
|
|
9
|
+
export declare class PveClient {
|
|
10
|
+
private readonly authHeader;
|
|
11
|
+
private readonly apiBase;
|
|
12
|
+
private readonly baseUrl;
|
|
13
|
+
constructor(config: AppConfig);
|
|
14
|
+
/** Send a GET request and return unwrapped data. */
|
|
15
|
+
get(path: string): Promise<unknown>;
|
|
16
|
+
/** Send a POST request with optional body and return unwrapped data. */
|
|
17
|
+
post(path: string, body?: Record<string, unknown>): Promise<unknown>;
|
|
18
|
+
/** Send a PUT request with optional body and return unwrapped data. */
|
|
19
|
+
put(path: string, body?: Record<string, unknown>): Promise<unknown>;
|
|
20
|
+
/** Send a DELETE request and return unwrapped data. */
|
|
21
|
+
delete(path: string): Promise<unknown>;
|
|
22
|
+
/**
|
|
23
|
+
* Validate the connection to PVE by calling GET /api2/json/version.
|
|
24
|
+
* Logs the PVE version on success.
|
|
25
|
+
*/
|
|
26
|
+
validateConnection(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Core request method. Builds the full URL, sends the request,
|
|
29
|
+
* checks for errors, and unwraps PVE's {"data": ...} envelope.
|
|
30
|
+
*/
|
|
31
|
+
private request;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a PVE client from config.
|
|
35
|
+
* Registers credentials as sensitive patterns before creating the client.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createClient(config: AppConfig): PveClient;
|
|
38
|
+
/**
|
|
39
|
+
* Validate connectivity to PVE.
|
|
40
|
+
* Must be called during startup before accepting MCP connections.
|
|
41
|
+
* Exits the process with code 1 if validation fails.
|
|
42
|
+
*/
|
|
43
|
+
export declare function validateConnection(client: PveClient): Promise<void>;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for Proxmox VE API.
|
|
3
|
+
*
|
|
4
|
+
* Uses native fetch (Node 18+) with PVE API Token authentication.
|
|
5
|
+
* All PVE JSON responses are wrapped in {"data": ...} — this client
|
|
6
|
+
* unwraps them so callers get clean data.
|
|
7
|
+
*/
|
|
8
|
+
import { PveError, registerSensitivePattern, sanitizeMessage } from "./errors.js";
|
|
9
|
+
import { logger } from "./logger.js";
|
|
10
|
+
/** Request timeout in milliseconds. */
|
|
11
|
+
const REQUEST_TIMEOUT_MS = 30_000;
|
|
12
|
+
export class PveClient {
|
|
13
|
+
authHeader;
|
|
14
|
+
apiBase;
|
|
15
|
+
baseUrl;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.baseUrl = config.baseUrl;
|
|
18
|
+
this.authHeader = `PVEAPIToken=${config.tokenId}=${config.tokenSecret}`;
|
|
19
|
+
this.apiBase = `${config.baseUrl}/api2/json`;
|
|
20
|
+
}
|
|
21
|
+
/** Send a GET request and return unwrapped data. */
|
|
22
|
+
async get(path) {
|
|
23
|
+
return this.request("GET", path);
|
|
24
|
+
}
|
|
25
|
+
/** Send a POST request with optional body and return unwrapped data. */
|
|
26
|
+
async post(path, body) {
|
|
27
|
+
return this.request("POST", path, body);
|
|
28
|
+
}
|
|
29
|
+
/** Send a PUT request with optional body and return unwrapped data. */
|
|
30
|
+
async put(path, body) {
|
|
31
|
+
return this.request("PUT", path, body);
|
|
32
|
+
}
|
|
33
|
+
/** Send a DELETE request and return unwrapped data. */
|
|
34
|
+
async delete(path) {
|
|
35
|
+
return this.request("DELETE", path);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Validate the connection to PVE by calling GET /api2/json/version.
|
|
39
|
+
* Logs the PVE version on success.
|
|
40
|
+
*/
|
|
41
|
+
async validateConnection() {
|
|
42
|
+
const url = `${this.apiBase}/version`;
|
|
43
|
+
try {
|
|
44
|
+
const response = await fetch(url, {
|
|
45
|
+
method: "GET",
|
|
46
|
+
headers: { Authorization: this.authHeader },
|
|
47
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
48
|
+
});
|
|
49
|
+
if (response.status === 401 || response.status === 403) {
|
|
50
|
+
throw new PveError("Authentication failed -- check PVE_TOKEN_ID and PVE_TOKEN_SECRET", response.status);
|
|
51
|
+
}
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
throw new PveError(`Connection check failed: ${response.status} ${response.statusText}`, response.status);
|
|
54
|
+
}
|
|
55
|
+
const json = (await response.json());
|
|
56
|
+
const version = json.data?.version ?? "unknown";
|
|
57
|
+
const release = json.data?.release ?? "";
|
|
58
|
+
logger.info(`Connected to Proxmox VE at ${this.baseUrl} (version: ${version}${release ? `, release: ${release}` : ""})`);
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
if (err instanceof PveError)
|
|
62
|
+
throw err;
|
|
63
|
+
throw new PveError(sanitizeMessage(`Cannot connect to Proxmox VE at ${this.baseUrl}: ${err instanceof Error ? err.message : String(err)}`));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Core request method. Builds the full URL, sends the request,
|
|
68
|
+
* checks for errors, and unwraps PVE's {"data": ...} envelope.
|
|
69
|
+
*/
|
|
70
|
+
async request(method, path, body) {
|
|
71
|
+
const url = `${this.apiBase}${path}`;
|
|
72
|
+
const headers = {
|
|
73
|
+
Authorization: this.authHeader,
|
|
74
|
+
};
|
|
75
|
+
if (body !== undefined) {
|
|
76
|
+
headers["Content-Type"] = "application/json";
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const response = await fetch(url, {
|
|
80
|
+
method,
|
|
81
|
+
headers,
|
|
82
|
+
body: body !== undefined ? JSON.stringify(body) : undefined,
|
|
83
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
|
84
|
+
});
|
|
85
|
+
if (!response.ok) {
|
|
86
|
+
let detail = `${response.status} ${response.statusText}`;
|
|
87
|
+
try {
|
|
88
|
+
const errBody = (await response.json());
|
|
89
|
+
if (errBody.errors) {
|
|
90
|
+
const messages = Object.entries(errBody.errors)
|
|
91
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
92
|
+
.join(", ");
|
|
93
|
+
detail += ` — ${messages}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Ignore JSON parse failures on error bodies
|
|
98
|
+
}
|
|
99
|
+
throw new PveError(sanitizeMessage(`${method} ${path} failed: ${detail}`), response.status);
|
|
100
|
+
}
|
|
101
|
+
// Some DELETE/POST endpoints return empty or non-JSON responses
|
|
102
|
+
const contentType = response.headers.get("content-type") || "";
|
|
103
|
+
if (!contentType.includes("json")) {
|
|
104
|
+
const text = await response.text();
|
|
105
|
+
return text || null;
|
|
106
|
+
}
|
|
107
|
+
const json = (await response.json());
|
|
108
|
+
return json.data !== undefined ? json.data : json;
|
|
109
|
+
}
|
|
110
|
+
catch (err) {
|
|
111
|
+
if (err instanceof PveError)
|
|
112
|
+
throw err;
|
|
113
|
+
throw new PveError(sanitizeMessage(err instanceof Error ? err.message : String(err)));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Create a PVE client from config.
|
|
119
|
+
* Registers credentials as sensitive patterns before creating the client.
|
|
120
|
+
*/
|
|
121
|
+
export function createClient(config) {
|
|
122
|
+
registerSensitivePattern(config.tokenId);
|
|
123
|
+
registerSensitivePattern(config.tokenSecret);
|
|
124
|
+
return new PveClient(config);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Validate connectivity to PVE.
|
|
128
|
+
* Must be called during startup before accepting MCP connections.
|
|
129
|
+
* Exits the process with code 1 if validation fails.
|
|
130
|
+
*/
|
|
131
|
+
export async function validateConnection(client) {
|
|
132
|
+
try {
|
|
133
|
+
await client.validateConnection();
|
|
134
|
+
}
|
|
135
|
+
catch (error) {
|
|
136
|
+
logger.error("Failed to connect to Proxmox VE.");
|
|
137
|
+
logger.error("Check that PVE_BASE_URL is correct and the PVE host is reachable.");
|
|
138
|
+
if (error instanceof Error) {
|
|
139
|
+
logger.error(`Details: ${sanitizeMessage(error.message)}`);
|
|
140
|
+
}
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable parsing and validation.
|
|
3
|
+
* Reads required and optional config from process.env.
|
|
4
|
+
*/
|
|
5
|
+
import type { AppConfig } from "../types/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* Load and validate application config from environment variables.
|
|
8
|
+
*
|
|
9
|
+
* Required: PVE_BASE_URL, PVE_TOKEN_ID, PVE_TOKEN_SECRET
|
|
10
|
+
* Optional: PVE_ACCESS_TIER (default: 'full'), PVE_CATEGORIES,
|
|
11
|
+
* PVE_VERIFY_SSL (default: 'true'), DEBUG
|
|
12
|
+
*
|
|
13
|
+
* Throws clear error (no credentials in message) if required vars are missing.
|
|
14
|
+
*/
|
|
15
|
+
export declare function loadConfig(): AppConfig;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variable parsing and validation.
|
|
3
|
+
* Reads required and optional config from process.env.
|
|
4
|
+
*/
|
|
5
|
+
import { VALID_CATEGORIES } from "../types/index.js";
|
|
6
|
+
import { logger } from "./logger.js";
|
|
7
|
+
/**
|
|
8
|
+
* Determine the access tier from PVE_ACCESS_TIER.
|
|
9
|
+
*
|
|
10
|
+
* Valid values: "read-only", "read-execute", "full" (default).
|
|
11
|
+
*/
|
|
12
|
+
function parseAccessTier() {
|
|
13
|
+
const tier = process.env.PVE_ACCESS_TIER;
|
|
14
|
+
if (tier === "read-only" || tier === "read-execute") {
|
|
15
|
+
return tier;
|
|
16
|
+
}
|
|
17
|
+
return "full";
|
|
18
|
+
}
|
|
19
|
+
function parseCategories(value) {
|
|
20
|
+
if (value === undefined || value === "") {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const categories = value
|
|
24
|
+
.split(",")
|
|
25
|
+
.map((s) => s.trim())
|
|
26
|
+
.filter((s) => s.length > 0);
|
|
27
|
+
const invalid = categories.filter((c) => !VALID_CATEGORIES.includes(c));
|
|
28
|
+
if (invalid.length > 0) {
|
|
29
|
+
logger.warn(`Ignoring unknown categories: ${invalid.join(", ")}. Valid: ${VALID_CATEGORIES.join(", ")}`);
|
|
30
|
+
}
|
|
31
|
+
const valid = categories.filter((c) => VALID_CATEGORIES.includes(c));
|
|
32
|
+
return valid.length > 0 ? valid : null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Load and validate application config from environment variables.
|
|
36
|
+
*
|
|
37
|
+
* Required: PVE_BASE_URL, PVE_TOKEN_ID, PVE_TOKEN_SECRET
|
|
38
|
+
* Optional: PVE_ACCESS_TIER (default: 'full'), PVE_CATEGORIES,
|
|
39
|
+
* PVE_VERIFY_SSL (default: 'true'), DEBUG
|
|
40
|
+
*
|
|
41
|
+
* Throws clear error (no credentials in message) if required vars are missing.
|
|
42
|
+
*/
|
|
43
|
+
export function loadConfig() {
|
|
44
|
+
const baseUrl = process.env.PVE_BASE_URL;
|
|
45
|
+
const tokenId = process.env.PVE_TOKEN_ID;
|
|
46
|
+
const tokenSecret = process.env.PVE_TOKEN_SECRET;
|
|
47
|
+
const missing = [];
|
|
48
|
+
if (!baseUrl)
|
|
49
|
+
missing.push("PVE_BASE_URL");
|
|
50
|
+
if (!tokenId)
|
|
51
|
+
missing.push("PVE_TOKEN_ID");
|
|
52
|
+
if (!tokenSecret)
|
|
53
|
+
missing.push("PVE_TOKEN_SECRET");
|
|
54
|
+
if (missing.length > 0) {
|
|
55
|
+
throw new Error(`Missing required environment variables: ${missing.join(", ")}. ` +
|
|
56
|
+
"Set these variables to connect to your Proxmox VE instance.");
|
|
57
|
+
}
|
|
58
|
+
const verifySsl = process.env.PVE_VERIFY_SSL !== "false";
|
|
59
|
+
return {
|
|
60
|
+
baseUrl: baseUrl.replace(/\/+$/, ""),
|
|
61
|
+
tokenId: tokenId,
|
|
62
|
+
tokenSecret: tokenSecret,
|
|
63
|
+
accessTier: parseAccessTier(),
|
|
64
|
+
categories: parseCategories(process.env.PVE_CATEGORIES),
|
|
65
|
+
verifySsl,
|
|
66
|
+
debug: Boolean(process.env.DEBUG),
|
|
67
|
+
};
|
|
68
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error sanitization layer.
|
|
3
|
+
*
|
|
4
|
+
* Strips sensitive credentials from error messages before they reach
|
|
5
|
+
* the LLM context. All PVE API errors should go through sanitizeMessage()
|
|
6
|
+
* to produce safe error strings.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Register a string that should be redacted from all error messages.
|
|
10
|
+
* Called at startup with token ID and secret before any API calls.
|
|
11
|
+
*/
|
|
12
|
+
export declare function registerSensitivePattern(pattern: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Replace all registered sensitive patterns and common auth header
|
|
15
|
+
* patterns with [REDACTED].
|
|
16
|
+
*/
|
|
17
|
+
export declare function sanitizeMessage(message: string): string;
|
|
18
|
+
/**
|
|
19
|
+
* Custom error class for PVE API errors with optional HTTP status code.
|
|
20
|
+
*/
|
|
21
|
+
export declare class PveError extends Error {
|
|
22
|
+
readonly statusCode?: number;
|
|
23
|
+
constructor(message: string, statusCode?: number);
|
|
24
|
+
}
|