@solomonneas/proxmox-mcp 0.3.0 → 0.5.1

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/dist/index.js CHANGED
@@ -14,6 +14,13 @@ function isTruthy(value) {
14
14
  if (!value) return false;
15
15
  return ["true", "1", "yes"].includes(value.toLowerCase());
16
16
  }
17
+ function hostnameFromUrl(url) {
18
+ try {
19
+ return new URL(url).hostname;
20
+ } catch {
21
+ return url;
22
+ }
23
+ }
17
24
  function resolveConfig(env) {
18
25
  const url = env.PROXMOX_URL;
19
26
  const tokenId = env.PROXMOX_TOKEN_ID;
@@ -21,16 +28,29 @@ function resolveConfig(env) {
21
28
  if (!url) throw new ConfigError("PROXMOX_URL is required");
22
29
  if (!tokenId) throw new ConfigError("PROXMOX_TOKEN_ID is required");
23
30
  if (!tokenSecret) throw new ConfigError("PROXMOX_TOKEN_SECRET is required");
31
+ const trimmedUrl = url.replace(/\/+$/, "");
32
+ const sshHost = env.PROXMOX_SSH_HOST ?? hostnameFromUrl(trimmedUrl);
33
+ const sshPort = env.PROXMOX_SSH_PORT ? parseInt(env.PROXMOX_SSH_PORT, 10) : 22;
34
+ const sshUser = env.PROXMOX_SSH_USER ?? "root";
35
+ const sshKey = env.PROXMOX_SSH_KEY ?? "~/.ssh/id_ed25519";
24
36
  return {
25
- url: url.replace(/\/+$/, ""),
37
+ url: trimmedUrl,
26
38
  tokenId,
27
39
  tokenSecret,
28
- tlsInsecure: isTruthy(env.PROXMOX_TLS_INSECURE)
40
+ tlsInsecure: isTruthy(env.PROXMOX_TLS_INSECURE),
41
+ ssh: {
42
+ host: sshHost,
43
+ port: sshPort,
44
+ user: sshUser,
45
+ keyPath: sshKey,
46
+ vmUser: env.PROXMOX_VM_SSH_USER ?? sshUser,
47
+ vmKeyPath: env.PROXMOX_VM_SSH_KEY ?? sshKey
48
+ }
29
49
  };
30
50
  }
31
51
 
32
52
  // src/proxmox-client.ts
33
- import { Agent as UndiciAgent } from "undici";
53
+ import { request as httpsRequest } from "https";
34
54
  var ProxmoxClientError = class extends Error {
35
55
  constructor(status, message) {
36
56
  super(`Proxmox ${status}: ${message}`);
@@ -50,28 +70,23 @@ var ProxmoxClient = class {
50
70
  this.cfg = cfg;
51
71
  this.authHeader = `PVEAPIToken=${cfg.tokenId}=${cfg.tokenSecret}`;
52
72
  this.retryDelayMs = opts.retryDelayMs ?? 1e3;
53
- if (cfg.tlsInsecure && cfg.url.startsWith("https://")) {
54
- this.dispatcher = new UndiciAgent({ connect: { rejectUnauthorized: false } });
55
- }
73
+ this.usesInsecureTls = cfg.tlsInsecure && cfg.url.startsWith("https://");
56
74
  }
57
75
  cfg;
58
76
  authHeader;
59
77
  retryDelayMs;
60
- // Node's global fetch (undici) ignores node:https.Agent. To actually skip
61
- // cert verification for self-signed PVE hosts we pass an undici Agent via
62
- // the `dispatcher` init option.
63
- dispatcher;
64
- async get(path) {
65
- return this.request("GET", path);
78
+ usesInsecureTls;
79
+ async get(path2) {
80
+ return this.request("GET", path2);
66
81
  }
67
- async post(path, body) {
68
- return this.request("POST", path, body);
82
+ async post(path2, body) {
83
+ return this.request("POST", path2, body);
69
84
  }
70
- async delete(path) {
71
- return this.request("DELETE", path);
85
+ async delete(path2) {
86
+ return this.request("DELETE", path2);
72
87
  }
73
- async request(method, path, body) {
74
- const url = this.cfg.url + "/api2/json" + path;
88
+ async request(method, path2, body) {
89
+ const url = this.cfg.url + "/api2/json" + path2;
75
90
  const headers = { authorization: this.authHeader };
76
91
  let bodyStr;
77
92
  if (body !== void 0) {
@@ -91,16 +106,14 @@ var ProxmoxClient = class {
91
106
  let lastErr;
92
107
  for (let attempt = 0; attempt < 2; attempt++) {
93
108
  try {
94
- const init = { method, headers, body: bodyStr };
95
- if (this.dispatcher) init.dispatcher = this.dispatcher;
96
- const res = await fetch(url, init);
109
+ const res = await this.fetchUrl(url, method, headers, bodyStr);
97
110
  if (res.status >= 200 && res.status < 300) {
98
111
  const text = await res.text();
99
112
  if (!text) return void 0;
100
113
  const parsed = JSON.parse(text);
101
114
  return parsed && typeof parsed === "object" && "data" in parsed ? parsed.data : parsed;
102
115
  }
103
- if (res.status >= 500) {
116
+ if ([502, 503, 504].includes(res.status)) {
104
117
  lastErr = new ProxmoxUnreachableError(`HTTP ${res.status}`);
105
118
  if (attempt === 0) await sleep(this.retryDelayMs);
106
119
  continue;
@@ -120,10 +133,43 @@ var ProxmoxClient = class {
120
133
  }
121
134
  throw lastErr ?? new ProxmoxUnreachableError("unknown");
122
135
  }
136
+ async fetchUrl(url, method, headers, body) {
137
+ if (!this.usesInsecureTls) {
138
+ return fetch(url, { method, headers, body });
139
+ }
140
+ return nodeRequest(url, method, headers, body, false);
141
+ }
123
142
  };
124
143
  function sleep(ms) {
125
144
  return new Promise((r) => setTimeout(r, ms));
126
145
  }
146
+ function nodeRequest(url, method, headers, body, rejectUnauthorized) {
147
+ return new Promise((resolve, reject) => {
148
+ const parsed = new URL(url);
149
+ const requestHeaders = { ...headers };
150
+ if (body !== void 0 && requestHeaders["content-length"] === void 0) {
151
+ requestHeaders["content-length"] = String(Buffer.byteLength(body, "utf8"));
152
+ }
153
+ const req = httpsRequest(
154
+ parsed,
155
+ { method, headers: requestHeaders, rejectUnauthorized },
156
+ (res) => {
157
+ const chunks = [];
158
+ res.on("data", (chunk) => chunks.push(chunk));
159
+ res.on("end", () => {
160
+ const text = Buffer.concat(chunks).toString("utf8");
161
+ resolve({
162
+ status: res.statusCode ?? 0,
163
+ text: async () => text
164
+ });
165
+ });
166
+ }
167
+ );
168
+ req.on("error", reject);
169
+ if (body !== void 0) req.write(body);
170
+ req.end();
171
+ });
172
+ }
127
173
 
128
174
  // src/security.ts
129
175
  var SECRETS = /* @__PURE__ */ new Set();
@@ -163,11 +209,34 @@ function redact(value) {
163
209
  import { Type } from "@sinclair/typebox";
164
210
 
165
211
  // src/tools/_util.ts
212
+ import { Value } from "@sinclair/typebox/value";
166
213
  function jsonToolResult(payload) {
167
214
  return {
168
215
  content: [{ type: "text", text: JSON.stringify(payload, null, 2) }]
169
216
  };
170
217
  }
218
+ var ToolInputError = class extends Error {
219
+ constructor(message) {
220
+ super(message);
221
+ this.name = "ToolInputError";
222
+ }
223
+ };
224
+ function validateToolArgs(schema, raw, toolName) {
225
+ if (Value.Check(schema, raw)) return raw;
226
+ const first = [...Value.Errors(schema, raw)][0];
227
+ const where = first?.path ? ` at ${first.path}` : "";
228
+ const message = first?.message ?? "input does not match schema";
229
+ throw new ToolInputError(`${toolName} invalid input${where}: ${message}`);
230
+ }
231
+ var SAFE_SEGMENT_RE = /^[\w.-]+$/;
232
+ function assertSafePathSegment(value, label) {
233
+ if (!SAFE_SEGMENT_RE.test(value)) {
234
+ throw new ToolInputError(
235
+ `invalid ${label} "${value}": expected only letters, digits, '_', '.', or '-'`
236
+ );
237
+ }
238
+ return value;
239
+ }
171
240
  async function resolveResource(client, vmid) {
172
241
  const resources = await client.get(
173
242
  "/cluster/resources"
@@ -250,6 +319,7 @@ function createProxmoxListVmsTool(getClient) {
250
319
 
251
320
  // src/tools/proxmox_get_resource.ts
252
321
  import { Type as Type4 } from "@sinclair/typebox";
322
+ var NAME = "proxmox_get_resource";
253
323
  var Schema4 = Type4.Object(
254
324
  {
255
325
  vmid: Type4.Integer({ minimum: 1, description: "Container or VM ID." })
@@ -258,12 +328,12 @@ var Schema4 = Type4.Object(
258
328
  );
259
329
  function createProxmoxGetResourceTool(getClient) {
260
330
  return {
261
- name: "proxmox_get_resource",
331
+ name: NAME,
262
332
  label: "proxmox: get resource",
263
333
  description: "Get full current status for one LXC or VM by vmid (resolves node+type from cluster resources, then GET /nodes/{node}/{type}/{vmid}/status/current).",
264
334
  parameters: Schema4,
265
335
  execute: async (_id, raw) => {
266
- const args = raw;
336
+ const args = validateToolArgs(Schema4, raw, NAME);
267
337
  const client = getClient();
268
338
  const { node, type } = await resolveResource(client, args.vmid);
269
339
  const status = await client.get(
@@ -274,27 +344,93 @@ function createProxmoxGetResourceTool(getClient) {
274
344
  };
275
345
  }
276
346
 
277
- // src/tools/proxmox_recent_tasks.ts
347
+ // src/tools/proxmox_get_vm_config.ts
278
348
  import { Type as Type5 } from "@sinclair/typebox";
279
349
  var Schema5 = Type5.Object(
280
350
  {
281
- limit: Type5.Optional(
282
- Type5.Integer({ minimum: 1, maximum: 500, description: "Max tasks to return (default 25)." })
351
+ vmid: Type5.Integer({ minimum: 1, description: "QEMU VM ID." })
352
+ },
353
+ { additionalProperties: false }
354
+ );
355
+
356
+ // src/tools/proxmox_get_container_config.ts
357
+ import { Type as Type6 } from "@sinclair/typebox";
358
+ var Schema6 = Type6.Object(
359
+ {
360
+ vmid: Type6.Integer({ minimum: 1, description: "LXC container ID." })
361
+ },
362
+ { additionalProperties: false }
363
+ );
364
+
365
+ // src/tools/proxmox_validate_qemu_smoke_source.ts
366
+ import { Type as Type7 } from "@sinclair/typebox";
367
+ var Schema7 = Type7.Object(
368
+ {
369
+ vmid: Type7.Integer({ minimum: 1, description: "QEMU VM ID to validate as a smoke clone source." }),
370
+ max_disk_gb: Type7.Optional(
371
+ Type7.Integer({ minimum: 1, description: "Maximum acceptable source disk size in GiB (default 64)." })
283
372
  ),
284
- vmid: Type5.Optional(
285
- Type5.Integer({ minimum: 1, description: "Filter tasks by vmid (post-filter)." })
373
+ allow_running: Type7.Optional(
374
+ Type7.Boolean({ description: "Allow running sources instead of requiring stopped/template state (default false)." })
375
+ )
376
+ },
377
+ { additionalProperties: false }
378
+ );
379
+ var GIB = 1024 ** 3;
380
+
381
+ // src/tools/proxmox_audit_permissions.ts
382
+ import { Type as Type8 } from "@sinclair/typebox";
383
+ var Schema8 = Type8.Object(
384
+ {
385
+ userid: Type8.Optional(
386
+ Type8.String({
387
+ minLength: 1,
388
+ description: "Optional user or full API token ID to audit. Defaults to current API identity."
389
+ })
390
+ ),
391
+ paths: Type8.Optional(
392
+ Type8.Array(Type8.String({ minLength: 1 }), {
393
+ minItems: 1,
394
+ description: "Permission paths to inspect. Defaults to common smoke-test paths."
395
+ })
396
+ ),
397
+ pool: Type8.Optional(Type8.String({ minLength: 1, description: "Pool path shortcut (default mcp-smoke)." })),
398
+ template_storage: Type8.Optional(Type8.String({ minLength: 1, description: "Template storage shortcut (default local)." })),
399
+ root_storage: Type8.Optional(Type8.String({ minLength: 1, description: "Root disk storage shortcut (default local-lvm)." })),
400
+ source_vmid: Type8.Optional(Type8.Integer({ minimum: 1, description: "Optional source VMID path to inspect." })),
401
+ target_vmid: Type8.Optional(Type8.Integer({ minimum: 1, description: "Optional target VMID path to inspect." })),
402
+ required_privileges: Type8.Optional(
403
+ Type8.Array(Type8.String({ minLength: 1 }), {
404
+ minItems: 1,
405
+ description: "Privileges to summarize on every returned path."
406
+ })
407
+ )
408
+ },
409
+ { additionalProperties: false }
410
+ );
411
+
412
+ // src/tools/proxmox_recent_tasks.ts
413
+ import { Type as Type9 } from "@sinclair/typebox";
414
+ var NAME2 = "proxmox_recent_tasks";
415
+ var Schema9 = Type9.Object(
416
+ {
417
+ limit: Type9.Optional(
418
+ Type9.Integer({ minimum: 1, maximum: 500, description: "Max tasks to return (default 25)." })
419
+ ),
420
+ vmid: Type9.Optional(
421
+ Type9.Integer({ minimum: 1, description: "Filter tasks by vmid (post-filter)." })
286
422
  )
287
423
  },
288
424
  { additionalProperties: false }
289
425
  );
290
426
  function createProxmoxRecentTasksTool(getClient) {
291
427
  return {
292
- name: "proxmox_recent_tasks",
428
+ name: NAME2,
293
429
  label: "proxmox: recent tasks",
294
430
  description: "List recent cluster tasks (UPID, type, status, node, user, timing) via GET /cluster/tasks. Optionally filter by vmid (post-filter client-side).",
295
- parameters: Schema5,
431
+ parameters: Schema9,
296
432
  execute: async (_id, raw) => {
297
- const args = raw;
433
+ const args = validateToolArgs(Schema9, raw, NAME2);
298
434
  const limit = args.limit ?? 25;
299
435
  const client = getClient();
300
436
  const tasks = await client.get("/cluster/tasks");
@@ -314,26 +450,27 @@ function createProxmoxRecentTasksTool(getClient) {
314
450
  }
315
451
 
316
452
  // src/tools/proxmox_list_backups.ts
317
- import { Type as Type6 } from "@sinclair/typebox";
318
- var Schema6 = Type6.Object(
453
+ import { Type as Type10 } from "@sinclair/typebox";
454
+ var NAME3 = "proxmox_list_backups";
455
+ var Schema10 = Type10.Object(
319
456
  {
320
- node: Type6.Optional(
321
- Type6.String({ minLength: 1, description: "Node to query (defaults to first node)." })
457
+ node: Type10.Optional(
458
+ Type10.String({ minLength: 1, description: "Node to query (defaults to first node)." })
322
459
  ),
323
- vmid: Type6.Optional(
324
- Type6.Integer({ minimum: 1, description: "Filter backups to a single vmid (post-filter)." })
460
+ vmid: Type10.Optional(
461
+ Type10.Integer({ minimum: 1, description: "Filter backups to a single vmid (post-filter)." })
325
462
  )
326
463
  },
327
464
  { additionalProperties: false }
328
465
  );
329
466
  function createProxmoxListBackupsTool(getClient) {
330
467
  return {
331
- name: "proxmox_list_backups",
468
+ name: NAME3,
332
469
  label: "proxmox: list backups",
333
470
  description: "List backup volumes on a node. Walks each backup-capable storage via GET /nodes/{node}/storage/{storage}/content?content=backup. Optionally filter by vmid.",
334
- parameters: Schema6,
471
+ parameters: Schema10,
335
472
  execute: async (_id, raw) => {
336
- const args = raw;
473
+ const args = validateToolArgs(Schema10, raw, NAME3);
337
474
  const client = getClient();
338
475
  let node = args.node;
339
476
  if (!node) {
@@ -356,12 +493,13 @@ function createProxmoxListBackupsTool(getClient) {
356
493
  }
357
494
 
358
495
  // src/tools/proxmox_resource_usage.ts
359
- import { Type as Type7 } from "@sinclair/typebox";
360
- var Schema7 = Type7.Object(
496
+ import { Type as Type11 } from "@sinclair/typebox";
497
+ var NAME4 = "proxmox_resource_usage";
498
+ var Schema11 = Type11.Object(
361
499
  {
362
- vmid: Type7.Integer({ minimum: 1, description: "Container or VM ID." }),
363
- timeframe: Type7.Optional(
364
- Type7.Union([Type7.Literal("hour"), Type7.Literal("day"), Type7.Literal("week")], {
500
+ vmid: Type11.Integer({ minimum: 1, description: "Container or VM ID." }),
501
+ timeframe: Type11.Optional(
502
+ Type11.Union([Type11.Literal("hour"), Type11.Literal("day"), Type11.Literal("week")], {
365
503
  description: "RRD timeframe window (default hour)."
366
504
  })
367
505
  )
@@ -370,12 +508,12 @@ var Schema7 = Type7.Object(
370
508
  );
371
509
  function createProxmoxResourceUsageTool(getClient) {
372
510
  return {
373
- name: "proxmox_resource_usage",
511
+ name: NAME4,
374
512
  label: "proxmox: resource usage",
375
513
  description: "Get historical CPU/memory/disk/network samples for one LXC or VM via GET /nodes/{node}/{type}/{vmid}/rrddata?timeframe=<hour|day|week>.",
376
- parameters: Schema7,
514
+ parameters: Schema11,
377
515
  execute: async (_id, raw) => {
378
- const args = raw;
516
+ const args = validateToolArgs(Schema11, raw, NAME4);
379
517
  const timeframe = args.timeframe ?? "hour";
380
518
  const client = getClient();
381
519
  const { node, type } = await resolveResource(client, args.vmid);
@@ -388,7 +526,7 @@ function createProxmoxResourceUsageTool(getClient) {
388
526
  }
389
527
 
390
528
  // src/tools/proxmox_start_resource.ts
391
- import { Type as Type8 } from "@sinclair/typebox";
529
+ import { Type as Type12 } from "@sinclair/typebox";
392
530
 
393
531
  // src/gates.ts
394
532
  var WriteGateError = class extends Error {
@@ -419,25 +557,25 @@ function assertEnvFlag(envKey, toolName, env = process.env) {
419
557
  }
420
558
 
421
559
  // src/tools/proxmox_start_resource.ts
422
- var Schema8 = Type8.Object(
560
+ var Schema12 = Type12.Object(
423
561
  {
424
- vmid: Type8.Integer({ minimum: 1, description: "Container or VM ID." }),
425
- confirm: Type8.Boolean({
562
+ vmid: Type12.Integer({ minimum: 1, description: "Container or VM ID." }),
563
+ confirm: Type12.Boolean({
426
564
  description: "Must be true to write. Tier-2 safe-write gate."
427
565
  })
428
566
  },
429
567
  { additionalProperties: false }
430
568
  );
431
- var NAME = "proxmox_start_resource";
569
+ var NAME5 = "proxmox_start_resource";
432
570
  function createProxmoxStartResourceTool(getClient) {
433
571
  return {
434
- name: NAME,
572
+ name: NAME5,
435
573
  label: "proxmox: start resource",
436
574
  description: "Start a stopped LXC container or QEMU VM by vmid. Tier-2 write; requires confirm:true.",
437
- parameters: Schema8,
575
+ parameters: Schema12,
438
576
  execute: async (_id, raw) => {
439
- assertConfirmedWrite(raw, NAME);
440
- const args = raw;
577
+ assertConfirmedWrite(raw, NAME5);
578
+ const args = validateToolArgs(Schema12, raw, NAME5);
441
579
  const client = getClient();
442
580
  const { node, type } = await resolveResource(client, args.vmid);
443
581
  const upid = await client.post(
@@ -450,15 +588,15 @@ function createProxmoxStartResourceTool(getClient) {
450
588
  }
451
589
 
452
590
  // src/tools/proxmox_stop_resource.ts
453
- import { Type as Type9 } from "@sinclair/typebox";
454
- var Schema9 = Type9.Object(
591
+ import { Type as Type13 } from "@sinclair/typebox";
592
+ var Schema13 = Type13.Object(
455
593
  {
456
- vmid: Type9.Integer({ minimum: 1, description: "Container or VM ID." }),
457
- confirm: Type9.Boolean({
594
+ vmid: Type13.Integer({ minimum: 1, description: "Container or VM ID." }),
595
+ confirm: Type13.Boolean({
458
596
  description: "Must be true to write. Tier-2 safe-write gate."
459
597
  }),
460
- timeoutSeconds: Type9.Optional(
461
- Type9.Integer({
598
+ timeoutSeconds: Type13.Optional(
599
+ Type13.Integer({
462
600
  minimum: 1,
463
601
  description: "Optional shutdown timeout in seconds (passed through to PVE as `timeout`)."
464
602
  })
@@ -466,16 +604,16 @@ var Schema9 = Type9.Object(
466
604
  },
467
605
  { additionalProperties: false }
468
606
  );
469
- var NAME2 = "proxmox_stop_resource";
607
+ var NAME6 = "proxmox_stop_resource";
470
608
  function createProxmoxStopResourceTool(getClient) {
471
609
  return {
472
- name: NAME2,
610
+ name: NAME6,
473
611
  label: "proxmox: stop resource",
474
612
  description: "Gracefully shutdown an LXC container or QEMU VM by vmid (POST status/shutdown). Tier-2 write; requires confirm:true.",
475
- parameters: Schema9,
613
+ parameters: Schema13,
476
614
  execute: async (_id, raw) => {
477
- assertConfirmedWrite(raw, NAME2);
478
- const args = raw;
615
+ assertConfirmedWrite(raw, NAME6);
616
+ const args = validateToolArgs(Schema13, raw, NAME6);
479
617
  const client = getClient();
480
618
  const { node, type } = await resolveResource(client, args.vmid);
481
619
  const body = {};
@@ -492,26 +630,26 @@ function createProxmoxStopResourceTool(getClient) {
492
630
  }
493
631
 
494
632
  // src/tools/proxmox_reboot_resource.ts
495
- import { Type as Type10 } from "@sinclair/typebox";
496
- var Schema10 = Type10.Object(
633
+ import { Type as Type14 } from "@sinclair/typebox";
634
+ var Schema14 = Type14.Object(
497
635
  {
498
- vmid: Type10.Integer({ minimum: 1, description: "Container or VM ID." }),
499
- confirm: Type10.Boolean({
636
+ vmid: Type14.Integer({ minimum: 1, description: "Container or VM ID." }),
637
+ confirm: Type14.Boolean({
500
638
  description: "Must be true to write. Tier-2 safe-write gate."
501
639
  })
502
640
  },
503
641
  { additionalProperties: false }
504
642
  );
505
- var NAME3 = "proxmox_reboot_resource";
643
+ var NAME7 = "proxmox_reboot_resource";
506
644
  function createProxmoxRebootResourceTool(getClient) {
507
645
  return {
508
- name: NAME3,
646
+ name: NAME7,
509
647
  label: "proxmox: reboot resource",
510
648
  description: "Reboot an LXC container or QEMU VM by vmid (POST status/reboot). Tier-2 write; requires confirm:true.",
511
- parameters: Schema10,
649
+ parameters: Schema14,
512
650
  execute: async (_id, raw) => {
513
- assertConfirmedWrite(raw, NAME3);
514
- const args = raw;
651
+ assertConfirmedWrite(raw, NAME7);
652
+ const args = validateToolArgs(Schema14, raw, NAME7);
515
653
  const client = getClient();
516
654
  const { node, type } = await resolveResource(client, args.vmid);
517
655
  const upid = await client.post(
@@ -524,33 +662,37 @@ function createProxmoxRebootResourceTool(getClient) {
524
662
  }
525
663
 
526
664
  // src/tools/proxmox_snapshot_resource.ts
527
- import { Type as Type11 } from "@sinclair/typebox";
528
- var Schema11 = Type11.Object(
665
+ import { Type as Type15 } from "@sinclair/typebox";
666
+ var Schema15 = Type15.Object(
529
667
  {
530
- vmid: Type11.Integer({ minimum: 1, description: "Container or VM ID." }),
531
- snapname: Type11.String({
668
+ vmid: Type15.Integer({ minimum: 1, description: "Container or VM ID." }),
669
+ snapname: Type15.String({
532
670
  minLength: 1,
533
671
  description: "Snapshot name (PVE convention: lowercase, no spaces)."
534
672
  }),
535
- description: Type11.Optional(
536
- Type11.String({ description: "Optional human description for the snapshot." })
673
+ description: Type15.Optional(
674
+ Type15.String({ description: "Optional human description for the snapshot." })
537
675
  ),
538
- confirm: Type11.Boolean({
676
+ confirm: Type15.Boolean({
539
677
  description: "Must be true to write. Tier-2 safe-write gate."
540
678
  })
541
679
  },
542
680
  { additionalProperties: false }
543
681
  );
544
- var NAME4 = "proxmox_snapshot_resource";
682
+ var NAME8 = "proxmox_snapshot_resource";
545
683
  function createProxmoxSnapshotResourceTool(getClient) {
546
684
  return {
547
- name: NAME4,
685
+ name: NAME8,
548
686
  label: "proxmox: snapshot resource",
549
687
  description: "Create a snapshot of an LXC container or QEMU VM by vmid (POST /snapshot with {snapname, description?}). Tier-2 write; requires confirm:true.",
550
- parameters: Schema11,
688
+ parameters: Schema15,
551
689
  execute: async (_id, raw) => {
552
- assertConfirmedWrite(raw, NAME4);
553
- const args = raw;
690
+ assertConfirmedWrite(raw, NAME8);
691
+ const args = validateToolArgs(
692
+ Schema15,
693
+ raw,
694
+ NAME8
695
+ );
554
696
  const client = getClient();
555
697
  const { node, type } = await resolveResource(client, args.vmid);
556
698
  const body = { snapname: args.snapname };
@@ -572,37 +714,52 @@ function createProxmoxSnapshotResourceTool(getClient) {
572
714
  };
573
715
  }
574
716
 
717
+ // src/tools/proxmox_rollback_snapshot.ts
718
+ import { Type as Type16 } from "@sinclair/typebox";
719
+ var Schema16 = Type16.Object(
720
+ {
721
+ vmid: Type16.Integer({ minimum: 1, description: "Container or VM ID." }),
722
+ snapname: Type16.String({ minLength: 1, description: "Snapshot name to roll back to." }),
723
+ start: Type16.Optional(
724
+ Type16.Boolean({ description: "Start the resource after rollback completes (default false)." })
725
+ ),
726
+ confirm: Type16.Boolean({ description: "Must be true. Tier-3 destructive gate." }),
727
+ destructive: Type16.Boolean({ description: "Must be true. Tier-3 destructive gate." })
728
+ },
729
+ { additionalProperties: false }
730
+ );
731
+
575
732
  // src/tools/proxmox_run_backup.ts
576
- import { Type as Type12 } from "@sinclair/typebox";
577
- var Schema12 = Type12.Object(
733
+ import { Type as Type17 } from "@sinclair/typebox";
734
+ var Schema17 = Type17.Object(
578
735
  {
579
- vmid: Type12.Integer({ minimum: 1, description: "Container or VM ID to back up." }),
580
- storage: Type12.String({
736
+ vmid: Type17.Integer({ minimum: 1, description: "Container or VM ID to back up." }),
737
+ storage: Type17.String({
581
738
  minLength: 1,
582
739
  description: "PVE storage ID where the vzdump archive should be written."
583
740
  }),
584
- mode: Type12.Optional(
585
- Type12.Union(
586
- [Type12.Literal("snapshot"), Type12.Literal("suspend"), Type12.Literal("stop")],
741
+ mode: Type17.Optional(
742
+ Type17.Union(
743
+ [Type17.Literal("snapshot"), Type17.Literal("suspend"), Type17.Literal("stop")],
587
744
  { description: "Backup mode. Defaults to 'snapshot'." }
588
745
  )
589
746
  ),
590
- confirm: Type12.Boolean({
747
+ confirm: Type17.Boolean({
591
748
  description: "Must be true to write. Tier-2 safe-write gate."
592
749
  })
593
750
  },
594
751
  { additionalProperties: false }
595
752
  );
596
- var NAME5 = "proxmox_run_backup";
753
+ var NAME9 = "proxmox_run_backup";
597
754
  function createProxmoxRunBackupTool(getClient) {
598
755
  return {
599
- name: NAME5,
756
+ name: NAME9,
600
757
  label: "proxmox: run backup",
601
758
  description: "Trigger a vzdump backup of a single vmid to a target storage (POST /nodes/{node}/vzdump with {vmid, storage, mode, compress:'zstd'}). Tier-2 write; requires confirm:true.",
602
- parameters: Schema12,
759
+ parameters: Schema17,
603
760
  execute: async (_id, raw) => {
604
- assertConfirmedWrite(raw, NAME5);
605
- const args = raw;
761
+ assertConfirmedWrite(raw, NAME9);
762
+ const args = validateToolArgs(Schema17, raw, NAME9);
606
763
  const mode = args.mode ?? "snapshot";
607
764
  const client = getClient();
608
765
  const { node } = await resolveResource(client, args.vmid);
@@ -624,10 +781,11 @@ function createProxmoxRunBackupTool(getClient) {
624
781
  }
625
782
 
626
783
  // src/tools/proxmox_get_task_status.ts
627
- import { Type as Type13 } from "@sinclair/typebox";
628
- var Schema13 = Type13.Object(
784
+ import { Type as Type18 } from "@sinclair/typebox";
785
+ var NAME10 = "proxmox_get_task_status";
786
+ var Schema18 = Type18.Object(
629
787
  {
630
- upid: Type13.String({
788
+ upid: Type18.String({
631
789
  minLength: 1,
632
790
  description: "Task UPID returned by a prior write tool (e.g. start, stop, snapshot, backup)."
633
791
  })
@@ -636,12 +794,12 @@ var Schema13 = Type13.Object(
636
794
  );
637
795
  function createProxmoxGetTaskStatusTool(getClient) {
638
796
  return {
639
- name: "proxmox_get_task_status",
797
+ name: NAME10,
640
798
  label: "proxmox: get task status",
641
799
  description: "Get the current status of a Proxmox task by UPID (running/stopped, exit status) via GET /nodes/{node}/tasks/{upid}/status. Node is parsed from the UPID.",
642
- parameters: Schema13,
800
+ parameters: Schema18,
643
801
  execute: async (_id, raw) => {
644
- const args = raw;
802
+ const args = validateToolArgs(Schema18, raw, NAME10);
645
803
  const { node } = parseTaskUpid(args.upid);
646
804
  const client = getClient();
647
805
  const status = await client.get(
@@ -653,18 +811,19 @@ function createProxmoxGetTaskStatusTool(getClient) {
653
811
  }
654
812
 
655
813
  // src/tools/proxmox_get_task_log.ts
656
- import { Type as Type14 } from "@sinclair/typebox";
657
- var Schema14 = Type14.Object(
814
+ import { Type as Type19 } from "@sinclair/typebox";
815
+ var NAME11 = "proxmox_get_task_log";
816
+ var Schema19 = Type19.Object(
658
817
  {
659
- upid: Type14.String({
818
+ upid: Type19.String({
660
819
  minLength: 1,
661
820
  description: "Task UPID returned by a prior write tool."
662
821
  }),
663
- start: Type14.Optional(
664
- Type14.Integer({ minimum: 0, description: "Line offset to start from (default 0)." })
822
+ start: Type19.Optional(
823
+ Type19.Integer({ minimum: 0, description: "Line offset to start from (default 0)." })
665
824
  ),
666
- limit: Type14.Optional(
667
- Type14.Integer({
825
+ limit: Type19.Optional(
826
+ Type19.Integer({
668
827
  minimum: 1,
669
828
  maximum: 500,
670
829
  description: "Max lines to return (default 50, max 500)."
@@ -675,12 +834,12 @@ var Schema14 = Type14.Object(
675
834
  );
676
835
  function createProxmoxGetTaskLogTool(getClient) {
677
836
  return {
678
- name: "proxmox_get_task_log",
837
+ name: NAME11,
679
838
  label: "proxmox: get task log",
680
839
  description: "Tail a Proxmox task log by UPID via GET /nodes/{node}/tasks/{upid}/log?start=N&limit=M. Node is parsed from the UPID. Returns { lines, total }.",
681
- parameters: Schema14,
840
+ parameters: Schema19,
682
841
  execute: async (_id, raw) => {
683
- const args = raw;
842
+ const args = validateToolArgs(Schema19, raw, NAME11);
684
843
  const { node } = parseTaskUpid(args.upid);
685
844
  const start = args.start ?? 0;
686
845
  const limit = args.limit ?? 50;
@@ -694,18 +853,19 @@ function createProxmoxGetTaskLogTool(getClient) {
694
853
  }
695
854
 
696
855
  // src/tools/proxmox_list_templates.ts
697
- import { Type as Type15 } from "@sinclair/typebox";
698
- var Schema15 = Type15.Object(
856
+ import { Type as Type20 } from "@sinclair/typebox";
857
+ var NAME12 = "proxmox_list_templates";
858
+ var Schema20 = Type20.Object(
699
859
  {
700
- node: Type15.Optional(
701
- Type15.String({ minLength: 1, description: "Node to query (defaults to first node)." })
860
+ node: Type20.Optional(
861
+ Type20.String({ minLength: 1, description: "Node to query (defaults to first node)." })
702
862
  ),
703
- storage: Type15.Optional(
704
- Type15.String({ minLength: 1, description: "Storage to query (defaults to 'local')." })
863
+ storage: Type20.Optional(
864
+ Type20.String({ minLength: 1, description: "Storage to query (defaults to 'local')." })
705
865
  ),
706
- kind: Type15.Optional(
707
- Type15.Union(
708
- [Type15.Literal("vztmpl"), Type15.Literal("iso"), Type15.Literal("both")],
866
+ kind: Type20.Optional(
867
+ Type20.Union(
868
+ [Type20.Literal("vztmpl"), Type20.Literal("iso"), Type20.Literal("both")],
709
869
  { description: "Template kind: 'vztmpl' (CT templates), 'iso' (VM ISOs), or 'both'. Defaults to 'both'." }
710
870
  )
711
871
  )
@@ -714,12 +874,12 @@ var Schema15 = Type15.Object(
714
874
  );
715
875
  function createProxmoxListTemplatesTool(getClient) {
716
876
  return {
717
- name: "proxmox_list_templates",
877
+ name: NAME12,
718
878
  label: "proxmox: list templates",
719
879
  description: "List available LXC container templates (vztmpl) and/or VM ISOs on a node/storage (GET /nodes/{node}/storage/{storage}/content?content=vztmpl|iso). Defaults to both kinds on storage 'local'.",
720
- parameters: Schema15,
880
+ parameters: Schema20,
721
881
  execute: async (_id, raw) => {
722
- const args = raw;
882
+ const args = validateToolArgs(Schema20, raw, NAME12);
723
883
  const client = getClient();
724
884
  let node = args.node;
725
885
  if (!node) {
@@ -729,18 +889,22 @@ function createProxmoxListTemplatesTool(getClient) {
729
889
  }
730
890
  const storage = args.storage ?? "local";
731
891
  const kind = args.kind ?? "both";
892
+ assertSafePathSegment(node, "node");
893
+ assertSafePathSegment(storage, "storage");
894
+ const nodeSeg = encodeURIComponent(node);
895
+ const storageSeg = encodeURIComponent(storage);
732
896
  const out = {
733
897
  node,
734
898
  storage
735
899
  };
736
900
  if (kind === "vztmpl" || kind === "both") {
737
901
  out.container_templates = await client.get(
738
- `/nodes/${node}/storage/${storage}/content?content=vztmpl`
902
+ `/nodes/${nodeSeg}/storage/${storageSeg}/content?content=vztmpl`
739
903
  );
740
904
  }
741
905
  if (kind === "iso" || kind === "both") {
742
906
  out.vm_isos = await client.get(
743
- `/nodes/${node}/storage/${storage}/content?content=iso`
907
+ `/nodes/${nodeSeg}/storage/${storageSeg}/content?content=iso`
744
908
  );
745
909
  }
746
910
  return jsonToolResult(out);
@@ -748,62 +912,145 @@ function createProxmoxListTemplatesTool(getClient) {
748
912
  };
749
913
  }
750
914
 
915
+ // src/tools/proxmox_list_storage.ts
916
+ import { Type as Type21 } from "@sinclair/typebox";
917
+ var Schema21 = Type21.Object(
918
+ {
919
+ node: Type21.Optional(
920
+ Type21.String({ minLength: 1, description: "Node to query. Defaults to all nodes." })
921
+ )
922
+ },
923
+ { additionalProperties: false }
924
+ );
925
+
926
+ // src/tools/proxmox_list_snapshots.ts
927
+ import { Type as Type22 } from "@sinclair/typebox";
928
+ var Schema22 = Type22.Object(
929
+ {
930
+ vmid: Type22.Integer({ minimum: 1, description: "Container or VM ID." })
931
+ },
932
+ { additionalProperties: false }
933
+ );
934
+
935
+ // src/tools/proxmox_guest_network.ts
936
+ import { Type as Type23 } from "@sinclair/typebox";
937
+ var Schema23 = Type23.Object(
938
+ {
939
+ vmid: Type23.Integer({ minimum: 1, description: "Container or VM ID." })
940
+ },
941
+ { additionalProperties: false }
942
+ );
943
+
944
+ // src/tools/proxmox_wait_task.ts
945
+ import { Type as Type24 } from "@sinclair/typebox";
946
+ var Schema24 = Type24.Object(
947
+ {
948
+ upid: Type24.String({ minLength: 1, description: "Task UPID to wait for." }),
949
+ timeoutSeconds: Type24.Optional(
950
+ Type24.Integer({ minimum: 1, maximum: 3600, description: "Max wait time in seconds. Default 60." })
951
+ ),
952
+ intervalMs: Type24.Optional(
953
+ Type24.Integer({ minimum: 100, maximum: 1e4, description: "Polling interval in milliseconds. Default 1000." })
954
+ )
955
+ },
956
+ { additionalProperties: false }
957
+ );
958
+
959
+ // src/tools/proxmox_next_vmid.ts
960
+ import { Type as Type25 } from "@sinclair/typebox";
961
+ var Schema25 = Type25.Object({}, { additionalProperties: false });
962
+
963
+ // src/tools/proxmox_list_pool_resources.ts
964
+ import { Type as Type26 } from "@sinclair/typebox";
965
+ var Schema26 = Type26.Object(
966
+ {
967
+ pool: Type26.Optional(
968
+ Type26.String({ minLength: 1, description: "Pool ID to inspect (default mcp-smoke)." })
969
+ )
970
+ },
971
+ { additionalProperties: false }
972
+ );
973
+
751
974
  // src/tools/proxmox_create_container.ts
752
- import { Type as Type16 } from "@sinclair/typebox";
753
- var Schema16 = Type16.Object(
975
+ import { Type as Type27 } from "@sinclair/typebox";
976
+ var Schema27 = Type27.Object(
754
977
  {
755
- vmid: Type16.Integer({ minimum: 1, description: "VMID for the new container." }),
756
- hostname: Type16.String({ minLength: 1, description: "Container hostname." }),
757
- ostemplate: Type16.String({
978
+ vmid: Type27.Integer({ minimum: 1, description: "VMID for the new container." }),
979
+ hostname: Type27.String({ minLength: 1, description: "Container hostname." }),
980
+ ostemplate: Type27.String({
758
981
  minLength: 1,
759
982
  description: "OS template volid (e.g. 'local:vztmpl/ubuntu-24.04-standard_*.tar.zst')."
760
983
  }),
761
- node: Type16.Optional(
762
- Type16.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
984
+ node: Type27.Optional(
985
+ Type27.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
763
986
  ),
764
- storage: Type16.Optional(
765
- Type16.String({ minLength: 1, description: "Root storage (default 'local-lvm')." })
987
+ storage: Type27.Optional(
988
+ Type27.String({ minLength: 1, description: "Root storage (default 'local-lvm')." })
766
989
  ),
767
- memory: Type16.Optional(
768
- Type16.Integer({ minimum: 16, description: "Memory in MiB (default 512)." })
990
+ memory: Type27.Optional(
991
+ Type27.Integer({ minimum: 16, description: "Memory in MiB (default 512)." })
769
992
  ),
770
- cores: Type16.Optional(
771
- Type16.Integer({ minimum: 1, description: "CPU cores (default 1)." })
993
+ cores: Type27.Optional(
994
+ Type27.Integer({ minimum: 1, description: "CPU cores (default 1)." })
772
995
  ),
773
- rootfs_size: Type16.Optional(
774
- Type16.String({ minLength: 1, description: "Root filesystem size in GB (default '8')." })
996
+ rootfs_size: Type27.Optional(
997
+ Type27.String({ minLength: 1, description: "Root filesystem size in GB (default '8')." })
775
998
  ),
776
- net: Type16.Optional(
777
- Type16.String({
999
+ net: Type27.Optional(
1000
+ Type27.String({
778
1001
  minLength: 1,
779
1002
  description: "Network config for net0 (default 'name=eth0,bridge=vmbr0,ip=dhcp')."
780
1003
  })
781
1004
  ),
782
- start: Type16.Optional(
783
- Type16.Boolean({ description: "Start after create (default false)." })
1005
+ start: Type27.Optional(
1006
+ Type27.Boolean({ description: "Start after create (default false)." })
1007
+ ),
1008
+ pool: Type27.Optional(
1009
+ Type27.String({ minLength: 1, description: "Optional resource pool ID to place the container into." })
1010
+ ),
1011
+ onboot: Type27.Optional(
1012
+ Type27.Boolean({ description: "Start container on host boot (default false)." })
784
1013
  ),
785
- password: Type16.Optional(
786
- Type16.String({ description: "Root password (optional)." })
1014
+ unprivileged: Type27.Optional(
1015
+ Type27.Boolean({ description: "Create an unprivileged container (default true)." })
787
1016
  ),
788
- ssh_public_keys: Type16.Optional(
789
- Type16.String({ description: "SSH public keys (optional)." })
1017
+ protection: Type27.Optional(
1018
+ Type27.Boolean({ description: "Enable Proxmox protection flag (default false)." })
790
1019
  ),
791
- confirm: Type16.Boolean({
1020
+ features: Type27.Optional(
1021
+ Type27.String({ minLength: 1, description: "Optional LXC features string, e.g. 'nesting=1'." })
1022
+ ),
1023
+ description: Type27.Optional(
1024
+ Type27.String({ description: "Optional container description." })
1025
+ ),
1026
+ tags: Type27.Optional(
1027
+ Type27.String({ minLength: 1, description: "Optional semicolon-delimited Proxmox tags." })
1028
+ ),
1029
+ password: Type27.Optional(
1030
+ Type27.String({ description: "Root password (optional)." })
1031
+ ),
1032
+ ssh_public_keys: Type27.Optional(
1033
+ Type27.String({ description: "SSH public keys (optional)." })
1034
+ ),
1035
+ confirm: Type27.Boolean({
792
1036
  description: "Must be true to write. Tier-2 safe-write gate."
793
1037
  })
794
1038
  },
795
1039
  { additionalProperties: false }
796
1040
  );
797
- var NAME6 = "proxmox_create_container";
1041
+ var NAME13 = "proxmox_create_container";
798
1042
  function createProxmoxCreateContainerTool(getClient) {
799
1043
  return {
800
- name: NAME6,
1044
+ name: NAME13,
801
1045
  label: "proxmox: create container",
802
1046
  description: "Create a new LXC container on a node (POST /nodes/{node}/lxc) with sensible defaults (storage local-lvm, 512MiB, 1 core, 8GB rootfs, DHCP net). Tier-2 write; requires confirm:true.",
803
- parameters: Schema16,
1047
+ parameters: Schema27,
804
1048
  execute: async (_id, raw) => {
805
- assertConfirmedWrite(raw, NAME6);
806
- const args = raw;
1049
+ assertConfirmedWrite(raw, NAME13);
1050
+ const args = validateToolArgs(Schema27, raw, NAME13);
1051
+ if (typeof args.password === "string" && args.password.length > 0) {
1052
+ registerSecret(args.password);
1053
+ }
807
1054
  const client = getClient();
808
1055
  let node = args.node;
809
1056
  if (!node) {
@@ -822,14 +1069,27 @@ function createProxmoxCreateContainerTool(getClient) {
822
1069
  cores: args.cores ?? 1,
823
1070
  rootfs: `${storage}:${rootfsSize}`,
824
1071
  net0: args.net ?? "name=eth0,bridge=vmbr0,ip=dhcp",
825
- start: args.start ? 1 : 0
1072
+ start: args.start ? 1 : 0,
1073
+ onboot: args.onboot ? 1 : 0,
1074
+ unprivileged: args.unprivileged === false ? 0 : 1,
1075
+ protection: args.protection ? 1 : 0
826
1076
  };
1077
+ for (const key of ["pool", "features"]) {
1078
+ const value = args[key];
1079
+ if (typeof value === "string" && value.length > 0) body[key] = value;
1080
+ }
827
1081
  if (typeof args.password === "string" && args.password.length > 0) {
828
1082
  body.password = args.password;
829
1083
  }
830
1084
  if (typeof args.ssh_public_keys === "string" && args.ssh_public_keys.length > 0) {
831
1085
  body["ssh-public-keys"] = args.ssh_public_keys;
832
1086
  }
1087
+ if (typeof args.description === "string" && args.description.length > 0) {
1088
+ body.description = args.description;
1089
+ }
1090
+ if (typeof args.tags === "string" && args.tags.length > 0) {
1091
+ body.tags = args.tags;
1092
+ }
833
1093
  const upid = await client.post(`/nodes/${node}/lxc`, body);
834
1094
  return jsonToolResult({
835
1095
  vmid: args.vmid,
@@ -842,57 +1102,114 @@ function createProxmoxCreateContainerTool(getClient) {
842
1102
  }
843
1103
 
844
1104
  // src/tools/proxmox_create_vm.ts
845
- import { Type as Type17 } from "@sinclair/typebox";
846
- var Schema17 = Type17.Object(
1105
+ import { Type as Type28 } from "@sinclair/typebox";
1106
+ var Schema28 = Type28.Object(
847
1107
  {
848
- vmid: Type17.Integer({ minimum: 1, description: "VMID for the new VM." }),
849
- name: Type17.String({ minLength: 1, description: "VM display name." }),
850
- node: Type17.Optional(
851
- Type17.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
1108
+ vmid: Type28.Integer({ minimum: 1, description: "VMID for the new VM." }),
1109
+ name: Type28.String({ minLength: 1, description: "VM display name." }),
1110
+ node: Type28.Optional(
1111
+ Type28.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
852
1112
  ),
853
- memory: Type17.Optional(
854
- Type17.Integer({ minimum: 16, description: "Memory in MiB (default 2048)." })
1113
+ memory: Type28.Optional(
1114
+ Type28.Integer({ minimum: 16, description: "Memory in MiB (default 2048)." })
855
1115
  ),
856
- cores: Type17.Optional(
857
- Type17.Integer({ minimum: 1, description: "CPU cores (default 2)." })
1116
+ cores: Type28.Optional(
1117
+ Type28.Integer({ minimum: 1, description: "CPU cores (default 2)." })
858
1118
  ),
859
- iso: Type17.Optional(
860
- Type17.String({
1119
+ iso: Type28.Optional(
1120
+ Type28.String({
861
1121
  minLength: 1,
862
1122
  description: "ISO volid for install media (e.g. 'local:iso/ubuntu-24.04.iso'). If set, attaches as ide2 cdrom."
863
1123
  })
864
1124
  ),
865
- disk_size: Type17.Optional(
866
- Type17.String({ minLength: 1, description: "Primary disk size in GB on scsi0 (default '32')." })
1125
+ disk_size: Type28.Optional(
1126
+ Type28.String({ minLength: 1, description: "Primary disk size in GB on scsi0 (default '32')." })
867
1127
  ),
868
- storage: Type17.Optional(
869
- Type17.String({ minLength: 1, description: "Disk storage (default 'local-lvm')." })
1128
+ storage: Type28.Optional(
1129
+ Type28.String({ minLength: 1, description: "Disk storage (default 'local-lvm')." })
870
1130
  ),
871
- net: Type17.Optional(
872
- Type17.String({
1131
+ net: Type28.Optional(
1132
+ Type28.String({
873
1133
  minLength: 1,
874
1134
  description: "Network config for net0 (default 'model=virtio,bridge=vmbr0')."
875
1135
  })
876
1136
  ),
877
- start: Type17.Optional(
878
- Type17.Boolean({ description: "Start after create (default false)." })
1137
+ start: Type28.Optional(
1138
+ Type28.Boolean({ description: "Start after create (default false)." })
879
1139
  ),
880
- confirm: Type17.Boolean({
1140
+ pool: Type28.Optional(
1141
+ Type28.String({ minLength: 1, description: "Optional resource pool ID to place the VM into." })
1142
+ ),
1143
+ onboot: Type28.Optional(
1144
+ Type28.Boolean({ description: "Start VM on host boot (default false)." })
1145
+ ),
1146
+ protection: Type28.Optional(
1147
+ Type28.Boolean({ description: "Enable Proxmox protection flag (default false)." })
1148
+ ),
1149
+ agent: Type28.Optional(
1150
+ Type28.Boolean({ description: "Enable QEMU guest agent in VM config (default false)." })
1151
+ ),
1152
+ scsihw: Type28.Optional(
1153
+ Type28.String({ minLength: 1, description: "Optional SCSI controller, e.g. 'virtio-scsi-pci'." })
1154
+ ),
1155
+ boot: Type28.Optional(
1156
+ Type28.String({ minLength: 1, description: "Optional boot order string." })
1157
+ ),
1158
+ bios: Type28.Optional(
1159
+ Type28.Union([Type28.Literal("seabios"), Type28.Literal("ovmf")], { description: "Optional VM BIOS type." })
1160
+ ),
1161
+ machine: Type28.Optional(
1162
+ Type28.String({ minLength: 1, description: "Optional machine type." })
1163
+ ),
1164
+ cpu: Type28.Optional(
1165
+ Type28.String({ minLength: 1, description: "Optional CPU type." })
1166
+ ),
1167
+ sockets: Type28.Optional(
1168
+ Type28.Integer({ minimum: 1, description: "Optional socket count." })
1169
+ ),
1170
+ description: Type28.Optional(
1171
+ Type28.String({ description: "Optional VM description." })
1172
+ ),
1173
+ tags: Type28.Optional(
1174
+ Type28.String({ minLength: 1, description: "Optional semicolon-delimited Proxmox tags." })
1175
+ ),
1176
+ ciuser: Type28.Optional(
1177
+ Type28.String({ minLength: 1, description: "Optional cloud-init username." })
1178
+ ),
1179
+ cipassword: Type28.Optional(
1180
+ Type28.String({ description: "Optional cloud-init password." })
1181
+ ),
1182
+ sshkeys: Type28.Optional(
1183
+ Type28.String({ description: "Optional cloud-init SSH public keys." })
1184
+ ),
1185
+ ipconfig0: Type28.Optional(
1186
+ Type28.String({ minLength: 1, description: "Optional cloud-init ipconfig0, e.g. 'ip=dhcp'." })
1187
+ ),
1188
+ nameserver: Type28.Optional(
1189
+ Type28.String({ minLength: 1, description: "Optional cloud-init DNS server list." })
1190
+ ),
1191
+ searchdomain: Type28.Optional(
1192
+ Type28.String({ minLength: 1, description: "Optional cloud-init DNS search domain." })
1193
+ ),
1194
+ confirm: Type28.Boolean({
881
1195
  description: "Must be true to write. Tier-2 safe-write gate."
882
1196
  })
883
1197
  },
884
1198
  { additionalProperties: false }
885
1199
  );
886
- var NAME7 = "proxmox_create_vm";
1200
+ var NAME14 = "proxmox_create_vm";
887
1201
  function createProxmoxCreateVmTool(getClient) {
888
1202
  return {
889
- name: NAME7,
1203
+ name: NAME14,
890
1204
  label: "proxmox: create vm",
891
1205
  description: "Create a new QEMU VM on a node (POST /nodes/{node}/qemu) with sensible defaults (2GiB, 2 cores, 32GB disk on local-lvm, virtio net). Optionally attaches an ISO as ide2 cdrom. Tier-2 write; requires confirm:true.",
892
- parameters: Schema17,
1206
+ parameters: Schema28,
893
1207
  execute: async (_id, raw) => {
894
- assertConfirmedWrite(raw, NAME7);
895
- const args = raw;
1208
+ assertConfirmedWrite(raw, NAME14);
1209
+ const args = validateToolArgs(Schema28, raw, NAME14);
1210
+ if (typeof args.cipassword === "string" && args.cipassword.length > 0) {
1211
+ registerSecret(args.cipassword);
1212
+ }
896
1213
  const client = getClient();
897
1214
  let node = args.node;
898
1215
  if (!node) {
@@ -909,11 +1226,19 @@ function createProxmoxCreateVmTool(getClient) {
909
1226
  cores: args.cores ?? 2,
910
1227
  scsi0: `${storage}:${diskSize}`,
911
1228
  net0: args.net ?? "model=virtio,bridge=vmbr0",
912
- start: args.start ? 1 : 0
1229
+ start: args.start ? 1 : 0,
1230
+ onboot: args.onboot ? 1 : 0,
1231
+ protection: args.protection ? 1 : 0,
1232
+ agent: args.agent ? 1 : 0
913
1233
  };
914
1234
  if (typeof args.iso === "string" && args.iso.length > 0) {
915
1235
  body.ide2 = `${args.iso},media=cdrom`;
916
1236
  }
1237
+ for (const key of ["pool", "scsihw", "boot", "bios", "machine", "cpu", "description", "tags", "ciuser", "cipassword", "sshkeys", "ipconfig0", "nameserver", "searchdomain"]) {
1238
+ const value = args[key];
1239
+ if (typeof value === "string" && value.length > 0) body[key] = value;
1240
+ }
1241
+ if (typeof args.sockets === "number") body.sockets = args.sockets;
917
1242
  const upid = await client.post(`/nodes/${node}/qemu`, body);
918
1243
  return jsonToolResult({
919
1244
  vmid: args.vmid,
@@ -926,37 +1251,46 @@ function createProxmoxCreateVmTool(getClient) {
926
1251
  }
927
1252
 
928
1253
  // src/tools/proxmox_clone_resource.ts
929
- import { Type as Type18 } from "@sinclair/typebox";
930
- var Schema18 = Type18.Object(
1254
+ import { Type as Type29 } from "@sinclair/typebox";
1255
+ var Schema29 = Type29.Object(
931
1256
  {
932
- source_vmid: Type18.Integer({ minimum: 1, description: "Source CT/VM ID to clone from." }),
933
- new_vmid: Type18.Integer({ minimum: 1, description: "VMID for the cloned resource." }),
934
- name: Type18.String({ minLength: 1, description: "Name/hostname for the new clone." }),
935
- full: Type18.Optional(
936
- Type18.Boolean({ description: "Full clone (default true). Set false for a linked clone." })
1257
+ source_vmid: Type29.Integer({ minimum: 1, description: "Source CT/VM ID to clone from." }),
1258
+ new_vmid: Type29.Integer({ minimum: 1, description: "VMID for the cloned resource." }),
1259
+ name: Type29.String({ minLength: 1, description: "Name/hostname for the new clone." }),
1260
+ full: Type29.Optional(
1261
+ Type29.Boolean({ description: "Full clone (default true). Set false for a linked clone." })
1262
+ ),
1263
+ storage: Type29.Optional(
1264
+ Type29.String({ minLength: 1, description: "Target storage (default: same as source)." })
937
1265
  ),
938
- storage: Type18.Optional(
939
- Type18.String({ minLength: 1, description: "Target storage (default: same as source)." })
1266
+ target_node: Type29.Optional(
1267
+ Type29.String({ minLength: 1, description: "Optional target node for the clone." })
940
1268
  ),
941
- snapname: Type18.Optional(
942
- Type18.String({ minLength: 1, description: "Clone from a named snapshot (optional)." })
1269
+ pool: Type29.Optional(
1270
+ Type29.String({ minLength: 1, description: "Optional resource pool ID for the clone." })
943
1271
  ),
944
- confirm: Type18.Boolean({
1272
+ snapname: Type29.Optional(
1273
+ Type29.String({ minLength: 1, description: "Clone from a named snapshot (optional)." })
1274
+ ),
1275
+ description: Type29.Optional(
1276
+ Type29.String({ description: "Optional description for the clone." })
1277
+ ),
1278
+ confirm: Type29.Boolean({
945
1279
  description: "Must be true to write. Tier-2 safe-write gate."
946
1280
  })
947
1281
  },
948
1282
  { additionalProperties: false }
949
1283
  );
950
- var NAME8 = "proxmox_clone_resource";
1284
+ var NAME15 = "proxmox_clone_resource";
951
1285
  function createProxmoxCloneResourceTool(getClient) {
952
1286
  return {
953
- name: NAME8,
1287
+ name: NAME15,
954
1288
  label: "proxmox: clone resource",
955
1289
  description: "Clone an existing LXC or QEMU resource by source_vmid to a new_vmid (POST /nodes/{node}/{type}/{source_vmid}/clone). Resolves source node/type from cluster resources. Tier-2 write; requires confirm:true.",
956
- parameters: Schema18,
1290
+ parameters: Schema29,
957
1291
  execute: async (_id, raw) => {
958
- assertConfirmedWrite(raw, NAME8);
959
- const args = raw;
1292
+ assertConfirmedWrite(raw, NAME15);
1293
+ const args = validateToolArgs(Schema29, raw, NAME15);
960
1294
  const client = getClient();
961
1295
  const { node, type } = await resolveResource(client, args.source_vmid);
962
1296
  const body = {
@@ -967,9 +1301,18 @@ function createProxmoxCloneResourceTool(getClient) {
967
1301
  if (typeof args.storage === "string" && args.storage.length > 0) {
968
1302
  body.storage = args.storage;
969
1303
  }
1304
+ if (typeof args.target_node === "string" && args.target_node.length > 0) {
1305
+ body.target = args.target_node;
1306
+ }
1307
+ if (typeof args.pool === "string" && args.pool.length > 0) {
1308
+ body.pool = args.pool;
1309
+ }
970
1310
  if (typeof args.snapname === "string" && args.snapname.length > 0) {
971
1311
  body.snapname = args.snapname;
972
1312
  }
1313
+ if (typeof args.description === "string" && args.description.length > 0) {
1314
+ body.description = args.description;
1315
+ }
973
1316
  const upid = await client.post(
974
1317
  `/nodes/${node}/${type}/${args.source_vmid}/clone`,
975
1318
  body
@@ -987,40 +1330,40 @@ function createProxmoxCloneResourceTool(getClient) {
987
1330
  }
988
1331
 
989
1332
  // src/tools/proxmox_destroy_resource.ts
990
- import { Type as Type19 } from "@sinclair/typebox";
991
- var Schema19 = Type19.Object(
1333
+ import { Type as Type30 } from "@sinclair/typebox";
1334
+ var Schema30 = Type30.Object(
992
1335
  {
993
- vmid: Type19.Integer({ minimum: 1, description: "Container or VM ID to destroy." }),
994
- purge: Type19.Optional(
995
- Type19.Boolean({
1336
+ vmid: Type30.Integer({ minimum: 1, description: "Container or VM ID to destroy." }),
1337
+ purge: Type30.Optional(
1338
+ Type30.Boolean({
996
1339
  description: "Remove from PVE backup/replication config too (default true)."
997
1340
  })
998
1341
  ),
999
- force: Type19.Optional(
1000
- Type19.Boolean({
1342
+ force: Type30.Optional(
1343
+ Type30.Boolean({
1001
1344
  description: "Allow destroying a running VM (default false)."
1002
1345
  })
1003
1346
  ),
1004
- confirm: Type19.Boolean({
1347
+ confirm: Type30.Boolean({
1005
1348
  description: "Must be true. Tier-3 destructive gate."
1006
1349
  }),
1007
- destructive: Type19.Boolean({
1350
+ destructive: Type30.Boolean({
1008
1351
  description: "Must be true. Tier-3 destructive gate."
1009
1352
  })
1010
1353
  },
1011
1354
  { additionalProperties: false }
1012
1355
  );
1013
- var NAME9 = "proxmox_destroy_resource";
1356
+ var NAME16 = "proxmox_destroy_resource";
1014
1357
  function createProxmoxDestroyResourceTool(getClient) {
1015
1358
  return {
1016
- name: NAME9,
1359
+ name: NAME16,
1017
1360
  label: "proxmox: destroy resource",
1018
1361
  description: "Permanently delete an LXC container or QEMU VM by vmid (DELETE /nodes/{node}/{type}/{vmid}). Tier-3 destructive; requires confirm:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
1019
- parameters: Schema19,
1362
+ parameters: Schema30,
1020
1363
  execute: async (_id, raw) => {
1021
- assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME9);
1022
- assertDestructive(raw, NAME9);
1023
- const args = raw;
1364
+ assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME16);
1365
+ assertDestructive(raw, NAME16);
1366
+ const args = validateToolArgs(Schema30, raw, NAME16);
1024
1367
  const purge = args.purge !== false;
1025
1368
  const force = args.force === true;
1026
1369
  const client = getClient();
@@ -1032,42 +1375,86 @@ function createProxmoxDestroyResourceTool(getClient) {
1032
1375
  }
1033
1376
  if (force && type === "lxc") params.append("force", "1");
1034
1377
  const qs = params.toString();
1035
- const path = qs.length > 0 ? `/nodes/${node}/${type}/${args.vmid}?${qs}` : `/nodes/${node}/${type}/${args.vmid}`;
1036
- const upid = await client.delete(path);
1378
+ const path2 = qs.length > 0 ? `/nodes/${node}/${type}/${args.vmid}?${qs}` : `/nodes/${node}/${type}/${args.vmid}`;
1379
+ const upid = await client.delete(path2);
1037
1380
  return jsonToolResult({ vmid: args.vmid, node, type, upid });
1038
1381
  }
1039
1382
  };
1040
1383
  }
1041
1384
 
1385
+ // src/tools/proxmox_cleanup_smoke_resources.ts
1386
+ import { Type as Type31 } from "@sinclair/typebox";
1387
+ var Schema31 = Type31.Object(
1388
+ {
1389
+ pool: Type31.Optional(
1390
+ Type31.String({ minLength: 1, description: "Pool ID to clean up (default mcp-smoke)." })
1391
+ ),
1392
+ name_prefix: Type31.Optional(
1393
+ Type31.String({
1394
+ minLength: 1,
1395
+ description: "Only delete guest names starting with this prefix (default mcp-smoke-)."
1396
+ })
1397
+ ),
1398
+ force: Type31.Optional(
1399
+ Type31.Boolean({
1400
+ description: "Allow deleting running smoke guests. Also passes force=1 for LXC cleanup (default false)."
1401
+ })
1402
+ ),
1403
+ dry_run: Type31.Optional(
1404
+ Type31.Boolean({ description: "Preview matching targets without deleting them (default true)." })
1405
+ ),
1406
+ wait: Type31.Optional(
1407
+ Type31.Boolean({ description: "Wait for delete tasks to finish when dry_run:false (default true)." })
1408
+ ),
1409
+ confirm: Type31.Optional(
1410
+ Type31.Boolean({ description: "Must be true when dry_run:false. Tier-3 destructive gate." })
1411
+ ),
1412
+ destructive: Type31.Optional(
1413
+ Type31.Boolean({ description: "Must be true when dry_run:false. Tier-3 destructive gate." })
1414
+ ),
1415
+ timeoutSeconds: Type31.Optional(
1416
+ Type31.Integer({ minimum: 1, maximum: 3600, description: "Max seconds to wait per delete task (default 180)." })
1417
+ ),
1418
+ intervalMs: Type31.Optional(
1419
+ Type31.Integer({ minimum: 100, maximum: 1e4, description: "Task polling interval in milliseconds (default 1000)." })
1420
+ )
1421
+ },
1422
+ { additionalProperties: false }
1423
+ );
1424
+
1042
1425
  // src/tools/proxmox_delete_snapshot.ts
1043
- import { Type as Type20 } from "@sinclair/typebox";
1044
- var Schema20 = Type20.Object(
1426
+ import { Type as Type32 } from "@sinclair/typebox";
1427
+ var Schema32 = Type32.Object(
1045
1428
  {
1046
- vmid: Type20.Integer({ minimum: 1, description: "Container or VM ID." }),
1047
- snapname: Type20.String({
1429
+ vmid: Type32.Integer({ minimum: 1, description: "Container or VM ID." }),
1430
+ snapname: Type32.String({
1048
1431
  minLength: 1,
1049
1432
  description: "Snapshot name to delete."
1050
1433
  }),
1051
- confirm: Type20.Boolean({
1434
+ confirm: Type32.Boolean({
1052
1435
  description: "Must be true. Tier-3 destructive gate."
1053
1436
  }),
1054
- destructive: Type20.Boolean({
1437
+ destructive: Type32.Boolean({
1055
1438
  description: "Must be true. Tier-3 destructive gate."
1056
1439
  })
1057
1440
  },
1058
1441
  { additionalProperties: false }
1059
1442
  );
1060
- var NAME10 = "proxmox_delete_snapshot";
1443
+ var NAME17 = "proxmox_delete_snapshot";
1061
1444
  function createProxmoxDeleteSnapshotTool(getClient) {
1062
1445
  return {
1063
- name: NAME10,
1446
+ name: NAME17,
1064
1447
  label: "proxmox: delete snapshot",
1065
1448
  description: "Delete a named snapshot from an LXC container or QEMU VM (DELETE /nodes/{node}/{type}/{vmid}/snapshot/{snapname}). Tier-3 destructive; requires confirm:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
1066
- parameters: Schema20,
1449
+ parameters: Schema32,
1067
1450
  execute: async (_id, raw) => {
1068
- assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME10);
1069
- assertDestructive(raw, NAME10);
1070
- const args = raw;
1451
+ assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME17);
1452
+ assertDestructive(raw, NAME17);
1453
+ const args = validateToolArgs(
1454
+ Schema32,
1455
+ raw,
1456
+ NAME17
1457
+ );
1071
1458
  const client = getClient();
1072
1459
  const { node, type } = await resolveResource(client, args.vmid);
1073
1460
  const upid = await client.delete(
@@ -1079,30 +1466,30 @@ function createProxmoxDeleteSnapshotTool(getClient) {
1079
1466
  }
1080
1467
 
1081
1468
  // src/tools/proxmox_force_stop_resource.ts
1082
- import { Type as Type21 } from "@sinclair/typebox";
1083
- var Schema21 = Type21.Object(
1469
+ import { Type as Type33 } from "@sinclair/typebox";
1470
+ var Schema33 = Type33.Object(
1084
1471
  {
1085
- vmid: Type21.Integer({ minimum: 1, description: "Container or VM ID to hard-stop." }),
1086
- confirm: Type21.Boolean({
1472
+ vmid: Type33.Integer({ minimum: 1, description: "Container or VM ID to hard-stop." }),
1473
+ confirm: Type33.Boolean({
1087
1474
  description: "Must be true. Tier-3 destructive gate."
1088
1475
  }),
1089
- destructive: Type21.Boolean({
1476
+ destructive: Type33.Boolean({
1090
1477
  description: "Must be true. Tier-3 destructive gate."
1091
1478
  })
1092
1479
  },
1093
1480
  { additionalProperties: false }
1094
1481
  );
1095
- var NAME11 = "proxmox_force_stop_resource";
1482
+ var NAME18 = "proxmox_force_stop_resource";
1096
1483
  function createProxmoxForceStopResourceTool(getClient) {
1097
1484
  return {
1098
- name: NAME11,
1485
+ name: NAME18,
1099
1486
  label: "proxmox: force stop resource",
1100
1487
  description: "Hard-kill an LXC container or QEMU VM (POST /nodes/{node}/{type}/{vmid}/status/stop). Unlike reboot/shutdown this is a non-graceful stop. Tier-3 destructive; requires confirm:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
1101
- parameters: Schema21,
1488
+ parameters: Schema33,
1102
1489
  execute: async (_id, raw) => {
1103
- assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME11);
1104
- assertDestructive(raw, NAME11);
1105
- const args = raw;
1490
+ assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME18);
1491
+ assertDestructive(raw, NAME18);
1492
+ const args = validateToolArgs(Schema33, raw, NAME18);
1106
1493
  const client = getClient();
1107
1494
  const { node, type } = await resolveResource(client, args.vmid);
1108
1495
  const upid = await client.post(
@@ -1114,6 +1501,80 @@ function createProxmoxForceStopResourceTool(getClient) {
1114
1501
  };
1115
1502
  }
1116
1503
 
1504
+ // src/tools/proxmox_exec.ts
1505
+ import { Type as Type34 } from "@sinclair/typebox";
1506
+ var Schema34 = Type34.Object(
1507
+ {
1508
+ vmid: Type34.Integer({ minimum: 1, description: "Container or VM id." }),
1509
+ command: Type34.String({ minLength: 1, description: "Shell command to run inside the resource." }),
1510
+ timeout: Type34.Optional(
1511
+ Type34.Integer({ minimum: 1, maximum: 3600, description: "Timeout in seconds (default 30)." })
1512
+ ),
1513
+ confirm: Type34.Boolean({ description: "Must be true to execute. Tier-2 safe-write gate." })
1514
+ },
1515
+ { additionalProperties: false }
1516
+ );
1517
+
1518
+ // src/tools/proxmox_read_file.ts
1519
+ import { Type as Type35 } from "@sinclair/typebox";
1520
+ var Schema35 = Type35.Object(
1521
+ {
1522
+ vmid: Type35.Integer({ minimum: 1, description: "Container or VM id." }),
1523
+ path: Type35.String({ minLength: 1, description: "Absolute file path inside the resource." }),
1524
+ confirm: Type35.Boolean({ description: "Must be true to read files from inside a guest." })
1525
+ },
1526
+ { additionalProperties: false }
1527
+ );
1528
+
1529
+ // src/tools/proxmox_write_file.ts
1530
+ import { Type as Type36 } from "@sinclair/typebox";
1531
+ import path from "path";
1532
+ var Schema36 = Type36.Object(
1533
+ {
1534
+ vmid: Type36.Integer({ minimum: 1, description: "Container or VM id." }),
1535
+ path: Type36.String({ minLength: 1, description: "Absolute destination path inside the resource." }),
1536
+ content: Type36.String({ description: "Text content to write." }),
1537
+ confirm: Type36.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
1538
+ },
1539
+ { additionalProperties: false }
1540
+ );
1541
+
1542
+ // src/tools/proxmox_stat_path.ts
1543
+ import { Type as Type37 } from "@sinclair/typebox";
1544
+ var Schema37 = Type37.Object(
1545
+ {
1546
+ vmid: Type37.Integer({ minimum: 1, description: "Container or VM id." }),
1547
+ path: Type37.String({ minLength: 1, description: "Absolute path inside the guest." }),
1548
+ confirm: Type37.Boolean({ description: "Must be true to inspect guest filesystem metadata." })
1549
+ },
1550
+ { additionalProperties: false }
1551
+ );
1552
+
1553
+ // src/tools/proxmox_list_directory.ts
1554
+ import { Type as Type38 } from "@sinclair/typebox";
1555
+ var Schema38 = Type38.Object(
1556
+ {
1557
+ vmid: Type38.Integer({ minimum: 1, description: "Container or VM id." }),
1558
+ path: Type38.String({ minLength: 1, description: "Absolute directory path inside the guest." }),
1559
+ confirm: Type38.Boolean({ description: "Must be true to inspect guest directory contents." })
1560
+ },
1561
+ { additionalProperties: false }
1562
+ );
1563
+
1564
+ // src/tools/proxmox_service_status.ts
1565
+ import { Type as Type39 } from "@sinclair/typebox";
1566
+ var Schema39 = Type39.Object(
1567
+ {
1568
+ vmid: Type39.Integer({ minimum: 1, description: "Container or VM id." }),
1569
+ service: Type39.String({ minLength: 1, description: "systemd service name inside the guest." }),
1570
+ confirm: Type39.Boolean({ description: "Must be true to inspect guest service state." })
1571
+ },
1572
+ { additionalProperties: false }
1573
+ );
1574
+
1575
+ // src/tools/service-action.ts
1576
+ import { Type as Type40 } from "@sinclair/typebox";
1577
+
1117
1578
  // index.ts
1118
1579
  function withRedactedErrors(tool) {
1119
1580
  const orig = tool.execute.bind(tool);