@solomonneas/proxmox-mcp 0.5.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -35
- package/dist/cli.js +3150 -376
- package/dist/index.js +3439 -353
- package/dist/mcp-bin.js +2879 -365
- package/dist/mcp-server.js +2881 -346
- package/openclaw.plugin.json +12 -4
- package/package.json +4 -9
package/dist/mcp-server.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// mcp-server.ts
|
|
4
|
+
import { realpathSync } from "fs";
|
|
5
|
+
import { pathToFileURL } from "url";
|
|
6
|
+
|
|
7
|
+
// src/server.ts
|
|
4
8
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
5
9
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
10
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -59,7 +63,6 @@ var ProxmoxClientError = class extends Error {
|
|
|
59
63
|
this.status = status;
|
|
60
64
|
this.name = "ProxmoxClientError";
|
|
61
65
|
}
|
|
62
|
-
status;
|
|
63
66
|
};
|
|
64
67
|
var ProxmoxUnreachableError = class extends Error {
|
|
65
68
|
constructor(cause) {
|
|
@@ -74,7 +77,6 @@ var ProxmoxClient = class {
|
|
|
74
77
|
this.retryDelayMs = opts.retryDelayMs ?? 1e3;
|
|
75
78
|
this.usesInsecureTls = cfg.tlsInsecure && cfg.url.startsWith("https://");
|
|
76
79
|
}
|
|
77
|
-
cfg;
|
|
78
80
|
authHeader;
|
|
79
81
|
retryDelayMs;
|
|
80
82
|
usesInsecureTls;
|
|
@@ -84,6 +86,9 @@ var ProxmoxClient = class {
|
|
|
84
86
|
async post(path2, body) {
|
|
85
87
|
return this.request("POST", path2, body);
|
|
86
88
|
}
|
|
89
|
+
async put(path2, body) {
|
|
90
|
+
return this.request("PUT", path2, body);
|
|
91
|
+
}
|
|
87
92
|
async delete(path2) {
|
|
88
93
|
return this.request("DELETE", path2);
|
|
89
94
|
}
|
|
@@ -96,6 +101,13 @@ var ProxmoxClient = class {
|
|
|
96
101
|
const form = new URLSearchParams();
|
|
97
102
|
for (const [k, v] of Object.entries(body)) {
|
|
98
103
|
if (v === void 0 || v === null) continue;
|
|
104
|
+
if (Array.isArray(v)) {
|
|
105
|
+
for (const item of v) {
|
|
106
|
+
if (item === void 0 || item === null) continue;
|
|
107
|
+
form.append(k, typeof item === "object" ? JSON.stringify(item) : String(item));
|
|
108
|
+
}
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
99
111
|
form.append(k, typeof v === "object" ? JSON.stringify(v) : String(v));
|
|
100
112
|
}
|
|
101
113
|
headers["content-type"] = "application/x-www-form-urlencoded";
|
|
@@ -184,7 +196,6 @@ var SshExecError = class extends Error {
|
|
|
184
196
|
this.phase = phase;
|
|
185
197
|
this.name = "SshExecError";
|
|
186
198
|
}
|
|
187
|
-
phase;
|
|
188
199
|
};
|
|
189
200
|
function expandHome(p) {
|
|
190
201
|
if (p.startsWith("~/")) return homedir() + p.slice(1);
|
|
@@ -323,19 +334,39 @@ async function execViaDirectSsh(targetCfg, command, timeoutMs, stdin) {
|
|
|
323
334
|
// src/security.ts
|
|
324
335
|
var SECRETS = /* @__PURE__ */ new Set();
|
|
325
336
|
var BASE64_TOKEN_RE = /[A-Za-z0-9+/=]{12,}/g;
|
|
337
|
+
var MIN_SUBSTRING_LENGTH = 8;
|
|
338
|
+
var warnedShortSecret = false;
|
|
339
|
+
function escapeRegExp(s) {
|
|
340
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
341
|
+
}
|
|
326
342
|
function registerSecret(s) {
|
|
327
|
-
if (s
|
|
343
|
+
if (!s || s.length === 0) return;
|
|
344
|
+
SECRETS.add(s);
|
|
345
|
+
if (s.length < MIN_SUBSTRING_LENGTH && !warnedShortSecret) {
|
|
346
|
+
warnedShortSecret = true;
|
|
347
|
+
console.error(
|
|
348
|
+
`proxmox-mcp: a registered secret is shorter than ${MIN_SUBSTRING_LENGTH} characters. It is still redacted, but only where it appears as a standalone value. If this is PROXMOX_TOKEN_SECRET, check that it was not truncated.`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
328
351
|
}
|
|
329
352
|
function maskString(s) {
|
|
330
353
|
let out = s;
|
|
331
354
|
for (const secret of SECRETS) {
|
|
332
|
-
if (out.includes(secret))
|
|
355
|
+
if (!out.includes(secret)) continue;
|
|
356
|
+
if (secret.length >= MIN_SUBSTRING_LENGTH) {
|
|
357
|
+
out = out.split(secret).join("REDACTED");
|
|
358
|
+
} else {
|
|
359
|
+
out = out.replace(
|
|
360
|
+
new RegExp(`(^|[^A-Za-z0-9])${escapeRegExp(secret)}(?=[^A-Za-z0-9]|$)`, "g"),
|
|
361
|
+
(_match, left) => `${left}REDACTED`
|
|
362
|
+
);
|
|
363
|
+
}
|
|
333
364
|
}
|
|
334
365
|
out = out.replace(BASE64_TOKEN_RE, (token) => {
|
|
335
366
|
try {
|
|
336
367
|
const decoded = Buffer.from(token, "base64").toString("utf8");
|
|
337
368
|
for (const secret of SECRETS) {
|
|
338
|
-
if (decoded.includes(secret)) return "REDACTED";
|
|
369
|
+
if (secret.length >= MIN_SUBSTRING_LENGTH && decoded.includes(secret)) return "REDACTED";
|
|
339
370
|
}
|
|
340
371
|
} catch {
|
|
341
372
|
}
|
|
@@ -398,6 +429,7 @@ async function resolveResource(client, vmid) {
|
|
|
398
429
|
const where = matches.map((m) => `${m.node}/${m.type}`).join(", ");
|
|
399
430
|
throw new Error(`vmid ${vmid} ambiguous - found on multiple nodes: ${where}. Refusing to proceed.`);
|
|
400
431
|
}
|
|
432
|
+
assertSafePathSegment(matches[0].node, "node");
|
|
401
433
|
return { node: matches[0].node, type: matches[0].type };
|
|
402
434
|
}
|
|
403
435
|
function parseTaskUpid(upid) {
|
|
@@ -408,6 +440,7 @@ function parseTaskUpid(upid) {
|
|
|
408
440
|
if (parts.length < 8) throw new Error(`invalid UPID format: ${upid}`);
|
|
409
441
|
const node = parts[1];
|
|
410
442
|
if (!node) throw new Error(`UPID missing node segment: ${upid}`);
|
|
443
|
+
if (!SAFE_SEGMENT_RE.test(node)) throw new Error(`invalid UPID format: bad node segment "${node}"`);
|
|
411
444
|
return { node };
|
|
412
445
|
}
|
|
413
446
|
|
|
@@ -1091,23 +1124,56 @@ function createProxmoxRollbackSnapshotTool(getClient) {
|
|
|
1091
1124
|
}
|
|
1092
1125
|
|
|
1093
1126
|
// src/tools/proxmox_run_backup.ts
|
|
1127
|
+
import { Type as Type18 } from "@sinclair/typebox";
|
|
1128
|
+
|
|
1129
|
+
// src/tools/task-wait.ts
|
|
1094
1130
|
import { Type as Type17 } from "@sinclair/typebox";
|
|
1095
|
-
var
|
|
1131
|
+
var taskWaitFields = {
|
|
1132
|
+
wait: Type17.Optional(
|
|
1133
|
+
Type17.Boolean({ description: "Block until the task finishes and include its exit status in the result." })
|
|
1134
|
+
),
|
|
1135
|
+
wait_timeout: Type17.Optional(
|
|
1136
|
+
Type17.Integer({ minimum: 1, maximum: 3600, description: "Max seconds to wait when wait:true (default 120)." })
|
|
1137
|
+
)
|
|
1138
|
+
};
|
|
1139
|
+
function sleep2(ms) {
|
|
1140
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1141
|
+
}
|
|
1142
|
+
async function resolveTaskWait(client, upid, args, intervalMs = 1e3) {
|
|
1143
|
+
if (!args.wait || typeof upid !== "string" || !upid.startsWith("UPID:")) return void 0;
|
|
1144
|
+
const { node } = parseTaskUpid(upid);
|
|
1145
|
+
const deadline = Date.now() + (args.wait_timeout ?? 120) * 1e3;
|
|
1146
|
+
let polls = 0;
|
|
1147
|
+
let last = null;
|
|
1148
|
+
while (Date.now() <= deadline) {
|
|
1149
|
+
polls += 1;
|
|
1150
|
+
last = await client.get(`/nodes/${node}/tasks/${encodeURIComponent(upid)}/status`);
|
|
1151
|
+
if (last.status === "stopped" || last.exitstatus) {
|
|
1152
|
+
return { done: true, polls, status: last.status, exitstatus: last.exitstatus, ok: last.exitstatus === "OK" };
|
|
1153
|
+
}
|
|
1154
|
+
await sleep2(Math.min(intervalMs, Math.max(0, deadline - Date.now())));
|
|
1155
|
+
}
|
|
1156
|
+
return { done: false, polls, status: last?.status };
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
// src/tools/proxmox_run_backup.ts
|
|
1160
|
+
var Schema17 = Type18.Object(
|
|
1096
1161
|
{
|
|
1097
|
-
vmid:
|
|
1098
|
-
storage:
|
|
1162
|
+
vmid: Type18.Integer({ minimum: 1, description: "Container or VM ID to back up." }),
|
|
1163
|
+
storage: Type18.String({
|
|
1099
1164
|
minLength: 1,
|
|
1100
1165
|
description: "PVE storage ID where the vzdump archive should be written."
|
|
1101
1166
|
}),
|
|
1102
|
-
mode:
|
|
1103
|
-
|
|
1104
|
-
[
|
|
1167
|
+
mode: Type18.Optional(
|
|
1168
|
+
Type18.Union(
|
|
1169
|
+
[Type18.Literal("snapshot"), Type18.Literal("suspend"), Type18.Literal("stop")],
|
|
1105
1170
|
{ description: "Backup mode. Defaults to 'snapshot'." }
|
|
1106
1171
|
)
|
|
1107
1172
|
),
|
|
1108
|
-
confirm:
|
|
1173
|
+
confirm: Type18.Boolean({
|
|
1109
1174
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1110
|
-
})
|
|
1175
|
+
}),
|
|
1176
|
+
...taskWaitFields
|
|
1111
1177
|
},
|
|
1112
1178
|
{ additionalProperties: false }
|
|
1113
1179
|
);
|
|
@@ -1130,23 +1196,25 @@ function createProxmoxRunBackupTool(getClient) {
|
|
|
1130
1196
|
mode,
|
|
1131
1197
|
compress: "zstd"
|
|
1132
1198
|
});
|
|
1199
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1133
1200
|
return jsonToolResult({
|
|
1134
1201
|
vmid: args.vmid,
|
|
1135
1202
|
node,
|
|
1136
1203
|
storage: args.storage,
|
|
1137
1204
|
mode,
|
|
1138
|
-
upid
|
|
1205
|
+
upid,
|
|
1206
|
+
...task ? { task } : {}
|
|
1139
1207
|
});
|
|
1140
1208
|
}
|
|
1141
1209
|
};
|
|
1142
1210
|
}
|
|
1143
1211
|
|
|
1144
1212
|
// src/tools/proxmox_get_task_status.ts
|
|
1145
|
-
import { Type as
|
|
1213
|
+
import { Type as Type19 } from "@sinclair/typebox";
|
|
1146
1214
|
var NAME15 = "proxmox_get_task_status";
|
|
1147
|
-
var Schema18 =
|
|
1215
|
+
var Schema18 = Type19.Object(
|
|
1148
1216
|
{
|
|
1149
|
-
upid:
|
|
1217
|
+
upid: Type19.String({
|
|
1150
1218
|
minLength: 1,
|
|
1151
1219
|
description: "Task UPID returned by a prior write tool (e.g. start, stop, snapshot, backup)."
|
|
1152
1220
|
})
|
|
@@ -1172,19 +1240,19 @@ function createProxmoxGetTaskStatusTool(getClient) {
|
|
|
1172
1240
|
}
|
|
1173
1241
|
|
|
1174
1242
|
// src/tools/proxmox_get_task_log.ts
|
|
1175
|
-
import { Type as
|
|
1243
|
+
import { Type as Type20 } from "@sinclair/typebox";
|
|
1176
1244
|
var NAME16 = "proxmox_get_task_log";
|
|
1177
|
-
var Schema19 =
|
|
1245
|
+
var Schema19 = Type20.Object(
|
|
1178
1246
|
{
|
|
1179
|
-
upid:
|
|
1247
|
+
upid: Type20.String({
|
|
1180
1248
|
minLength: 1,
|
|
1181
1249
|
description: "Task UPID returned by a prior write tool."
|
|
1182
1250
|
}),
|
|
1183
|
-
start:
|
|
1184
|
-
|
|
1251
|
+
start: Type20.Optional(
|
|
1252
|
+
Type20.Integer({ minimum: 0, description: "Line offset to start from (default 0)." })
|
|
1185
1253
|
),
|
|
1186
|
-
limit:
|
|
1187
|
-
|
|
1254
|
+
limit: Type20.Optional(
|
|
1255
|
+
Type20.Integer({
|
|
1188
1256
|
minimum: 1,
|
|
1189
1257
|
maximum: 500,
|
|
1190
1258
|
description: "Max lines to return (default 50, max 500)."
|
|
@@ -1214,19 +1282,19 @@ function createProxmoxGetTaskLogTool(getClient) {
|
|
|
1214
1282
|
}
|
|
1215
1283
|
|
|
1216
1284
|
// src/tools/proxmox_list_templates.ts
|
|
1217
|
-
import { Type as
|
|
1285
|
+
import { Type as Type21 } from "@sinclair/typebox";
|
|
1218
1286
|
var NAME17 = "proxmox_list_templates";
|
|
1219
|
-
var Schema20 =
|
|
1287
|
+
var Schema20 = Type21.Object(
|
|
1220
1288
|
{
|
|
1221
|
-
node:
|
|
1222
|
-
|
|
1289
|
+
node: Type21.Optional(
|
|
1290
|
+
Type21.String({ minLength: 1, description: "Node to query (defaults to first node)." })
|
|
1223
1291
|
),
|
|
1224
|
-
storage:
|
|
1225
|
-
|
|
1292
|
+
storage: Type21.Optional(
|
|
1293
|
+
Type21.String({ minLength: 1, description: "Storage to query (defaults to 'local')." })
|
|
1226
1294
|
),
|
|
1227
|
-
kind:
|
|
1228
|
-
|
|
1229
|
-
[
|
|
1295
|
+
kind: Type21.Optional(
|
|
1296
|
+
Type21.Union(
|
|
1297
|
+
[Type21.Literal("vztmpl"), Type21.Literal("iso"), Type21.Literal("both")],
|
|
1230
1298
|
{ description: "Template kind: 'vztmpl' (CT templates), 'iso' (VM ISOs), or 'both'. Defaults to 'both'." }
|
|
1231
1299
|
)
|
|
1232
1300
|
)
|
|
@@ -1274,11 +1342,11 @@ function createProxmoxListTemplatesTool(getClient) {
|
|
|
1274
1342
|
}
|
|
1275
1343
|
|
|
1276
1344
|
// src/tools/proxmox_list_storage.ts
|
|
1277
|
-
import { Type as
|
|
1278
|
-
var Schema21 =
|
|
1345
|
+
import { Type as Type22 } from "@sinclair/typebox";
|
|
1346
|
+
var Schema21 = Type22.Object(
|
|
1279
1347
|
{
|
|
1280
|
-
node:
|
|
1281
|
-
|
|
1348
|
+
node: Type22.Optional(
|
|
1349
|
+
Type22.String({ minLength: 1, description: "Node to query. Defaults to all nodes." })
|
|
1282
1350
|
)
|
|
1283
1351
|
},
|
|
1284
1352
|
{ additionalProperties: false }
|
|
@@ -1312,10 +1380,10 @@ function createProxmoxListStorageTool(getClient) {
|
|
|
1312
1380
|
}
|
|
1313
1381
|
|
|
1314
1382
|
// src/tools/proxmox_list_snapshots.ts
|
|
1315
|
-
import { Type as
|
|
1316
|
-
var Schema22 =
|
|
1383
|
+
import { Type as Type23 } from "@sinclair/typebox";
|
|
1384
|
+
var Schema22 = Type23.Object(
|
|
1317
1385
|
{
|
|
1318
|
-
vmid:
|
|
1386
|
+
vmid: Type23.Integer({ minimum: 1, description: "Container or VM ID." })
|
|
1319
1387
|
},
|
|
1320
1388
|
{ additionalProperties: false }
|
|
1321
1389
|
);
|
|
@@ -1337,10 +1405,10 @@ function createProxmoxListSnapshotsTool(getClient) {
|
|
|
1337
1405
|
}
|
|
1338
1406
|
|
|
1339
1407
|
// src/tools/proxmox_guest_network.ts
|
|
1340
|
-
import { Type as
|
|
1341
|
-
var Schema23 =
|
|
1408
|
+
import { Type as Type24 } from "@sinclair/typebox";
|
|
1409
|
+
var Schema23 = Type24.Object(
|
|
1342
1410
|
{
|
|
1343
|
-
vmid:
|
|
1411
|
+
vmid: Type24.Integer({ minimum: 1, description: "Container or VM ID." })
|
|
1344
1412
|
},
|
|
1345
1413
|
{ additionalProperties: false }
|
|
1346
1414
|
);
|
|
@@ -1379,15 +1447,15 @@ function createProxmoxGuestNetworkTool(getClient) {
|
|
|
1379
1447
|
}
|
|
1380
1448
|
|
|
1381
1449
|
// src/tools/proxmox_wait_task.ts
|
|
1382
|
-
import { Type as
|
|
1383
|
-
var Schema24 =
|
|
1450
|
+
import { Type as Type25 } from "@sinclair/typebox";
|
|
1451
|
+
var Schema24 = Type25.Object(
|
|
1384
1452
|
{
|
|
1385
|
-
upid:
|
|
1386
|
-
timeoutSeconds:
|
|
1387
|
-
|
|
1453
|
+
upid: Type25.String({ minLength: 1, description: "Task UPID to wait for." }),
|
|
1454
|
+
timeoutSeconds: Type25.Optional(
|
|
1455
|
+
Type25.Integer({ minimum: 1, maximum: 3600, description: "Max wait time in seconds. Default 60." })
|
|
1388
1456
|
),
|
|
1389
|
-
intervalMs:
|
|
1390
|
-
|
|
1457
|
+
intervalMs: Type25.Optional(
|
|
1458
|
+
Type25.Integer({ minimum: 100, maximum: 1e4, description: "Polling interval in milliseconds. Default 1000." })
|
|
1391
1459
|
)
|
|
1392
1460
|
},
|
|
1393
1461
|
{ additionalProperties: false }
|
|
@@ -1416,19 +1484,19 @@ function createProxmoxWaitTaskTool(getClient) {
|
|
|
1416
1484
|
if (lastStatus.status === "stopped" || lastStatus.exitstatus) {
|
|
1417
1485
|
return jsonToolResult({ upid: args.upid, node, done: true, polls, status: lastStatus });
|
|
1418
1486
|
}
|
|
1419
|
-
await
|
|
1487
|
+
await sleep3(Math.min(intervalMs, Math.max(0, deadline - Date.now())));
|
|
1420
1488
|
}
|
|
1421
1489
|
return jsonToolResult({ upid: args.upid, node, done: false, polls, status: lastStatus });
|
|
1422
1490
|
}
|
|
1423
1491
|
};
|
|
1424
1492
|
}
|
|
1425
|
-
function
|
|
1493
|
+
function sleep3(ms) {
|
|
1426
1494
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1427
1495
|
}
|
|
1428
1496
|
|
|
1429
1497
|
// src/tools/proxmox_next_vmid.ts
|
|
1430
|
-
import { Type as
|
|
1431
|
-
var Schema25 =
|
|
1498
|
+
import { Type as Type26 } from "@sinclair/typebox";
|
|
1499
|
+
var Schema25 = Type26.Object({}, { additionalProperties: false });
|
|
1432
1500
|
var NAME22 = "proxmox_next_vmid";
|
|
1433
1501
|
function createProxmoxNextVmidTool(getClient) {
|
|
1434
1502
|
return {
|
|
@@ -1445,11 +1513,11 @@ function createProxmoxNextVmidTool(getClient) {
|
|
|
1445
1513
|
}
|
|
1446
1514
|
|
|
1447
1515
|
// src/tools/proxmox_list_pool_resources.ts
|
|
1448
|
-
import { Type as
|
|
1449
|
-
var Schema26 =
|
|
1516
|
+
import { Type as Type27 } from "@sinclair/typebox";
|
|
1517
|
+
var Schema26 = Type27.Object(
|
|
1450
1518
|
{
|
|
1451
|
-
pool:
|
|
1452
|
-
|
|
1519
|
+
pool: Type27.Optional(
|
|
1520
|
+
Type27.String({ minLength: 1, description: "Pool ID to inspect (default mcp-smoke)." })
|
|
1453
1521
|
)
|
|
1454
1522
|
},
|
|
1455
1523
|
{ additionalProperties: false }
|
|
@@ -1477,69 +1545,70 @@ function createProxmoxListPoolResourcesTool(getClient) {
|
|
|
1477
1545
|
}
|
|
1478
1546
|
|
|
1479
1547
|
// src/tools/proxmox_create_container.ts
|
|
1480
|
-
import { Type as
|
|
1481
|
-
var Schema27 =
|
|
1548
|
+
import { Type as Type28 } from "@sinclair/typebox";
|
|
1549
|
+
var Schema27 = Type28.Object(
|
|
1482
1550
|
{
|
|
1483
|
-
vmid:
|
|
1484
|
-
hostname:
|
|
1485
|
-
ostemplate:
|
|
1551
|
+
vmid: Type28.Integer({ minimum: 1, description: "VMID for the new container." }),
|
|
1552
|
+
hostname: Type28.String({ minLength: 1, description: "Container hostname." }),
|
|
1553
|
+
ostemplate: Type28.String({
|
|
1486
1554
|
minLength: 1,
|
|
1487
1555
|
description: "OS template volid (e.g. 'local:vztmpl/ubuntu-24.04-standard_*.tar.zst')."
|
|
1488
1556
|
}),
|
|
1489
|
-
node:
|
|
1490
|
-
|
|
1557
|
+
node: Type28.Optional(
|
|
1558
|
+
Type28.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
|
|
1491
1559
|
),
|
|
1492
|
-
storage:
|
|
1493
|
-
|
|
1560
|
+
storage: Type28.Optional(
|
|
1561
|
+
Type28.String({ minLength: 1, description: "Root storage (default 'local-lvm')." })
|
|
1494
1562
|
),
|
|
1495
|
-
memory:
|
|
1496
|
-
|
|
1563
|
+
memory: Type28.Optional(
|
|
1564
|
+
Type28.Integer({ minimum: 16, description: "Memory in MiB (default 512)." })
|
|
1497
1565
|
),
|
|
1498
|
-
cores:
|
|
1499
|
-
|
|
1566
|
+
cores: Type28.Optional(
|
|
1567
|
+
Type28.Integer({ minimum: 1, description: "CPU cores (default 1)." })
|
|
1500
1568
|
),
|
|
1501
|
-
rootfs_size:
|
|
1502
|
-
|
|
1569
|
+
rootfs_size: Type28.Optional(
|
|
1570
|
+
Type28.String({ minLength: 1, description: "Root filesystem size in GB (default '8')." })
|
|
1503
1571
|
),
|
|
1504
|
-
net:
|
|
1505
|
-
|
|
1572
|
+
net: Type28.Optional(
|
|
1573
|
+
Type28.String({
|
|
1506
1574
|
minLength: 1,
|
|
1507
1575
|
description: "Network config for net0 (default 'name=eth0,bridge=vmbr0,ip=dhcp')."
|
|
1508
1576
|
})
|
|
1509
1577
|
),
|
|
1510
|
-
start:
|
|
1511
|
-
|
|
1578
|
+
start: Type28.Optional(
|
|
1579
|
+
Type28.Boolean({ description: "Start after create (default false)." })
|
|
1512
1580
|
),
|
|
1513
|
-
pool:
|
|
1514
|
-
|
|
1581
|
+
pool: Type28.Optional(
|
|
1582
|
+
Type28.String({ minLength: 1, description: "Optional resource pool ID to place the container into." })
|
|
1515
1583
|
),
|
|
1516
|
-
onboot:
|
|
1517
|
-
|
|
1584
|
+
onboot: Type28.Optional(
|
|
1585
|
+
Type28.Boolean({ description: "Start container on host boot (default false)." })
|
|
1518
1586
|
),
|
|
1519
|
-
unprivileged:
|
|
1520
|
-
|
|
1587
|
+
unprivileged: Type28.Optional(
|
|
1588
|
+
Type28.Boolean({ description: "Create an unprivileged container (default true)." })
|
|
1521
1589
|
),
|
|
1522
|
-
protection:
|
|
1523
|
-
|
|
1590
|
+
protection: Type28.Optional(
|
|
1591
|
+
Type28.Boolean({ description: "Enable Proxmox protection flag (default false)." })
|
|
1524
1592
|
),
|
|
1525
|
-
features:
|
|
1526
|
-
|
|
1593
|
+
features: Type28.Optional(
|
|
1594
|
+
Type28.String({ minLength: 1, description: "Optional LXC features string, e.g. 'nesting=1'." })
|
|
1527
1595
|
),
|
|
1528
|
-
description:
|
|
1529
|
-
|
|
1596
|
+
description: Type28.Optional(
|
|
1597
|
+
Type28.String({ description: "Optional container description." })
|
|
1530
1598
|
),
|
|
1531
|
-
tags:
|
|
1532
|
-
|
|
1599
|
+
tags: Type28.Optional(
|
|
1600
|
+
Type28.String({ minLength: 1, description: "Optional semicolon-delimited Proxmox tags." })
|
|
1533
1601
|
),
|
|
1534
|
-
password:
|
|
1535
|
-
|
|
1602
|
+
password: Type28.Optional(
|
|
1603
|
+
Type28.String({ description: "Root password (optional)." })
|
|
1536
1604
|
),
|
|
1537
|
-
ssh_public_keys:
|
|
1538
|
-
|
|
1605
|
+
ssh_public_keys: Type28.Optional(
|
|
1606
|
+
Type28.String({ description: "SSH public keys (optional)." })
|
|
1539
1607
|
),
|
|
1540
|
-
confirm:
|
|
1608
|
+
confirm: Type28.Boolean({
|
|
1541
1609
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1542
|
-
})
|
|
1610
|
+
}),
|
|
1611
|
+
...taskWaitFields
|
|
1543
1612
|
},
|
|
1544
1613
|
{ additionalProperties: false }
|
|
1545
1614
|
);
|
|
@@ -1558,7 +1627,9 @@ function createProxmoxCreateContainerTool(getClient) {
|
|
|
1558
1627
|
}
|
|
1559
1628
|
const client = getClient();
|
|
1560
1629
|
let node = args.node;
|
|
1561
|
-
if (
|
|
1630
|
+
if (node) {
|
|
1631
|
+
assertSafePathSegment(node, "node");
|
|
1632
|
+
} else {
|
|
1562
1633
|
const nodes = await client.get("/cluster/resources?type=node");
|
|
1563
1634
|
if (nodes.length === 0) throw new Error("no nodes found in cluster resources");
|
|
1564
1635
|
node = nodes[0].node;
|
|
@@ -1596,109 +1667,112 @@ function createProxmoxCreateContainerTool(getClient) {
|
|
|
1596
1667
|
body.tags = args.tags;
|
|
1597
1668
|
}
|
|
1598
1669
|
const upid = await client.post(`/nodes/${node}/lxc`, body);
|
|
1670
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1599
1671
|
return jsonToolResult({
|
|
1600
1672
|
vmid: args.vmid,
|
|
1601
1673
|
node,
|
|
1602
1674
|
hostname: args.hostname,
|
|
1603
|
-
upid
|
|
1675
|
+
upid,
|
|
1676
|
+
...task ? { task } : {}
|
|
1604
1677
|
});
|
|
1605
1678
|
}
|
|
1606
1679
|
};
|
|
1607
1680
|
}
|
|
1608
1681
|
|
|
1609
1682
|
// src/tools/proxmox_create_vm.ts
|
|
1610
|
-
import { Type as
|
|
1611
|
-
var Schema28 =
|
|
1683
|
+
import { Type as Type29 } from "@sinclair/typebox";
|
|
1684
|
+
var Schema28 = Type29.Object(
|
|
1612
1685
|
{
|
|
1613
|
-
vmid:
|
|
1614
|
-
name:
|
|
1615
|
-
node:
|
|
1616
|
-
|
|
1686
|
+
vmid: Type29.Integer({ minimum: 1, description: "VMID for the new VM." }),
|
|
1687
|
+
name: Type29.String({ minLength: 1, description: "VM display name." }),
|
|
1688
|
+
node: Type29.Optional(
|
|
1689
|
+
Type29.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
|
|
1617
1690
|
),
|
|
1618
|
-
memory:
|
|
1619
|
-
|
|
1691
|
+
memory: Type29.Optional(
|
|
1692
|
+
Type29.Integer({ minimum: 16, description: "Memory in MiB (default 2048)." })
|
|
1620
1693
|
),
|
|
1621
|
-
cores:
|
|
1622
|
-
|
|
1694
|
+
cores: Type29.Optional(
|
|
1695
|
+
Type29.Integer({ minimum: 1, description: "CPU cores (default 2)." })
|
|
1623
1696
|
),
|
|
1624
|
-
iso:
|
|
1625
|
-
|
|
1697
|
+
iso: Type29.Optional(
|
|
1698
|
+
Type29.String({
|
|
1626
1699
|
minLength: 1,
|
|
1627
1700
|
description: "ISO volid for install media (e.g. 'local:iso/ubuntu-24.04.iso'). If set, attaches as ide2 cdrom."
|
|
1628
1701
|
})
|
|
1629
1702
|
),
|
|
1630
|
-
disk_size:
|
|
1631
|
-
|
|
1703
|
+
disk_size: Type29.Optional(
|
|
1704
|
+
Type29.String({ minLength: 1, description: "Primary disk size in GB on scsi0 (default '32')." })
|
|
1632
1705
|
),
|
|
1633
|
-
storage:
|
|
1634
|
-
|
|
1706
|
+
storage: Type29.Optional(
|
|
1707
|
+
Type29.String({ minLength: 1, description: "Disk storage (default 'local-lvm')." })
|
|
1635
1708
|
),
|
|
1636
|
-
net:
|
|
1637
|
-
|
|
1709
|
+
net: Type29.Optional(
|
|
1710
|
+
Type29.String({
|
|
1638
1711
|
minLength: 1,
|
|
1639
1712
|
description: "Network config for net0 (default 'model=virtio,bridge=vmbr0')."
|
|
1640
1713
|
})
|
|
1641
1714
|
),
|
|
1642
|
-
start:
|
|
1643
|
-
|
|
1715
|
+
start: Type29.Optional(
|
|
1716
|
+
Type29.Boolean({ description: "Start after create (default false)." })
|
|
1644
1717
|
),
|
|
1645
|
-
pool:
|
|
1646
|
-
|
|
1718
|
+
pool: Type29.Optional(
|
|
1719
|
+
Type29.String({ minLength: 1, description: "Optional resource pool ID to place the VM into." })
|
|
1647
1720
|
),
|
|
1648
|
-
onboot:
|
|
1649
|
-
|
|
1721
|
+
onboot: Type29.Optional(
|
|
1722
|
+
Type29.Boolean({ description: "Start VM on host boot (default false)." })
|
|
1650
1723
|
),
|
|
1651
|
-
protection:
|
|
1652
|
-
|
|
1724
|
+
protection: Type29.Optional(
|
|
1725
|
+
Type29.Boolean({ description: "Enable Proxmox protection flag (default false)." })
|
|
1653
1726
|
),
|
|
1654
|
-
agent:
|
|
1655
|
-
|
|
1727
|
+
agent: Type29.Optional(
|
|
1728
|
+
Type29.Boolean({ description: "Enable QEMU guest agent in VM config (default false)." })
|
|
1656
1729
|
),
|
|
1657
|
-
scsihw:
|
|
1658
|
-
|
|
1730
|
+
scsihw: Type29.Optional(
|
|
1731
|
+
Type29.String({ minLength: 1, description: "Optional SCSI controller, e.g. 'virtio-scsi-pci'." })
|
|
1659
1732
|
),
|
|
1660
|
-
boot:
|
|
1661
|
-
|
|
1733
|
+
boot: Type29.Optional(
|
|
1734
|
+
Type29.String({ minLength: 1, description: "Optional boot order string." })
|
|
1662
1735
|
),
|
|
1663
|
-
bios:
|
|
1664
|
-
|
|
1736
|
+
bios: Type29.Optional(
|
|
1737
|
+
Type29.Union([Type29.Literal("seabios"), Type29.Literal("ovmf")], { description: "Optional VM BIOS type." })
|
|
1665
1738
|
),
|
|
1666
|
-
machine:
|
|
1667
|
-
|
|
1739
|
+
machine: Type29.Optional(
|
|
1740
|
+
Type29.String({ minLength: 1, description: "Optional machine type." })
|
|
1668
1741
|
),
|
|
1669
|
-
cpu:
|
|
1670
|
-
|
|
1742
|
+
cpu: Type29.Optional(
|
|
1743
|
+
Type29.String({ minLength: 1, description: "Optional CPU type." })
|
|
1671
1744
|
),
|
|
1672
|
-
sockets:
|
|
1673
|
-
|
|
1745
|
+
sockets: Type29.Optional(
|
|
1746
|
+
Type29.Integer({ minimum: 1, description: "Optional socket count." })
|
|
1674
1747
|
),
|
|
1675
|
-
description:
|
|
1676
|
-
|
|
1748
|
+
description: Type29.Optional(
|
|
1749
|
+
Type29.String({ description: "Optional VM description." })
|
|
1677
1750
|
),
|
|
1678
|
-
tags:
|
|
1679
|
-
|
|
1751
|
+
tags: Type29.Optional(
|
|
1752
|
+
Type29.String({ minLength: 1, description: "Optional semicolon-delimited Proxmox tags." })
|
|
1680
1753
|
),
|
|
1681
|
-
ciuser:
|
|
1682
|
-
|
|
1754
|
+
ciuser: Type29.Optional(
|
|
1755
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init username." })
|
|
1683
1756
|
),
|
|
1684
|
-
cipassword:
|
|
1685
|
-
|
|
1757
|
+
cipassword: Type29.Optional(
|
|
1758
|
+
Type29.String({ description: "Optional cloud-init password." })
|
|
1686
1759
|
),
|
|
1687
|
-
sshkeys:
|
|
1688
|
-
|
|
1760
|
+
sshkeys: Type29.Optional(
|
|
1761
|
+
Type29.String({ description: "Optional cloud-init SSH public keys." })
|
|
1689
1762
|
),
|
|
1690
|
-
ipconfig0:
|
|
1691
|
-
|
|
1763
|
+
ipconfig0: Type29.Optional(
|
|
1764
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init ipconfig0, e.g. 'ip=dhcp'." })
|
|
1692
1765
|
),
|
|
1693
|
-
nameserver:
|
|
1694
|
-
|
|
1766
|
+
nameserver: Type29.Optional(
|
|
1767
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init DNS server list." })
|
|
1695
1768
|
),
|
|
1696
|
-
searchdomain:
|
|
1697
|
-
|
|
1769
|
+
searchdomain: Type29.Optional(
|
|
1770
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init DNS search domain." })
|
|
1698
1771
|
),
|
|
1699
|
-
confirm:
|
|
1772
|
+
confirm: Type29.Boolean({
|
|
1700
1773
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1701
|
-
})
|
|
1774
|
+
}),
|
|
1775
|
+
...taskWaitFields
|
|
1702
1776
|
},
|
|
1703
1777
|
{ additionalProperties: false }
|
|
1704
1778
|
);
|
|
@@ -1717,7 +1791,9 @@ function createProxmoxCreateVmTool(getClient) {
|
|
|
1717
1791
|
}
|
|
1718
1792
|
const client = getClient();
|
|
1719
1793
|
let node = args.node;
|
|
1720
|
-
if (
|
|
1794
|
+
if (node) {
|
|
1795
|
+
assertSafePathSegment(node, "node");
|
|
1796
|
+
} else {
|
|
1721
1797
|
const nodes = await client.get("/cluster/resources?type=node");
|
|
1722
1798
|
if (nodes.length === 0) throw new Error("no nodes found in cluster resources");
|
|
1723
1799
|
node = nodes[0].node;
|
|
@@ -1745,44 +1821,47 @@ function createProxmoxCreateVmTool(getClient) {
|
|
|
1745
1821
|
}
|
|
1746
1822
|
if (typeof args.sockets === "number") body.sockets = args.sockets;
|
|
1747
1823
|
const upid = await client.post(`/nodes/${node}/qemu`, body);
|
|
1824
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1748
1825
|
return jsonToolResult({
|
|
1749
1826
|
vmid: args.vmid,
|
|
1750
1827
|
node,
|
|
1751
1828
|
name: args.name,
|
|
1752
|
-
upid
|
|
1829
|
+
upid,
|
|
1830
|
+
...task ? { task } : {}
|
|
1753
1831
|
});
|
|
1754
1832
|
}
|
|
1755
1833
|
};
|
|
1756
1834
|
}
|
|
1757
1835
|
|
|
1758
1836
|
// src/tools/proxmox_clone_resource.ts
|
|
1759
|
-
import { Type as
|
|
1760
|
-
var Schema29 =
|
|
1837
|
+
import { Type as Type30 } from "@sinclair/typebox";
|
|
1838
|
+
var Schema29 = Type30.Object(
|
|
1761
1839
|
{
|
|
1762
|
-
source_vmid:
|
|
1763
|
-
new_vmid:
|
|
1764
|
-
name:
|
|
1765
|
-
full:
|
|
1766
|
-
|
|
1840
|
+
source_vmid: Type30.Integer({ minimum: 1, description: "Source CT/VM ID to clone from." }),
|
|
1841
|
+
new_vmid: Type30.Integer({ minimum: 1, description: "VMID for the cloned resource." }),
|
|
1842
|
+
name: Type30.String({ minLength: 1, description: "Name/hostname for the new clone." }),
|
|
1843
|
+
full: Type30.Optional(
|
|
1844
|
+
Type30.Boolean({ description: "Full clone (default true). Set false for a linked clone." })
|
|
1767
1845
|
),
|
|
1768
|
-
storage:
|
|
1769
|
-
|
|
1846
|
+
storage: Type30.Optional(
|
|
1847
|
+
Type30.String({ minLength: 1, description: "Target storage (default: same as source)." })
|
|
1770
1848
|
),
|
|
1771
|
-
target_node:
|
|
1772
|
-
|
|
1849
|
+
target_node: Type30.Optional(
|
|
1850
|
+
Type30.String({ minLength: 1, description: "Optional target node for the clone." })
|
|
1773
1851
|
),
|
|
1774
|
-
pool:
|
|
1775
|
-
|
|
1852
|
+
pool: Type30.Optional(
|
|
1853
|
+
Type30.String({ minLength: 1, description: "Optional resource pool ID for the clone." })
|
|
1776
1854
|
),
|
|
1777
|
-
snapname:
|
|
1778
|
-
|
|
1855
|
+
snapname: Type30.Optional(
|
|
1856
|
+
Type30.String({ minLength: 1, description: "Clone from a named snapshot (optional)." })
|
|
1779
1857
|
),
|
|
1780
|
-
description:
|
|
1781
|
-
|
|
1858
|
+
description: Type30.Optional(
|
|
1859
|
+
Type30.String({ description: "Optional description for the clone." })
|
|
1782
1860
|
),
|
|
1783
|
-
confirm:
|
|
1861
|
+
confirm: Type30.Boolean({
|
|
1784
1862
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1785
|
-
})
|
|
1863
|
+
}),
|
|
1864
|
+
...taskWaitFields
|
|
1786
1865
|
},
|
|
1787
1866
|
{ additionalProperties: false }
|
|
1788
1867
|
);
|
|
@@ -1822,39 +1901,42 @@ function createProxmoxCloneResourceTool(getClient) {
|
|
|
1822
1901
|
`/nodes/${node}/${type}/${args.source_vmid}/clone`,
|
|
1823
1902
|
body
|
|
1824
1903
|
);
|
|
1904
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1825
1905
|
return jsonToolResult({
|
|
1826
1906
|
source_vmid: args.source_vmid,
|
|
1827
1907
|
new_vmid: args.new_vmid,
|
|
1828
1908
|
node,
|
|
1829
1909
|
type,
|
|
1830
1910
|
name: args.name,
|
|
1831
|
-
upid
|
|
1911
|
+
upid,
|
|
1912
|
+
...task ? { task } : {}
|
|
1832
1913
|
});
|
|
1833
1914
|
}
|
|
1834
1915
|
};
|
|
1835
1916
|
}
|
|
1836
1917
|
|
|
1837
1918
|
// src/tools/proxmox_destroy_resource.ts
|
|
1838
|
-
import { Type as
|
|
1839
|
-
var Schema30 =
|
|
1919
|
+
import { Type as Type31 } from "@sinclair/typebox";
|
|
1920
|
+
var Schema30 = Type31.Object(
|
|
1840
1921
|
{
|
|
1841
|
-
vmid:
|
|
1842
|
-
purge:
|
|
1843
|
-
|
|
1922
|
+
vmid: Type31.Integer({ minimum: 1, description: "Container or VM ID to destroy." }),
|
|
1923
|
+
purge: Type31.Optional(
|
|
1924
|
+
Type31.Boolean({
|
|
1844
1925
|
description: "Remove from PVE backup/replication config too (default true)."
|
|
1845
1926
|
})
|
|
1846
1927
|
),
|
|
1847
|
-
force:
|
|
1848
|
-
|
|
1928
|
+
force: Type31.Optional(
|
|
1929
|
+
Type31.Boolean({
|
|
1849
1930
|
description: "Allow destroying a running VM (default false)."
|
|
1850
1931
|
})
|
|
1851
1932
|
),
|
|
1852
|
-
confirm:
|
|
1933
|
+
confirm: Type31.Boolean({
|
|
1853
1934
|
description: "Must be true. Tier-3 destructive gate."
|
|
1854
1935
|
}),
|
|
1855
|
-
destructive:
|
|
1936
|
+
destructive: Type31.Boolean({
|
|
1856
1937
|
description: "Must be true. Tier-3 destructive gate."
|
|
1857
|
-
})
|
|
1938
|
+
}),
|
|
1939
|
+
...taskWaitFields
|
|
1858
1940
|
},
|
|
1859
1941
|
{ additionalProperties: false }
|
|
1860
1942
|
);
|
|
@@ -1882,46 +1964,47 @@ function createProxmoxDestroyResourceTool(getClient) {
|
|
|
1882
1964
|
const qs = params.toString();
|
|
1883
1965
|
const path2 = qs.length > 0 ? `/nodes/${node}/${type}/${args.vmid}?${qs}` : `/nodes/${node}/${type}/${args.vmid}`;
|
|
1884
1966
|
const upid = await client.delete(path2);
|
|
1885
|
-
|
|
1967
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1968
|
+
return jsonToolResult({ vmid: args.vmid, node, type, upid, ...task ? { task } : {} });
|
|
1886
1969
|
}
|
|
1887
1970
|
};
|
|
1888
1971
|
}
|
|
1889
1972
|
|
|
1890
1973
|
// src/tools/proxmox_cleanup_smoke_resources.ts
|
|
1891
|
-
import { Type as
|
|
1892
|
-
var Schema31 =
|
|
1974
|
+
import { Type as Type32 } from "@sinclair/typebox";
|
|
1975
|
+
var Schema31 = Type32.Object(
|
|
1893
1976
|
{
|
|
1894
|
-
pool:
|
|
1895
|
-
|
|
1977
|
+
pool: Type32.Optional(
|
|
1978
|
+
Type32.String({ minLength: 1, description: "Pool ID to clean up (default mcp-smoke)." })
|
|
1896
1979
|
),
|
|
1897
|
-
name_prefix:
|
|
1898
|
-
|
|
1980
|
+
name_prefix: Type32.Optional(
|
|
1981
|
+
Type32.String({
|
|
1899
1982
|
minLength: 1,
|
|
1900
1983
|
description: "Only delete guest names starting with this prefix (default mcp-smoke-)."
|
|
1901
1984
|
})
|
|
1902
1985
|
),
|
|
1903
|
-
force:
|
|
1904
|
-
|
|
1986
|
+
force: Type32.Optional(
|
|
1987
|
+
Type32.Boolean({
|
|
1905
1988
|
description: "Allow deleting running smoke guests. Also passes force=1 for LXC cleanup (default false)."
|
|
1906
1989
|
})
|
|
1907
1990
|
),
|
|
1908
|
-
dry_run:
|
|
1909
|
-
|
|
1991
|
+
dry_run: Type32.Optional(
|
|
1992
|
+
Type32.Boolean({ description: "Preview matching targets without deleting them (default true)." })
|
|
1910
1993
|
),
|
|
1911
|
-
wait:
|
|
1912
|
-
|
|
1994
|
+
wait: Type32.Optional(
|
|
1995
|
+
Type32.Boolean({ description: "Wait for delete tasks to finish when dry_run:false (default true)." })
|
|
1913
1996
|
),
|
|
1914
|
-
confirm:
|
|
1915
|
-
|
|
1997
|
+
confirm: Type32.Optional(
|
|
1998
|
+
Type32.Boolean({ description: "Must be true when dry_run:false. Tier-3 destructive gate." })
|
|
1916
1999
|
),
|
|
1917
|
-
destructive:
|
|
1918
|
-
|
|
2000
|
+
destructive: Type32.Optional(
|
|
2001
|
+
Type32.Boolean({ description: "Must be true when dry_run:false. Tier-3 destructive gate." })
|
|
1919
2002
|
),
|
|
1920
|
-
timeoutSeconds:
|
|
1921
|
-
|
|
2003
|
+
timeoutSeconds: Type32.Optional(
|
|
2004
|
+
Type32.Integer({ minimum: 1, maximum: 3600, description: "Max seconds to wait per delete task (default 180)." })
|
|
1922
2005
|
),
|
|
1923
|
-
intervalMs:
|
|
1924
|
-
|
|
2006
|
+
intervalMs: Type32.Optional(
|
|
2007
|
+
Type32.Integer({ minimum: 100, maximum: 1e4, description: "Task polling interval in milliseconds (default 1000)." })
|
|
1925
2008
|
)
|
|
1926
2009
|
},
|
|
1927
2010
|
{ additionalProperties: false }
|
|
@@ -2021,18 +2104,18 @@ function createProxmoxCleanupSmokeResourcesTool(getClient) {
|
|
|
2021
2104
|
}
|
|
2022
2105
|
|
|
2023
2106
|
// src/tools/proxmox_delete_snapshot.ts
|
|
2024
|
-
import { Type as
|
|
2025
|
-
var Schema32 =
|
|
2107
|
+
import { Type as Type33 } from "@sinclair/typebox";
|
|
2108
|
+
var Schema32 = Type33.Object(
|
|
2026
2109
|
{
|
|
2027
|
-
vmid:
|
|
2028
|
-
snapname:
|
|
2110
|
+
vmid: Type33.Integer({ minimum: 1, description: "Container or VM ID." }),
|
|
2111
|
+
snapname: Type33.String({
|
|
2029
2112
|
minLength: 1,
|
|
2030
2113
|
description: "Snapshot name to delete."
|
|
2031
2114
|
}),
|
|
2032
|
-
confirm:
|
|
2115
|
+
confirm: Type33.Boolean({
|
|
2033
2116
|
description: "Must be true. Tier-3 destructive gate."
|
|
2034
2117
|
}),
|
|
2035
|
-
destructive:
|
|
2118
|
+
destructive: Type33.Boolean({
|
|
2036
2119
|
description: "Must be true. Tier-3 destructive gate."
|
|
2037
2120
|
})
|
|
2038
2121
|
},
|
|
@@ -2064,14 +2147,14 @@ function createProxmoxDeleteSnapshotTool(getClient) {
|
|
|
2064
2147
|
}
|
|
2065
2148
|
|
|
2066
2149
|
// src/tools/proxmox_force_stop_resource.ts
|
|
2067
|
-
import { Type as
|
|
2068
|
-
var Schema33 =
|
|
2150
|
+
import { Type as Type34 } from "@sinclair/typebox";
|
|
2151
|
+
var Schema33 = Type34.Object(
|
|
2069
2152
|
{
|
|
2070
|
-
vmid:
|
|
2071
|
-
confirm:
|
|
2153
|
+
vmid: Type34.Integer({ minimum: 1, description: "Container or VM ID to hard-stop." }),
|
|
2154
|
+
confirm: Type34.Boolean({
|
|
2072
2155
|
description: "Must be true. Tier-3 destructive gate."
|
|
2073
2156
|
}),
|
|
2074
|
-
destructive:
|
|
2157
|
+
destructive: Type34.Boolean({
|
|
2075
2158
|
description: "Must be true. Tier-3 destructive gate."
|
|
2076
2159
|
})
|
|
2077
2160
|
},
|
|
@@ -2100,7 +2183,41 @@ function createProxmoxForceStopResourceTool(getClient) {
|
|
|
2100
2183
|
}
|
|
2101
2184
|
|
|
2102
2185
|
// src/tools/proxmox_exec.ts
|
|
2103
|
-
import { Type as
|
|
2186
|
+
import { Type as Type35 } from "@sinclair/typebox";
|
|
2187
|
+
|
|
2188
|
+
// src/guest-agent.ts
|
|
2189
|
+
var GuestAgentError = class extends Error {
|
|
2190
|
+
constructor(message) {
|
|
2191
|
+
super(`guest-agent: ${message}`);
|
|
2192
|
+
this.name = "GuestAgentError";
|
|
2193
|
+
}
|
|
2194
|
+
};
|
|
2195
|
+
function sleep4(ms) {
|
|
2196
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2197
|
+
}
|
|
2198
|
+
async function execViaGuestAgent(client, node, vmid, command, timeoutMs, stdin, pollIntervalMs = 500) {
|
|
2199
|
+
const base = `/nodes/${node}/qemu/${vmid}/agent`;
|
|
2200
|
+
const body = { command: ["/bin/sh", "-c", command] };
|
|
2201
|
+
if (stdin !== void 0) body["input-data"] = stdin;
|
|
2202
|
+
const started = await client.post(`${base}/exec`, body);
|
|
2203
|
+
const pid = started?.pid;
|
|
2204
|
+
if (typeof pid !== "number") {
|
|
2205
|
+
throw new GuestAgentError(`agent/exec did not return a pid for vmid ${vmid}`);
|
|
2206
|
+
}
|
|
2207
|
+
const deadline = Date.now() + timeoutMs;
|
|
2208
|
+
while (Date.now() <= deadline) {
|
|
2209
|
+
const status = await client.get(`${base}/exec-status?pid=${pid}`);
|
|
2210
|
+
if (status.exited === 1 || status.exited === true) {
|
|
2211
|
+
return {
|
|
2212
|
+
stdout: status["out-data"] ?? "",
|
|
2213
|
+
stderr: status["err-data"] ?? "",
|
|
2214
|
+
exitCode: typeof status.exitcode === "number" ? status.exitcode : -1
|
|
2215
|
+
};
|
|
2216
|
+
}
|
|
2217
|
+
await sleep4(Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
|
|
2218
|
+
}
|
|
2219
|
+
throw new GuestAgentError(`command in vmid ${vmid} did not finish within ${timeoutMs}ms`);
|
|
2220
|
+
}
|
|
2104
2221
|
|
|
2105
2222
|
// src/tools/ssh-target.ts
|
|
2106
2223
|
function nonEmptyEnv(key) {
|
|
@@ -2148,15 +2265,44 @@ function missingQemuSshHostMessage(vmid) {
|
|
|
2148
2265
|
return `vmid ${vmid} is QEMU and has no PROXMOX_VM_${vmid}_SSH_HOST set and guest agent did not return a usable IP. Install qemu-guest-agent in the VM and enable it with 'qm set ${vmid} --agent 1', or pin the IP via env.`;
|
|
2149
2266
|
}
|
|
2150
2267
|
|
|
2268
|
+
// src/tools/guest-command.ts
|
|
2269
|
+
function resolveExecBackend() {
|
|
2270
|
+
const v = (process.env.PROXMOX_EXEC_BACKEND ?? "ssh").toLowerCase();
|
|
2271
|
+
return v === "guest-agent" || v === "agent" ? "guest-agent" : "ssh";
|
|
2272
|
+
}
|
|
2273
|
+
async function execInQemuGuest(client, ssh, node, vmid, command, timeoutMs, vmDefaults, stdin) {
|
|
2274
|
+
if (resolveExecBackend() === "guest-agent") {
|
|
2275
|
+
return execViaGuestAgent(client, node, vmid, command, timeoutMs, stdin);
|
|
2276
|
+
}
|
|
2277
|
+
const host = await resolveQemuSshHost(client, node, vmid);
|
|
2278
|
+
if (!host) throw new Error(missingQemuSshHostMessage(vmid));
|
|
2279
|
+
return ssh.execViaDirectSsh(qemuSshTarget(vmid, host, vmDefaults), command, timeoutMs, stdin);
|
|
2280
|
+
}
|
|
2281
|
+
function shellSingleQuote(s) {
|
|
2282
|
+
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2283
|
+
}
|
|
2284
|
+
function assertAbsoluteGuestPath(path2, toolName) {
|
|
2285
|
+
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2286
|
+
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2287
|
+
}
|
|
2288
|
+
async function runGuestCommand(client, ssh, vmDefaults, vmid, command, timeoutMs, stdin) {
|
|
2289
|
+
const { node, type } = await resolveResource(client, vmid);
|
|
2290
|
+
if (type === "lxc") {
|
|
2291
|
+
return { node, type, result: await ssh.execInLxc(vmid, command, timeoutMs, stdin) };
|
|
2292
|
+
}
|
|
2293
|
+
const result = await execInQemuGuest(client, ssh, node, vmid, command, timeoutMs, vmDefaults, stdin);
|
|
2294
|
+
return { node, type, result };
|
|
2295
|
+
}
|
|
2296
|
+
|
|
2151
2297
|
// src/tools/proxmox_exec.ts
|
|
2152
|
-
var Schema34 =
|
|
2298
|
+
var Schema34 = Type35.Object(
|
|
2153
2299
|
{
|
|
2154
|
-
vmid:
|
|
2155
|
-
command:
|
|
2156
|
-
timeout:
|
|
2157
|
-
|
|
2300
|
+
vmid: Type35.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2301
|
+
command: Type35.String({ minLength: 1, description: "Shell command to run inside the resource." }),
|
|
2302
|
+
timeout: Type35.Optional(
|
|
2303
|
+
Type35.Integer({ minimum: 1, maximum: 3600, description: "Timeout in seconds (default 30)." })
|
|
2158
2304
|
),
|
|
2159
|
-
confirm:
|
|
2305
|
+
confirm: Type35.Boolean({ description: "Must be true to execute. Tier-2 safe-write gate." })
|
|
2160
2306
|
},
|
|
2161
2307
|
{ additionalProperties: false }
|
|
2162
2308
|
);
|
|
@@ -2165,7 +2311,7 @@ function createProxmoxExecTool(getClient, getSsh, vmDefaults) {
|
|
|
2165
2311
|
return {
|
|
2166
2312
|
name: NAME31,
|
|
2167
2313
|
label: "proxmox: exec in container or VM",
|
|
2168
|
-
description: "Run a shell command inside an LXC container (via SSH+pct exec) or QEMU VM (via direct SSH,
|
|
2314
|
+
description: "Run a shell command inside an LXC container (via SSH+pct exec) or QEMU VM (via direct SSH by default, or the qemu-guest-agent API when PROXMOX_EXEC_BACKEND=guest-agent - no in-guest SSH key needed). Returns stdout/stderr/exit_code. Tier-2 write; requires confirm:true.",
|
|
2169
2315
|
parameters: Schema34,
|
|
2170
2316
|
execute: async (_id, raw) => {
|
|
2171
2317
|
assertConfirmedWrite(raw, NAME31);
|
|
@@ -2184,12 +2330,7 @@ function createProxmoxExecTool(getClient, getSsh, vmDefaults) {
|
|
|
2184
2330
|
exit_code: result2.exitCode
|
|
2185
2331
|
});
|
|
2186
2332
|
}
|
|
2187
|
-
const
|
|
2188
|
-
if (!host) {
|
|
2189
|
-
throw new Error(missingQemuSshHostMessage(args.vmid));
|
|
2190
|
-
}
|
|
2191
|
-
const target = qemuSshTarget(args.vmid, host, vmDefaults);
|
|
2192
|
-
const result = await ssh.execViaDirectSsh(target, args.command, timeoutMs);
|
|
2333
|
+
const result = await execInQemuGuest(client, ssh, node, args.vmid, args.command, timeoutMs, vmDefaults);
|
|
2193
2334
|
return jsonToolResult({
|
|
2194
2335
|
vmid: args.vmid,
|
|
2195
2336
|
type,
|
|
@@ -2202,20 +2343,20 @@ function createProxmoxExecTool(getClient, getSsh, vmDefaults) {
|
|
|
2202
2343
|
}
|
|
2203
2344
|
|
|
2204
2345
|
// src/tools/proxmox_read_file.ts
|
|
2205
|
-
import { Type as
|
|
2206
|
-
var Schema35 =
|
|
2346
|
+
import { Type as Type36 } from "@sinclair/typebox";
|
|
2347
|
+
var Schema35 = Type36.Object(
|
|
2207
2348
|
{
|
|
2208
|
-
vmid:
|
|
2209
|
-
path:
|
|
2210
|
-
confirm:
|
|
2349
|
+
vmid: Type36.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2350
|
+
path: Type36.String({ minLength: 1, description: "Absolute file path inside the resource." }),
|
|
2351
|
+
confirm: Type36.Boolean({ description: "Must be true to read files from inside a guest." })
|
|
2211
2352
|
},
|
|
2212
2353
|
{ additionalProperties: false }
|
|
2213
2354
|
);
|
|
2214
2355
|
var NAME32 = "proxmox_read_file";
|
|
2215
|
-
function
|
|
2356
|
+
function shellSingleQuote2(s) {
|
|
2216
2357
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2217
2358
|
}
|
|
2218
|
-
function
|
|
2359
|
+
function assertAbsoluteGuestPath2(path2, toolName) {
|
|
2219
2360
|
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2220
2361
|
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2221
2362
|
}
|
|
@@ -2228,21 +2369,17 @@ function createProxmoxReadFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2228
2369
|
execute: async (_id, raw) => {
|
|
2229
2370
|
assertConfirmedWrite(raw, NAME32);
|
|
2230
2371
|
const args = validateToolArgs(Schema35, raw, NAME32);
|
|
2231
|
-
|
|
2372
|
+
assertAbsoluteGuestPath2(args.path, NAME32);
|
|
2232
2373
|
const client = getClient();
|
|
2233
2374
|
const { node, type } = await resolveResource(client, args.vmid);
|
|
2234
|
-
const command = `cat -- ${
|
|
2375
|
+
const command = `cat -- ${shellSingleQuote2(args.path)}`;
|
|
2235
2376
|
const ssh = getSsh();
|
|
2236
2377
|
const timeoutMs = 3e4;
|
|
2237
2378
|
let result;
|
|
2238
2379
|
if (type === "lxc") {
|
|
2239
2380
|
result = await ssh.execInLxc(args.vmid, command, timeoutMs);
|
|
2240
2381
|
} else {
|
|
2241
|
-
|
|
2242
|
-
if (!host) {
|
|
2243
|
-
throw new Error(missingQemuSshHostMessage(args.vmid));
|
|
2244
|
-
}
|
|
2245
|
-
result = await ssh.execViaDirectSsh(qemuSshTarget(args.vmid, host, vmDefaults), command, timeoutMs);
|
|
2382
|
+
result = await execInQemuGuest(client, ssh, node, args.vmid, command, timeoutMs, vmDefaults);
|
|
2246
2383
|
}
|
|
2247
2384
|
if (result.exitCode !== 0) {
|
|
2248
2385
|
throw new Error(result.stderr.trim() || `read_file failed with exit code ${result.exitCode}`);
|
|
@@ -2253,22 +2390,22 @@ function createProxmoxReadFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2253
2390
|
}
|
|
2254
2391
|
|
|
2255
2392
|
// src/tools/proxmox_write_file.ts
|
|
2256
|
-
import { Type as
|
|
2393
|
+
import { Type as Type37 } from "@sinclair/typebox";
|
|
2257
2394
|
import path from "path";
|
|
2258
|
-
var Schema36 =
|
|
2395
|
+
var Schema36 = Type37.Object(
|
|
2259
2396
|
{
|
|
2260
|
-
vmid:
|
|
2261
|
-
path:
|
|
2262
|
-
content:
|
|
2263
|
-
confirm:
|
|
2397
|
+
vmid: Type37.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2398
|
+
path: Type37.String({ minLength: 1, description: "Absolute destination path inside the resource." }),
|
|
2399
|
+
content: Type37.String({ description: "Text content to write." }),
|
|
2400
|
+
confirm: Type37.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
2264
2401
|
},
|
|
2265
2402
|
{ additionalProperties: false }
|
|
2266
2403
|
);
|
|
2267
2404
|
var NAME33 = "proxmox_write_file";
|
|
2268
|
-
function
|
|
2405
|
+
function shellSingleQuote3(s) {
|
|
2269
2406
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2270
2407
|
}
|
|
2271
|
-
function
|
|
2408
|
+
function assertAbsoluteGuestPath3(path2, toolName) {
|
|
2272
2409
|
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2273
2410
|
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2274
2411
|
}
|
|
@@ -2281,23 +2418,19 @@ function createProxmoxWriteFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2281
2418
|
execute: async (_id, raw) => {
|
|
2282
2419
|
assertConfirmedWrite(raw, NAME33);
|
|
2283
2420
|
const args = validateToolArgs(Schema36, raw, NAME33);
|
|
2284
|
-
|
|
2421
|
+
assertAbsoluteGuestPath3(args.path, NAME33);
|
|
2285
2422
|
const client = getClient();
|
|
2286
2423
|
const { node, type } = await resolveResource(client, args.vmid);
|
|
2287
2424
|
const ssh = getSsh();
|
|
2288
2425
|
const timeoutMs = 3e4;
|
|
2289
2426
|
const parent = path.posix.dirname(args.path);
|
|
2290
|
-
const mkdirCmd = `mkdir -p -- ${
|
|
2291
|
-
const writeCmd = `cat > ${
|
|
2427
|
+
const mkdirCmd = `mkdir -p -- ${shellSingleQuote3(parent)}`;
|
|
2428
|
+
const writeCmd = `cat > ${shellSingleQuote3(args.path)}`;
|
|
2292
2429
|
const runOne = async (command, stdin) => {
|
|
2293
2430
|
if (type === "lxc") {
|
|
2294
2431
|
return ssh.execInLxc(args.vmid, command, timeoutMs, stdin);
|
|
2295
2432
|
}
|
|
2296
|
-
|
|
2297
|
-
if (!host) {
|
|
2298
|
-
throw new Error(missingQemuSshHostMessage(args.vmid));
|
|
2299
|
-
}
|
|
2300
|
-
return ssh.execViaDirectSsh(qemuSshTarget(args.vmid, host, vmDefaults), command, timeoutMs, stdin);
|
|
2433
|
+
return execInQemuGuest(client, ssh, node, args.vmid, command, timeoutMs, vmDefaults, stdin);
|
|
2301
2434
|
};
|
|
2302
2435
|
const mkdirResult = await runOne(mkdirCmd);
|
|
2303
2436
|
if (mkdirResult.exitCode !== 0) {
|
|
@@ -2317,33 +2450,12 @@ function createProxmoxWriteFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2317
2450
|
}
|
|
2318
2451
|
|
|
2319
2452
|
// src/tools/proxmox_stat_path.ts
|
|
2320
|
-
import { Type as
|
|
2321
|
-
|
|
2322
|
-
// src/tools/guest-command.ts
|
|
2323
|
-
function shellSingleQuote3(s) {
|
|
2324
|
-
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2325
|
-
}
|
|
2326
|
-
function assertAbsoluteGuestPath3(path2, toolName) {
|
|
2327
|
-
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2328
|
-
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2329
|
-
}
|
|
2330
|
-
async function runGuestCommand(client, ssh, vmDefaults, vmid, command, timeoutMs, stdin) {
|
|
2331
|
-
const { node, type } = await resolveResource(client, vmid);
|
|
2332
|
-
if (type === "lxc") {
|
|
2333
|
-
return { node, type, result: await ssh.execInLxc(vmid, command, timeoutMs, stdin) };
|
|
2334
|
-
}
|
|
2335
|
-
const host = await resolveQemuSshHost(client, node, vmid);
|
|
2336
|
-
if (!host) throw new Error(missingQemuSshHostMessage(vmid));
|
|
2337
|
-
const target = qemuSshTarget(vmid, host, vmDefaults);
|
|
2338
|
-
return { node, type, result: await ssh.execViaDirectSsh(target, command, timeoutMs, stdin) };
|
|
2339
|
-
}
|
|
2340
|
-
|
|
2341
|
-
// src/tools/proxmox_stat_path.ts
|
|
2342
|
-
var Schema37 = Type37.Object(
|
|
2453
|
+
import { Type as Type38 } from "@sinclair/typebox";
|
|
2454
|
+
var Schema37 = Type38.Object(
|
|
2343
2455
|
{
|
|
2344
|
-
vmid:
|
|
2345
|
-
path:
|
|
2346
|
-
confirm:
|
|
2456
|
+
vmid: Type38.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2457
|
+
path: Type38.String({ minLength: 1, description: "Absolute path inside the guest." }),
|
|
2458
|
+
confirm: Type38.Boolean({ description: "Must be true to inspect guest filesystem metadata." })
|
|
2347
2459
|
},
|
|
2348
2460
|
{ additionalProperties: false }
|
|
2349
2461
|
);
|
|
@@ -2374,8 +2486,8 @@ function createProxmoxStatPathTool(getClient, getSsh, vmDefaults) {
|
|
|
2374
2486
|
execute: async (_id, raw) => {
|
|
2375
2487
|
assertConfirmedWrite(raw, NAME34);
|
|
2376
2488
|
const args = validateToolArgs(Schema37, raw, NAME34);
|
|
2377
|
-
|
|
2378
|
-
const command = `stat -Lc '%F\\0%s\\0%U\\0%G\\0%a\\0%Y\\0%n\\0' -- ${
|
|
2489
|
+
assertAbsoluteGuestPath(args.path, NAME34);
|
|
2490
|
+
const command = `stat -Lc '%F\\0%s\\0%U\\0%G\\0%a\\0%Y\\0%n\\0' -- ${shellSingleQuote(args.path)}`;
|
|
2379
2491
|
const { node, type, result } = await runGuestCommand(
|
|
2380
2492
|
getClient(),
|
|
2381
2493
|
getSsh(),
|
|
@@ -2398,12 +2510,12 @@ function createProxmoxStatPathTool(getClient, getSsh, vmDefaults) {
|
|
|
2398
2510
|
}
|
|
2399
2511
|
|
|
2400
2512
|
// src/tools/proxmox_list_directory.ts
|
|
2401
|
-
import { Type as
|
|
2402
|
-
var Schema38 =
|
|
2513
|
+
import { Type as Type39 } from "@sinclair/typebox";
|
|
2514
|
+
var Schema38 = Type39.Object(
|
|
2403
2515
|
{
|
|
2404
|
-
vmid:
|
|
2405
|
-
path:
|
|
2406
|
-
confirm:
|
|
2516
|
+
vmid: Type39.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2517
|
+
path: Type39.String({ minLength: 1, description: "Absolute directory path inside the guest." }),
|
|
2518
|
+
confirm: Type39.Boolean({ description: "Must be true to inspect guest directory contents." })
|
|
2407
2519
|
},
|
|
2408
2520
|
{ additionalProperties: false }
|
|
2409
2521
|
);
|
|
@@ -2436,8 +2548,8 @@ function createProxmoxListDirectoryTool(getClient, getSsh, vmDefaults) {
|
|
|
2436
2548
|
execute: async (_id, raw) => {
|
|
2437
2549
|
assertConfirmedWrite(raw, NAME35);
|
|
2438
2550
|
const args = validateToolArgs(Schema38, raw, NAME35);
|
|
2439
|
-
|
|
2440
|
-
const command = `find ${
|
|
2551
|
+
assertAbsoluteGuestPath(args.path, NAME35);
|
|
2552
|
+
const command = `find ${shellSingleQuote(args.path)} -mindepth 1 -maxdepth 1 -printf '%f\\0%y\\0%s\\0%T@\\0'`;
|
|
2441
2553
|
const { node, type, result } = await runGuestCommand(
|
|
2442
2554
|
getClient(),
|
|
2443
2555
|
getSsh(),
|
|
@@ -2456,12 +2568,12 @@ function createProxmoxListDirectoryTool(getClient, getSsh, vmDefaults) {
|
|
|
2456
2568
|
}
|
|
2457
2569
|
|
|
2458
2570
|
// src/tools/proxmox_service_status.ts
|
|
2459
|
-
import { Type as
|
|
2460
|
-
var Schema39 =
|
|
2571
|
+
import { Type as Type40 } from "@sinclair/typebox";
|
|
2572
|
+
var Schema39 = Type40.Object(
|
|
2461
2573
|
{
|
|
2462
|
-
vmid:
|
|
2463
|
-
service:
|
|
2464
|
-
confirm:
|
|
2574
|
+
vmid: Type40.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2575
|
+
service: Type40.String({ minLength: 1, description: "systemd service name inside the guest." }),
|
|
2576
|
+
confirm: Type40.Boolean({ description: "Must be true to inspect guest service state." })
|
|
2465
2577
|
},
|
|
2466
2578
|
{ additionalProperties: false }
|
|
2467
2579
|
);
|
|
@@ -2485,7 +2597,7 @@ function createProxmoxServiceStatusTool(getClient, getSsh, vmDefaults) {
|
|
|
2485
2597
|
assertConfirmedWrite(raw, NAME36);
|
|
2486
2598
|
const args = validateToolArgs(Schema39, raw, NAME36);
|
|
2487
2599
|
if (args.service.includes("\0")) throw new Error(`${NAME36} service cannot contain NUL bytes`);
|
|
2488
|
-
const command = `systemctl show --no-pager --property=Id,LoadState,ActiveState,SubState,UnitFileState,Description -- ${
|
|
2600
|
+
const command = `systemctl show --no-pager --property=Id,LoadState,ActiveState,SubState,UnitFileState,Description -- ${shellSingleQuote(args.service)}`;
|
|
2489
2601
|
const { node, type, result } = await runGuestCommand(
|
|
2490
2602
|
getClient(),
|
|
2491
2603
|
getSsh(),
|
|
@@ -2504,7 +2616,7 @@ function createProxmoxServiceStatusTool(getClient, getSsh, vmDefaults) {
|
|
|
2504
2616
|
}
|
|
2505
2617
|
|
|
2506
2618
|
// src/tools/service-action.ts
|
|
2507
|
-
import { Type as
|
|
2619
|
+
import { Type as Type41 } from "@sinclair/typebox";
|
|
2508
2620
|
function parseSystemctlShow2(stdout) {
|
|
2509
2621
|
const out = {};
|
|
2510
2622
|
for (const line of stdout.trimEnd().split("\n")) {
|
|
@@ -2515,11 +2627,11 @@ function parseSystemctlShow2(stdout) {
|
|
|
2515
2627
|
return out;
|
|
2516
2628
|
}
|
|
2517
2629
|
function schemaFor(action) {
|
|
2518
|
-
return
|
|
2630
|
+
return Type41.Object(
|
|
2519
2631
|
{
|
|
2520
|
-
vmid:
|
|
2521
|
-
service:
|
|
2522
|
-
confirm:
|
|
2632
|
+
vmid: Type41.Integer({ minimum: 1, description: "Container or VM id." }),
|
|
2633
|
+
service: Type41.String({ minLength: 1, description: `systemd service name to ${action} inside the guest.` }),
|
|
2634
|
+
confirm: Type41.Boolean({ description: `Must be true to ${action} a guest service.` })
|
|
2523
2635
|
},
|
|
2524
2636
|
{ additionalProperties: false }
|
|
2525
2637
|
);
|
|
@@ -2536,7 +2648,7 @@ function createServiceActionTool(action, getClient, getSsh, vmDefaults) {
|
|
|
2536
2648
|
assertConfirmedWrite(raw, name);
|
|
2537
2649
|
const args = validateToolArgs(schema, raw, name);
|
|
2538
2650
|
if (args.service.includes("\0")) throw new Error(`${name} service cannot contain NUL bytes`);
|
|
2539
|
-
const quoted =
|
|
2651
|
+
const quoted = shellSingleQuote(args.service);
|
|
2540
2652
|
const command = `systemctl ${action} -- ${quoted} && systemctl show --no-pager --property=Id,LoadState,ActiveState,SubState,UnitFileState,Description -- ${quoted}`;
|
|
2541
2653
|
const { node, type, result } = await runGuestCommand(
|
|
2542
2654
|
getClient(),
|
|
@@ -2576,30 +2688,1928 @@ function createProxmoxServiceRestartTool(getClient, getSsh, vmDefaults) {
|
|
|
2576
2688
|
return createServiceActionTool("restart", getClient, getSsh, vmDefaults);
|
|
2577
2689
|
}
|
|
2578
2690
|
|
|
2579
|
-
// src/
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
}
|
|
2589
|
-
|
|
2590
|
-
|
|
2691
|
+
// src/tools/proxmox_update_vm_config.ts
|
|
2692
|
+
import { Type as Type43 } from "@sinclair/typebox";
|
|
2693
|
+
|
|
2694
|
+
// src/tools/resource-config.ts
|
|
2695
|
+
import { Type as Type42 } from "@sinclair/typebox";
|
|
2696
|
+
var CONFIG_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
2697
|
+
var configEditFields = {
|
|
2698
|
+
cores: Type42.Optional(Type42.Integer({ minimum: 1, description: "CPU cores." })),
|
|
2699
|
+
memory: Type42.Optional(Type42.Integer({ minimum: 16, description: "RAM in MiB." })),
|
|
2700
|
+
description: Type42.Optional(Type42.String({ description: "Free-form description / notes." })),
|
|
2701
|
+
onboot: Type42.Optional(Type42.Boolean({ description: "Start on host boot." })),
|
|
2702
|
+
tags: Type42.Optional(Type42.String({ description: "Semicolon-delimited Proxmox tags." })),
|
|
2703
|
+
cpulimit: Type42.Optional(Type42.Number({ minimum: 0, description: "CPU limit (0 = unlimited)." })),
|
|
2704
|
+
cpuunits: Type42.Optional(Type42.Integer({ minimum: 1, description: "CPU weight / shares." })),
|
|
2705
|
+
protection: Type42.Optional(
|
|
2706
|
+
Type42.Boolean({ description: "Protection flag (blocks destroy/disk-remove)." })
|
|
2707
|
+
),
|
|
2708
|
+
set: Type42.Optional(
|
|
2709
|
+
Type42.Record(Type42.String(), Type42.Union([Type42.String(), Type42.Number(), Type42.Boolean()]), {
|
|
2710
|
+
description: 'Arbitrary PVE config keys to set, e.g. {"net0":"virtio,bridge=vmbr0","bios":"ovmf"}. Escape hatch for keys not exposed as typed fields.'
|
|
2711
|
+
})
|
|
2712
|
+
),
|
|
2713
|
+
unset: Type42.Optional(
|
|
2714
|
+
Type42.Array(Type42.String(), {
|
|
2715
|
+
description: 'Config keys to unset/revert to default, e.g. ["tags","description"].'
|
|
2716
|
+
})
|
|
2717
|
+
),
|
|
2718
|
+
digest: Type42.Optional(
|
|
2719
|
+
Type42.String({
|
|
2720
|
+
description: "SHA1 config digest for optimistic concurrency; edit is rejected if config changed."
|
|
2721
|
+
})
|
|
2722
|
+
)
|
|
2723
|
+
};
|
|
2724
|
+
function normalize(v) {
|
|
2725
|
+
if (typeof v === "boolean") return v ? 1 : 0;
|
|
2726
|
+
if (typeof v === "number") return v;
|
|
2727
|
+
return String(v);
|
|
2728
|
+
}
|
|
2729
|
+
function buildConfigBody(args, extraTyped, toolName) {
|
|
2730
|
+
const body = {};
|
|
2731
|
+
const typed = {
|
|
2732
|
+
cores: args.cores,
|
|
2733
|
+
memory: args.memory,
|
|
2734
|
+
description: args.description,
|
|
2735
|
+
onboot: args.onboot,
|
|
2736
|
+
tags: args.tags,
|
|
2737
|
+
cpulimit: args.cpulimit,
|
|
2738
|
+
cpuunits: args.cpuunits,
|
|
2739
|
+
protection: args.protection,
|
|
2740
|
+
...extraTyped
|
|
2741
|
+
};
|
|
2742
|
+
for (const [k, v] of Object.entries(typed)) {
|
|
2743
|
+
if (v !== void 0) body[k] = normalize(v);
|
|
2591
2744
|
}
|
|
2592
|
-
if (
|
|
2593
|
-
|
|
2745
|
+
if (args.set) {
|
|
2746
|
+
for (const [k, v] of Object.entries(args.set)) {
|
|
2747
|
+
if (!CONFIG_KEY_RE.test(k)) {
|
|
2748
|
+
throw new ToolInputError(`${toolName}: invalid config key "${k}" in set`);
|
|
2749
|
+
}
|
|
2750
|
+
body[k] = normalize(v);
|
|
2751
|
+
}
|
|
2594
2752
|
}
|
|
2595
|
-
|
|
2596
|
-
|
|
2753
|
+
const unset = (args.unset ?? []).filter((k) => k.length > 0);
|
|
2754
|
+
for (const k of unset) {
|
|
2755
|
+
if (!CONFIG_KEY_RE.test(k)) {
|
|
2756
|
+
throw new ToolInputError(`${toolName}: invalid config key "${k}" in unset`);
|
|
2757
|
+
}
|
|
2597
2758
|
}
|
|
2598
|
-
if (
|
|
2599
|
-
|
|
2759
|
+
if (unset.length > 0) body.delete = unset.join(",");
|
|
2760
|
+
if (args.digest) body.digest = args.digest;
|
|
2761
|
+
const mutations = Object.keys(body).filter((k) => k !== "digest");
|
|
2762
|
+
if (mutations.length === 0) {
|
|
2763
|
+
throw new ToolInputError(
|
|
2764
|
+
`${toolName}: no config changes supplied. Provide at least one field, a "set" entry, or an "unset" key.`
|
|
2765
|
+
);
|
|
2600
2766
|
}
|
|
2601
|
-
|
|
2602
|
-
|
|
2767
|
+
return body;
|
|
2768
|
+
}
|
|
2769
|
+
|
|
2770
|
+
// src/tools/proxmox_update_vm_config.ts
|
|
2771
|
+
var Schema40 = Type43.Object(
|
|
2772
|
+
{
|
|
2773
|
+
vmid: Type43.Integer({ minimum: 1, description: "QEMU VM ID to reconfigure." }),
|
|
2774
|
+
name: Type43.Optional(Type43.String({ minLength: 1, description: "VM name." })),
|
|
2775
|
+
sockets: Type43.Optional(Type43.Integer({ minimum: 1, description: "CPU sockets." })),
|
|
2776
|
+
balloon: Type43.Optional(
|
|
2777
|
+
Type43.Integer({ minimum: 0, description: "Ballooning target in MiB (0 disables)." })
|
|
2778
|
+
),
|
|
2779
|
+
...configEditFields,
|
|
2780
|
+
confirm: Type43.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
2781
|
+
},
|
|
2782
|
+
{ additionalProperties: false }
|
|
2783
|
+
);
|
|
2784
|
+
var NAME37 = "proxmox_update_vm_config";
|
|
2785
|
+
function createProxmoxUpdateVmConfigTool(getClient) {
|
|
2786
|
+
return {
|
|
2787
|
+
name: NAME37,
|
|
2788
|
+
label: "proxmox: update VM config",
|
|
2789
|
+
description: "Edit an existing QEMU VM's config (PUT /nodes/{node}/qemu/{vmid}/config): cores, memory, sockets, balloon, name, description, onboot, tags, plus arbitrary keys via `set` and key removal via `unset`. Some changes (CPU/mem/disk on a running VM) apply as pending until reboot. Tier-2 write; requires confirm:true.",
|
|
2790
|
+
parameters: Schema40,
|
|
2791
|
+
execute: async (_id, raw) => {
|
|
2792
|
+
assertConfirmedWrite(raw, NAME37);
|
|
2793
|
+
const args = validateToolArgs(Schema40, raw, NAME37);
|
|
2794
|
+
const client = getClient();
|
|
2795
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
2796
|
+
if (type !== "qemu") {
|
|
2797
|
+
throw new Error(`vmid ${args.vmid} is an LXC container, not a QEMU VM. Use proxmox_update_container_config.`);
|
|
2798
|
+
}
|
|
2799
|
+
const body = buildConfigBody(args, { name: args.name, sockets: args.sockets, balloon: args.balloon }, NAME37);
|
|
2800
|
+
const upid = await client.put(`/nodes/${node}/qemu/${args.vmid}/config`, body);
|
|
2801
|
+
const changed = Object.keys(body).filter((k) => k !== "digest" && k !== "delete");
|
|
2802
|
+
const removed = typeof body.delete === "string" ? body.delete.split(",") : [];
|
|
2803
|
+
return jsonToolResult({ vmid: args.vmid, node, type, changed, removed, upid: upid ?? null });
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
// src/tools/proxmox_update_container_config.ts
|
|
2809
|
+
import { Type as Type44 } from "@sinclair/typebox";
|
|
2810
|
+
var Schema41 = Type44.Object(
|
|
2811
|
+
{
|
|
2812
|
+
vmid: Type44.Integer({ minimum: 1, description: "LXC container ID to reconfigure." }),
|
|
2813
|
+
hostname: Type44.Optional(Type44.String({ minLength: 1, description: "Container hostname." })),
|
|
2814
|
+
swap: Type44.Optional(Type44.Integer({ minimum: 0, description: "Swap in MiB." })),
|
|
2815
|
+
nameserver: Type44.Optional(Type44.String({ minLength: 1, description: "DNS server IP(s), space-separated." })),
|
|
2816
|
+
...configEditFields,
|
|
2817
|
+
confirm: Type44.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
2818
|
+
},
|
|
2819
|
+
{ additionalProperties: false }
|
|
2820
|
+
);
|
|
2821
|
+
var NAME38 = "proxmox_update_container_config";
|
|
2822
|
+
function createProxmoxUpdateContainerConfigTool(getClient) {
|
|
2823
|
+
return {
|
|
2824
|
+
name: NAME38,
|
|
2825
|
+
label: "proxmox: update container config",
|
|
2826
|
+
description: "Edit an existing LXC container's config (PUT /nodes/{node}/lxc/{vmid}/config): cores, memory, swap, hostname, nameserver, description, onboot, tags, plus arbitrary keys via `set` and key removal via `unset`. Tier-2 write; requires confirm:true.",
|
|
2827
|
+
parameters: Schema41,
|
|
2828
|
+
execute: async (_id, raw) => {
|
|
2829
|
+
assertConfirmedWrite(raw, NAME38);
|
|
2830
|
+
const args = validateToolArgs(Schema41, raw, NAME38);
|
|
2831
|
+
const client = getClient();
|
|
2832
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
2833
|
+
if (type !== "lxc") {
|
|
2834
|
+
throw new Error(`vmid ${args.vmid} is a QEMU VM, not an LXC container. Use proxmox_update_vm_config.`);
|
|
2835
|
+
}
|
|
2836
|
+
const body = buildConfigBody(
|
|
2837
|
+
args,
|
|
2838
|
+
{ hostname: args.hostname, swap: args.swap, nameserver: args.nameserver },
|
|
2839
|
+
NAME38
|
|
2840
|
+
);
|
|
2841
|
+
const upid = await client.put(`/nodes/${node}/lxc/${args.vmid}/config`, body);
|
|
2842
|
+
const changed = Object.keys(body).filter((k) => k !== "digest" && k !== "delete");
|
|
2843
|
+
const removed = typeof body.delete === "string" ? body.delete.split(",") : [];
|
|
2844
|
+
return jsonToolResult({ vmid: args.vmid, node, type, changed, removed, upid: upid ?? null });
|
|
2845
|
+
}
|
|
2846
|
+
};
|
|
2847
|
+
}
|
|
2848
|
+
|
|
2849
|
+
// src/tools/proxmox_resize_disk.ts
|
|
2850
|
+
import { Type as Type45 } from "@sinclair/typebox";
|
|
2851
|
+
var DISK_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
2852
|
+
var SIZE_RE = /^\+?\d+(\.\d+)?[KMGT]?$/;
|
|
2853
|
+
var Schema42 = Type45.Object(
|
|
2854
|
+
{
|
|
2855
|
+
vmid: Type45.Integer({ minimum: 1, description: "Container or VM ID." }),
|
|
2856
|
+
disk: Type45.String({
|
|
2857
|
+
minLength: 1,
|
|
2858
|
+
description: "Disk key to resize, e.g. 'scsi0', 'virtio0', 'rootfs', 'mp0'."
|
|
2859
|
+
}),
|
|
2860
|
+
size: Type45.String({
|
|
2861
|
+
minLength: 1,
|
|
2862
|
+
description: "New size ('32G') or growth increment ('+2G'). PVE grows only; shrink is refused."
|
|
2863
|
+
}),
|
|
2864
|
+
confirm: Type45.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." }),
|
|
2865
|
+
...taskWaitFields
|
|
2866
|
+
},
|
|
2867
|
+
{ additionalProperties: false }
|
|
2868
|
+
);
|
|
2869
|
+
var NAME39 = "proxmox_resize_disk";
|
|
2870
|
+
function createProxmoxResizeDiskTool(getClient) {
|
|
2871
|
+
return {
|
|
2872
|
+
name: NAME39,
|
|
2873
|
+
label: "proxmox: resize disk",
|
|
2874
|
+
description: "Grow a VM or container disk (PUT /nodes/{node}/{type}/{vmid}/resize) with {disk,size}. Size is absolute ('32G') or an increment ('+2G'); Proxmox only grows disks. Tier-2 write; requires confirm:true.",
|
|
2875
|
+
parameters: Schema42,
|
|
2876
|
+
execute: async (_id, raw) => {
|
|
2877
|
+
assertConfirmedWrite(raw, NAME39);
|
|
2878
|
+
const args = validateToolArgs(
|
|
2879
|
+
Schema42,
|
|
2880
|
+
raw,
|
|
2881
|
+
NAME39
|
|
2882
|
+
);
|
|
2883
|
+
if (!DISK_KEY_RE.test(args.disk)) {
|
|
2884
|
+
throw new ToolInputError(`${NAME39}: invalid disk key "${args.disk}"`);
|
|
2885
|
+
}
|
|
2886
|
+
if (!SIZE_RE.test(args.size)) {
|
|
2887
|
+
throw new ToolInputError(
|
|
2888
|
+
`${NAME39}: invalid size "${args.size}". Use '32G' (absolute) or '+2G' (growth).`
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2891
|
+
const client = getClient();
|
|
2892
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
2893
|
+
const upid = await client.put(`/nodes/${node}/${type}/${args.vmid}/resize`, {
|
|
2894
|
+
disk: args.disk,
|
|
2895
|
+
size: args.size
|
|
2896
|
+
});
|
|
2897
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
2898
|
+
return jsonToolResult({ vmid: args.vmid, node, type, disk: args.disk, size: args.size, upid: upid ?? null, ...task ? { task } : {} });
|
|
2899
|
+
}
|
|
2900
|
+
};
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
// src/tools/proxmox_restore_backup.ts
|
|
2904
|
+
import { Type as Type46 } from "@sinclair/typebox";
|
|
2905
|
+
var Schema43 = Type46.Object(
|
|
2906
|
+
{
|
|
2907
|
+
vmid: Type46.Integer({ minimum: 1, description: "Target VMID to restore into." }),
|
|
2908
|
+
archive: Type46.String({
|
|
2909
|
+
minLength: 1,
|
|
2910
|
+
description: "Backup archive volid or path, e.g. 'local:backup/vzdump-lxc-115-2026_01_01-00_00_00.tar.zst' or a PBS volid."
|
|
2911
|
+
}),
|
|
2912
|
+
type: Type46.Optional(
|
|
2913
|
+
Type46.Union([Type46.Literal("lxc"), Type46.Literal("qemu")], {
|
|
2914
|
+
description: "Guest type. Inferred from the archive name when omitted."
|
|
2915
|
+
})
|
|
2916
|
+
),
|
|
2917
|
+
node: Type46.Optional(
|
|
2918
|
+
Type46.String({ minLength: 1, description: "Node to restore on (defaults to first node for a new vmid)." })
|
|
2919
|
+
),
|
|
2920
|
+
storage: Type46.Optional(
|
|
2921
|
+
Type46.String({ minLength: 1, description: "Target storage for restored disks (defaults to the archive's)." })
|
|
2922
|
+
),
|
|
2923
|
+
pool: Type46.Optional(Type46.String({ minLength: 1, description: "Resource pool to place the guest into." })),
|
|
2924
|
+
unique: Type46.Optional(
|
|
2925
|
+
Type46.Boolean({ description: "QEMU: regenerate MAC addresses / UUID on restore." })
|
|
2926
|
+
),
|
|
2927
|
+
force: Type46.Optional(
|
|
2928
|
+
Type46.Boolean({
|
|
2929
|
+
description: "Overwrite an EXISTING vmid (wipes its disks). Requires the destructive gate."
|
|
2930
|
+
})
|
|
2931
|
+
),
|
|
2932
|
+
confirm: Type46.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." }),
|
|
2933
|
+
destructive: Type46.Optional(
|
|
2934
|
+
Type46.Boolean({ description: "Required only when overwriting an existing vmid (force)." })
|
|
2935
|
+
),
|
|
2936
|
+
...taskWaitFields
|
|
2937
|
+
},
|
|
2938
|
+
{ additionalProperties: false }
|
|
2939
|
+
);
|
|
2940
|
+
var NAME40 = "proxmox_restore_backup";
|
|
2941
|
+
function inferType(archive) {
|
|
2942
|
+
const a = archive.toLowerCase();
|
|
2943
|
+
if (a.includes("qemu") || a.includes("/vm/")) return "qemu";
|
|
2944
|
+
if (a.includes("lxc") || a.includes("/ct/")) return "lxc";
|
|
2945
|
+
return null;
|
|
2946
|
+
}
|
|
2947
|
+
function createProxmoxRestoreBackupTool(getClient) {
|
|
2948
|
+
return {
|
|
2949
|
+
name: NAME40,
|
|
2950
|
+
label: "proxmox: restore backup",
|
|
2951
|
+
description: "Restore a vzdump/PBS backup into a VMID (POST /nodes/{node}/{type}/{vmid} with restore=1). Restoring to a new VMID is Tier-2 (confirm:true). Overwriting an EXISTING VMID wipes its disks and additionally requires force:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
|
|
2952
|
+
parameters: Schema43,
|
|
2953
|
+
execute: async (_id, raw) => {
|
|
2954
|
+
assertConfirmedWrite(raw, NAME40);
|
|
2955
|
+
const args = validateToolArgs(Schema43, raw, NAME40);
|
|
2956
|
+
if (/[\r\n]/.test(args.archive)) {
|
|
2957
|
+
throw new ToolInputError(`${NAME40}: archive must not contain newlines`);
|
|
2958
|
+
}
|
|
2959
|
+
const type = args.type ?? inferType(args.archive);
|
|
2960
|
+
if (!type) {
|
|
2961
|
+
throw new ToolInputError(
|
|
2962
|
+
`${NAME40}: could not infer guest type from archive "${args.archive}". Pass type:"lxc" or "qemu".`
|
|
2963
|
+
);
|
|
2964
|
+
}
|
|
2965
|
+
const client = getClient();
|
|
2966
|
+
const resources = await client.get("/cluster/resources");
|
|
2967
|
+
const existing = resources.find(
|
|
2968
|
+
(r) => r.vmid === args.vmid && (r.type === "lxc" || r.type === "qemu")
|
|
2969
|
+
);
|
|
2970
|
+
let node;
|
|
2971
|
+
if (existing) {
|
|
2972
|
+
if (args.force !== true) {
|
|
2973
|
+
throw new ToolInputError(
|
|
2974
|
+
`${NAME40}: vmid ${args.vmid} already exists on ${existing.node}. To overwrite it, pass force:true (also requires destructive:true + PROXMOX_ENABLE_DESTRUCTIVE=1).`
|
|
2975
|
+
);
|
|
2976
|
+
}
|
|
2977
|
+
assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME40);
|
|
2978
|
+
assertDestructive(raw, NAME40);
|
|
2979
|
+
if (existing.type !== type) {
|
|
2980
|
+
throw new Error(
|
|
2981
|
+
`vmid ${args.vmid} exists as ${existing.type} but archive is ${type}. Refusing cross-type overwrite.`
|
|
2982
|
+
);
|
|
2983
|
+
}
|
|
2984
|
+
node = existing.node;
|
|
2985
|
+
} else {
|
|
2986
|
+
if (args.node) {
|
|
2987
|
+
assertSafePathSegment(args.node, "node");
|
|
2988
|
+
node = args.node;
|
|
2989
|
+
} else {
|
|
2990
|
+
const nodes = resources.filter((r) => r.type === "node");
|
|
2991
|
+
if (nodes.length === 0) throw new Error("no nodes found in cluster resources");
|
|
2992
|
+
node = nodes[0].node;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
const body = {
|
|
2996
|
+
vmid: args.vmid,
|
|
2997
|
+
restore: 1
|
|
2998
|
+
};
|
|
2999
|
+
if (type === "qemu") body.archive = args.archive;
|
|
3000
|
+
else body.ostemplate = args.archive;
|
|
3001
|
+
if (existing && args.force === true) body.force = 1;
|
|
3002
|
+
if (args.storage) body.storage = args.storage;
|
|
3003
|
+
if (args.pool) body.pool = args.pool;
|
|
3004
|
+
if (args.unique === true && type === "qemu") body.unique = 1;
|
|
3005
|
+
const upid = await client.post(`/nodes/${node}/${type}`, body);
|
|
3006
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
3007
|
+
return jsonToolResult({
|
|
3008
|
+
vmid: args.vmid,
|
|
3009
|
+
node,
|
|
3010
|
+
type,
|
|
3011
|
+
archive: args.archive,
|
|
3012
|
+
overwrite: Boolean(existing),
|
|
3013
|
+
upid,
|
|
3014
|
+
...task ? { task } : {}
|
|
3015
|
+
});
|
|
3016
|
+
}
|
|
3017
|
+
};
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
// src/tools/proxmox_migrate_resource.ts
|
|
3021
|
+
import { Type as Type47 } from "@sinclair/typebox";
|
|
3022
|
+
var Schema44 = Type47.Object(
|
|
3023
|
+
{
|
|
3024
|
+
vmid: Type47.Integer({ minimum: 1, description: "Container or VM ID to migrate." }),
|
|
3025
|
+
target: Type47.String({ minLength: 1, description: "Target node name to migrate to." }),
|
|
3026
|
+
online: Type47.Optional(
|
|
3027
|
+
Type47.Boolean({ description: "QEMU: live-migrate a running VM (no downtime)." })
|
|
3028
|
+
),
|
|
3029
|
+
restart: Type47.Optional(
|
|
3030
|
+
Type47.Boolean({ description: "LXC: restart-migrate a running container (brief downtime)." })
|
|
3031
|
+
),
|
|
3032
|
+
with_local_disks: Type47.Optional(
|
|
3033
|
+
Type47.Boolean({ description: "QEMU: also migrate local (non-shared) disks." })
|
|
3034
|
+
),
|
|
3035
|
+
targetstorage: Type47.Optional(
|
|
3036
|
+
Type47.String({ minLength: 1, description: "Map disks onto this storage on the target node." })
|
|
3037
|
+
),
|
|
3038
|
+
bwlimit: Type47.Optional(
|
|
3039
|
+
Type47.Integer({ minimum: 0, description: "Bandwidth limit in KiB/s (0 = unlimited)." })
|
|
3040
|
+
),
|
|
3041
|
+
confirm: Type47.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." }),
|
|
3042
|
+
...taskWaitFields
|
|
3043
|
+
},
|
|
3044
|
+
{ additionalProperties: false }
|
|
3045
|
+
);
|
|
3046
|
+
var NAME41 = "proxmox_migrate_resource";
|
|
3047
|
+
function createProxmoxMigrateResourceTool(getClient) {
|
|
3048
|
+
return {
|
|
3049
|
+
name: NAME41,
|
|
3050
|
+
label: "proxmox: migrate resource",
|
|
3051
|
+
description: "Migrate a VM or container to another node (POST /nodes/{node}/{type}/{vmid}/migrate). QEMU supports online (live) migration; LXC uses restart mode. Tier-2 write; requires confirm:true.",
|
|
3052
|
+
parameters: Schema44,
|
|
3053
|
+
execute: async (_id, raw) => {
|
|
3054
|
+
assertConfirmedWrite(raw, NAME41);
|
|
3055
|
+
const args = validateToolArgs(Schema44, raw, NAME41);
|
|
3056
|
+
assertSafePathSegment(args.target, "target node");
|
|
3057
|
+
const client = getClient();
|
|
3058
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3059
|
+
if (args.target === node) {
|
|
3060
|
+
throw new Error(`vmid ${args.vmid} is already on node ${node}; nothing to migrate.`);
|
|
3061
|
+
}
|
|
3062
|
+
const body = { target: args.target };
|
|
3063
|
+
if (type === "qemu") {
|
|
3064
|
+
if (args.online) body.online = 1;
|
|
3065
|
+
if (args.with_local_disks) body["with-local-disks"] = 1;
|
|
3066
|
+
} else {
|
|
3067
|
+
if (args.restart || args.online) body.restart = 1;
|
|
3068
|
+
}
|
|
3069
|
+
if (args.targetstorage) body.targetstorage = args.targetstorage;
|
|
3070
|
+
if (typeof args.bwlimit === "number") body.bwlimit = args.bwlimit;
|
|
3071
|
+
const upid = await client.post(`/nodes/${node}/${type}/${args.vmid}/migrate`, body);
|
|
3072
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
3073
|
+
return jsonToolResult({ vmid: args.vmid, node, type, target: args.target, upid, ...task ? { task } : {} });
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
// src/tools/proxmox_suspend_resource.ts
|
|
3079
|
+
import { Type as Type48 } from "@sinclair/typebox";
|
|
3080
|
+
var Schema45 = Type48.Object(
|
|
3081
|
+
{
|
|
3082
|
+
vmid: Type48.Integer({ minimum: 1, description: "Container or VM ID." }),
|
|
3083
|
+
todisk: Type48.Optional(
|
|
3084
|
+
Type48.Boolean({ description: "QEMU: suspend to disk (hibernate) instead of to RAM." })
|
|
3085
|
+
),
|
|
3086
|
+
confirm: Type48.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3087
|
+
},
|
|
3088
|
+
{ additionalProperties: false }
|
|
3089
|
+
);
|
|
3090
|
+
var NAME42 = "proxmox_suspend_resource";
|
|
3091
|
+
function createProxmoxSuspendResourceTool(getClient) {
|
|
3092
|
+
return {
|
|
3093
|
+
name: NAME42,
|
|
3094
|
+
label: "proxmox: suspend resource",
|
|
3095
|
+
description: "Suspend (pause) a running LXC or QEMU guest (POST /nodes/{node}/{type}/{vmid}/status/suspend). QEMU can suspend to disk with todisk:true. Tier-2 write; requires confirm:true.",
|
|
3096
|
+
parameters: Schema45,
|
|
3097
|
+
execute: async (_id, raw) => {
|
|
3098
|
+
assertConfirmedWrite(raw, NAME42);
|
|
3099
|
+
const args = validateToolArgs(Schema45, raw, NAME42);
|
|
3100
|
+
const client = getClient();
|
|
3101
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3102
|
+
const body = {};
|
|
3103
|
+
if (args.todisk && type === "qemu") body.todisk = 1;
|
|
3104
|
+
const upid = await client.post(`/nodes/${node}/${type}/${args.vmid}/status/suspend`, body);
|
|
3105
|
+
return jsonToolResult({ vmid: args.vmid, node, type, upid });
|
|
3106
|
+
}
|
|
3107
|
+
};
|
|
3108
|
+
}
|
|
3109
|
+
|
|
3110
|
+
// src/tools/proxmox_resume_resource.ts
|
|
3111
|
+
import { Type as Type49 } from "@sinclair/typebox";
|
|
3112
|
+
var Schema46 = Type49.Object(
|
|
3113
|
+
{
|
|
3114
|
+
vmid: Type49.Integer({ minimum: 1, description: "Container or VM ID." }),
|
|
3115
|
+
confirm: Type49.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3116
|
+
},
|
|
3117
|
+
{ additionalProperties: false }
|
|
3118
|
+
);
|
|
3119
|
+
var NAME43 = "proxmox_resume_resource";
|
|
3120
|
+
function createProxmoxResumeResourceTool(getClient) {
|
|
3121
|
+
return {
|
|
3122
|
+
name: NAME43,
|
|
3123
|
+
label: "proxmox: resume resource",
|
|
3124
|
+
description: "Resume a suspended LXC or QEMU guest (POST /nodes/{node}/{type}/{vmid}/status/resume). Tier-2 write; requires confirm:true.",
|
|
3125
|
+
parameters: Schema46,
|
|
3126
|
+
execute: async (_id, raw) => {
|
|
3127
|
+
assertConfirmedWrite(raw, NAME43);
|
|
3128
|
+
const args = validateToolArgs(Schema46, raw, NAME43);
|
|
3129
|
+
const client = getClient();
|
|
3130
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3131
|
+
const upid = await client.post(`/nodes/${node}/${type}/${args.vmid}/status/resume`, {});
|
|
3132
|
+
return jsonToolResult({ vmid: args.vmid, node, type, upid });
|
|
3133
|
+
}
|
|
3134
|
+
};
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
// src/tools/proxmox_reset_resource.ts
|
|
3138
|
+
import { Type as Type50 } from "@sinclair/typebox";
|
|
3139
|
+
var Schema47 = Type50.Object(
|
|
3140
|
+
{
|
|
3141
|
+
vmid: Type50.Integer({ minimum: 1, description: "QEMU VM ID." }),
|
|
3142
|
+
confirm: Type50.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3143
|
+
},
|
|
3144
|
+
{ additionalProperties: false }
|
|
3145
|
+
);
|
|
3146
|
+
var NAME44 = "proxmox_reset_resource";
|
|
3147
|
+
function createProxmoxResetResourceTool(getClient) {
|
|
3148
|
+
return {
|
|
3149
|
+
name: NAME44,
|
|
3150
|
+
label: "proxmox: reset resource",
|
|
3151
|
+
description: "Hard-reset a running QEMU VM (POST /nodes/{node}/qemu/{vmid}/status/reset) - equivalent to the reset button, no graceful shutdown. QEMU only. Tier-2 write; requires confirm:true.",
|
|
3152
|
+
parameters: Schema47,
|
|
3153
|
+
execute: async (_id, raw) => {
|
|
3154
|
+
assertConfirmedWrite(raw, NAME44);
|
|
3155
|
+
const args = validateToolArgs(Schema47, raw, NAME44);
|
|
3156
|
+
const client = getClient();
|
|
3157
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3158
|
+
if (type !== "qemu") {
|
|
3159
|
+
throw new Error(`vmid ${args.vmid} is an LXC container; reset is QEMU-only. Use proxmox_reboot_resource.`);
|
|
3160
|
+
}
|
|
3161
|
+
const upid = await client.post(`/nodes/${node}/qemu/${args.vmid}/status/reset`, {});
|
|
3162
|
+
return jsonToolResult({ vmid: args.vmid, node, type, upid });
|
|
3163
|
+
}
|
|
3164
|
+
};
|
|
3165
|
+
}
|
|
3166
|
+
|
|
3167
|
+
// src/tools/proxmox_convert_to_template.ts
|
|
3168
|
+
import { Type as Type51 } from "@sinclair/typebox";
|
|
3169
|
+
var Schema48 = Type51.Object(
|
|
3170
|
+
{
|
|
3171
|
+
vmid: Type51.Integer({ minimum: 1, description: "Container or VM ID to convert into a template." }),
|
|
3172
|
+
confirm: Type51.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3173
|
+
},
|
|
3174
|
+
{ additionalProperties: false }
|
|
3175
|
+
);
|
|
3176
|
+
var NAME45 = "proxmox_convert_to_template";
|
|
3177
|
+
function createProxmoxConvertToTemplateTool(getClient) {
|
|
3178
|
+
return {
|
|
3179
|
+
name: NAME45,
|
|
3180
|
+
label: "proxmox: convert to template",
|
|
3181
|
+
description: "Convert a stopped VM or container into a template (POST /nodes/{node}/{type}/{vmid}/template). One-way: a template cannot be started, only cloned from. Tier-2 write; requires confirm:true.",
|
|
3182
|
+
parameters: Schema48,
|
|
3183
|
+
execute: async (_id, raw) => {
|
|
3184
|
+
assertConfirmedWrite(raw, NAME45);
|
|
3185
|
+
const args = validateToolArgs(Schema48, raw, NAME45);
|
|
3186
|
+
const client = getClient();
|
|
3187
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3188
|
+
const upid = await client.post(`/nodes/${node}/${type}/${args.vmid}/template`, {});
|
|
3189
|
+
return jsonToolResult({ vmid: args.vmid, node, type, template: true, upid: upid ?? null });
|
|
3190
|
+
}
|
|
3191
|
+
};
|
|
3192
|
+
}
|
|
3193
|
+
|
|
3194
|
+
// src/tools/proxmox_list_storage_content.ts
|
|
3195
|
+
import { Type as Type52 } from "@sinclair/typebox";
|
|
3196
|
+
var Schema49 = Type52.Object(
|
|
3197
|
+
{
|
|
3198
|
+
node: Type52.String({ minLength: 1, description: "Node whose storage to inspect." }),
|
|
3199
|
+
storage: Type52.String({ minLength: 1, description: "Storage ID, e.g. 'local', 'local-lvm'." }),
|
|
3200
|
+
content: Type52.Optional(
|
|
3201
|
+
Type52.Union(
|
|
3202
|
+
[
|
|
3203
|
+
Type52.Literal("backup"),
|
|
3204
|
+
Type52.Literal("iso"),
|
|
3205
|
+
Type52.Literal("vztmpl"),
|
|
3206
|
+
Type52.Literal("images"),
|
|
3207
|
+
Type52.Literal("rootdir"),
|
|
3208
|
+
Type52.Literal("snippets")
|
|
3209
|
+
],
|
|
3210
|
+
{ description: "Filter by content type (backup, iso, vztmpl, images, rootdir, snippets)." }
|
|
3211
|
+
)
|
|
3212
|
+
),
|
|
3213
|
+
vmid: Type52.Optional(Type52.Integer({ minimum: 1, description: "Filter to a single owning VMID." }))
|
|
3214
|
+
},
|
|
3215
|
+
{ additionalProperties: false }
|
|
3216
|
+
);
|
|
3217
|
+
var NAME46 = "proxmox_list_storage_content";
|
|
3218
|
+
function createProxmoxListStorageContentTool(getClient) {
|
|
3219
|
+
return {
|
|
3220
|
+
name: NAME46,
|
|
3221
|
+
label: "proxmox: list storage content",
|
|
3222
|
+
description: "List volumes on a storage (GET /nodes/{node}/storage/{storage}/content): ISOs, container templates, disk images, and backups, with size + owning vmid. Optionally filter by content type or vmid. Tier-1 read.",
|
|
3223
|
+
parameters: Schema49,
|
|
3224
|
+
execute: async (_id, raw) => {
|
|
3225
|
+
const args = validateToolArgs(
|
|
3226
|
+
Schema49,
|
|
3227
|
+
raw,
|
|
3228
|
+
NAME46
|
|
3229
|
+
);
|
|
3230
|
+
assertSafePathSegment(args.node, "node");
|
|
3231
|
+
assertSafePathSegment(args.storage, "storage");
|
|
3232
|
+
const params = new URLSearchParams();
|
|
3233
|
+
if (args.content) params.append("content", args.content);
|
|
3234
|
+
if (typeof args.vmid === "number") params.append("vmid", String(args.vmid));
|
|
3235
|
+
const qs = params.toString();
|
|
3236
|
+
const path2 = `/nodes/${args.node}/storage/${args.storage}/content${qs ? `?${qs}` : ""}`;
|
|
3237
|
+
const items = await getClient().get(path2);
|
|
3238
|
+
return jsonToolResult({ node: args.node, storage: args.storage, count: items.length, content: items });
|
|
3239
|
+
}
|
|
3240
|
+
};
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
// src/tools/proxmox_download_url.ts
|
|
3244
|
+
import { Type as Type53 } from "@sinclair/typebox";
|
|
3245
|
+
var Schema50 = Type53.Object(
|
|
3246
|
+
{
|
|
3247
|
+
node: Type53.String({ minLength: 1, description: "Node to download onto." }),
|
|
3248
|
+
storage: Type53.String({ minLength: 1, description: "Target storage ID (must allow iso/vztmpl content)." }),
|
|
3249
|
+
content: Type53.Union([Type53.Literal("iso"), Type53.Literal("vztmpl")], {
|
|
3250
|
+
description: "Content type: 'iso' for an install image, 'vztmpl' for a container template."
|
|
3251
|
+
}),
|
|
3252
|
+
url: Type53.String({ minLength: 1, description: "HTTP(S) URL to download from." }),
|
|
3253
|
+
filename: Type53.String({ minLength: 1, description: "Destination filename on the storage." }),
|
|
3254
|
+
checksum: Type53.Optional(Type53.String({ minLength: 1, description: "Expected checksum of the download." })),
|
|
3255
|
+
checksum_algorithm: Type53.Optional(
|
|
3256
|
+
Type53.Union(
|
|
3257
|
+
[Type53.Literal("md5"), Type53.Literal("sha1"), Type53.Literal("sha256"), Type53.Literal("sha512")],
|
|
3258
|
+
{ description: "Algorithm for the checksum." }
|
|
3259
|
+
)
|
|
3260
|
+
),
|
|
3261
|
+
verify_certificates: Type53.Optional(
|
|
3262
|
+
Type53.Boolean({ description: "Verify the source server's TLS cert (default true)." })
|
|
3263
|
+
),
|
|
3264
|
+
confirm: Type53.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." }),
|
|
3265
|
+
...taskWaitFields
|
|
3266
|
+
},
|
|
3267
|
+
{ additionalProperties: false }
|
|
3268
|
+
);
|
|
3269
|
+
var NAME47 = "proxmox_download_url";
|
|
3270
|
+
function createProxmoxDownloadUrlTool(getClient) {
|
|
3271
|
+
return {
|
|
3272
|
+
name: NAME47,
|
|
3273
|
+
label: "proxmox: download url",
|
|
3274
|
+
description: "Download an ISO or container template from a URL onto a storage (POST /nodes/{node}/storage/{storage}/download-url). Optional checksum verification. Tier-2 write; requires confirm:true.",
|
|
3275
|
+
parameters: Schema50,
|
|
3276
|
+
execute: async (_id, raw) => {
|
|
3277
|
+
assertConfirmedWrite(raw, NAME47);
|
|
3278
|
+
const args = validateToolArgs(Schema50, raw, NAME47);
|
|
3279
|
+
assertSafePathSegment(args.node, "node");
|
|
3280
|
+
assertSafePathSegment(args.storage, "storage");
|
|
3281
|
+
if (!/^https?:\/\//i.test(args.url)) {
|
|
3282
|
+
throw new ToolInputError(`${NAME47}: url must be http(s)`);
|
|
3283
|
+
}
|
|
3284
|
+
if (args.checksum && !args.checksum_algorithm) {
|
|
3285
|
+
throw new ToolInputError(`${NAME47}: checksum_algorithm is required when checksum is set`);
|
|
3286
|
+
}
|
|
3287
|
+
const body = {
|
|
3288
|
+
content: args.content,
|
|
3289
|
+
url: args.url,
|
|
3290
|
+
filename: args.filename
|
|
3291
|
+
};
|
|
3292
|
+
if (args.checksum) body.checksum = args.checksum;
|
|
3293
|
+
if (args.checksum_algorithm) body["checksum-algorithm"] = args.checksum_algorithm;
|
|
3294
|
+
if (args.verify_certificates === false) body["verify-certificates"] = 0;
|
|
3295
|
+
const client = getClient();
|
|
3296
|
+
const upid = await client.post(
|
|
3297
|
+
`/nodes/${args.node}/storage/${args.storage}/download-url`,
|
|
3298
|
+
body
|
|
3299
|
+
);
|
|
3300
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
3301
|
+
return jsonToolResult({
|
|
3302
|
+
node: args.node,
|
|
3303
|
+
storage: args.storage,
|
|
3304
|
+
content: args.content,
|
|
3305
|
+
filename: args.filename,
|
|
3306
|
+
upid,
|
|
3307
|
+
...task ? { task } : {}
|
|
3308
|
+
});
|
|
3309
|
+
}
|
|
3310
|
+
};
|
|
3311
|
+
}
|
|
3312
|
+
|
|
3313
|
+
// src/tools/proxmox_delete_volume.ts
|
|
3314
|
+
import { Type as Type54 } from "@sinclair/typebox";
|
|
3315
|
+
var VOLID_RE = /^[\w.-]+:[\w./-]+$/;
|
|
3316
|
+
var Schema51 = Type54.Object(
|
|
3317
|
+
{
|
|
3318
|
+
node: Type54.String({ minLength: 1, description: "Node the storage is on." }),
|
|
3319
|
+
storage: Type54.String({ minLength: 1, description: "Storage ID holding the volume." }),
|
|
3320
|
+
volume: Type54.String({
|
|
3321
|
+
minLength: 1,
|
|
3322
|
+
description: "Full volid to delete, e.g. 'local:backup/vzdump-lxc-100-...tar.zst'."
|
|
3323
|
+
}),
|
|
3324
|
+
confirm: Type54.Boolean({ description: "Must be true. Tier-3 destructive gate." }),
|
|
3325
|
+
destructive: Type54.Boolean({ description: "Must be true. Tier-3 destructive gate." })
|
|
3326
|
+
},
|
|
3327
|
+
{ additionalProperties: false }
|
|
3328
|
+
);
|
|
3329
|
+
var NAME48 = "proxmox_delete_volume";
|
|
3330
|
+
function createProxmoxDeleteVolumeTool(getClient) {
|
|
3331
|
+
return {
|
|
3332
|
+
name: NAME48,
|
|
3333
|
+
label: "proxmox: delete volume",
|
|
3334
|
+
description: "Permanently delete a storage volume - a backup archive, ISO, template, or disk image (DELETE /nodes/{node}/storage/{storage}/content/{volume}). Tier-3 destructive; requires confirm:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
|
|
3335
|
+
parameters: Schema51,
|
|
3336
|
+
execute: async (_id, raw) => {
|
|
3337
|
+
assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME48);
|
|
3338
|
+
assertDestructive(raw, NAME48);
|
|
3339
|
+
const args = validateToolArgs(Schema51, raw, NAME48);
|
|
3340
|
+
assertSafePathSegment(args.node, "node");
|
|
3341
|
+
assertSafePathSegment(args.storage, "storage");
|
|
3342
|
+
if (args.volume.includes("..") || !VOLID_RE.test(args.volume)) {
|
|
3343
|
+
throw new ToolInputError(`${NAME48}: invalid volume id "${args.volume}"`);
|
|
3344
|
+
}
|
|
3345
|
+
const path2 = `/nodes/${args.node}/storage/${args.storage}/content/${encodeURIComponent(args.volume)}`;
|
|
3346
|
+
const upid = await getClient().delete(path2);
|
|
3347
|
+
return jsonToolResult({ node: args.node, storage: args.storage, volume: args.volume, upid: upid ?? null });
|
|
3348
|
+
}
|
|
3349
|
+
};
|
|
3350
|
+
}
|
|
3351
|
+
|
|
3352
|
+
// src/tools/proxmox_list_node_services.ts
|
|
3353
|
+
import { Type as Type55 } from "@sinclair/typebox";
|
|
3354
|
+
var Schema52 = Type55.Object(
|
|
3355
|
+
{ node: Type55.String({ minLength: 1, description: "Node to inspect." }) },
|
|
3356
|
+
{ additionalProperties: false }
|
|
3357
|
+
);
|
|
3358
|
+
var NAME49 = "proxmox_list_node_services";
|
|
3359
|
+
function createProxmoxListNodeServicesTool(getClient) {
|
|
3360
|
+
return {
|
|
3361
|
+
name: NAME49,
|
|
3362
|
+
label: "proxmox: list node services",
|
|
3363
|
+
description: "List the Proxmox host's systemd services and their state (GET /nodes/{node}/services): pveproxy, pvedaemon, pve-cluster, corosync, etc. Tier-1 read.",
|
|
3364
|
+
parameters: Schema52,
|
|
3365
|
+
execute: async (_id, raw) => {
|
|
3366
|
+
const args = validateToolArgs(Schema52, raw, NAME49);
|
|
3367
|
+
assertSafePathSegment(args.node, "node");
|
|
3368
|
+
const services = await getClient().get(`/nodes/${args.node}/services`);
|
|
3369
|
+
return jsonToolResult({ node: args.node, count: services.length, services });
|
|
3370
|
+
}
|
|
3371
|
+
};
|
|
3372
|
+
}
|
|
3373
|
+
|
|
3374
|
+
// src/tools/proxmox_list_updates.ts
|
|
3375
|
+
import { Type as Type56 } from "@sinclair/typebox";
|
|
3376
|
+
var Schema53 = Type56.Object(
|
|
3377
|
+
{ node: Type56.String({ minLength: 1, description: "Node to check for pending package updates." }) },
|
|
3378
|
+
{ additionalProperties: false }
|
|
3379
|
+
);
|
|
3380
|
+
var NAME50 = "proxmox_list_updates";
|
|
3381
|
+
function createProxmoxListUpdatesTool(getClient) {
|
|
3382
|
+
return {
|
|
3383
|
+
name: NAME50,
|
|
3384
|
+
label: "proxmox: list updates",
|
|
3385
|
+
description: "List pending APT package updates on a node (GET /nodes/{node}/apt/update): package, current and candidate versions. Read-only; does not refresh the index or install anything. Note: Proxmox gates this endpoint behind the Sys.Modify privilege, so an audit-only token gets 403. Tier-1 read.",
|
|
3386
|
+
parameters: Schema53,
|
|
3387
|
+
execute: async (_id, raw) => {
|
|
3388
|
+
const args = validateToolArgs(Schema53, raw, NAME50);
|
|
3389
|
+
assertSafePathSegment(args.node, "node");
|
|
3390
|
+
const updates = await getClient().get(`/nodes/${args.node}/apt/update`);
|
|
3391
|
+
return jsonToolResult({ node: args.node, count: updates.length, updates });
|
|
3392
|
+
}
|
|
3393
|
+
};
|
|
3394
|
+
}
|
|
3395
|
+
|
|
3396
|
+
// src/tools/proxmox_list_disks.ts
|
|
3397
|
+
import { Type as Type57 } from "@sinclair/typebox";
|
|
3398
|
+
var Schema54 = Type57.Object(
|
|
3399
|
+
{
|
|
3400
|
+
node: Type57.String({ minLength: 1, description: "Node whose physical disks to list." }),
|
|
3401
|
+
include_partitions: Type57.Optional(
|
|
3402
|
+
Type57.Boolean({ description: "Include partitions in the listing (default false)." })
|
|
3403
|
+
)
|
|
3404
|
+
},
|
|
3405
|
+
{ additionalProperties: false }
|
|
3406
|
+
);
|
|
3407
|
+
var NAME51 = "proxmox_list_disks";
|
|
3408
|
+
function createProxmoxListDisksTool(getClient) {
|
|
3409
|
+
return {
|
|
3410
|
+
name: NAME51,
|
|
3411
|
+
label: "proxmox: list disks",
|
|
3412
|
+
description: "List a node's physical disks with model, size, type, SMART health and wearout (GET /nodes/{node}/disks/list). Tier-1 read.",
|
|
3413
|
+
parameters: Schema54,
|
|
3414
|
+
execute: async (_id, raw) => {
|
|
3415
|
+
const args = validateToolArgs(Schema54, raw, NAME51);
|
|
3416
|
+
assertSafePathSegment(args.node, "node");
|
|
3417
|
+
const qs = args.include_partitions ? "?include-partitions=1" : "";
|
|
3418
|
+
const disks = await getClient().get(`/nodes/${args.node}/disks/list${qs}`);
|
|
3419
|
+
return jsonToolResult({ node: args.node, count: disks.length, disks });
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
}
|
|
3423
|
+
|
|
3424
|
+
// src/tools/proxmox_cancel_task.ts
|
|
3425
|
+
import { Type as Type58 } from "@sinclair/typebox";
|
|
3426
|
+
var Schema55 = Type58.Object(
|
|
3427
|
+
{
|
|
3428
|
+
upid: Type58.String({ minLength: 1, description: "UPID of the running task to stop." }),
|
|
3429
|
+
confirm: Type58.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3430
|
+
},
|
|
3431
|
+
{ additionalProperties: false }
|
|
3432
|
+
);
|
|
3433
|
+
var NAME52 = "proxmox_cancel_task";
|
|
3434
|
+
function createProxmoxCancelTaskTool(getClient) {
|
|
3435
|
+
return {
|
|
3436
|
+
name: NAME52,
|
|
3437
|
+
label: "proxmox: cancel task",
|
|
3438
|
+
description: "Stop a running Proxmox task by UPID (DELETE /nodes/{node}/tasks/{upid}) - e.g. abort a stuck migration or backup. The node is parsed from the UPID. Tier-2 write; requires confirm:true.",
|
|
3439
|
+
parameters: Schema55,
|
|
3440
|
+
execute: async (_id, raw) => {
|
|
3441
|
+
assertConfirmedWrite(raw, NAME52);
|
|
3442
|
+
const args = validateToolArgs(Schema55, raw, NAME52);
|
|
3443
|
+
const { node } = parseTaskUpid(args.upid);
|
|
3444
|
+
await getClient().delete(`/nodes/${node}/tasks/${encodeURIComponent(args.upid)}`);
|
|
3445
|
+
return jsonToolResult({ upid: args.upid, node, stopped: true });
|
|
3446
|
+
}
|
|
3447
|
+
};
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
// src/tools/proxmox_node_power.ts
|
|
3451
|
+
import { Type as Type59 } from "@sinclair/typebox";
|
|
3452
|
+
var Schema56 = Type59.Object(
|
|
3453
|
+
{
|
|
3454
|
+
node: Type59.String({ minLength: 1, description: "Node to power-cycle." }),
|
|
3455
|
+
command: Type59.Union([Type59.Literal("reboot"), Type59.Literal("shutdown")], {
|
|
3456
|
+
description: "'reboot' or 'shutdown' the physical/virtual host."
|
|
3457
|
+
}),
|
|
3458
|
+
confirm: Type59.Boolean({ description: "Must be true. Tier-3 destructive gate." }),
|
|
3459
|
+
destructive: Type59.Boolean({ description: "Must be true. Tier-3 destructive gate." })
|
|
3460
|
+
},
|
|
3461
|
+
{ additionalProperties: false }
|
|
3462
|
+
);
|
|
3463
|
+
var NAME53 = "proxmox_node_power";
|
|
3464
|
+
function createProxmoxNodePowerTool(getClient) {
|
|
3465
|
+
return {
|
|
3466
|
+
name: NAME53,
|
|
3467
|
+
label: "proxmox: node power",
|
|
3468
|
+
description: "Reboot or shut down an entire Proxmox node (POST /nodes/{node}/status), which takes down every guest on it. Tier-3 destructive; requires confirm:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
|
|
3469
|
+
parameters: Schema56,
|
|
3470
|
+
execute: async (_id, raw) => {
|
|
3471
|
+
assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME53);
|
|
3472
|
+
assertDestructive(raw, NAME53);
|
|
3473
|
+
const args = validateToolArgs(Schema56, raw, NAME53);
|
|
3474
|
+
assertSafePathSegment(args.node, "node");
|
|
3475
|
+
await getClient().post(`/nodes/${args.node}/status`, { command: args.command });
|
|
3476
|
+
return jsonToolResult({ node: args.node, command: args.command, issued: true });
|
|
3477
|
+
}
|
|
3478
|
+
};
|
|
3479
|
+
}
|
|
3480
|
+
|
|
3481
|
+
// src/tools/proxmox_list_firewall_rules.ts
|
|
3482
|
+
import { Type as Type61 } from "@sinclair/typebox";
|
|
3483
|
+
|
|
3484
|
+
// src/tools/firewall-target.ts
|
|
3485
|
+
import { Type as Type60 } from "@sinclair/typebox";
|
|
3486
|
+
var firewallScopeFields = {
|
|
3487
|
+
scope: Type60.Union(
|
|
3488
|
+
[Type60.Literal("cluster"), Type60.Literal("node"), Type60.Literal("guest")],
|
|
3489
|
+
{ description: "Firewall scope: 'cluster', 'node' (needs node), or 'guest' (needs vmid)." }
|
|
3490
|
+
),
|
|
3491
|
+
node: Type60.Optional(Type60.String({ minLength: 1, description: "Node name (required when scope='node')." })),
|
|
3492
|
+
vmid: Type60.Optional(Type60.Integer({ minimum: 1, description: "Guest VMID (required when scope='guest')." }))
|
|
3493
|
+
};
|
|
3494
|
+
async function resolveFirewallBase(client, args, toolName) {
|
|
3495
|
+
if (args.scope === "cluster") {
|
|
3496
|
+
return { base: "/cluster/firewall", label: "cluster" };
|
|
3497
|
+
}
|
|
3498
|
+
if (args.scope === "node") {
|
|
3499
|
+
if (!args.node) throw new ToolInputError(`${toolName}: node is required when scope='node'`);
|
|
3500
|
+
assertSafePathSegment(args.node, "node");
|
|
3501
|
+
return { base: `/nodes/${args.node}/firewall`, label: `node ${args.node}` };
|
|
3502
|
+
}
|
|
3503
|
+
if (typeof args.vmid !== "number") {
|
|
3504
|
+
throw new ToolInputError(`${toolName}: vmid is required when scope='guest'`);
|
|
3505
|
+
}
|
|
3506
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3507
|
+
return { base: `/nodes/${node}/${type}/${args.vmid}/firewall`, label: `${type} ${args.vmid}` };
|
|
3508
|
+
}
|
|
3509
|
+
|
|
3510
|
+
// src/tools/proxmox_list_firewall_rules.ts
|
|
3511
|
+
var Schema57 = Type61.Object({ ...firewallScopeFields }, { additionalProperties: false });
|
|
3512
|
+
var NAME54 = "proxmox_list_firewall_rules";
|
|
3513
|
+
function createProxmoxListFirewallRulesTool(getClient) {
|
|
3514
|
+
return {
|
|
3515
|
+
name: NAME54,
|
|
3516
|
+
label: "proxmox: list firewall rules",
|
|
3517
|
+
description: "List firewall rules at the cluster, node, or guest scope (GET {base}/firewall/rules). Returns rule position, action, direction, and match fields. Tier-1 read.",
|
|
3518
|
+
parameters: Schema57,
|
|
3519
|
+
execute: async (_id, raw) => {
|
|
3520
|
+
const args = validateToolArgs(Schema57, raw, NAME54);
|
|
3521
|
+
const client = getClient();
|
|
3522
|
+
const { base, label } = await resolveFirewallBase(client, args, NAME54);
|
|
3523
|
+
const rules = await client.get(`${base}/rules`);
|
|
3524
|
+
return jsonToolResult({ scope: label, count: Array.isArray(rules) ? rules.length : 0, rules });
|
|
3525
|
+
}
|
|
3526
|
+
};
|
|
3527
|
+
}
|
|
3528
|
+
|
|
3529
|
+
// src/tools/proxmox_get_firewall_options.ts
|
|
3530
|
+
import { Type as Type62 } from "@sinclair/typebox";
|
|
3531
|
+
var Schema58 = Type62.Object({ ...firewallScopeFields }, { additionalProperties: false });
|
|
3532
|
+
var NAME55 = "proxmox_get_firewall_options";
|
|
3533
|
+
function createProxmoxGetFirewallOptionsTool(getClient) {
|
|
3534
|
+
return {
|
|
3535
|
+
name: NAME55,
|
|
3536
|
+
label: "proxmox: get firewall options",
|
|
3537
|
+
description: "Read firewall options at the cluster, node, or guest scope (GET {base}/firewall/options): whether the firewall is enabled, default in/out policy, logging. Tier-1 read.",
|
|
3538
|
+
parameters: Schema58,
|
|
3539
|
+
execute: async (_id, raw) => {
|
|
3540
|
+
const args = validateToolArgs(Schema58, raw, NAME55);
|
|
3541
|
+
const client = getClient();
|
|
3542
|
+
const { base, label } = await resolveFirewallBase(client, args, NAME55);
|
|
3543
|
+
const options = await client.get(`${base}/options`);
|
|
3544
|
+
return jsonToolResult({ scope: label, options });
|
|
3545
|
+
}
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
|
|
3549
|
+
// src/tools/proxmox_add_firewall_rule.ts
|
|
3550
|
+
import { Type as Type63 } from "@sinclair/typebox";
|
|
3551
|
+
var Schema59 = Type63.Object(
|
|
3552
|
+
{
|
|
3553
|
+
...firewallScopeFields,
|
|
3554
|
+
type: Type63.Union([Type63.Literal("in"), Type63.Literal("out"), Type63.Literal("group")], {
|
|
3555
|
+
description: "Rule direction: 'in', 'out', or 'group' (attach a security group)."
|
|
3556
|
+
}),
|
|
3557
|
+
action: Type63.String({
|
|
3558
|
+
minLength: 1,
|
|
3559
|
+
description: "ACCEPT, DROP, REJECT, or a security-group name when type='group'."
|
|
3560
|
+
}),
|
|
3561
|
+
source: Type63.Optional(Type63.String({ minLength: 1, description: "Source CIDR/IP/alias." })),
|
|
3562
|
+
dest: Type63.Optional(Type63.String({ minLength: 1, description: "Destination CIDR/IP/alias." })),
|
|
3563
|
+
proto: Type63.Optional(Type63.String({ minLength: 1, description: "Protocol, e.g. tcp, udp, icmp." })),
|
|
3564
|
+
dport: Type63.Optional(Type63.String({ minLength: 1, description: "Destination port(s), e.g. '22' or '8000:8100'." })),
|
|
3565
|
+
sport: Type63.Optional(Type63.String({ minLength: 1, description: "Source port(s)." })),
|
|
3566
|
+
macro: Type63.Optional(Type63.String({ minLength: 1, description: "Predefined macro, e.g. 'SSH', 'HTTP'." })),
|
|
3567
|
+
comment: Type63.Optional(Type63.String({ description: "Human-readable comment." })),
|
|
3568
|
+
enable: Type63.Optional(Type63.Boolean({ description: "Whether the rule is active (default true)." })),
|
|
3569
|
+
pos: Type63.Optional(Type63.Integer({ minimum: 0, description: "Insert position (default: prepend at 0)." })),
|
|
3570
|
+
confirm: Type63.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3571
|
+
},
|
|
3572
|
+
{ additionalProperties: false }
|
|
3573
|
+
);
|
|
3574
|
+
var NAME56 = "proxmox_add_firewall_rule";
|
|
3575
|
+
function createProxmoxAddFirewallRuleTool(getClient) {
|
|
3576
|
+
return {
|
|
3577
|
+
name: NAME56,
|
|
3578
|
+
label: "proxmox: add firewall rule",
|
|
3579
|
+
description: "Add a firewall rule at the cluster, node, or guest scope (POST {base}/firewall/rules). Tier-2 write; requires confirm:true.",
|
|
3580
|
+
parameters: Schema59,
|
|
3581
|
+
execute: async (_id, raw) => {
|
|
3582
|
+
assertConfirmedWrite(raw, NAME56);
|
|
3583
|
+
const args = validateToolArgs(Schema59, raw, NAME56);
|
|
3584
|
+
const client = getClient();
|
|
3585
|
+
const { base, label } = await resolveFirewallBase(client, args, NAME56);
|
|
3586
|
+
const body = { type: args.type, action: args.action };
|
|
3587
|
+
for (const k of ["source", "dest", "proto", "dport", "sport", "macro", "comment"]) {
|
|
3588
|
+
const v = args[k];
|
|
3589
|
+
if (typeof v === "string" && v.length > 0) body[k] = v;
|
|
3590
|
+
}
|
|
3591
|
+
body.enable = args.enable === false ? 0 : 1;
|
|
3592
|
+
if (typeof args.pos === "number") body.pos = args.pos;
|
|
3593
|
+
await client.post(`${base}/rules`, body);
|
|
3594
|
+
return jsonToolResult({ scope: label, type: args.type, action: args.action, added: true });
|
|
3595
|
+
}
|
|
3596
|
+
};
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3599
|
+
// src/tools/proxmox_delete_firewall_rule.ts
|
|
3600
|
+
import { Type as Type64 } from "@sinclair/typebox";
|
|
3601
|
+
var Schema60 = Type64.Object(
|
|
3602
|
+
{
|
|
3603
|
+
...firewallScopeFields,
|
|
3604
|
+
pos: Type64.Integer({ minimum: 0, description: "Rule position/index to delete (see list_firewall_rules)." }),
|
|
3605
|
+
digest: Type64.Optional(
|
|
3606
|
+
Type64.String({ minLength: 1, description: "Ruleset digest for optimistic concurrency." })
|
|
3607
|
+
),
|
|
3608
|
+
confirm: Type64.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3609
|
+
},
|
|
3610
|
+
{ additionalProperties: false }
|
|
3611
|
+
);
|
|
3612
|
+
var NAME57 = "proxmox_delete_firewall_rule";
|
|
3613
|
+
function createProxmoxDeleteFirewallRuleTool(getClient) {
|
|
3614
|
+
return {
|
|
3615
|
+
name: NAME57,
|
|
3616
|
+
label: "proxmox: delete firewall rule",
|
|
3617
|
+
description: "Delete a firewall rule by position at the cluster, node, or guest scope (DELETE {base}/firewall/rules/{pos}). Tier-2 write; requires confirm:true.",
|
|
3618
|
+
parameters: Schema60,
|
|
3619
|
+
execute: async (_id, raw) => {
|
|
3620
|
+
assertConfirmedWrite(raw, NAME57);
|
|
3621
|
+
const args = validateToolArgs(Schema60, raw, NAME57);
|
|
3622
|
+
const client = getClient();
|
|
3623
|
+
const { base, label } = await resolveFirewallBase(client, args, NAME57);
|
|
3624
|
+
const qs = args.digest ? `?digest=${encodeURIComponent(args.digest)}` : "";
|
|
3625
|
+
await client.delete(`${base}/rules/${args.pos}${qs}`);
|
|
3626
|
+
return jsonToolResult({ scope: label, pos: args.pos, deleted: true });
|
|
3627
|
+
}
|
|
3628
|
+
};
|
|
3629
|
+
}
|
|
3630
|
+
|
|
3631
|
+
// src/tools/proxmox_set_firewall_enabled.ts
|
|
3632
|
+
import { Type as Type65 } from "@sinclair/typebox";
|
|
3633
|
+
var Schema61 = Type65.Object(
|
|
3634
|
+
{
|
|
3635
|
+
...firewallScopeFields,
|
|
3636
|
+
enable: Type65.Boolean({ description: "Turn the firewall on (true) or off (false) for this scope." }),
|
|
3637
|
+
confirm: Type65.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3638
|
+
},
|
|
3639
|
+
{ additionalProperties: false }
|
|
3640
|
+
);
|
|
3641
|
+
var NAME58 = "proxmox_set_firewall_enabled";
|
|
3642
|
+
function createProxmoxSetFirewallEnabledTool(getClient) {
|
|
3643
|
+
return {
|
|
3644
|
+
name: NAME58,
|
|
3645
|
+
label: "proxmox: set firewall enabled",
|
|
3646
|
+
description: "Enable or disable the firewall at the cluster, node, or guest scope (PUT {base}/firewall/options with enable). Note: the cluster-level switch gates all others. Tier-2 write; requires confirm:true.",
|
|
3647
|
+
parameters: Schema61,
|
|
3648
|
+
execute: async (_id, raw) => {
|
|
3649
|
+
assertConfirmedWrite(raw, NAME58);
|
|
3650
|
+
const args = validateToolArgs(Schema61, raw, NAME58);
|
|
3651
|
+
const client = getClient();
|
|
3652
|
+
const { base, label } = await resolveFirewallBase(client, args, NAME58);
|
|
3653
|
+
await client.put(`${base}/options`, { enable: args.enable ? 1 : 0 });
|
|
3654
|
+
return jsonToolResult({ scope: label, enabled: args.enable });
|
|
3655
|
+
}
|
|
3656
|
+
};
|
|
3657
|
+
}
|
|
3658
|
+
|
|
3659
|
+
// src/tools/proxmox_move_disk.ts
|
|
3660
|
+
import { Type as Type66 } from "@sinclair/typebox";
|
|
3661
|
+
var DISK_KEY_RE2 = /^[a-zA-Z][a-zA-Z0-9_]*$/;
|
|
3662
|
+
var Schema62 = Type66.Object(
|
|
3663
|
+
{
|
|
3664
|
+
vmid: Type66.Integer({ minimum: 1, description: "Container or VM ID." }),
|
|
3665
|
+
disk: Type66.String({
|
|
3666
|
+
minLength: 1,
|
|
3667
|
+
description: "Disk/volume key to move, e.g. 'scsi0' (QEMU) or 'rootfs'/'mp0' (LXC)."
|
|
3668
|
+
}),
|
|
3669
|
+
target_storage: Type66.String({ minLength: 1, description: "Target storage to move the disk onto." }),
|
|
3670
|
+
delete_source: Type66.Optional(
|
|
3671
|
+
Type66.Boolean({ description: "Delete the original disk after a successful move (default false)." })
|
|
3672
|
+
),
|
|
3673
|
+
confirm: Type66.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." }),
|
|
3674
|
+
...taskWaitFields
|
|
3675
|
+
},
|
|
3676
|
+
{ additionalProperties: false }
|
|
3677
|
+
);
|
|
3678
|
+
var NAME59 = "proxmox_move_disk";
|
|
3679
|
+
function createProxmoxMoveDiskTool(getClient) {
|
|
3680
|
+
return {
|
|
3681
|
+
name: NAME59,
|
|
3682
|
+
label: "proxmox: move disk",
|
|
3683
|
+
description: "Relocate a VM disk (POST /nodes/{node}/qemu/{vmid}/move_disk) or container volume (POST /nodes/{node}/lxc/{vmid}/move_volume) to another storage. Optionally deletes the source after a successful copy. Tier-2 write; requires confirm:true.",
|
|
3684
|
+
parameters: Schema62,
|
|
3685
|
+
execute: async (_id, raw) => {
|
|
3686
|
+
assertConfirmedWrite(raw, NAME59);
|
|
3687
|
+
const args = validateToolArgs(Schema62, raw, NAME59);
|
|
3688
|
+
if (!DISK_KEY_RE2.test(args.disk)) {
|
|
3689
|
+
throw new Error(`${NAME59}: invalid disk key "${args.disk}"`);
|
|
3690
|
+
}
|
|
3691
|
+
assertSafePathSegment(args.target_storage, "target_storage");
|
|
3692
|
+
const client = getClient();
|
|
3693
|
+
const { node, type } = await resolveResource(client, args.vmid);
|
|
3694
|
+
const del = args.delete_source === true ? 1 : 0;
|
|
3695
|
+
let upid;
|
|
3696
|
+
if (type === "qemu") {
|
|
3697
|
+
upid = await client.post(`/nodes/${node}/qemu/${args.vmid}/move_disk`, {
|
|
3698
|
+
disk: args.disk,
|
|
3699
|
+
storage: args.target_storage,
|
|
3700
|
+
delete: del
|
|
3701
|
+
});
|
|
3702
|
+
} else {
|
|
3703
|
+
upid = await client.post(`/nodes/${node}/lxc/${args.vmid}/move_volume`, {
|
|
3704
|
+
volume: args.disk,
|
|
3705
|
+
storage: args.target_storage,
|
|
3706
|
+
delete: del
|
|
3707
|
+
});
|
|
3708
|
+
}
|
|
3709
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
3710
|
+
return jsonToolResult({
|
|
3711
|
+
vmid: args.vmid,
|
|
3712
|
+
node,
|
|
3713
|
+
type,
|
|
3714
|
+
disk: args.disk,
|
|
3715
|
+
target_storage: args.target_storage,
|
|
3716
|
+
deleted_source: del === 1,
|
|
3717
|
+
upid,
|
|
3718
|
+
...task ? { task } : {}
|
|
3719
|
+
});
|
|
3720
|
+
}
|
|
3721
|
+
};
|
|
3722
|
+
}
|
|
3723
|
+
|
|
3724
|
+
// src/tools/proxmox_list_storage_config.ts
|
|
3725
|
+
import { Type as Type67 } from "@sinclair/typebox";
|
|
3726
|
+
var Schema63 = Type67.Object({}, { additionalProperties: false });
|
|
3727
|
+
var NAME60 = "proxmox_list_storage_config";
|
|
3728
|
+
function createProxmoxListStorageConfigTool(getClient) {
|
|
3729
|
+
return {
|
|
3730
|
+
name: NAME60,
|
|
3731
|
+
label: "proxmox: list storage config",
|
|
3732
|
+
description: "List datacenter storage definitions (GET /storage): id, type, allowed content, node restrictions, shared/disabled flags. This is the cluster storage configuration, distinct from per-node status. Tier-1 read.",
|
|
3733
|
+
parameters: Schema63,
|
|
3734
|
+
execute: async () => {
|
|
3735
|
+
const defs = await getClient().get("/storage");
|
|
3736
|
+
return jsonToolResult({ count: defs.length, storage: defs });
|
|
3737
|
+
}
|
|
3738
|
+
};
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3741
|
+
// src/tools/proxmox_create_storage.ts
|
|
3742
|
+
import { Type as Type68 } from "@sinclair/typebox";
|
|
3743
|
+
var OPT_KEY_RE = /^[a-zA-Z][a-zA-Z0-9_-]*$/;
|
|
3744
|
+
var Schema64 = Type68.Object(
|
|
3745
|
+
{
|
|
3746
|
+
storage: Type68.String({ minLength: 1, description: "New storage ID." }),
|
|
3747
|
+
type: Type68.Union(
|
|
3748
|
+
[
|
|
3749
|
+
Type68.Literal("dir"),
|
|
3750
|
+
Type68.Literal("nfs"),
|
|
3751
|
+
Type68.Literal("cifs"),
|
|
3752
|
+
Type68.Literal("lvm"),
|
|
3753
|
+
Type68.Literal("lvmthin"),
|
|
3754
|
+
Type68.Literal("zfspool"),
|
|
3755
|
+
Type68.Literal("pbs"),
|
|
3756
|
+
Type68.Literal("cephfs"),
|
|
3757
|
+
Type68.Literal("rbd")
|
|
3758
|
+
],
|
|
3759
|
+
{ description: "Storage backend type." }
|
|
3760
|
+
),
|
|
3761
|
+
content: Type68.Optional(
|
|
3762
|
+
Type68.String({ minLength: 1, description: "Comma-separated content types, e.g. 'images,rootdir' or 'iso,backup,vztmpl'." })
|
|
3763
|
+
),
|
|
3764
|
+
options: Type68.Optional(
|
|
3765
|
+
Type68.Record(Type68.String(), Type68.Union([Type68.String(), Type68.Number(), Type68.Boolean()]), {
|
|
3766
|
+
description: 'Type-specific keys, e.g. {"path":"/mnt/data"} for dir, {"server":"1.2.3.4","export":"/nfs"} for nfs, {"vgname":"pve","thinpool":"data"} for lvmthin.'
|
|
3767
|
+
})
|
|
3768
|
+
),
|
|
3769
|
+
nodes: Type68.Optional(Type68.String({ minLength: 1, description: "Restrict to these nodes (comma-separated)." })),
|
|
3770
|
+
disable: Type68.Optional(Type68.Boolean({ description: "Create the storage in a disabled state." })),
|
|
3771
|
+
confirm: Type68.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3772
|
+
},
|
|
3773
|
+
{ additionalProperties: false }
|
|
3774
|
+
);
|
|
3775
|
+
var NAME61 = "proxmox_create_storage";
|
|
3776
|
+
function createProxmoxCreateStorageTool(getClient) {
|
|
3777
|
+
return {
|
|
3778
|
+
name: NAME61,
|
|
3779
|
+
label: "proxmox: create storage",
|
|
3780
|
+
description: "Define a new datacenter storage (POST /storage) of a given type with content types and type-specific keys via `options`. Tier-2 write; requires confirm:true.",
|
|
3781
|
+
parameters: Schema64,
|
|
3782
|
+
execute: async (_id, raw) => {
|
|
3783
|
+
assertConfirmedWrite(raw, NAME61);
|
|
3784
|
+
const args = validateToolArgs(Schema64, raw, NAME61);
|
|
3785
|
+
assertSafePathSegment(args.storage, "storage");
|
|
3786
|
+
const body = { storage: args.storage, type: args.type };
|
|
3787
|
+
if (args.content) body.content = args.content;
|
|
3788
|
+
if (args.nodes) body.nodes = args.nodes;
|
|
3789
|
+
if (args.disable) body.disable = 1;
|
|
3790
|
+
if (args.options) {
|
|
3791
|
+
for (const [k, v] of Object.entries(args.options)) {
|
|
3792
|
+
if (!OPT_KEY_RE.test(k)) throw new ToolInputError(`${NAME61}: invalid option key "${k}"`);
|
|
3793
|
+
body[k] = typeof v === "boolean" ? v ? 1 : 0 : v;
|
|
3794
|
+
}
|
|
3795
|
+
}
|
|
3796
|
+
await getClient().post(`/storage`, body);
|
|
3797
|
+
return jsonToolResult({ storage: args.storage, type: args.type, created: true });
|
|
3798
|
+
}
|
|
3799
|
+
};
|
|
3800
|
+
}
|
|
3801
|
+
|
|
3802
|
+
// src/tools/proxmox_delete_storage.ts
|
|
3803
|
+
import { Type as Type69 } from "@sinclair/typebox";
|
|
3804
|
+
var Schema65 = Type69.Object(
|
|
3805
|
+
{
|
|
3806
|
+
storage: Type69.String({ minLength: 1, description: "Storage ID to remove from the datacenter config." }),
|
|
3807
|
+
confirm: Type69.Boolean({ description: "Must be true. Tier-3 destructive gate." }),
|
|
3808
|
+
destructive: Type69.Boolean({ description: "Must be true. Tier-3 destructive gate." })
|
|
3809
|
+
},
|
|
3810
|
+
{ additionalProperties: false }
|
|
3811
|
+
);
|
|
3812
|
+
var NAME62 = "proxmox_delete_storage";
|
|
3813
|
+
function createProxmoxDeleteStorageTool(getClient) {
|
|
3814
|
+
return {
|
|
3815
|
+
name: NAME62,
|
|
3816
|
+
label: "proxmox: delete storage",
|
|
3817
|
+
description: "Remove a storage definition from the datacenter config (DELETE /storage/{id}). Does not erase the underlying data, but detaches it from Proxmox. Tier-3 destructive; requires confirm:true, destructive:true, and env PROXMOX_ENABLE_DESTRUCTIVE=1.",
|
|
3818
|
+
parameters: Schema65,
|
|
3819
|
+
execute: async (_id, raw) => {
|
|
3820
|
+
assertEnvFlag("PROXMOX_ENABLE_DESTRUCTIVE", NAME62);
|
|
3821
|
+
assertDestructive(raw, NAME62);
|
|
3822
|
+
const args = validateToolArgs(Schema65, raw, NAME62);
|
|
3823
|
+
assertSafePathSegment(args.storage, "storage");
|
|
3824
|
+
await getClient().delete(`/storage/${args.storage}`);
|
|
3825
|
+
return jsonToolResult({ storage: args.storage, deleted: true });
|
|
3826
|
+
}
|
|
3827
|
+
};
|
|
3828
|
+
}
|
|
3829
|
+
|
|
3830
|
+
// src/tools/proxmox_list_backup_jobs.ts
|
|
3831
|
+
import { Type as Type70 } from "@sinclair/typebox";
|
|
3832
|
+
var Schema66 = Type70.Object({}, { additionalProperties: false });
|
|
3833
|
+
var NAME63 = "proxmox_list_backup_jobs";
|
|
3834
|
+
function createProxmoxListBackupJobsTool(getClient) {
|
|
3835
|
+
return {
|
|
3836
|
+
name: NAME63,
|
|
3837
|
+
label: "proxmox: list backup jobs",
|
|
3838
|
+
description: "List scheduled backup (vzdump) jobs (GET /cluster/backup): id, schedule, target storage, selection, and enabled state. Tier-1 read.",
|
|
3839
|
+
parameters: Schema66,
|
|
3840
|
+
execute: async () => {
|
|
3841
|
+
const jobs = await getClient().get("/cluster/backup");
|
|
3842
|
+
return jsonToolResult({ count: jobs.length, jobs });
|
|
3843
|
+
}
|
|
3844
|
+
};
|
|
3845
|
+
}
|
|
3846
|
+
|
|
3847
|
+
// src/tools/proxmox_create_backup_job.ts
|
|
3848
|
+
import { Type as Type71 } from "@sinclair/typebox";
|
|
3849
|
+
var Schema67 = Type71.Object(
|
|
3850
|
+
{
|
|
3851
|
+
schedule: Type71.String({ minLength: 1, description: "Systemd-calendar schedule, e.g. '02:00' or 'mon..fri 21:00'." }),
|
|
3852
|
+
storage: Type71.String({ minLength: 1, description: "Target storage for the backups." }),
|
|
3853
|
+
all: Type71.Optional(Type71.Boolean({ description: "Back up all guests. Mutually exclusive with vmid/pool." })),
|
|
3854
|
+
vmid: Type71.Optional(Type71.String({ minLength: 1, description: "Comma-separated VMIDs to back up." })),
|
|
3855
|
+
pool: Type71.Optional(Type71.String({ minLength: 1, description: "Back up all guests in this pool." })),
|
|
3856
|
+
mode: Type71.Optional(
|
|
3857
|
+
Type71.Union([Type71.Literal("snapshot"), Type71.Literal("suspend"), Type71.Literal("stop")], {
|
|
3858
|
+
description: "Backup mode (default snapshot)."
|
|
3859
|
+
})
|
|
3860
|
+
),
|
|
3861
|
+
compress: Type71.Optional(
|
|
3862
|
+
Type71.Union([Type71.Literal("zstd"), Type71.Literal("gzip"), Type71.Literal("lzo"), Type71.Literal("0")], {
|
|
3863
|
+
description: "Compression (default zstd)."
|
|
3864
|
+
})
|
|
3865
|
+
),
|
|
3866
|
+
enabled: Type71.Optional(Type71.Boolean({ description: "Whether the job is active (default true)." })),
|
|
3867
|
+
mailto: Type71.Optional(Type71.String({ minLength: 1, description: "Email address for notifications." })),
|
|
3868
|
+
comment: Type71.Optional(Type71.String({ description: "Job comment/description." })),
|
|
3869
|
+
confirm: Type71.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3870
|
+
},
|
|
3871
|
+
{ additionalProperties: false }
|
|
3872
|
+
);
|
|
3873
|
+
var NAME64 = "proxmox_create_backup_job";
|
|
3874
|
+
function createProxmoxCreateBackupJobTool(getClient) {
|
|
3875
|
+
return {
|
|
3876
|
+
name: NAME64,
|
|
3877
|
+
label: "proxmox: create backup job",
|
|
3878
|
+
description: "Create a scheduled backup (vzdump) job (POST /cluster/backup). Specify a schedule + storage and a selection (all, vmid list, or pool). Tier-2 write; requires confirm:true.",
|
|
3879
|
+
parameters: Schema67,
|
|
3880
|
+
execute: async (_id, raw) => {
|
|
3881
|
+
assertConfirmedWrite(raw, NAME64);
|
|
3882
|
+
const args = validateToolArgs(Schema67, raw, NAME64);
|
|
3883
|
+
const selectors = [args.all ? "all" : null, args.vmid ? "vmid" : null, args.pool ? "pool" : null].filter(Boolean);
|
|
3884
|
+
if (selectors.length === 0) {
|
|
3885
|
+
throw new ToolInputError(`${NAME64}: provide exactly one selection - all, vmid, or pool.`);
|
|
3886
|
+
}
|
|
3887
|
+
if (selectors.length > 1) {
|
|
3888
|
+
throw new ToolInputError(`${NAME64}: selection is exclusive - pass only one of all/vmid/pool.`);
|
|
3889
|
+
}
|
|
3890
|
+
const body = {
|
|
3891
|
+
schedule: args.schedule,
|
|
3892
|
+
storage: args.storage,
|
|
3893
|
+
mode: args.mode ?? "snapshot",
|
|
3894
|
+
compress: args.compress ?? "zstd",
|
|
3895
|
+
enabled: args.enabled === false ? 0 : 1
|
|
3896
|
+
};
|
|
3897
|
+
if (args.all) body.all = 1;
|
|
3898
|
+
if (args.vmid) body.vmid = args.vmid;
|
|
3899
|
+
if (args.pool) body.pool = args.pool;
|
|
3900
|
+
if (args.mailto) body.mailto = args.mailto;
|
|
3901
|
+
if (typeof args.comment === "string" && args.comment.length > 0) body.comment = args.comment;
|
|
3902
|
+
await getClient().post(`/cluster/backup`, body);
|
|
3903
|
+
return jsonToolResult({ schedule: args.schedule, storage: args.storage, created: true });
|
|
3904
|
+
}
|
|
3905
|
+
};
|
|
3906
|
+
}
|
|
3907
|
+
|
|
3908
|
+
// src/tools/proxmox_delete_backup_job.ts
|
|
3909
|
+
import { Type as Type72 } from "@sinclair/typebox";
|
|
3910
|
+
var Schema68 = Type72.Object(
|
|
3911
|
+
{
|
|
3912
|
+
id: Type72.String({ minLength: 1, description: "Backup job ID (from proxmox_list_backup_jobs)." }),
|
|
3913
|
+
confirm: Type72.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
3914
|
+
},
|
|
3915
|
+
{ additionalProperties: false }
|
|
3916
|
+
);
|
|
3917
|
+
var NAME65 = "proxmox_delete_backup_job";
|
|
3918
|
+
function createProxmoxDeleteBackupJobTool(getClient) {
|
|
3919
|
+
return {
|
|
3920
|
+
name: NAME65,
|
|
3921
|
+
label: "proxmox: delete backup job",
|
|
3922
|
+
description: "Delete a scheduled backup job by id (DELETE /cluster/backup/{id}). Removes the schedule only; existing backup archives are untouched. Tier-2 write; requires confirm:true.",
|
|
3923
|
+
parameters: Schema68,
|
|
3924
|
+
execute: async (_id, raw) => {
|
|
3925
|
+
assertConfirmedWrite(raw, NAME65);
|
|
3926
|
+
const args = validateToolArgs(Schema68, raw, NAME65);
|
|
3927
|
+
assertSafePathSegment(args.id, "id");
|
|
3928
|
+
await getClient().delete(`/cluster/backup/${args.id}`);
|
|
3929
|
+
return jsonToolResult({ id: args.id, deleted: true });
|
|
3930
|
+
}
|
|
3931
|
+
};
|
|
3932
|
+
}
|
|
3933
|
+
|
|
3934
|
+
// src/tools/proxmox_list_users.ts
|
|
3935
|
+
import { Type as Type73 } from "@sinclair/typebox";
|
|
3936
|
+
var Schema69 = Type73.Object({}, { additionalProperties: false });
|
|
3937
|
+
var NAME66 = "proxmox_list_users";
|
|
3938
|
+
function createProxmoxListUsersTool(getClient) {
|
|
3939
|
+
return {
|
|
3940
|
+
name: NAME66,
|
|
3941
|
+
label: "proxmox: list users",
|
|
3942
|
+
description: "List Proxmox access users (GET /access/users): userid, realm, enabled/expire state, comment. Tier-1 read.",
|
|
3943
|
+
parameters: Schema69,
|
|
3944
|
+
execute: async () => {
|
|
3945
|
+
const users = await getClient().get("/access/users");
|
|
3946
|
+
return jsonToolResult({ count: users.length, users });
|
|
3947
|
+
}
|
|
3948
|
+
};
|
|
3949
|
+
}
|
|
3950
|
+
|
|
3951
|
+
// src/tools/proxmox_list_roles.ts
|
|
3952
|
+
import { Type as Type74 } from "@sinclair/typebox";
|
|
3953
|
+
var Schema70 = Type74.Object({}, { additionalProperties: false });
|
|
3954
|
+
var NAME67 = "proxmox_list_roles";
|
|
3955
|
+
function createProxmoxListRolesTool(getClient) {
|
|
3956
|
+
return {
|
|
3957
|
+
name: NAME67,
|
|
3958
|
+
label: "proxmox: list roles",
|
|
3959
|
+
description: "List Proxmox roles and their privileges (GET /access/roles). Tier-1 read.",
|
|
3960
|
+
parameters: Schema70,
|
|
3961
|
+
execute: async () => {
|
|
3962
|
+
const roles = await getClient().get("/access/roles");
|
|
3963
|
+
return jsonToolResult({ count: roles.length, roles });
|
|
3964
|
+
}
|
|
3965
|
+
};
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
// src/tools/proxmox_list_acl.ts
|
|
3969
|
+
import { Type as Type75 } from "@sinclair/typebox";
|
|
3970
|
+
var Schema71 = Type75.Object({}, { additionalProperties: false });
|
|
3971
|
+
var NAME68 = "proxmox_list_acl";
|
|
3972
|
+
function createProxmoxListAclTool(getClient) {
|
|
3973
|
+
return {
|
|
3974
|
+
name: NAME68,
|
|
3975
|
+
label: "proxmox: list ACL",
|
|
3976
|
+
description: "List access-control entries (GET /access/acl): which user/group/token holds which role on which path, and whether it propagates. Tier-1 read.",
|
|
3977
|
+
parameters: Schema71,
|
|
3978
|
+
execute: async () => {
|
|
3979
|
+
const acl = await getClient().get("/access/acl");
|
|
3980
|
+
return jsonToolResult({ count: acl.length, acl });
|
|
3981
|
+
}
|
|
3982
|
+
};
|
|
3983
|
+
}
|
|
3984
|
+
|
|
3985
|
+
// src/tools/proxmox_list_pools.ts
|
|
3986
|
+
import { Type as Type76 } from "@sinclair/typebox";
|
|
3987
|
+
var Schema72 = Type76.Object({}, { additionalProperties: false });
|
|
3988
|
+
var NAME69 = "proxmox_list_pools";
|
|
3989
|
+
function createProxmoxListPoolsTool(getClient) {
|
|
3990
|
+
return {
|
|
3991
|
+
name: NAME69,
|
|
3992
|
+
label: "proxmox: list pools",
|
|
3993
|
+
description: "List all resource pools (GET /pools) with their comments. Use proxmox_list_pool_resources for a pool's members. Tier-1 read.",
|
|
3994
|
+
parameters: Schema72,
|
|
3995
|
+
execute: async () => {
|
|
3996
|
+
const pools = await getClient().get("/pools");
|
|
3997
|
+
return jsonToolResult({ count: pools.length, pools });
|
|
3998
|
+
}
|
|
3999
|
+
};
|
|
4000
|
+
}
|
|
4001
|
+
|
|
4002
|
+
// src/tools/proxmox_list_tokens.ts
|
|
4003
|
+
import { Type as Type77 } from "@sinclair/typebox";
|
|
4004
|
+
var USERID_RE = /^[\w.+-]+@[\w.-]+$/;
|
|
4005
|
+
var Schema73 = Type77.Object(
|
|
4006
|
+
{ userid: Type77.String({ minLength: 1, description: "User to list API tokens for, e.g. 'root@pam'." }) },
|
|
4007
|
+
{ additionalProperties: false }
|
|
4008
|
+
);
|
|
4009
|
+
var NAME70 = "proxmox_list_tokens";
|
|
4010
|
+
function createProxmoxListTokensTool(getClient) {
|
|
4011
|
+
return {
|
|
4012
|
+
name: NAME70,
|
|
4013
|
+
label: "proxmox: list tokens",
|
|
4014
|
+
description: "List API tokens for a user (GET /access/users/{userid}/token). Secrets are never returned by Proxmox after creation. Tier-1 read.",
|
|
4015
|
+
parameters: Schema73,
|
|
4016
|
+
execute: async (_id, raw) => {
|
|
4017
|
+
const args = validateToolArgs(Schema73, raw, NAME70);
|
|
4018
|
+
if (!USERID_RE.test(args.userid)) throw new ToolInputError(`${NAME70}: invalid userid "${args.userid}"`);
|
|
4019
|
+
const tokens = await getClient().get(`/access/users/${encodeURIComponent(args.userid)}/token`);
|
|
4020
|
+
return jsonToolResult({ userid: args.userid, count: tokens.length, tokens });
|
|
4021
|
+
}
|
|
4022
|
+
};
|
|
4023
|
+
}
|
|
4024
|
+
|
|
4025
|
+
// src/tools/proxmox_set_acl.ts
|
|
4026
|
+
import { Type as Type78 } from "@sinclair/typebox";
|
|
4027
|
+
var ACL_PATH_RE = /^\/[\w./-]*$/;
|
|
4028
|
+
var ROLE_RE = /^[A-Za-z][\w.-]*$/;
|
|
4029
|
+
var UGID_RE = /^[\w.+-]+(@[\w.-]+)?(![\w.-]+)?$/;
|
|
4030
|
+
var Schema74 = Type78.Object(
|
|
4031
|
+
{
|
|
4032
|
+
path: Type78.String({ minLength: 1, description: "ACL path, e.g. '/vms/100', '/pool/team', '/storage/local', '/'." }),
|
|
4033
|
+
roles: Type78.String({ minLength: 1, description: "Role name(s), comma-separated, e.g. 'PVEVMAdmin'." }),
|
|
4034
|
+
userid: Type78.Optional(Type78.String({ minLength: 1, description: "User or token to grant, e.g. 'bob@pve' or 'bob@pve!ci'." })),
|
|
4035
|
+
group: Type78.Optional(Type78.String({ minLength: 1, description: "Group to grant." })),
|
|
4036
|
+
propagate: Type78.Optional(Type78.Boolean({ description: "Propagate to child paths (default true)." })),
|
|
4037
|
+
remove: Type78.Optional(Type78.Boolean({ description: "Remove the ACL instead of adding it." })),
|
|
4038
|
+
confirm: Type78.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4039
|
+
},
|
|
4040
|
+
{ additionalProperties: false }
|
|
4041
|
+
);
|
|
4042
|
+
var NAME71 = "proxmox_set_acl";
|
|
4043
|
+
function createProxmoxSetAclTool(getClient) {
|
|
4044
|
+
return {
|
|
4045
|
+
name: NAME71,
|
|
4046
|
+
label: "proxmox: set ACL",
|
|
4047
|
+
description: "Grant or remove a role for a user/token or group on a path (PUT /access/acl). Set remove:true to revoke. Tier-2 write; requires confirm:true.",
|
|
4048
|
+
parameters: Schema74,
|
|
4049
|
+
execute: async (_id, raw) => {
|
|
4050
|
+
assertConfirmedWrite(raw, NAME71);
|
|
4051
|
+
const args = validateToolArgs(Schema74, raw, NAME71);
|
|
4052
|
+
if (!ACL_PATH_RE.test(args.path)) throw new ToolInputError(`${NAME71}: invalid path "${args.path}"`);
|
|
4053
|
+
for (const r of args.roles.split(",")) {
|
|
4054
|
+
if (!ROLE_RE.test(r.trim())) throw new ToolInputError(`${NAME71}: invalid role "${r}"`);
|
|
4055
|
+
}
|
|
4056
|
+
if (!args.userid && !args.group) {
|
|
4057
|
+
throw new ToolInputError(`${NAME71}: provide userid or group.`);
|
|
4058
|
+
}
|
|
4059
|
+
const body = { path: args.path, roles: args.roles };
|
|
4060
|
+
if (args.userid) {
|
|
4061
|
+
if (!UGID_RE.test(args.userid)) throw new ToolInputError(`${NAME71}: invalid userid "${args.userid}"`);
|
|
4062
|
+
if (args.userid.includes("!")) body.tokens = args.userid;
|
|
4063
|
+
else body.users = args.userid;
|
|
4064
|
+
}
|
|
4065
|
+
if (args.group) body.groups = args.group;
|
|
4066
|
+
body.propagate = args.propagate === false ? 0 : 1;
|
|
4067
|
+
if (args.remove === true) body.delete = 1;
|
|
4068
|
+
await getClient().put(`/access/acl`, body);
|
|
4069
|
+
return jsonToolResult({
|
|
4070
|
+
path: args.path,
|
|
4071
|
+
roles: args.roles,
|
|
4072
|
+
userid: args.userid,
|
|
4073
|
+
group: args.group,
|
|
4074
|
+
removed: args.remove === true
|
|
4075
|
+
});
|
|
4076
|
+
}
|
|
4077
|
+
};
|
|
4078
|
+
}
|
|
4079
|
+
|
|
4080
|
+
// src/tools/proxmox_create_token.ts
|
|
4081
|
+
import { Type as Type79 } from "@sinclair/typebox";
|
|
4082
|
+
var TOKENID_RE = /^[\w.-]+$/;
|
|
4083
|
+
var Schema75 = Type79.Object(
|
|
4084
|
+
{
|
|
4085
|
+
userid: Type79.String({ minLength: 1, description: "Owning user, e.g. 'automation@pve'." }),
|
|
4086
|
+
tokenid: Type79.String({ minLength: 1, description: "New token name (the part after '!')." }),
|
|
4087
|
+
comment: Type79.Optional(Type79.String({ description: "Token comment." })),
|
|
4088
|
+
privsep: Type79.Optional(
|
|
4089
|
+
Type79.Boolean({ description: "Privilege separation (default true): the token gets only ACLs granted to it directly." })
|
|
4090
|
+
),
|
|
4091
|
+
expire: Type79.Optional(Type79.Integer({ minimum: 0, description: "Expiry as a Unix timestamp (0 = never)." })),
|
|
4092
|
+
confirm: Type79.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4093
|
+
},
|
|
4094
|
+
{ additionalProperties: false }
|
|
4095
|
+
);
|
|
4096
|
+
var NAME72 = "proxmox_create_token";
|
|
4097
|
+
function createProxmoxCreateTokenTool(getClient) {
|
|
4098
|
+
return {
|
|
4099
|
+
name: NAME72,
|
|
4100
|
+
label: "proxmox: create token",
|
|
4101
|
+
description: "Create an API token for a user (POST /access/users/{userid}/token/{tokenid}). Returns the secret ONCE - it cannot be retrieved later. With privsep (default), grant it access separately via proxmox_set_acl. Tier-2 write; requires confirm:true.",
|
|
4102
|
+
parameters: Schema75,
|
|
4103
|
+
execute: async (_id, raw) => {
|
|
4104
|
+
assertConfirmedWrite(raw, NAME72);
|
|
4105
|
+
const args = validateToolArgs(Schema75, raw, NAME72);
|
|
4106
|
+
if (!USERID_RE.test(args.userid)) throw new ToolInputError(`${NAME72}: invalid userid "${args.userid}"`);
|
|
4107
|
+
if (!TOKENID_RE.test(args.tokenid)) throw new ToolInputError(`${NAME72}: invalid tokenid "${args.tokenid}"`);
|
|
4108
|
+
const body = { privsep: args.privsep === false ? 0 : 1 };
|
|
4109
|
+
if (typeof args.comment === "string" && args.comment.length > 0) body.comment = args.comment;
|
|
4110
|
+
if (typeof args.expire === "number") body.expire = args.expire;
|
|
4111
|
+
const res = await getClient().post(
|
|
4112
|
+
`/access/users/${encodeURIComponent(args.userid)}/token/${encodeURIComponent(args.tokenid)}`,
|
|
4113
|
+
body
|
|
4114
|
+
);
|
|
4115
|
+
return jsonToolResult({
|
|
4116
|
+
userid: args.userid,
|
|
4117
|
+
tokenid: args.tokenid,
|
|
4118
|
+
full_tokenid: res?.["full-tokenid"] ?? `${args.userid}!${args.tokenid}`,
|
|
4119
|
+
secret: res?.value ?? null,
|
|
4120
|
+
note: "Store the secret now; Proxmox will not show it again."
|
|
4121
|
+
});
|
|
4122
|
+
}
|
|
4123
|
+
};
|
|
4124
|
+
}
|
|
4125
|
+
|
|
4126
|
+
// src/tools/proxmox_delete_token.ts
|
|
4127
|
+
import { Type as Type80 } from "@sinclair/typebox";
|
|
4128
|
+
var TOKENID_RE2 = /^[\w.-]+$/;
|
|
4129
|
+
var Schema76 = Type80.Object(
|
|
4130
|
+
{
|
|
4131
|
+
userid: Type80.String({ minLength: 1, description: "Owning user, e.g. 'automation@pve'." }),
|
|
4132
|
+
tokenid: Type80.String({ minLength: 1, description: "Token name to revoke (the part after '!')." }),
|
|
4133
|
+
confirm: Type80.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4134
|
+
},
|
|
4135
|
+
{ additionalProperties: false }
|
|
4136
|
+
);
|
|
4137
|
+
var NAME73 = "proxmox_delete_token";
|
|
4138
|
+
function createProxmoxDeleteTokenTool(getClient) {
|
|
4139
|
+
return {
|
|
4140
|
+
name: NAME73,
|
|
4141
|
+
label: "proxmox: delete token",
|
|
4142
|
+
description: "Revoke an API token (DELETE /access/users/{userid}/token/{tokenid}). Immediately invalidates the token. Tier-2 write; requires confirm:true.",
|
|
4143
|
+
parameters: Schema76,
|
|
4144
|
+
execute: async (_id, raw) => {
|
|
4145
|
+
assertConfirmedWrite(raw, NAME73);
|
|
4146
|
+
const args = validateToolArgs(Schema76, raw, NAME73);
|
|
4147
|
+
if (!USERID_RE.test(args.userid)) throw new ToolInputError(`${NAME73}: invalid userid "${args.userid}"`);
|
|
4148
|
+
if (!TOKENID_RE2.test(args.tokenid)) throw new ToolInputError(`${NAME73}: invalid tokenid "${args.tokenid}"`);
|
|
4149
|
+
await getClient().delete(
|
|
4150
|
+
`/access/users/${encodeURIComponent(args.userid)}/token/${encodeURIComponent(args.tokenid)}`
|
|
4151
|
+
);
|
|
4152
|
+
return jsonToolResult({ userid: args.userid, tokenid: args.tokenid, deleted: true });
|
|
4153
|
+
}
|
|
4154
|
+
};
|
|
4155
|
+
}
|
|
4156
|
+
|
|
4157
|
+
// src/tools/proxmox_create_pool.ts
|
|
4158
|
+
import { Type as Type81 } from "@sinclair/typebox";
|
|
4159
|
+
var Schema77 = Type81.Object(
|
|
4160
|
+
{
|
|
4161
|
+
poolid: Type81.String({ minLength: 1, description: "New pool ID." }),
|
|
4162
|
+
comment: Type81.Optional(Type81.String({ description: "Pool comment/description." })),
|
|
4163
|
+
confirm: Type81.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4164
|
+
},
|
|
4165
|
+
{ additionalProperties: false }
|
|
4166
|
+
);
|
|
4167
|
+
var NAME74 = "proxmox_create_pool";
|
|
4168
|
+
function createProxmoxCreatePoolTool(getClient) {
|
|
4169
|
+
return {
|
|
4170
|
+
name: NAME74,
|
|
4171
|
+
label: "proxmox: create pool",
|
|
4172
|
+
description: "Create a resource pool (POST /pools). Add guests/storage to it with proxmox_update_pool. Tier-2 write; requires confirm:true.",
|
|
4173
|
+
parameters: Schema77,
|
|
4174
|
+
execute: async (_id, raw) => {
|
|
4175
|
+
assertConfirmedWrite(raw, NAME74);
|
|
4176
|
+
const args = validateToolArgs(Schema77, raw, NAME74);
|
|
4177
|
+
assertSafePathSegment(args.poolid, "poolid");
|
|
4178
|
+
const body = { poolid: args.poolid };
|
|
4179
|
+
if (typeof args.comment === "string" && args.comment.length > 0) body.comment = args.comment;
|
|
4180
|
+
await getClient().post(`/pools`, body);
|
|
4181
|
+
return jsonToolResult({ poolid: args.poolid, created: true });
|
|
4182
|
+
}
|
|
4183
|
+
};
|
|
4184
|
+
}
|
|
4185
|
+
|
|
4186
|
+
// src/tools/proxmox_update_pool.ts
|
|
4187
|
+
import { Type as Type82 } from "@sinclair/typebox";
|
|
4188
|
+
var VMID_LIST_RE = /^\d+(,\d+)*$/;
|
|
4189
|
+
var Schema78 = Type82.Object(
|
|
4190
|
+
{
|
|
4191
|
+
poolid: Type82.String({ minLength: 1, description: "Pool to modify." }),
|
|
4192
|
+
vms: Type82.Optional(Type82.String({ minLength: 1, description: "Comma-separated VMIDs to add (or remove with remove:true)." })),
|
|
4193
|
+
storage: Type82.Optional(Type82.String({ minLength: 1, description: "Comma-separated storage IDs to add/remove." })),
|
|
4194
|
+
comment: Type82.Optional(Type82.String({ description: "Update the pool comment." })),
|
|
4195
|
+
remove: Type82.Optional(Type82.Boolean({ description: "Remove the listed members instead of adding them." })),
|
|
4196
|
+
confirm: Type82.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4197
|
+
},
|
|
4198
|
+
{ additionalProperties: false }
|
|
4199
|
+
);
|
|
4200
|
+
var NAME75 = "proxmox_update_pool";
|
|
4201
|
+
function createProxmoxUpdatePoolTool(getClient) {
|
|
4202
|
+
return {
|
|
4203
|
+
name: NAME75,
|
|
4204
|
+
label: "proxmox: update pool",
|
|
4205
|
+
description: "Add or remove guests/storage in a resource pool, or update its comment (PUT /pools/{poolid}). Set remove:true to detach the listed members. Tier-2 write; requires confirm:true.",
|
|
4206
|
+
parameters: Schema78,
|
|
4207
|
+
execute: async (_id, raw) => {
|
|
4208
|
+
assertConfirmedWrite(raw, NAME75);
|
|
4209
|
+
const args = validateToolArgs(Schema78, raw, NAME75);
|
|
4210
|
+
assertSafePathSegment(args.poolid, "poolid");
|
|
4211
|
+
if (args.vms && !VMID_LIST_RE.test(args.vms)) {
|
|
4212
|
+
throw new ToolInputError(`${NAME75}: vms must be a comma-separated list of numeric VMIDs`);
|
|
4213
|
+
}
|
|
4214
|
+
if (!args.vms && !args.storage && typeof args.comment !== "string") {
|
|
4215
|
+
throw new ToolInputError(`${NAME75}: provide vms, storage, or comment to change.`);
|
|
4216
|
+
}
|
|
4217
|
+
const body = {};
|
|
4218
|
+
if (args.vms) body.vms = args.vms;
|
|
4219
|
+
if (args.storage) body.storage = args.storage;
|
|
4220
|
+
if (typeof args.comment === "string") body.comment = args.comment;
|
|
4221
|
+
if (args.remove === true) body.delete = 1;
|
|
4222
|
+
await getClient().put(`/pools/${args.poolid}`, body);
|
|
4223
|
+
return jsonToolResult({
|
|
4224
|
+
poolid: args.poolid,
|
|
4225
|
+
vms: args.vms,
|
|
4226
|
+
storage: args.storage,
|
|
4227
|
+
removed: args.remove === true
|
|
4228
|
+
});
|
|
4229
|
+
}
|
|
4230
|
+
};
|
|
4231
|
+
}
|
|
4232
|
+
|
|
4233
|
+
// src/tools/proxmox_delete_pool.ts
|
|
4234
|
+
import { Type as Type83 } from "@sinclair/typebox";
|
|
4235
|
+
var Schema79 = Type83.Object(
|
|
4236
|
+
{
|
|
4237
|
+
poolid: Type83.String({ minLength: 1, description: "Pool to delete (must be empty)." }),
|
|
4238
|
+
confirm: Type83.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4239
|
+
},
|
|
4240
|
+
{ additionalProperties: false }
|
|
4241
|
+
);
|
|
4242
|
+
var NAME76 = "proxmox_delete_pool";
|
|
4243
|
+
function createProxmoxDeletePoolTool(getClient) {
|
|
4244
|
+
return {
|
|
4245
|
+
name: NAME76,
|
|
4246
|
+
label: "proxmox: delete pool",
|
|
4247
|
+
description: "Delete a resource pool (DELETE /pools/{poolid}). Proxmox requires the pool to be empty first; guests/storage are not deleted, only the grouping. Tier-2 write; requires confirm:true.",
|
|
4248
|
+
parameters: Schema79,
|
|
4249
|
+
execute: async (_id, raw) => {
|
|
4250
|
+
assertConfirmedWrite(raw, NAME76);
|
|
4251
|
+
const args = validateToolArgs(Schema79, raw, NAME76);
|
|
4252
|
+
assertSafePathSegment(args.poolid, "poolid");
|
|
4253
|
+
await getClient().delete(`/pools/${args.poolid}`);
|
|
4254
|
+
return jsonToolResult({ poolid: args.poolid, deleted: true });
|
|
4255
|
+
}
|
|
4256
|
+
};
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4259
|
+
// src/tools/proxmox_cluster_status.ts
|
|
4260
|
+
import { Type as Type84 } from "@sinclair/typebox";
|
|
4261
|
+
var Schema80 = Type84.Object({}, { additionalProperties: false });
|
|
4262
|
+
var NAME77 = "proxmox_cluster_status";
|
|
4263
|
+
function createProxmoxClusterStatusTool(getClient) {
|
|
4264
|
+
return {
|
|
4265
|
+
name: NAME77,
|
|
4266
|
+
label: "proxmox: cluster status",
|
|
4267
|
+
description: "Cluster membership + quorum: each node's id, IP, online state, and (on a cluster) the quorate flag. (GET /cluster/status). Tier-1 read.",
|
|
4268
|
+
parameters: Schema80,
|
|
4269
|
+
execute: async () => {
|
|
4270
|
+
const items = await getClient().get("/cluster/status");
|
|
4271
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4272
|
+
return jsonToolResult({ count: list.length, nodes: list });
|
|
4273
|
+
}
|
|
4274
|
+
};
|
|
4275
|
+
}
|
|
4276
|
+
|
|
4277
|
+
// src/tools/proxmox_ha_status.ts
|
|
4278
|
+
import { Type as Type85 } from "@sinclair/typebox";
|
|
4279
|
+
var Schema81 = Type85.Object({}, { additionalProperties: false });
|
|
4280
|
+
var NAME78 = "proxmox_ha_status";
|
|
4281
|
+
function createProxmoxHaStatusTool(getClient) {
|
|
4282
|
+
return {
|
|
4283
|
+
name: NAME78,
|
|
4284
|
+
label: "proxmox: HA status",
|
|
4285
|
+
description: "Current HA manager status: quorum, fencing/CRM state, and per-resource HA state. (GET /cluster/ha/status/current). Tier-1 read.",
|
|
4286
|
+
parameters: Schema81,
|
|
4287
|
+
execute: async () => {
|
|
4288
|
+
const items = await getClient().get("/cluster/ha/status/current");
|
|
4289
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4290
|
+
return jsonToolResult({ count: list.length, entries: list });
|
|
4291
|
+
}
|
|
4292
|
+
};
|
|
4293
|
+
}
|
|
4294
|
+
|
|
4295
|
+
// src/tools/proxmox_list_ha_resources.ts
|
|
4296
|
+
import { Type as Type86 } from "@sinclair/typebox";
|
|
4297
|
+
var Schema82 = Type86.Object({}, { additionalProperties: false });
|
|
4298
|
+
var NAME79 = "proxmox_list_ha_resources";
|
|
4299
|
+
function createProxmoxListHaResourcesTool(getClient) {
|
|
4300
|
+
return {
|
|
4301
|
+
name: NAME79,
|
|
4302
|
+
label: "proxmox: list HA resources",
|
|
4303
|
+
description: "HA-managed resources (sid, state, group/comment). (GET /cluster/ha/resources). Tier-1 read.",
|
|
4304
|
+
parameters: Schema82,
|
|
4305
|
+
execute: async () => {
|
|
4306
|
+
const items = await getClient().get("/cluster/ha/resources");
|
|
4307
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4308
|
+
return jsonToolResult({ count: list.length, resources: list });
|
|
4309
|
+
}
|
|
4310
|
+
};
|
|
4311
|
+
}
|
|
4312
|
+
|
|
4313
|
+
// src/tools/proxmox_list_ha_rules.ts
|
|
4314
|
+
import { Type as Type87 } from "@sinclair/typebox";
|
|
4315
|
+
var Schema83 = Type87.Object({}, { additionalProperties: false });
|
|
4316
|
+
var NAME80 = "proxmox_list_ha_rules";
|
|
4317
|
+
function createProxmoxListHaRulesTool(getClient) {
|
|
4318
|
+
return {
|
|
4319
|
+
name: NAME80,
|
|
4320
|
+
label: "proxmox: list HA rules",
|
|
4321
|
+
description: "HA rules (PVE 9+ replacement for HA groups): node affinity and resource placement. (GET /cluster/ha/rules). Tier-1 read.",
|
|
4322
|
+
parameters: Schema83,
|
|
4323
|
+
execute: async () => {
|
|
4324
|
+
const items = await getClient().get("/cluster/ha/rules");
|
|
4325
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4326
|
+
return jsonToolResult({ count: list.length, rules: list });
|
|
4327
|
+
}
|
|
4328
|
+
};
|
|
4329
|
+
}
|
|
4330
|
+
|
|
4331
|
+
// src/tools/proxmox_list_replication.ts
|
|
4332
|
+
import { Type as Type88 } from "@sinclair/typebox";
|
|
4333
|
+
var Schema84 = Type88.Object({}, { additionalProperties: false });
|
|
4334
|
+
var NAME81 = "proxmox_list_replication";
|
|
4335
|
+
function createProxmoxListReplicationTool(getClient) {
|
|
4336
|
+
return {
|
|
4337
|
+
name: NAME81,
|
|
4338
|
+
label: "proxmox: list replication",
|
|
4339
|
+
description: "Storage replication jobs (id, source guest, target node, schedule). (GET /cluster/replication). Tier-1 read.",
|
|
4340
|
+
parameters: Schema84,
|
|
4341
|
+
execute: async () => {
|
|
4342
|
+
const items = await getClient().get("/cluster/replication");
|
|
4343
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4344
|
+
return jsonToolResult({ count: list.length, jobs: list });
|
|
4345
|
+
}
|
|
4346
|
+
};
|
|
4347
|
+
}
|
|
4348
|
+
|
|
4349
|
+
// src/tools/proxmox_list_sdn_zones.ts
|
|
4350
|
+
import { Type as Type89 } from "@sinclair/typebox";
|
|
4351
|
+
var Schema85 = Type89.Object({}, { additionalProperties: false });
|
|
4352
|
+
var NAME82 = "proxmox_list_sdn_zones";
|
|
4353
|
+
function createProxmoxListSdnZonesTool(getClient) {
|
|
4354
|
+
return {
|
|
4355
|
+
name: NAME82,
|
|
4356
|
+
label: "proxmox: list SDN zones",
|
|
4357
|
+
description: "Software-defined-networking zones. (GET /cluster/sdn/zones). Tier-1 read.",
|
|
4358
|
+
parameters: Schema85,
|
|
4359
|
+
execute: async () => {
|
|
4360
|
+
const items = await getClient().get("/cluster/sdn/zones");
|
|
4361
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4362
|
+
return jsonToolResult({ count: list.length, zones: list });
|
|
4363
|
+
}
|
|
4364
|
+
};
|
|
4365
|
+
}
|
|
4366
|
+
|
|
4367
|
+
// src/tools/proxmox_list_sdn_vnets.ts
|
|
4368
|
+
import { Type as Type90 } from "@sinclair/typebox";
|
|
4369
|
+
var Schema86 = Type90.Object({}, { additionalProperties: false });
|
|
4370
|
+
var NAME83 = "proxmox_list_sdn_vnets";
|
|
4371
|
+
function createProxmoxListSdnVnetsTool(getClient) {
|
|
4372
|
+
return {
|
|
4373
|
+
name: NAME83,
|
|
4374
|
+
label: "proxmox: list SDN vnets",
|
|
4375
|
+
description: "Software-defined-networking virtual networks. (GET /cluster/sdn/vnets). Tier-1 read.",
|
|
4376
|
+
parameters: Schema86,
|
|
4377
|
+
execute: async () => {
|
|
4378
|
+
const items = await getClient().get("/cluster/sdn/vnets");
|
|
4379
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4380
|
+
return jsonToolResult({ count: list.length, vnets: list });
|
|
4381
|
+
}
|
|
4382
|
+
};
|
|
4383
|
+
}
|
|
4384
|
+
|
|
4385
|
+
// src/tools/proxmox_list_metric_servers.ts
|
|
4386
|
+
import { Type as Type91 } from "@sinclair/typebox";
|
|
4387
|
+
var Schema87 = Type91.Object({}, { additionalProperties: false });
|
|
4388
|
+
var NAME84 = "proxmox_list_metric_servers";
|
|
4389
|
+
function createProxmoxListMetricServersTool(getClient) {
|
|
4390
|
+
return {
|
|
4391
|
+
name: NAME84,
|
|
4392
|
+
label: "proxmox: list metric servers",
|
|
4393
|
+
description: "External metrics servers (InfluxDB/Graphite) configured for the cluster. (GET /cluster/metrics/server). Tier-1 read.",
|
|
4394
|
+
parameters: Schema87,
|
|
4395
|
+
execute: async () => {
|
|
4396
|
+
const items = await getClient().get("/cluster/metrics/server");
|
|
4397
|
+
const list = Array.isArray(items) ? items : [items];
|
|
4398
|
+
return jsonToolResult({ count: list.length, servers: list });
|
|
4399
|
+
}
|
|
4400
|
+
};
|
|
4401
|
+
}
|
|
4402
|
+
|
|
4403
|
+
// src/tools/proxmox_get_cluster_options.ts
|
|
4404
|
+
import { Type as Type92 } from "@sinclair/typebox";
|
|
4405
|
+
var Schema88 = Type92.Object({}, { additionalProperties: false });
|
|
4406
|
+
var NAME85 = "proxmox_get_cluster_options";
|
|
4407
|
+
function createProxmoxGetClusterOptionsTool(getClient) {
|
|
4408
|
+
return {
|
|
4409
|
+
name: NAME85,
|
|
4410
|
+
label: "proxmox: get cluster options",
|
|
4411
|
+
description: "Read datacenter-wide options (GET /cluster/options): keyboard, MAC prefix, allowed tags, default migration settings, etc. Tier-1 read.",
|
|
4412
|
+
parameters: Schema88,
|
|
4413
|
+
execute: async () => {
|
|
4414
|
+
const options = await getClient().get("/cluster/options");
|
|
4415
|
+
return jsonToolResult({ options });
|
|
4416
|
+
}
|
|
4417
|
+
};
|
|
4418
|
+
}
|
|
4419
|
+
|
|
4420
|
+
// src/tools/proxmox_cluster_log.ts
|
|
4421
|
+
import { Type as Type93 } from "@sinclair/typebox";
|
|
4422
|
+
var Schema89 = Type93.Object(
|
|
4423
|
+
{
|
|
4424
|
+
max: Type93.Optional(
|
|
4425
|
+
Type93.Integer({ minimum: 1, maximum: 1e3, description: "Max number of recent log entries (default 50)." })
|
|
4426
|
+
)
|
|
4427
|
+
},
|
|
4428
|
+
{ additionalProperties: false }
|
|
4429
|
+
);
|
|
4430
|
+
var NAME86 = "proxmox_cluster_log";
|
|
4431
|
+
function createProxmoxClusterLogTool(getClient) {
|
|
4432
|
+
return {
|
|
4433
|
+
name: NAME86,
|
|
4434
|
+
label: "proxmox: cluster log",
|
|
4435
|
+
description: "Read the recent cluster-wide log (GET /cluster/log): task start/end, auth, and daemon messages across all nodes. Tier-1 read.",
|
|
4436
|
+
parameters: Schema89,
|
|
4437
|
+
execute: async (_id, raw) => {
|
|
4438
|
+
const args = validateToolArgs(Schema89, raw, NAME86);
|
|
4439
|
+
const max = args.max ?? 50;
|
|
4440
|
+
const entries = await getClient().get(`/cluster/log?max=${max}`);
|
|
4441
|
+
return jsonToolResult({ count: Array.isArray(entries) ? entries.length : 0, entries });
|
|
4442
|
+
}
|
|
4443
|
+
};
|
|
4444
|
+
}
|
|
4445
|
+
|
|
4446
|
+
// src/tools/proxmox_add_ha_resource.ts
|
|
4447
|
+
import { Type as Type94 } from "@sinclair/typebox";
|
|
4448
|
+
var SID_RE = /^(vm|ct):\d+$/;
|
|
4449
|
+
var Schema90 = Type94.Object(
|
|
4450
|
+
{
|
|
4451
|
+
sid: Type94.String({ minLength: 1, description: "HA resource id, 'vm:<vmid>' or 'ct:<vmid>'." }),
|
|
4452
|
+
state: Type94.Optional(
|
|
4453
|
+
Type94.Union(
|
|
4454
|
+
[Type94.Literal("started"), Type94.Literal("stopped"), Type94.Literal("disabled"), Type94.Literal("ignored")],
|
|
4455
|
+
{ description: "Requested HA state (default 'started')." }
|
|
4456
|
+
)
|
|
4457
|
+
),
|
|
4458
|
+
comment: Type94.Optional(Type94.String({ description: "Comment." })),
|
|
4459
|
+
max_restart: Type94.Optional(Type94.Integer({ minimum: 0, description: "Max restart attempts on the same node." })),
|
|
4460
|
+
max_relocate: Type94.Optional(Type94.Integer({ minimum: 0, description: "Max relocation attempts to other nodes." })),
|
|
4461
|
+
confirm: Type94.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4462
|
+
},
|
|
4463
|
+
{ additionalProperties: false }
|
|
4464
|
+
);
|
|
4465
|
+
var NAME87 = "proxmox_add_ha_resource";
|
|
4466
|
+
function createProxmoxAddHaResourceTool(getClient) {
|
|
4467
|
+
return {
|
|
4468
|
+
name: NAME87,
|
|
4469
|
+
label: "proxmox: add HA resource",
|
|
4470
|
+
description: "Place a VM or container under HA management (POST /cluster/ha/resources). Only meaningful on a quorate multi-node cluster. Tier-2 write; requires confirm:true.",
|
|
4471
|
+
parameters: Schema90,
|
|
4472
|
+
execute: async (_id, raw) => {
|
|
4473
|
+
assertConfirmedWrite(raw, NAME87);
|
|
4474
|
+
const args = validateToolArgs(Schema90, raw, NAME87);
|
|
4475
|
+
if (!SID_RE.test(args.sid)) throw new ToolInputError(`${NAME87}: sid must be 'vm:<vmid>' or 'ct:<vmid>'`);
|
|
4476
|
+
const body = { sid: args.sid, state: args.state ?? "started" };
|
|
4477
|
+
if (typeof args.comment === "string" && args.comment.length > 0) body.comment = args.comment;
|
|
4478
|
+
if (typeof args.max_restart === "number") body.max_restart = args.max_restart;
|
|
4479
|
+
if (typeof args.max_relocate === "number") body.max_relocate = args.max_relocate;
|
|
4480
|
+
await getClient().post(`/cluster/ha/resources`, body);
|
|
4481
|
+
return jsonToolResult({ sid: args.sid, state: args.state ?? "started", added: true });
|
|
4482
|
+
}
|
|
4483
|
+
};
|
|
4484
|
+
}
|
|
4485
|
+
|
|
4486
|
+
// src/tools/proxmox_delete_ha_resource.ts
|
|
4487
|
+
import { Type as Type95 } from "@sinclair/typebox";
|
|
4488
|
+
var SID_RE2 = /^(vm|ct):\d+$/;
|
|
4489
|
+
var Schema91 = Type95.Object(
|
|
4490
|
+
{
|
|
4491
|
+
sid: Type95.String({ minLength: 1, description: "HA resource id to remove, 'vm:<vmid>' or 'ct:<vmid>'." }),
|
|
4492
|
+
confirm: Type95.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4493
|
+
},
|
|
4494
|
+
{ additionalProperties: false }
|
|
4495
|
+
);
|
|
4496
|
+
var NAME88 = "proxmox_delete_ha_resource";
|
|
4497
|
+
function createProxmoxDeleteHaResourceTool(getClient) {
|
|
4498
|
+
return {
|
|
4499
|
+
name: NAME88,
|
|
4500
|
+
label: "proxmox: delete HA resource",
|
|
4501
|
+
description: "Remove a VM or container from HA management (DELETE /cluster/ha/resources/{sid}). The guest keeps running; only HA management stops. Tier-2 write; requires confirm:true.",
|
|
4502
|
+
parameters: Schema91,
|
|
4503
|
+
execute: async (_id, raw) => {
|
|
4504
|
+
assertConfirmedWrite(raw, NAME88);
|
|
4505
|
+
const args = validateToolArgs(Schema91, raw, NAME88);
|
|
4506
|
+
if (!SID_RE2.test(args.sid)) throw new ToolInputError(`${NAME88}: sid must be 'vm:<vmid>' or 'ct:<vmid>'`);
|
|
4507
|
+
await getClient().delete(`/cluster/ha/resources/${encodeURIComponent(args.sid)}`);
|
|
4508
|
+
return jsonToolResult({ sid: args.sid, deleted: true });
|
|
4509
|
+
}
|
|
4510
|
+
};
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4513
|
+
// src/tools/proxmox_create_replication.ts
|
|
4514
|
+
import { Type as Type96 } from "@sinclair/typebox";
|
|
4515
|
+
var Schema92 = Type96.Object(
|
|
4516
|
+
{
|
|
4517
|
+
vmid: Type96.Integer({ minimum: 1, description: "Guest to replicate." }),
|
|
4518
|
+
target: Type96.String({ minLength: 1, description: "Target node to replicate to (must differ from the source node)." }),
|
|
4519
|
+
job_number: Type96.Optional(Type96.Integer({ minimum: 0, description: "Job number, forming the id '<vmid>-<n>' (default 0)." })),
|
|
4520
|
+
schedule: Type96.Optional(Type96.String({ minLength: 1, description: "Replication schedule, e.g. '*/15' or '02:00' (default '*/15')." })),
|
|
4521
|
+
rate: Type96.Optional(Type96.Number({ minimum: 0, description: "Rate limit in MB/s (0 = unlimited)." })),
|
|
4522
|
+
comment: Type96.Optional(Type96.String({ description: "Comment." })),
|
|
4523
|
+
disable: Type96.Optional(Type96.Boolean({ description: "Create the job disabled." })),
|
|
4524
|
+
confirm: Type96.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4525
|
+
},
|
|
4526
|
+
{ additionalProperties: false }
|
|
4527
|
+
);
|
|
4528
|
+
var NAME89 = "proxmox_create_replication";
|
|
4529
|
+
function createProxmoxCreateReplicationTool(getClient) {
|
|
4530
|
+
return {
|
|
4531
|
+
name: NAME89,
|
|
4532
|
+
label: "proxmox: create replication",
|
|
4533
|
+
description: "Create a storage replication job for a guest to another node (POST /cluster/replication). Requires a multi-node cluster with a different target node. Tier-2 write; requires confirm:true.",
|
|
4534
|
+
parameters: Schema92,
|
|
4535
|
+
execute: async (_id, raw) => {
|
|
4536
|
+
assertConfirmedWrite(raw, NAME89);
|
|
4537
|
+
const args = validateToolArgs(Schema92, raw, NAME89);
|
|
4538
|
+
assertSafePathSegment(args.target, "target");
|
|
4539
|
+
const client = getClient();
|
|
4540
|
+
const { node } = await resolveResource(client, args.vmid);
|
|
4541
|
+
if (args.target === node) {
|
|
4542
|
+
throw new Error(`replication target ${args.target} must differ from the guest's node ${node}.`);
|
|
4543
|
+
}
|
|
4544
|
+
const id = `${args.vmid}-${args.job_number ?? 0}`;
|
|
4545
|
+
const body = {
|
|
4546
|
+
id,
|
|
4547
|
+
type: "local",
|
|
4548
|
+
target: args.target,
|
|
4549
|
+
schedule: args.schedule ?? "*/15"
|
|
4550
|
+
};
|
|
4551
|
+
if (typeof args.rate === "number") body.rate = args.rate;
|
|
4552
|
+
if (typeof args.comment === "string" && args.comment.length > 0) body.comment = args.comment;
|
|
4553
|
+
if (args.disable) body.disable = 1;
|
|
4554
|
+
await client.post(`/cluster/replication`, body);
|
|
4555
|
+
return jsonToolResult({ id, vmid: args.vmid, node, target: args.target, created: true });
|
|
4556
|
+
}
|
|
4557
|
+
};
|
|
4558
|
+
}
|
|
4559
|
+
|
|
4560
|
+
// src/tools/proxmox_delete_replication.ts
|
|
4561
|
+
import { Type as Type97 } from "@sinclair/typebox";
|
|
4562
|
+
var REPL_ID_RE = /^\d+-\d+$/;
|
|
4563
|
+
var Schema93 = Type97.Object(
|
|
4564
|
+
{
|
|
4565
|
+
id: Type97.String({ minLength: 1, description: "Replication job id, '<vmid>-<n>' (from proxmox_list_replication)." }),
|
|
4566
|
+
force: Type97.Optional(Type97.Boolean({ description: "Force removal even if the target is unreachable." })),
|
|
4567
|
+
confirm: Type97.Boolean({ description: "Must be true to write. Tier-2 safe-write gate." })
|
|
4568
|
+
},
|
|
4569
|
+
{ additionalProperties: false }
|
|
4570
|
+
);
|
|
4571
|
+
var NAME90 = "proxmox_delete_replication";
|
|
4572
|
+
function createProxmoxDeleteReplicationTool(getClient) {
|
|
4573
|
+
return {
|
|
4574
|
+
name: NAME90,
|
|
4575
|
+
label: "proxmox: delete replication",
|
|
4576
|
+
description: "Delete a storage replication job (DELETE /cluster/replication/{id}). Tier-2 write; requires confirm:true.",
|
|
4577
|
+
parameters: Schema93,
|
|
4578
|
+
execute: async (_id, raw) => {
|
|
4579
|
+
assertConfirmedWrite(raw, NAME90);
|
|
4580
|
+
const args = validateToolArgs(Schema93, raw, NAME90);
|
|
4581
|
+
if (!REPL_ID_RE.test(args.id)) throw new ToolInputError(`${NAME90}: id must be '<vmid>-<n>'`);
|
|
4582
|
+
const qs = args.force ? "?force=1" : "";
|
|
4583
|
+
await getClient().delete(`/cluster/replication/${args.id}${qs}`);
|
|
4584
|
+
return jsonToolResult({ id: args.id, deleted: true });
|
|
4585
|
+
}
|
|
4586
|
+
};
|
|
4587
|
+
}
|
|
4588
|
+
|
|
4589
|
+
// src/errors.ts
|
|
4590
|
+
function classifyToolError(error) {
|
|
4591
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
4592
|
+
if (err instanceof ToolInputError) {
|
|
4593
|
+
return { error: err.message, code: "TOOL_INPUT_INVALID", name: err.name };
|
|
4594
|
+
}
|
|
4595
|
+
if (err instanceof WriteGateError) {
|
|
4596
|
+
const code = err.message.includes("requires env flag") ? "DESTRUCTIVE_ENV_REQUIRED" : err.message.includes("destructive operation") ? "DESTRUCTIVE_CONFIRMATION_REQUIRED" : "WRITE_CONFIRMATION_REQUIRED";
|
|
4597
|
+
return { error: err.message, code, name: err.name };
|
|
4598
|
+
}
|
|
4599
|
+
if (err instanceof ProxmoxClientError) {
|
|
4600
|
+
return { error: err.message, code: `PROXMOX_HTTP_${err.status}`, name: err.name, status: err.status };
|
|
4601
|
+
}
|
|
4602
|
+
if (err instanceof ProxmoxUnreachableError) {
|
|
4603
|
+
return { error: err.message, code: "PROXMOX_UNREACHABLE", name: err.name };
|
|
4604
|
+
}
|
|
4605
|
+
if (err instanceof SshExecError) {
|
|
4606
|
+
return { error: err.message, code: `SSH_${err.phase.toUpperCase()}_FAILED`, name: err.name };
|
|
4607
|
+
}
|
|
4608
|
+
if (/vmid \d+ not found in cluster resources/.test(err.message)) {
|
|
4609
|
+
return { error: err.message, code: "VMID_NOT_FOUND", name: err.name };
|
|
4610
|
+
}
|
|
4611
|
+
if (/invalid UPID format/.test(err.message)) {
|
|
4612
|
+
return { error: err.message, code: "TASK_UPID_INVALID", name: err.name };
|
|
2603
4613
|
}
|
|
2604
4614
|
if (/task did not finish OK/i.test(err.message) || /task failed/i.test(err.message)) {
|
|
2605
4615
|
return { error: err.message, code: "TASK_FAILED", name: err.name };
|
|
@@ -2607,11 +4617,421 @@ function classifyToolError(error) {
|
|
|
2607
4617
|
return { error: err.message, code: "TOOL_ERROR", name: err.name };
|
|
2608
4618
|
}
|
|
2609
4619
|
|
|
2610
|
-
//
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
4620
|
+
// src/registry.ts
|
|
4621
|
+
var TOOL_TIERS = {
|
|
4622
|
+
"proxmox_add_firewall_rule": "safe-write",
|
|
4623
|
+
"proxmox_add_ha_resource": "safe-write",
|
|
4624
|
+
"proxmox_audit_permissions": "read",
|
|
4625
|
+
"proxmox_cancel_task": "safe-write",
|
|
4626
|
+
"proxmox_cleanup_smoke_resources": "destructive",
|
|
4627
|
+
"proxmox_clone_resource": "safe-write",
|
|
4628
|
+
"proxmox_cluster_log": "read",
|
|
4629
|
+
"proxmox_cluster_status": "read",
|
|
4630
|
+
"proxmox_convert_to_template": "safe-write",
|
|
4631
|
+
"proxmox_create_backup_job": "safe-write",
|
|
4632
|
+
"proxmox_create_container": "safe-write",
|
|
4633
|
+
"proxmox_create_pool": "safe-write",
|
|
4634
|
+
"proxmox_create_replication": "safe-write",
|
|
4635
|
+
"proxmox_create_storage": "safe-write",
|
|
4636
|
+
"proxmox_create_token": "safe-write",
|
|
4637
|
+
"proxmox_create_vm": "safe-write",
|
|
4638
|
+
"proxmox_delete_backup_job": "safe-write",
|
|
4639
|
+
"proxmox_delete_firewall_rule": "safe-write",
|
|
4640
|
+
"proxmox_delete_ha_resource": "safe-write",
|
|
4641
|
+
"proxmox_delete_pool": "safe-write",
|
|
4642
|
+
"proxmox_delete_replication": "safe-write",
|
|
4643
|
+
"proxmox_delete_snapshot": "destructive",
|
|
4644
|
+
"proxmox_delete_storage": "destructive",
|
|
4645
|
+
"proxmox_delete_token": "safe-write",
|
|
4646
|
+
"proxmox_delete_volume": "destructive",
|
|
4647
|
+
"proxmox_destroy_resource": "destructive",
|
|
4648
|
+
"proxmox_download_url": "safe-write",
|
|
4649
|
+
"proxmox_exec": "safe-write",
|
|
4650
|
+
"proxmox_force_stop_resource": "destructive",
|
|
4651
|
+
"proxmox_get_cluster_options": "read",
|
|
4652
|
+
"proxmox_get_container_config": "read",
|
|
4653
|
+
"proxmox_get_firewall_options": "read",
|
|
4654
|
+
"proxmox_get_resource": "read",
|
|
4655
|
+
"proxmox_get_task_log": "read",
|
|
4656
|
+
"proxmox_get_task_status": "read",
|
|
4657
|
+
"proxmox_get_vm_config": "read",
|
|
4658
|
+
"proxmox_guest_network": "read",
|
|
4659
|
+
"proxmox_ha_status": "read",
|
|
4660
|
+
"proxmox_list_acl": "read",
|
|
4661
|
+
"proxmox_list_backup_jobs": "read",
|
|
4662
|
+
"proxmox_list_backups": "read",
|
|
4663
|
+
"proxmox_list_containers": "read",
|
|
4664
|
+
"proxmox_list_directory": "safe-write",
|
|
4665
|
+
"proxmox_list_disks": "read",
|
|
4666
|
+
"proxmox_list_firewall_rules": "read",
|
|
4667
|
+
"proxmox_list_ha_resources": "read",
|
|
4668
|
+
"proxmox_list_ha_rules": "read",
|
|
4669
|
+
"proxmox_list_metric_servers": "read",
|
|
4670
|
+
"proxmox_list_node_services": "read",
|
|
4671
|
+
"proxmox_list_pool_resources": "read",
|
|
4672
|
+
"proxmox_list_pools": "read",
|
|
4673
|
+
"proxmox_list_replication": "read",
|
|
4674
|
+
"proxmox_list_roles": "read",
|
|
4675
|
+
"proxmox_list_sdn_vnets": "read",
|
|
4676
|
+
"proxmox_list_sdn_zones": "read",
|
|
4677
|
+
"proxmox_list_snapshots": "read",
|
|
4678
|
+
"proxmox_list_storage_config": "read",
|
|
4679
|
+
"proxmox_list_storage_content": "read",
|
|
4680
|
+
"proxmox_list_storage": "read",
|
|
4681
|
+
"proxmox_list_templates": "read",
|
|
4682
|
+
"proxmox_list_tokens": "read",
|
|
4683
|
+
"proxmox_list_updates": "read",
|
|
4684
|
+
"proxmox_list_users": "read",
|
|
4685
|
+
"proxmox_list_vms": "read",
|
|
4686
|
+
"proxmox_migrate_resource": "safe-write",
|
|
4687
|
+
"proxmox_move_disk": "safe-write",
|
|
4688
|
+
"proxmox_next_vmid": "read",
|
|
4689
|
+
"proxmox_node_power": "destructive",
|
|
4690
|
+
"proxmox_read_file": "safe-write",
|
|
4691
|
+
"proxmox_reboot_resource": "safe-write",
|
|
4692
|
+
"proxmox_recent_tasks": "read",
|
|
4693
|
+
"proxmox_reset_resource": "safe-write",
|
|
4694
|
+
"proxmox_resize_disk": "safe-write",
|
|
4695
|
+
"proxmox_resource_usage": "read",
|
|
4696
|
+
"proxmox_restore_backup": "destructive",
|
|
4697
|
+
"proxmox_resume_resource": "safe-write",
|
|
4698
|
+
"proxmox_rollback_snapshot": "destructive",
|
|
4699
|
+
"proxmox_run_backup": "safe-write",
|
|
4700
|
+
"proxmox_service_restart": "safe-write",
|
|
4701
|
+
"proxmox_service_start": "safe-write",
|
|
4702
|
+
"proxmox_service_status": "safe-write",
|
|
4703
|
+
"proxmox_service_stop": "safe-write",
|
|
4704
|
+
"proxmox_set_acl": "safe-write",
|
|
4705
|
+
"proxmox_set_firewall_enabled": "safe-write",
|
|
4706
|
+
"proxmox_snapshot_resource": "safe-write",
|
|
4707
|
+
"proxmox_start_resource": "safe-write",
|
|
4708
|
+
"proxmox_stat_path": "safe-write",
|
|
4709
|
+
"proxmox_status": "read",
|
|
4710
|
+
"proxmox_stop_resource": "safe-write",
|
|
4711
|
+
"proxmox_suspend_resource": "safe-write",
|
|
4712
|
+
"proxmox_update_container_config": "safe-write",
|
|
4713
|
+
"proxmox_update_pool": "safe-write",
|
|
4714
|
+
"proxmox_update_vm_config": "safe-write",
|
|
4715
|
+
"proxmox_validate_qemu_smoke_source": "read",
|
|
4716
|
+
"proxmox_wait_task": "read",
|
|
4717
|
+
"proxmox_write_file": "safe-write"
|
|
4718
|
+
};
|
|
4719
|
+
function annotationsForTier(tier) {
|
|
4720
|
+
switch (tier) {
|
|
4721
|
+
case "read":
|
|
4722
|
+
return { readOnlyHint: true };
|
|
4723
|
+
case "safe-write":
|
|
4724
|
+
return { readOnlyHint: false, destructiveHint: false };
|
|
4725
|
+
case "destructive":
|
|
4726
|
+
return { readOnlyHint: false, destructiveHint: true };
|
|
4727
|
+
}
|
|
4728
|
+
}
|
|
4729
|
+
function tierForTool(name) {
|
|
4730
|
+
const tier = TOOL_TIERS[name];
|
|
4731
|
+
if (tier === void 0) {
|
|
4732
|
+
throw new Error(`registry: no access tier declared for tool "${name}"`);
|
|
4733
|
+
}
|
|
4734
|
+
return tier;
|
|
4735
|
+
}
|
|
4736
|
+
|
|
4737
|
+
// src/search.ts
|
|
4738
|
+
var DOMAINS = [
|
|
4739
|
+
"resources",
|
|
4740
|
+
"storage",
|
|
4741
|
+
"backups",
|
|
4742
|
+
"firewall",
|
|
4743
|
+
"identity",
|
|
4744
|
+
"cluster",
|
|
4745
|
+
"ha",
|
|
4746
|
+
"guest-ops"
|
|
4747
|
+
];
|
|
4748
|
+
var STOPWORDS = /* @__PURE__ */ new Set([
|
|
4749
|
+
"the",
|
|
4750
|
+
"a",
|
|
4751
|
+
"an",
|
|
4752
|
+
"of",
|
|
4753
|
+
"on",
|
|
4754
|
+
"in",
|
|
4755
|
+
"to",
|
|
4756
|
+
"and",
|
|
4757
|
+
"or",
|
|
4758
|
+
"for",
|
|
4759
|
+
"with",
|
|
4760
|
+
"me",
|
|
4761
|
+
"my",
|
|
4762
|
+
"is",
|
|
4763
|
+
"are",
|
|
4764
|
+
"it",
|
|
4765
|
+
"its",
|
|
4766
|
+
"that",
|
|
4767
|
+
"this",
|
|
4768
|
+
"at",
|
|
4769
|
+
"by",
|
|
4770
|
+
"from",
|
|
4771
|
+
"into",
|
|
4772
|
+
"then",
|
|
4773
|
+
"please",
|
|
4774
|
+
"all",
|
|
4775
|
+
"any",
|
|
4776
|
+
"some",
|
|
4777
|
+
"which",
|
|
4778
|
+
"what",
|
|
4779
|
+
"where",
|
|
4780
|
+
"how",
|
|
4781
|
+
"do",
|
|
4782
|
+
"does"
|
|
4783
|
+
]);
|
|
4784
|
+
function tokenize(text) {
|
|
4785
|
+
return text.toLowerCase().split(/[^a-z0-9]+/).filter((t) => t.length > 1 && !STOPWORDS.has(t));
|
|
4786
|
+
}
|
|
4787
|
+
var stem = (name) => name.replace(/^proxmox_/, "");
|
|
4788
|
+
function buildIdf(index) {
|
|
4789
|
+
const n = index.length;
|
|
4790
|
+
const df = /* @__PURE__ */ new Map();
|
|
4791
|
+
for (const rec of index) {
|
|
4792
|
+
const terms = /* @__PURE__ */ new Set([
|
|
4793
|
+
...tokenize(stem(rec.name)),
|
|
4794
|
+
...rec.keywords.flatMap((k) => tokenize(k)),
|
|
4795
|
+
...tokenize(rec.description)
|
|
4796
|
+
]);
|
|
4797
|
+
for (const t of terms) df.set(t, (df.get(t) ?? 0) + 1);
|
|
4798
|
+
}
|
|
4799
|
+
return (term) => Math.max(1, Math.log((n + 1) / ((df.get(term) ?? 0) + 0.5)));
|
|
4800
|
+
}
|
|
4801
|
+
function scoreRecord(queryTerms, rec, idf) {
|
|
4802
|
+
if (queryTerms.length === 0) return 0;
|
|
4803
|
+
const keywordSet = new Set(rec.keywords.map((k) => k.toLowerCase()));
|
|
4804
|
+
const nameTokens = new Set(tokenize(stem(rec.name)));
|
|
4805
|
+
const descTokens = new Set(tokenize(rec.description));
|
|
4806
|
+
let score = 0;
|
|
4807
|
+
for (const term of queryTerms) {
|
|
4808
|
+
const w = idf(term);
|
|
4809
|
+
if (keywordSet.has(term)) score += 10 * w;
|
|
4810
|
+
else if ([...keywordSet].some((k) => k.includes(term) || term.includes(k))) score += 5 * w;
|
|
4811
|
+
if (nameTokens.has(term)) score += 6 * w;
|
|
4812
|
+
if (term === rec.domain || rec.domain.includes(term)) score += 2 * w;
|
|
4813
|
+
if (descTokens.has(term)) score += 3 * w;
|
|
4814
|
+
}
|
|
4815
|
+
return score;
|
|
4816
|
+
}
|
|
4817
|
+
function buildSearchIndex(descriptors, meta) {
|
|
4818
|
+
return descriptors.map((d) => {
|
|
4819
|
+
const m = meta[d.name];
|
|
4820
|
+
if (m === void 0) {
|
|
4821
|
+
throw new Error(`search: no search metadata (domain/keywords) for tool "${d.name}"`);
|
|
4822
|
+
}
|
|
4823
|
+
return { name: d.name, description: d.description, domain: m.domain, keywords: m.keywords };
|
|
4824
|
+
});
|
|
4825
|
+
}
|
|
4826
|
+
function splitIntents(query) {
|
|
4827
|
+
const parts = query.split(/\b(?:then|and)\b|[,;]+/i).map((s) => s.trim()).filter((s) => s.length > 0);
|
|
4828
|
+
return parts.length > 0 ? parts : [query];
|
|
4829
|
+
}
|
|
4830
|
+
function searchTools(query, index, opts = {}) {
|
|
4831
|
+
const { limit = 5, domain } = opts;
|
|
4832
|
+
const segments = splitIntents(query).map(tokenize);
|
|
4833
|
+
const idf = buildIdf(index);
|
|
4834
|
+
const pool = domain ? index.filter((r) => r.domain === domain) : index;
|
|
4835
|
+
return pool.map((rec) => ({
|
|
4836
|
+
name: rec.name,
|
|
4837
|
+
// A tool's score is its best fit to any single intent, not the blurred whole.
|
|
4838
|
+
score: Math.max(...segments.map((terms) => scoreRecord(terms, rec, idf))),
|
|
4839
|
+
domain: rec.domain
|
|
4840
|
+
})).filter((h) => h.score > 0).sort((a, b) => b.score - a.score || a.name.localeCompare(b.name)).slice(0, limit);
|
|
4841
|
+
}
|
|
4842
|
+
var TOOL_SEARCH_META = {
|
|
4843
|
+
"proxmox_add_firewall_rule": { domain: "firewall", keywords: ["allow", "block", "traffic", "ingress", "egress", "permit", "deny"] },
|
|
4844
|
+
"proxmox_add_ha_resource": { domain: "ha", keywords: ["protect", "failover", "availability", "fencing", "placement", "managed"] },
|
|
4845
|
+
"proxmox_audit_permissions": { domain: "identity", keywords: ["access", "rights", "privileges", "grants", "inspect", "who can"] },
|
|
4846
|
+
"proxmox_cancel_task": { domain: "cluster", keywords: ["abort", "terminate", "interrupt", "halt", "running", "job"] },
|
|
4847
|
+
"proxmox_cleanup_smoke_resources": { domain: "resources", keywords: ["purge", "leftovers", "testing", "preview", "dryrun", "tear down"] },
|
|
4848
|
+
"proxmox_clone_resource": { domain: "resources", keywords: ["copy", "duplicate", "fork", "instantiate", "source", "linked"] },
|
|
4849
|
+
"proxmox_cluster_log": { domain: "cluster", keywords: ["events", "history", "messages", "daemon", "entries", "audit"] },
|
|
4850
|
+
"proxmox_cluster_status": { domain: "cluster", keywords: ["membership", "quorum", "online", "health", "voting", "members"] },
|
|
4851
|
+
"proxmox_convert_to_template": { domain: "resources", keywords: ["golden", "image", "master", "reusable", "freeze", "base"] },
|
|
4852
|
+
"proxmox_create_backup_job": { domain: "backups", keywords: ["schedule", "vzdump", "nightly", "recurring", "automate", "retention"] },
|
|
4853
|
+
"proxmox_create_container": { domain: "resources", keywords: ["lxc", "provision", "instantiate", "deploy", "guest", "spin up"] },
|
|
4854
|
+
"proxmox_create_pool": { domain: "identity", keywords: ["group", "collection", "organize", "bucket", "membership", "grouping"] },
|
|
4855
|
+
"proxmox_create_replication": { domain: "ha", keywords: ["mirror", "synchronize", "failover", "remote", "target", "zfs"] },
|
|
4856
|
+
"proxmox_create_storage": { domain: "storage", keywords: ["datastore", "capacity", "backend", "attach", "volume", "define"] },
|
|
4857
|
+
"proxmox_create_token": { domain: "identity", keywords: ["apikey", "credential", "secret", "generate", "account", "auth"] },
|
|
4858
|
+
"proxmox_create_vm": { domain: "resources", keywords: ["qemu", "machine", "virtual", "provision", "guest", "spin up"] },
|
|
4859
|
+
"proxmox_delete_backup_job": { domain: "backups", keywords: ["unschedule", "remove", "recurring", "vzdump", "cancel", "nightly"] },
|
|
4860
|
+
"proxmox_delete_firewall_rule": { domain: "firewall", keywords: ["remove", "discard", "clear", "retract", "eliminate", "drop"] },
|
|
4861
|
+
"proxmox_delete_ha_resource": { domain: "ha", keywords: ["unmanage", "detach", "remove", "failover", "release", "availability"] },
|
|
4862
|
+
"proxmox_delete_pool": { domain: "identity", keywords: ["disband", "empty", "remove", "group", "collection", "tear down"] },
|
|
4863
|
+
"proxmox_delete_replication": { domain: "ha", keywords: ["unsync", "mirror", "cancel", "remove", "teardown", "stop"] },
|
|
4864
|
+
"proxmox_delete_snapshot": { domain: "resources", keywords: ["discard", "remove", "checkpoint", "recovery", "purge", "clear"] },
|
|
4865
|
+
"proxmox_delete_storage": { domain: "storage", keywords: ["detach", "unmount", "disconnect", "remove", "deprovision", "undefine"] },
|
|
4866
|
+
"proxmox_delete_token": { domain: "identity", keywords: ["revoke", "invalidate", "disable", "expire", "credential", "apikey"] },
|
|
4867
|
+
"proxmox_delete_volume": { domain: "storage", keywords: ["erase", "discard", "decommission", "archive", "image", "purge"] },
|
|
4868
|
+
"proxmox_destroy_resource": { domain: "resources", keywords: ["permanent", "decommission", "wipe", "remove", "guest", "delete"] },
|
|
4869
|
+
"proxmox_download_url": { domain: "storage", keywords: ["fetch", "installer", "checksum", "remote", "import", "iso"] },
|
|
4870
|
+
"proxmox_exec": { domain: "guest-ops", keywords: ["shell", "terminal", "command", "script", "stdout", "inside"] },
|
|
4871
|
+
"proxmox_force_stop_resource": { domain: "resources", keywords: ["hardkill", "emergency", "shutdown", "terminate", "poweroff", "kill"] },
|
|
4872
|
+
"proxmox_get_cluster_options": { domain: "cluster", keywords: ["datacenter", "settings", "keyboard", "migration", "defaults", "global"] },
|
|
4873
|
+
"proxmox_get_container_config": { domain: "resources", keywords: ["lxc", "settings", "hardware", "inspect", "properties", "show"] },
|
|
4874
|
+
"proxmox_get_firewall_options": { domain: "firewall", keywords: ["policy", "inbound", "outbound", "logging", "enabled", "default"] },
|
|
4875
|
+
"proxmox_get_resource": { domain: "resources", keywords: ["inspect", "guest", "details", "current", "health", "state"] },
|
|
4876
|
+
"proxmox_get_task_log": { domain: "cluster", keywords: ["tail", "output", "messages", "progress", "diagnose", "upid"] },
|
|
4877
|
+
"proxmox_get_task_status": { domain: "cluster", keywords: ["progress", "running", "completed", "exit", "operation", "upid"] },
|
|
4878
|
+
"proxmox_get_vm_config": { domain: "resources", keywords: ["qemu", "settings", "hardware", "inspect", "properties", "show"] },
|
|
4879
|
+
"proxmox_guest_network": { domain: "guest-ops", keywords: ["address", "interfaces", "ipvfour", "ethernet", "agent", "ip"] },
|
|
4880
|
+
"proxmox_ha_status": { domain: "ha", keywords: ["availability", "fencing", "quorum", "failover", "manager", "crm"] },
|
|
4881
|
+
"proxmox_list_acl": { domain: "identity", keywords: ["access", "entries", "grants", "bindings", "propagation", "permissions"] },
|
|
4882
|
+
"proxmox_list_backup_jobs": { domain: "backups", keywords: ["schedules", "vzdump", "automation", "retention", "archives", "recurring"] },
|
|
4883
|
+
"proxmox_list_backups": { domain: "backups", keywords: ["archives", "recovery", "copies", "vzdump", "restorepoints", "dumps"] },
|
|
4884
|
+
"proxmox_list_containers": { domain: "resources", keywords: ["lxc", "guests", "inventory", "workloads", "instances", "running"] },
|
|
4885
|
+
"proxmox_list_directory": { domain: "guest-ops", keywords: ["browse", "filesystem", "folder", "files", "enumerate", "inside"] },
|
|
4886
|
+
"proxmox_list_disks": { domain: "storage", keywords: ["drives", "smart", "wearout", "capacity", "hardware", "physical"] },
|
|
4887
|
+
"proxmox_list_firewall_rules": { domain: "firewall", keywords: ["policies", "filters", "traffic", "allow", "deny", "security"] },
|
|
4888
|
+
"proxmox_list_ha_resources": { domain: "ha", keywords: ["managed", "guests", "availability", "failover", "assignments", "protected"] },
|
|
4889
|
+
"proxmox_list_ha_rules": { domain: "ha", keywords: ["affinity", "placement", "constraints", "colocation", "preference", "policy"] },
|
|
4890
|
+
"proxmox_list_metric_servers": { domain: "cluster", keywords: ["monitoring", "telemetry", "influxdb", "graphite", "endpoints", "observability"] },
|
|
4891
|
+
"proxmox_list_node_services": { domain: "cluster", keywords: ["systemd", "daemons", "pveproxy", "pvedaemon", "corosync", "host"] },
|
|
4892
|
+
"proxmox_list_pool_resources": { domain: "identity", keywords: ["members", "grouping", "guests", "contents", "assignment", "belongs"] },
|
|
4893
|
+
"proxmox_list_pools": { domain: "identity", keywords: ["groups", "collections", "comments", "categories", "organization", "groupings"] },
|
|
4894
|
+
"proxmox_list_replication": { domain: "ha", keywords: ["mirroring", "synchronization", "failover", "source", "target", "sync jobs"] },
|
|
4895
|
+
"proxmox_list_roles": { domain: "identity", keywords: ["privileges", "rbac", "access", "permissions", "capabilities", "levels"] },
|
|
4896
|
+
"proxmox_list_sdn_vnets": { domain: "cluster", keywords: ["networks", "vlans", "overlays", "segments", "switches", "virtual"] },
|
|
4897
|
+
"proxmox_list_sdn_zones": { domain: "cluster", keywords: ["networks", "boundaries", "routing", "segments", "regions", "isolation"] },
|
|
4898
|
+
"proxmox_list_snapshots": { domain: "resources", keywords: ["checkpoints", "restorepoints", "history", "recovery", "savedstate", "rollback"] },
|
|
4899
|
+
"proxmox_list_storage": { domain: "storage", keywords: ["capacity", "free", "datastore", "space", "usage", "available"] },
|
|
4900
|
+
"proxmox_list_storage_config": { domain: "storage", keywords: ["datastores", "backends", "definitions", "shared", "restrictions", "setup"] },
|
|
4901
|
+
"proxmox_list_storage_content": { domain: "storage", keywords: ["volumes", "isos", "images", "archives", "templates", "files"] },
|
|
4902
|
+
"proxmox_list_templates": { domain: "storage", keywords: ["vztmpl", "isos", "images", "media", "bootable", "appliance"] },
|
|
4903
|
+
"proxmox_list_tokens": { domain: "identity", keywords: ["apikeys", "credentials", "secrets", "accounts", "authentication", "keys"] },
|
|
4904
|
+
"proxmox_list_updates": { domain: "cluster", keywords: ["patches", "packages", "upgrades", "apt", "outdated", "pending"] },
|
|
4905
|
+
"proxmox_list_users": { domain: "identity", keywords: ["accounts", "realms", "logins", "enabled", "access", "members"] },
|
|
4906
|
+
"proxmox_list_vms": { domain: "resources", keywords: ["qemu", "machines", "guests", "inventory", "workloads", "running"] },
|
|
4907
|
+
"proxmox_migrate_resource": { domain: "resources", keywords: ["relocate", "transfer", "live", "host", "rebalance", "move"] },
|
|
4908
|
+
"proxmox_move_disk": { domain: "storage", keywords: ["relocate", "volume", "backend", "transfer", "datastore", "reassign"] },
|
|
4909
|
+
"proxmox_next_vmid": { domain: "cluster", keywords: ["available", "identifier", "unused", "allocate", "number", "free"] },
|
|
4910
|
+
"proxmox_node_power": { domain: "cluster", keywords: ["reboot", "shutdown", "hypervisor", "restart", "host", "halt"] },
|
|
4911
|
+
"proxmox_read_file": { domain: "guest-ops", keywords: ["cat", "contents", "text", "document", "inspect", "inside"] },
|
|
4912
|
+
"proxmox_reboot_resource": { domain: "resources", keywords: ["restart", "cycle", "guest", "bounce", "powercycle", "graceful"] },
|
|
4913
|
+
"proxmox_recent_tasks": { domain: "cluster", keywords: ["activity", "history", "operations", "queue", "audit", "jobs"] },
|
|
4914
|
+
"proxmox_reset_resource": { domain: "resources", keywords: ["hardrestart", "button", "ungraceful", "reboot", "powercycle", "forced"] },
|
|
4915
|
+
"proxmox_resize_disk": { domain: "storage", keywords: ["grow", "expand", "increase", "capacity", "extend", "enlarge"] },
|
|
4916
|
+
"proxmox_resource_usage": { domain: "resources", keywords: ["metrics", "statistics", "cpu", "memory", "performance", "graphs"] },
|
|
4917
|
+
"proxmox_restore_backup": { domain: "backups", keywords: ["recover", "recreate", "overwrite", "vzdump", "archive", "revert"] },
|
|
4918
|
+
"proxmox_resume_resource": { domain: "resources", keywords: ["unpause", "continue", "wake", "thaw", "reawaken", "unfreeze"] },
|
|
4919
|
+
"proxmox_rollback_snapshot": { domain: "resources", keywords: ["revert", "undo", "previous", "checkpoint", "recover", "restore"] },
|
|
4920
|
+
"proxmox_run_backup": { domain: "backups", keywords: ["trigger", "vzdump", "archive", "save", "protect", "execute"] },
|
|
4921
|
+
"proxmox_service_restart": { domain: "guest-ops", keywords: ["systemd", "bounce", "reload", "daemon", "inside", "unit"] },
|
|
4922
|
+
"proxmox_service_start": { domain: "guest-ops", keywords: ["systemd", "launch", "boot", "daemon", "inside", "activate"] },
|
|
4923
|
+
"proxmox_service_status": { domain: "guest-ops", keywords: ["systemd", "running", "daemon", "health", "inside", "check"] },
|
|
4924
|
+
"proxmox_service_stop": { domain: "guest-ops", keywords: ["systemd", "halt", "kill", "daemon", "inside", "deactivate"] },
|
|
4925
|
+
"proxmox_set_acl": { domain: "identity", keywords: ["grant", "revoke", "permissions", "rights", "privileges", "assign"] },
|
|
4926
|
+
"proxmox_set_firewall_enabled": { domain: "firewall", keywords: ["toggle", "activate", "deactivate", "switch", "policy", "turn on"] },
|
|
4927
|
+
"proxmox_snapshot_resource": { domain: "resources", keywords: ["checkpoint", "capture", "freeze", "save", "restorepoint", "point in time"] },
|
|
4928
|
+
"proxmox_start_resource": { domain: "resources", keywords: ["boot", "poweron", "launch", "activate", "bringup", "turn on"] },
|
|
4929
|
+
"proxmox_stat_path": { domain: "guest-ops", keywords: ["metadata", "size", "permissions", "directory", "details", "exists"] },
|
|
4930
|
+
"proxmox_status": { domain: "cluster", keywords: ["version", "health", "nodes", "uptime", "overview", "summary"] },
|
|
4931
|
+
"proxmox_stop_resource": { domain: "resources", keywords: ["shutdown", "halt", "graceful", "poweroff", "deactivate", "turn off"] },
|
|
4932
|
+
"proxmox_suspend_resource": { domain: "resources", keywords: ["pause", "freeze", "sleep", "hibernate", "interrupt", "hold"] },
|
|
4933
|
+
"proxmox_update_container_config": { domain: "resources", keywords: ["edit", "modify", "lxc", "settings", "hostname", "cores"] },
|
|
4934
|
+
"proxmox_update_pool": { domain: "identity", keywords: ["modify", "members", "group", "comment", "detach", "edit"] },
|
|
4935
|
+
"proxmox_update_vm_config": { domain: "resources", keywords: ["edit", "modify", "qemu", "settings", "sockets", "cores"] },
|
|
4936
|
+
"proxmox_validate_qemu_smoke_source": { domain: "resources", keywords: ["verify", "safe", "clone", "agent", "passthrough", "readiness"] },
|
|
4937
|
+
"proxmox_wait_task": { domain: "cluster", keywords: ["poll", "monitor", "watch", "timeout", "complete", "block"] },
|
|
4938
|
+
"proxmox_write_file": { domain: "guest-ops", keywords: ["save", "upload", "text", "contents", "directories", "inside"] }
|
|
4939
|
+
};
|
|
4940
|
+
|
|
4941
|
+
// src/deferred.ts
|
|
4942
|
+
import { Type as Type98 } from "@sinclair/typebox";
|
|
4943
|
+
var SEARCH_TOOL_NAME = "proxmox_search_tools";
|
|
4944
|
+
var DEFERRED_ENV_FLAG = "PROXMOX_DEFERRED_TOOLS";
|
|
4945
|
+
var TRUTHY = ["true", "1", "yes"];
|
|
4946
|
+
function deferredModeEnabled(env = process.env) {
|
|
4947
|
+
const value = env[DEFERRED_ENV_FLAG];
|
|
4948
|
+
return typeof value === "string" && TRUTHY.includes(value.toLowerCase());
|
|
4949
|
+
}
|
|
4950
|
+
var SEARCH_TOOL_DESCRIPTION = `Find Proxmox tools by describing the task in plain language, then call the tool this returns. Only this search tool is loaded at first; matching tools are added to your tool list on demand, so re-read your tool list after calling this and then call the chosen tool directly with its own arguments. Describe the whole task in one query ("snapshot 110 then resize its disk") and each intent is matched separately. Results carry the tool's access tier and the gate arguments it will require; the gates are enforced by the tool itself, so a tool appearing here is not permission to skip them.`;
|
|
4951
|
+
var searchToolParameters = Type98.Object(
|
|
4952
|
+
{
|
|
4953
|
+
query: Type98.String({
|
|
4954
|
+
description: "What you are trying to do, in plain language. Multiple intents are fine.",
|
|
4955
|
+
minLength: 1
|
|
4956
|
+
}),
|
|
4957
|
+
domain: Type98.Optional(
|
|
4958
|
+
Type98.Union(
|
|
4959
|
+
DOMAINS.map((d) => Type98.Literal(d)),
|
|
4960
|
+
{ description: "Optional hard filter to a single tool domain." }
|
|
4961
|
+
)
|
|
4962
|
+
),
|
|
4963
|
+
limit: Type98.Optional(
|
|
4964
|
+
Type98.Integer({
|
|
4965
|
+
minimum: 1,
|
|
4966
|
+
maximum: 25,
|
|
4967
|
+
default: 5,
|
|
4968
|
+
description: "Maximum tools to return and load (default 5)."
|
|
4969
|
+
})
|
|
4970
|
+
)
|
|
4971
|
+
},
|
|
4972
|
+
{ additionalProperties: false }
|
|
4973
|
+
);
|
|
4974
|
+
var GATE_HINTS = {
|
|
4975
|
+
read: null,
|
|
4976
|
+
"safe-write": { confirm: true },
|
|
4977
|
+
destructive: { confirm: true, destructive: true, env: "PROXMOX_ENABLE_DESTRUCTIVE=1" }
|
|
4978
|
+
};
|
|
4979
|
+
function createDeferredSession() {
|
|
4980
|
+
const loaded = /* @__PURE__ */ new Set();
|
|
4981
|
+
return {
|
|
4982
|
+
isLoaded: (name) => loaded.has(name),
|
|
4983
|
+
loadedTools: () => [...loaded],
|
|
4984
|
+
load(names) {
|
|
4985
|
+
const added = [];
|
|
4986
|
+
for (const name of names) {
|
|
4987
|
+
if (!loaded.has(name)) {
|
|
4988
|
+
loaded.add(name);
|
|
4989
|
+
added.push(name);
|
|
4990
|
+
}
|
|
4991
|
+
}
|
|
4992
|
+
return added;
|
|
4993
|
+
}
|
|
4994
|
+
};
|
|
4995
|
+
}
|
|
4996
|
+
function runToolSearch(args, index, session) {
|
|
4997
|
+
const query = args.query;
|
|
4998
|
+
if (typeof query !== "string" || query.trim() === "") {
|
|
4999
|
+
throw new ToolInputError(`${SEARCH_TOOL_NAME} requires a non-empty "query" string.`);
|
|
5000
|
+
}
|
|
5001
|
+
const domain = args.domain === void 0 ? void 0 : args.domain;
|
|
5002
|
+
if (domain !== void 0 && !DOMAINS.includes(domain)) {
|
|
5003
|
+
throw new ToolInputError(
|
|
5004
|
+
`${SEARCH_TOOL_NAME}: unknown domain "${String(args.domain)}". Valid domains: ${DOMAINS.join(", ")}.`
|
|
5005
|
+
);
|
|
5006
|
+
}
|
|
5007
|
+
const limit = typeof args.limit === "number" ? args.limit : 5;
|
|
5008
|
+
const hits = searchTools(query, index, { limit, domain }).map((h) => {
|
|
5009
|
+
const tier = TOOL_TIERS[h.name] ?? "safe-write";
|
|
5010
|
+
return {
|
|
5011
|
+
name: h.name,
|
|
5012
|
+
tier,
|
|
5013
|
+
domain: h.domain,
|
|
5014
|
+
description: index.find((r) => r.name === h.name)?.description ?? "",
|
|
5015
|
+
requires: GATE_HINTS[tier]
|
|
5016
|
+
};
|
|
5017
|
+
});
|
|
5018
|
+
const added = session.load(hits.map((h) => h.name));
|
|
5019
|
+
return {
|
|
5020
|
+
hits,
|
|
5021
|
+
added,
|
|
5022
|
+
result: jsonToolResult({
|
|
5023
|
+
query,
|
|
5024
|
+
matched: hits.length,
|
|
5025
|
+
loaded: added,
|
|
5026
|
+
already_loaded: hits.filter((h) => !added.includes(h.name)).map((h) => h.name),
|
|
5027
|
+
tools: hits,
|
|
5028
|
+
next_step: hits.length === 0 ? "No tool matched. Try naming the Proxmox object (snapshot, storage, ACL, backup job) rather than the outcome." : "These tools are now in your tool list. Re-read it, then call the one you want directly with its own arguments."
|
|
5029
|
+
})
|
|
5030
|
+
};
|
|
5031
|
+
}
|
|
5032
|
+
|
|
5033
|
+
// src/server.ts
|
|
5034
|
+
function createMcpServer(cfg = resolveConfig(process.env)) {
|
|
2615
5035
|
registerSecret(cfg.tokenId);
|
|
2616
5036
|
registerSecret(cfg.tokenSecret);
|
|
2617
5037
|
registerSecret(`PVEAPIToken=${cfg.tokenId}=${cfg.tokenSecret}`);
|
|
@@ -2669,14 +5089,122 @@ async function startServer() {
|
|
|
2669
5089
|
createProxmoxServiceStatusTool(getClient, getSsh, vmDefaults),
|
|
2670
5090
|
createProxmoxServiceStartTool(getClient, getSsh, vmDefaults),
|
|
2671
5091
|
createProxmoxServiceStopTool(getClient, getSsh, vmDefaults),
|
|
2672
|
-
createProxmoxServiceRestartTool(getClient, getSsh, vmDefaults)
|
|
5092
|
+
createProxmoxServiceRestartTool(getClient, getSsh, vmDefaults),
|
|
5093
|
+
createProxmoxUpdateVmConfigTool(getClient),
|
|
5094
|
+
createProxmoxUpdateContainerConfigTool(getClient),
|
|
5095
|
+
createProxmoxResizeDiskTool(getClient),
|
|
5096
|
+
createProxmoxRestoreBackupTool(getClient),
|
|
5097
|
+
createProxmoxMigrateResourceTool(getClient),
|
|
5098
|
+
createProxmoxSuspendResourceTool(getClient),
|
|
5099
|
+
createProxmoxResumeResourceTool(getClient),
|
|
5100
|
+
createProxmoxResetResourceTool(getClient),
|
|
5101
|
+
createProxmoxConvertToTemplateTool(getClient),
|
|
5102
|
+
createProxmoxListStorageContentTool(getClient),
|
|
5103
|
+
createProxmoxDownloadUrlTool(getClient),
|
|
5104
|
+
createProxmoxDeleteVolumeTool(getClient),
|
|
5105
|
+
createProxmoxListNodeServicesTool(getClient),
|
|
5106
|
+
createProxmoxListUpdatesTool(getClient),
|
|
5107
|
+
createProxmoxListDisksTool(getClient),
|
|
5108
|
+
createProxmoxCancelTaskTool(getClient),
|
|
5109
|
+
createProxmoxNodePowerTool(getClient),
|
|
5110
|
+
createProxmoxListFirewallRulesTool(getClient),
|
|
5111
|
+
createProxmoxGetFirewallOptionsTool(getClient),
|
|
5112
|
+
createProxmoxAddFirewallRuleTool(getClient),
|
|
5113
|
+
createProxmoxDeleteFirewallRuleTool(getClient),
|
|
5114
|
+
createProxmoxSetFirewallEnabledTool(getClient),
|
|
5115
|
+
createProxmoxMoveDiskTool(getClient),
|
|
5116
|
+
createProxmoxListStorageConfigTool(getClient),
|
|
5117
|
+
createProxmoxCreateStorageTool(getClient),
|
|
5118
|
+
createProxmoxDeleteStorageTool(getClient),
|
|
5119
|
+
createProxmoxListBackupJobsTool(getClient),
|
|
5120
|
+
createProxmoxCreateBackupJobTool(getClient),
|
|
5121
|
+
createProxmoxDeleteBackupJobTool(getClient),
|
|
5122
|
+
createProxmoxListUsersTool(getClient),
|
|
5123
|
+
createProxmoxListRolesTool(getClient),
|
|
5124
|
+
createProxmoxListAclTool(getClient),
|
|
5125
|
+
createProxmoxListPoolsTool(getClient),
|
|
5126
|
+
createProxmoxListTokensTool(getClient),
|
|
5127
|
+
createProxmoxSetAclTool(getClient),
|
|
5128
|
+
createProxmoxCreateTokenTool(getClient),
|
|
5129
|
+
createProxmoxDeleteTokenTool(getClient),
|
|
5130
|
+
createProxmoxCreatePoolTool(getClient),
|
|
5131
|
+
createProxmoxUpdatePoolTool(getClient),
|
|
5132
|
+
createProxmoxDeletePoolTool(getClient),
|
|
5133
|
+
createProxmoxClusterStatusTool(getClient),
|
|
5134
|
+
createProxmoxHaStatusTool(getClient),
|
|
5135
|
+
createProxmoxListHaResourcesTool(getClient),
|
|
5136
|
+
createProxmoxListHaRulesTool(getClient),
|
|
5137
|
+
createProxmoxListReplicationTool(getClient),
|
|
5138
|
+
createProxmoxListSdnZonesTool(getClient),
|
|
5139
|
+
createProxmoxListSdnVnetsTool(getClient),
|
|
5140
|
+
createProxmoxListMetricServersTool(getClient),
|
|
5141
|
+
createProxmoxGetClusterOptionsTool(getClient),
|
|
5142
|
+
createProxmoxClusterLogTool(getClient),
|
|
5143
|
+
createProxmoxAddHaResourceTool(getClient),
|
|
5144
|
+
createProxmoxDeleteHaResourceTool(getClient),
|
|
5145
|
+
createProxmoxCreateReplicationTool(getClient),
|
|
5146
|
+
createProxmoxDeleteReplicationTool(getClient)
|
|
2673
5147
|
];
|
|
2674
5148
|
const toolMap = new Map(tools.map((t) => [t.name, t]));
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
5149
|
+
{
|
|
5150
|
+
const registered = new Set(tools.map((t) => t.name));
|
|
5151
|
+
const declared = new Set(Object.keys(TOOL_TIERS));
|
|
5152
|
+
const missing = [...registered].filter((n) => !declared.has(n));
|
|
5153
|
+
const extra = [...declared].filter((n) => !registered.has(n));
|
|
5154
|
+
if (missing.length > 0 || extra.length > 0) {
|
|
5155
|
+
throw new Error(
|
|
5156
|
+
`registry/tool drift: missing tier for [${missing.join(", ")}]; tier declared for unregistered [${extra.join(", ")}]`
|
|
5157
|
+
);
|
|
5158
|
+
}
|
|
5159
|
+
}
|
|
5160
|
+
const deferred = deferredModeEnabled(process.env);
|
|
5161
|
+
const session = deferred ? createDeferredSession() : null;
|
|
5162
|
+
const searchIndex = deferred ? buildSearchIndex(
|
|
5163
|
+
tools.map((t) => ({ name: t.name, description: t.description })),
|
|
5164
|
+
TOOL_SEARCH_META
|
|
5165
|
+
) : null;
|
|
5166
|
+
if (toolMap.has(SEARCH_TOOL_NAME)) {
|
|
5167
|
+
throw new Error(`search tool name ${SEARCH_TOOL_NAME} collides with a registered tool`);
|
|
5168
|
+
}
|
|
5169
|
+
const server = new Server(
|
|
5170
|
+
{ name: "proxmox-mcp", version: "0.12.0" },
|
|
5171
|
+
{ capabilities: { tools: deferred ? { listChanged: true } : {} } }
|
|
5172
|
+
);
|
|
5173
|
+
const descriptorFor = (t) => ({
|
|
5174
|
+
name: t.name,
|
|
5175
|
+
description: t.description,
|
|
5176
|
+
inputSchema: t.parameters,
|
|
5177
|
+
annotations: annotationsForTier(tierForTool(t.name))
|
|
5178
|
+
});
|
|
5179
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
5180
|
+
if (!deferred || session === null) return { tools: tools.map(descriptorFor) };
|
|
5181
|
+
return {
|
|
5182
|
+
tools: [
|
|
5183
|
+
{
|
|
5184
|
+
name: SEARCH_TOOL_NAME,
|
|
5185
|
+
description: SEARCH_TOOL_DESCRIPTION,
|
|
5186
|
+
inputSchema: searchToolParameters,
|
|
5187
|
+
annotations: { readOnlyHint: true }
|
|
5188
|
+
},
|
|
5189
|
+
...tools.filter((t) => session.isLoaded(t.name)).map(descriptorFor)
|
|
5190
|
+
]
|
|
5191
|
+
};
|
|
5192
|
+
});
|
|
2679
5193
|
server.setRequestHandler(CallToolRequestSchema, async (req) => {
|
|
5194
|
+
if (deferred && session !== null && searchIndex !== null && req.params.name === SEARCH_TOOL_NAME) {
|
|
5195
|
+
try {
|
|
5196
|
+
const outcome = runToolSearch(
|
|
5197
|
+
req.params.arguments ?? {},
|
|
5198
|
+
searchIndex,
|
|
5199
|
+
session
|
|
5200
|
+
);
|
|
5201
|
+
if (outcome.added.length > 0) await server.sendToolListChanged();
|
|
5202
|
+
return outcome.result;
|
|
5203
|
+
} catch (e) {
|
|
5204
|
+
const payload = redact(classifyToolError(e));
|
|
5205
|
+
return { content: [{ type: "text", text: JSON.stringify(payload) }], isError: true };
|
|
5206
|
+
}
|
|
5207
|
+
}
|
|
2680
5208
|
const t = toolMap.get(req.params.name);
|
|
2681
5209
|
if (!t) {
|
|
2682
5210
|
return {
|
|
@@ -2691,6 +5219,7 @@ async function startServer() {
|
|
|
2691
5219
|
isError: true
|
|
2692
5220
|
};
|
|
2693
5221
|
}
|
|
5222
|
+
if (deferred && session !== null) session.load([t.name]);
|
|
2694
5223
|
try {
|
|
2695
5224
|
return await t.execute(req.params.name, req.params.arguments ?? {});
|
|
2696
5225
|
} catch (e) {
|
|
@@ -2698,12 +5227,16 @@ async function startServer() {
|
|
|
2698
5227
|
return { content: [{ type: "text", text: JSON.stringify(payload) }], isError: true };
|
|
2699
5228
|
}
|
|
2700
5229
|
});
|
|
5230
|
+
return server;
|
|
5231
|
+
}
|
|
5232
|
+
async function startServer() {
|
|
5233
|
+
const server = createMcpServer();
|
|
2701
5234
|
const transport = new StdioServerTransport();
|
|
2702
5235
|
const __send = transport.send.bind(transport);
|
|
2703
5236
|
transport.send = (message) => {
|
|
2704
|
-
const
|
|
2705
|
-
if (Array.isArray(
|
|
2706
|
-
for (const t of
|
|
5237
|
+
const tools = message?.result?.tools;
|
|
5238
|
+
if (Array.isArray(tools)) {
|
|
5239
|
+
for (const t of tools) {
|
|
2707
5240
|
if (t?.inputSchema) delete t.inputSchema.$schema;
|
|
2708
5241
|
if (t?.outputSchema) delete t.outputSchema.$schema;
|
|
2709
5242
|
}
|
|
@@ -2712,6 +5245,8 @@ async function startServer() {
|
|
|
2712
5245
|
};
|
|
2713
5246
|
await server.connect(transport);
|
|
2714
5247
|
}
|
|
5248
|
+
|
|
5249
|
+
// mcp-server.ts
|
|
2715
5250
|
var isEntrypoint = (() => {
|
|
2716
5251
|
const arg = process.argv[1];
|
|
2717
5252
|
if (typeof arg !== "string") return false;
|