forked from gilby125/mcp-proxmox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
3269 lines (2896 loc) · 124 KB
/
index.js
File metadata and controls
3269 lines (2896 loc) · 124 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env node
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
import fetch from 'node-fetch';
import https from 'https';
import crypto from 'crypto';
import { readFileSync } from 'fs';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';
// Load environment variables from .env file
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const envPath = join(__dirname, '../.env');
try {
const envFile = readFileSync(envPath, 'utf8');
const envVars = envFile.split('\n').filter(line => line.includes('=') && !line.trim().startsWith('#'));
for (const line of envVars) {
const [key, ...values] = line.split('=');
// Validate key is a valid environment variable name (alphanumeric and underscore only)
if (key && values.length > 0 && /^[A-Z_][A-Z0-9_]*$/.test(key.trim())) {
// Remove surrounding quotes if present and trim
let value = values.join('=').trim();
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
value = value.slice(1, -1);
}
process.env[key.trim()] = value;
}
}
} catch (error) {
console.error('Warning: Could not load .env file:', error.message);
}
class ProxmoxServer {
constructor() {
this.server = new Server(
{
name: 'proxmox-server',
version: '1.0.0',
},
{
capabilities: {
tools: {},
},
}
);
this.proxmoxHost = process.env.PROXMOX_HOST;
if (!this.proxmoxHost) {
throw new Error('PROXMOX_HOST environment variable is required');
}
this.proxmoxUser = process.env.PROXMOX_USER || 'root@pam';
this.proxmoxTokenName = process.env.PROXMOX_TOKEN_NAME || 'mcpserver';
this.proxmoxTokenValue = process.env.PROXMOX_TOKEN_VALUE;
if (!this.proxmoxTokenValue) {
throw new Error('PROXMOX_TOKEN_VALUE environment variable is required');
}
this.proxmoxPort = process.env.PROXMOX_PORT || '8006';
this.allowElevated = process.env.PROXMOX_ALLOW_ELEVATED === 'true';
// Create agent that accepts self-signed certificates
this.httpsAgent = new https.Agent({
rejectUnauthorized: false
});
this.setupToolHandlers();
}
// Input validation methods for security
validateNodeName(node) {
if (!node || typeof node !== 'string') {
throw new Error('Node name is required and must be a string');
}
// Only allow alphanumeric, hyphens, and underscores
if (!/^[a-zA-Z0-9\-_]+$/.test(node)) {
throw new Error('Invalid node name format. Only alphanumeric, hyphens, and underscores allowed');
}
if (node.length > 64) {
throw new Error('Node name too long (max 64 characters)');
}
return node;
}
validateVMID(vmid) {
if (!vmid) {
throw new Error('VM ID is required');
}
const id = parseInt(vmid, 10);
if (isNaN(id) || id < 100 || id > 999999999) {
throw new Error('Invalid VM ID. Must be a number between 100 and 999999999');
}
return id.toString();
}
validateStorageName(storage) {
if (!storage || typeof storage !== 'string') {
throw new Error('Storage name is required and must be a string');
}
// Proxmox storage IDs: alphanumeric, hyphens, underscores, dots
if (!/^[a-zA-Z0-9\-_.]+$/.test(storage)) {
throw new Error('Invalid storage name format. Only alphanumeric, hyphens, underscores, and dots allowed');
}
if (storage.length > 64) {
throw new Error('Storage name too long (max 64 characters)');
}
return storage;
}
validateSnapshotName(snapname) {
if (!snapname || typeof snapname !== 'string') {
throw new Error('Snapshot name is required and must be a string');
}
// Proxmox snapshot names: alphanumeric, hyphens, underscores
if (!/^[a-zA-Z0-9\-_]+$/.test(snapname)) {
throw new Error('Invalid snapshot name format. Only alphanumeric, hyphens, and underscores allowed');
}
if (snapname.length > 40) {
throw new Error('Snapshot name too long (max 40 characters)');
}
return snapname;
}
validateDiskName(disk) {
if (!disk || typeof disk !== 'string') {
throw new Error('Disk name is required and must be a string');
}
// Valid Proxmox disk names: scsi0-15, virtio0-15, sata0-5, ide0-3, efidisk0, tpmstate0, rootfs, mp0-255
if (!/^(scsi|virtio|sata|ide|efidisk|tpmstate|rootfs|mp)\d*$/.test(disk)) {
throw new Error('Invalid disk name format. Expected: scsi0-15, virtio0-15, sata0-5, ide0-3, efidisk0, tpmstate0, rootfs, or mp0-255');
}
return disk;
}
validateNetworkName(net) {
if (!net || typeof net !== 'string') {
throw new Error('Network interface name is required and must be a string');
}
// Valid Proxmox network names: net0-31
if (!/^net\d{1,2}$/.test(net)) {
throw new Error('Invalid network interface name. Expected: net0-31');
}
const num = parseInt(net.replace('net', ''), 10);
if (num > 31) {
throw new Error('Network interface number out of range (max: net31)');
}
return net;
}
validateBridgeName(bridge) {
if (!bridge || typeof bridge !== 'string') {
throw new Error('Bridge name is required and must be a string');
}
// Proxmox bridges: vmbr0-999 or custom names (alphanumeric, hyphens, underscores)
if (!/^[a-zA-Z0-9\-_]+$/.test(bridge)) {
throw new Error('Invalid bridge name format. Only alphanumeric, hyphens, and underscores allowed');
}
if (bridge.length > 32) {
throw new Error('Bridge name too long (max 32 characters)');
}
return bridge;
}
validateMountPoint(mp) {
if (!mp || typeof mp !== 'string') {
throw new Error('Mount point name is required and must be a string');
}
// Valid Proxmox mount points: mp0-255, rootfs
if (!/^(mp\d{1,3}|rootfs)$/.test(mp)) {
throw new Error('Invalid mount point name. Expected: mp0-255 or rootfs');
}
if (mp.startsWith('mp')) {
const num = parseInt(mp.replace('mp', ''), 10);
if (num > 255) {
throw new Error('Mount point number out of range (max: mp255)');
}
}
return mp;
}
validateCommand(command) {
if (!command || typeof command !== 'string') {
throw new Error('Command is required and must be a string');
}
// Check for dangerous characters that could be used for command injection
const dangerousChars = /[;&|`$(){}[\]<>\\]/g;
if (dangerousChars.test(command)) {
throw new Error('Command contains potentially dangerous characters: ; & | ` $ ( ) { } [ ] < > \\');
}
// Limit command length
if (command.length > 1000) {
throw new Error('Command exceeds maximum allowed length (1000 characters)');
}
return command;
}
generateSecurePassword() {
// Generate a secure random password using Node.js crypto
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*';
let password = '';
const randomBytes = crypto.randomBytes(16);
for (let i = 0; i < 16; i++) {
password += chars[randomBytes[i] % chars.length];
}
return password;
}
async proxmoxRequest(endpoint, method = 'GET', body = null) {
const baseUrl = `https://${this.proxmoxHost}:${this.proxmoxPort}/api2/json`;
const url = `${baseUrl}${endpoint}`;
const headers = {
'Authorization': `PVEAPIToken=${this.proxmoxUser}!${this.proxmoxTokenName}=${this.proxmoxTokenValue}`,
'Content-Type': 'application/json'
};
const options = {
method,
headers,
agent: this.httpsAgent
};
if (body) {
options.body = JSON.stringify(body);
}
try {
const response = await fetch(url, options);
if (!response.ok) {
const errorText = await response.text();
throw new Error(`Proxmox API error: ${response.status} - ${errorText}`);
}
const textResponse = await response.text();
if (!textResponse.trim()) {
throw new Error('Empty response from Proxmox API');
}
const data = JSON.parse(textResponse);
return data.data;
} catch (error) {
if (error.name === 'SyntaxError') {
throw new Error(`Failed to parse Proxmox API response: ${error.message}`);
}
throw new Error(`Failed to connect to Proxmox: ${error.message}`);
}
}
setupToolHandlers() {
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [
{
name: 'proxmox_get_nodes',
description: 'List all Proxmox cluster nodes with their status and resources',
inputSchema: {
type: 'object',
properties: {}
}
},
{
name: 'proxmox_get_node_status',
description: 'Get detailed status information for a specific Proxmox node',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name (e.g., pve1, proxmox-node2)' }
},
required: ['node']
}
},
{
name: 'proxmox_get_vms',
description: 'List all virtual machines across the cluster with their status',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Optional: filter by specific node' },
type: { type: 'string', enum: ['qemu', 'lxc', 'all'], description: 'VM type filter', default: 'all' }
}
}
},
{
name: 'proxmox_get_vm_status',
description: 'Get detailed status information for a specific VM',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
type: { type: 'string', enum: ['qemu', 'lxc'], description: 'VM type', default: 'qemu' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_execute_vm_command',
description: 'Execute a shell command on a virtual machine via Proxmox API',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
command: { type: 'string', description: 'Shell command to execute' },
type: { type: 'string', enum: ['qemu', 'lxc'], description: 'VM type', default: 'qemu' }
},
required: ['node', 'vmid', 'command']
}
},
{
name: 'proxmox_get_storage',
description: 'List all storage pools and their usage across the cluster',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Optional: filter by specific node' }
}
}
},
{
name: 'proxmox_get_cluster_status',
description: 'Get overall cluster status including nodes and resource usage',
inputSchema: {
type: 'object',
properties: {}
}
},
{
name: 'proxmox_list_templates',
description: 'List available LXC container templates on a storage',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name' },
storage: { type: 'string', description: 'Storage name (e.g., local)', default: 'local' }
},
required: ['node']
}
},
{
name: 'proxmox_create_lxc',
description: 'Create a new LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container will be created' },
vmid: { type: 'string', description: 'Container ID number (must be unique, or use proxmox_get_next_vmid)' },
ostemplate: { type: 'string', description: 'OS template (e.g., local:vztmpl/debian-12-standard_12.2-1_amd64.tar.gz)' },
hostname: { type: 'string', description: 'Container hostname' },
password: { type: 'string', description: 'Root password' },
memory: { type: 'number', description: 'RAM in MB', default: 512 },
storage: { type: 'string', description: 'Storage location', default: 'local-lvm' },
rootfs: { type: 'string', description: 'Root filesystem size in GB', default: '8' }
},
required: ['node', 'vmid', 'ostemplate']
}
},
{
name: 'proxmox_create_vm',
description: 'Create a new QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM will be created' },
vmid: { type: 'string', description: 'VM ID number (must be unique, or use proxmox_get_next_vmid)' },
name: { type: 'string', description: 'VM name' },
memory: { type: 'number', description: 'RAM in MB', default: 512 },
cores: { type: 'number', description: 'Number of CPU cores', default: 1 },
sockets: { type: 'number', description: 'Number of CPU sockets', default: 1 },
disk_size: { type: 'string', description: 'Disk size (e.g., "8G", "10G")', default: '8G' },
storage: { type: 'string', description: 'Storage location for disk', default: 'local-lvm' },
iso: { type: 'string', description: 'ISO image (e.g., "local:iso/alpine-virt-3.19.1-x86_64.iso"), optional' },
ostype: { type: 'string', description: 'OS type (l26=Linux 2.6+, win10, etc)', default: 'l26' },
net0: { type: 'string', description: 'Network interface config', default: 'virtio,bridge=vmbr0' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_get_next_vmid',
description: 'Get the next available VM/Container ID number',
inputSchema: {
type: 'object',
properties: {}
}
},
{
name: 'proxmox_start_lxc',
description: 'Start an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_start_vm',
description: 'Start a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_stop_lxc',
description: 'Stop an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_stop_vm',
description: 'Stop a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_delete_lxc',
description: 'Delete an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number to delete' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_delete_vm',
description: 'Delete a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number to delete' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_reboot_lxc',
description: 'Reboot an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_reboot_vm',
description: 'Reboot a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_shutdown_lxc',
description: 'Gracefully shutdown an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_shutdown_vm',
description: 'Gracefully shutdown a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_pause_vm',
description: 'Pause a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_resume_vm',
description: 'Resume a paused QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_clone_lxc',
description: 'Clone an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID to clone from' },
newid: { type: 'string', description: 'New container ID' },
hostname: { type: 'string', description: 'Hostname for cloned container (optional)' }
},
required: ['node', 'vmid', 'newid']
}
},
{
name: 'proxmox_clone_vm',
description: 'Clone a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID to clone from' },
newid: { type: 'string', description: 'New VM ID' },
name: { type: 'string', description: 'Name for cloned VM (optional)' }
},
required: ['node', 'vmid', 'newid']
}
},
{
name: 'proxmox_resize_lxc',
description: 'Resize an LXC container CPU/memory (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
memory: { type: 'number', description: 'Memory in MB (optional)' },
cores: { type: 'number', description: 'Number of CPU cores (optional)' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_resize_vm',
description: 'Resize a QEMU VM CPU/memory (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
memory: { type: 'number', description: 'Memory in MB (optional)' },
cores: { type: 'number', description: 'Number of CPU cores (optional)' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_create_snapshot_lxc',
description: 'Create a snapshot of an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
snapname: { type: 'string', description: 'Snapshot name' }
},
required: ['node', 'vmid', 'snapname']
}
},
{
name: 'proxmox_create_snapshot_vm',
description: 'Create a snapshot of a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
snapname: { type: 'string', description: 'Snapshot name' }
},
required: ['node', 'vmid', 'snapname']
}
},
{
name: 'proxmox_list_snapshots_lxc',
description: 'List all snapshots of an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_list_snapshots_vm',
description: 'List all snapshots of a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_rollback_snapshot_lxc',
description: 'Rollback an LXC container to a snapshot (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
snapname: { type: 'string', description: 'Snapshot name to rollback to' }
},
required: ['node', 'vmid', 'snapname']
}
},
{
name: 'proxmox_rollback_snapshot_vm',
description: 'Rollback a QEMU virtual machine to a snapshot (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
snapname: { type: 'string', description: 'Snapshot name to rollback to' }
},
required: ['node', 'vmid', 'snapname']
}
},
{
name: 'proxmox_delete_snapshot_lxc',
description: 'Delete a snapshot of an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
snapname: { type: 'string', description: 'Snapshot name to delete' }
},
required: ['node', 'vmid', 'snapname']
}
},
{
name: 'proxmox_delete_snapshot_vm',
description: 'Delete a snapshot of a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
snapname: { type: 'string', description: 'Snapshot name to delete' }
},
required: ['node', 'vmid', 'snapname']
}
},
{
name: 'proxmox_create_backup_lxc',
description: 'Create a backup of an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
storage: { type: 'string', description: 'Storage location for backup', default: 'local' },
mode: { type: 'string', enum: ['snapshot', 'suspend', 'stop'], description: 'Backup mode', default: 'snapshot' },
compress: { type: 'string', enum: ['none', 'lzo', 'gzip', 'zstd'], description: 'Compression algorithm', default: 'zstd' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_create_backup_vm',
description: 'Create a backup of a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
storage: { type: 'string', description: 'Storage location for backup', default: 'local' },
mode: { type: 'string', enum: ['snapshot', 'suspend', 'stop'], description: 'Backup mode', default: 'snapshot' },
compress: { type: 'string', enum: ['none', 'lzo', 'gzip', 'zstd'], description: 'Compression algorithm', default: 'zstd' }
},
required: ['node', 'vmid']
}
},
{
name: 'proxmox_list_backups',
description: 'List all backups on a storage (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name' },
storage: { type: 'string', description: 'Storage name', default: 'local' }
},
required: ['node']
}
},
{
name: 'proxmox_restore_backup_lxc',
description: 'Restore an LXC container from backup (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container will be restored' },
vmid: { type: 'string', description: 'New container ID for restored container' },
archive: { type: 'string', description: 'Backup archive path (e.g., local:backup/vzdump-lxc-100-2025_11_06-09_00_00.tar.zst)' },
storage: { type: 'string', description: 'Storage location for restored container (optional)' }
},
required: ['node', 'vmid', 'archive']
}
},
{
name: 'proxmox_restore_backup_vm',
description: 'Restore a QEMU virtual machine from backup (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM will be restored' },
vmid: { type: 'string', description: 'New VM ID for restored VM' },
archive: { type: 'string', description: 'Backup archive path (e.g., local:backup/vzdump-qemu-100-2025_11_06-09_00_00.vma.zst)' },
storage: { type: 'string', description: 'Storage location for restored VM (optional)' }
},
required: ['node', 'vmid', 'archive']
}
},
{
name: 'proxmox_delete_backup',
description: 'Delete a backup file from storage (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name' },
storage: { type: 'string', description: 'Storage name (e.g., local)' },
volume: { type: 'string', description: 'Backup volume ID (e.g., local:backup/vzdump-lxc-100-2025_11_06-09_00_00.tar.zst)' }
},
required: ['node', 'storage', 'volume']
}
},
{
name: 'proxmox_add_disk_vm',
description: 'Add a new disk to a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
disk: { type: 'string', description: 'Disk name (e.g., scsi1, virtio1, sata1, ide1)' },
storage: { type: 'string', description: 'Storage name (e.g., local-lvm)' },
size: { type: 'string', description: 'Disk size in GB (e.g., 10)' }
},
required: ['node', 'vmid', 'disk', 'storage', 'size']
}
},
{
name: 'proxmox_add_mountpoint_lxc',
description: 'Add a mount point to an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
mp: { type: 'string', description: 'Mount point name (e.g., mp0, mp1, mp2)' },
storage: { type: 'string', description: 'Storage name (e.g., local-lvm)' },
size: { type: 'string', description: 'Mount point size in GB (e.g., 10)' }
},
required: ['node', 'vmid', 'mp', 'storage', 'size']
}
},
{
name: 'proxmox_resize_disk_vm',
description: 'Resize a QEMU VM disk (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
disk: { type: 'string', description: 'Disk name (e.g., scsi0, virtio0, sata0, ide0)' },
size: { type: 'string', description: 'New size with + for relative or absolute (e.g., +10G or 50G)' }
},
required: ['node', 'vmid', 'disk', 'size']
}
},
{
name: 'proxmox_resize_disk_lxc',
description: 'Resize an LXC container disk or mount point (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
disk: { type: 'string', description: 'Disk name (rootfs, mp0, mp1, etc.)' },
size: { type: 'string', description: 'New size with + for relative or absolute (e.g., +10G or 50G)' }
},
required: ['node', 'vmid', 'disk', 'size']
}
},
{
name: 'proxmox_remove_disk_vm',
description: 'Remove a disk from a QEMU virtual machine (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
disk: { type: 'string', description: 'Disk name to remove (e.g., scsi1, virtio1, sata1, ide1)' }
},
required: ['node', 'vmid', 'disk']
}
},
{
name: 'proxmox_remove_mountpoint_lxc',
description: 'Remove a mount point from an LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
mp: { type: 'string', description: 'Mount point name to remove (e.g., mp0, mp1, mp2)' }
},
required: ['node', 'vmid', 'mp']
}
},
{
name: 'proxmox_move_disk_vm',
description: 'Move a QEMU VM disk to different storage (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
disk: { type: 'string', description: 'Disk name to move (e.g., scsi0, virtio0, sata0, ide0)' },
storage: { type: 'string', description: 'Target storage name' },
delete: { type: 'boolean', description: 'Delete source disk after move (default: true)', default: true }
},
required: ['node', 'vmid', 'disk', 'storage']
}
},
{
name: 'proxmox_move_disk_lxc',
description: 'Move an LXC container disk to different storage (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
disk: { type: 'string', description: 'Disk/volume name to move (rootfs, mp0, mp1, etc.)' },
storage: { type: 'string', description: 'Target storage name' },
delete: { type: 'boolean', description: 'Delete source disk after move (default: true)', default: true }
},
required: ['node', 'vmid', 'disk', 'storage']
}
},
{
name: 'proxmox_add_network_vm',
description: 'Add network interface to QEMU VM (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
net: { type: 'string', description: 'Network interface name (net0, net1, net2, etc.)' },
bridge: { type: 'string', description: 'Bridge name (e.g., vmbr0, vmbr1)' },
model: { type: 'string', description: 'Network model (virtio, e1000, rtl8139, vmxnet3)', default: 'virtio' },
macaddr: { type: 'string', description: 'MAC address (XX:XX:XX:XX:XX:XX) - auto-generated if not specified' },
vlan: { type: 'number', description: 'VLAN tag (1-4094)' },
firewall: { type: 'boolean', description: 'Enable firewall on this interface' }
},
required: ['node', 'vmid', 'net', 'bridge']
}
},
{
name: 'proxmox_add_network_lxc',
description: 'Add network interface to LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
net: { type: 'string', description: 'Network interface name (net0, net1, net2, etc.)' },
bridge: { type: 'string', description: 'Bridge name (e.g., vmbr0, vmbr1)' },
ip: { type: 'string', description: 'IP address (dhcp, 192.168.1.100/24, auto)' },
gw: { type: 'string', description: 'Gateway IP address' },
firewall: { type: 'boolean', description: 'Enable firewall on this interface' }
},
required: ['node', 'vmid', 'net', 'bridge']
}
},
{
name: 'proxmox_update_network_vm',
description: 'Update/modify VM network interface configuration (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
net: { type: 'string', description: 'Network interface name to update (net0, net1, net2, etc.)' },
bridge: { type: 'string', description: 'Bridge name (e.g., vmbr0, vmbr1)' },
model: { type: 'string', description: 'Network model (virtio, e1000, rtl8139, vmxnet3)' },
macaddr: { type: 'string', description: 'MAC address (XX:XX:XX:XX:XX:XX)' },
vlan: { type: 'number', description: 'VLAN tag (1-4094)' },
firewall: { type: 'boolean', description: 'Enable firewall on this interface' }
},
required: ['node', 'vmid', 'net']
}
},
{
name: 'proxmox_update_network_lxc',
description: 'Update/modify LXC network interface configuration (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
net: { type: 'string', description: 'Network interface name to update (net0, net1, net2, etc.)' },
bridge: { type: 'string', description: 'Bridge name (e.g., vmbr0, vmbr1)' },
ip: { type: 'string', description: 'IP address (dhcp, 192.168.1.100/24, auto)' },
gw: { type: 'string', description: 'Gateway IP address' },
firewall: { type: 'boolean', description: 'Enable firewall on this interface' }
},
required: ['node', 'vmid', 'net']
}
},
{
name: 'proxmox_remove_network_vm',
description: 'Remove network interface from QEMU VM (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where VM is located' },
vmid: { type: 'string', description: 'VM ID number' },
net: { type: 'string', description: 'Network interface name to remove (net0, net1, net2, etc.)' }
},
required: ['node', 'vmid', 'net']
}
},
{
name: 'proxmox_remove_network_lxc',
description: 'Remove network interface from LXC container (requires elevated permissions)',
inputSchema: {
type: 'object',
properties: {
node: { type: 'string', description: 'Node name where container is located' },
vmid: { type: 'string', description: 'Container ID number' },
net: { type: 'string', description: 'Network interface name to remove (net0, net1, net2, etc.)' }
},
required: ['node', 'vmid', 'net']
}
}
]
}));
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
const { name, arguments: args } = request.params;
try {
switch (name) {
case 'proxmox_get_nodes':
return await this.getNodes();
case 'proxmox_get_node_status':
return await this.getNodeStatus(args.node);