@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/cli.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// cli.ts
|
|
4
|
-
import { realpathSync
|
|
5
|
-
import { pathToFileURL
|
|
4
|
+
import { realpathSync } from "fs";
|
|
5
|
+
import { pathToFileURL } from "url";
|
|
6
6
|
|
|
7
7
|
// src/proxmox-client.ts
|
|
8
8
|
import { request as httpsRequest } from "https";
|
|
@@ -12,7 +12,6 @@ var ProxmoxClientError = class extends Error {
|
|
|
12
12
|
this.status = status;
|
|
13
13
|
this.name = "ProxmoxClientError";
|
|
14
14
|
}
|
|
15
|
-
status;
|
|
16
15
|
};
|
|
17
16
|
var ProxmoxUnreachableError = class extends Error {
|
|
18
17
|
constructor(cause) {
|
|
@@ -27,7 +26,6 @@ var ProxmoxClient = class {
|
|
|
27
26
|
this.retryDelayMs = opts.retryDelayMs ?? 1e3;
|
|
28
27
|
this.usesInsecureTls = cfg.tlsInsecure && cfg.url.startsWith("https://");
|
|
29
28
|
}
|
|
30
|
-
cfg;
|
|
31
29
|
authHeader;
|
|
32
30
|
retryDelayMs;
|
|
33
31
|
usesInsecureTls;
|
|
@@ -37,6 +35,9 @@ var ProxmoxClient = class {
|
|
|
37
35
|
async post(path2, body) {
|
|
38
36
|
return this.request("POST", path2, body);
|
|
39
37
|
}
|
|
38
|
+
async put(path2, body) {
|
|
39
|
+
return this.request("PUT", path2, body);
|
|
40
|
+
}
|
|
40
41
|
async delete(path2) {
|
|
41
42
|
return this.request("DELETE", path2);
|
|
42
43
|
}
|
|
@@ -49,6 +50,13 @@ var ProxmoxClient = class {
|
|
|
49
50
|
const form = new URLSearchParams();
|
|
50
51
|
for (const [k, v] of Object.entries(body)) {
|
|
51
52
|
if (v === void 0 || v === null) continue;
|
|
53
|
+
if (Array.isArray(v)) {
|
|
54
|
+
for (const item of v) {
|
|
55
|
+
if (item === void 0 || item === null) continue;
|
|
56
|
+
form.append(k, typeof item === "object" ? JSON.stringify(item) : String(item));
|
|
57
|
+
}
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
52
60
|
form.append(k, typeof v === "object" ? JSON.stringify(v) : String(v));
|
|
53
61
|
}
|
|
54
62
|
headers["content-type"] = "application/x-www-form-urlencoded";
|
|
@@ -175,19 +183,39 @@ function resolveConfig(env) {
|
|
|
175
183
|
// src/security.ts
|
|
176
184
|
var SECRETS = /* @__PURE__ */ new Set();
|
|
177
185
|
var BASE64_TOKEN_RE = /[A-Za-z0-9+/=]{12,}/g;
|
|
186
|
+
var MIN_SUBSTRING_LENGTH = 8;
|
|
187
|
+
var warnedShortSecret = false;
|
|
188
|
+
function escapeRegExp(s) {
|
|
189
|
+
return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
190
|
+
}
|
|
178
191
|
function registerSecret(s) {
|
|
179
|
-
if (s
|
|
192
|
+
if (!s || s.length === 0) return;
|
|
193
|
+
SECRETS.add(s);
|
|
194
|
+
if (s.length < MIN_SUBSTRING_LENGTH && !warnedShortSecret) {
|
|
195
|
+
warnedShortSecret = true;
|
|
196
|
+
console.error(
|
|
197
|
+
`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.`
|
|
198
|
+
);
|
|
199
|
+
}
|
|
180
200
|
}
|
|
181
201
|
function maskString(s) {
|
|
182
202
|
let out = s;
|
|
183
203
|
for (const secret of SECRETS) {
|
|
184
|
-
if (out.includes(secret))
|
|
204
|
+
if (!out.includes(secret)) continue;
|
|
205
|
+
if (secret.length >= MIN_SUBSTRING_LENGTH) {
|
|
206
|
+
out = out.split(secret).join("REDACTED");
|
|
207
|
+
} else {
|
|
208
|
+
out = out.replace(
|
|
209
|
+
new RegExp(`(^|[^A-Za-z0-9])${escapeRegExp(secret)}(?=[^A-Za-z0-9]|$)`, "g"),
|
|
210
|
+
(_match, left) => `${left}REDACTED`
|
|
211
|
+
);
|
|
212
|
+
}
|
|
185
213
|
}
|
|
186
214
|
out = out.replace(BASE64_TOKEN_RE, (token) => {
|
|
187
215
|
try {
|
|
188
216
|
const decoded = Buffer.from(token, "base64").toString("utf8");
|
|
189
217
|
for (const secret of SECRETS) {
|
|
190
|
-
if (decoded.includes(secret)) return "REDACTED";
|
|
218
|
+
if (secret.length >= MIN_SUBSTRING_LENGTH && decoded.includes(secret)) return "REDACTED";
|
|
191
219
|
}
|
|
192
220
|
} catch {
|
|
193
221
|
}
|
|
@@ -206,7 +234,7 @@ function redact(value) {
|
|
|
206
234
|
return value;
|
|
207
235
|
}
|
|
208
236
|
|
|
209
|
-
//
|
|
237
|
+
// src/server.ts
|
|
210
238
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
211
239
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
212
240
|
import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
@@ -222,7 +250,6 @@ var SshExecError = class extends Error {
|
|
|
222
250
|
this.phase = phase;
|
|
223
251
|
this.name = "SshExecError";
|
|
224
252
|
}
|
|
225
|
-
phase;
|
|
226
253
|
};
|
|
227
254
|
function expandHome(p) {
|
|
228
255
|
if (p.startsWith("~/")) return homedir() + p.slice(1);
|
|
@@ -402,6 +429,7 @@ async function resolveResource(client, vmid) {
|
|
|
402
429
|
const where = matches.map((m) => `${m.node}/${m.type}`).join(", ");
|
|
403
430
|
throw new Error(`vmid ${vmid} ambiguous - found on multiple nodes: ${where}. Refusing to proceed.`);
|
|
404
431
|
}
|
|
432
|
+
assertSafePathSegment(matches[0].node, "node");
|
|
405
433
|
return { node: matches[0].node, type: matches[0].type };
|
|
406
434
|
}
|
|
407
435
|
function parseTaskUpid(upid) {
|
|
@@ -412,6 +440,7 @@ function parseTaskUpid(upid) {
|
|
|
412
440
|
if (parts.length < 8) throw new Error(`invalid UPID format: ${upid}`);
|
|
413
441
|
const node = parts[1];
|
|
414
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}"`);
|
|
415
444
|
return { node };
|
|
416
445
|
}
|
|
417
446
|
|
|
@@ -1095,23 +1124,56 @@ function createProxmoxRollbackSnapshotTool(getClient) {
|
|
|
1095
1124
|
}
|
|
1096
1125
|
|
|
1097
1126
|
// src/tools/proxmox_run_backup.ts
|
|
1127
|
+
import { Type as Type18 } from "@sinclair/typebox";
|
|
1128
|
+
|
|
1129
|
+
// src/tools/task-wait.ts
|
|
1098
1130
|
import { Type as Type17 } from "@sinclair/typebox";
|
|
1099
|
-
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(
|
|
1100
1161
|
{
|
|
1101
|
-
vmid:
|
|
1102
|
-
storage:
|
|
1162
|
+
vmid: Type18.Integer({ minimum: 1, description: "Container or VM ID to back up." }),
|
|
1163
|
+
storage: Type18.String({
|
|
1103
1164
|
minLength: 1,
|
|
1104
1165
|
description: "PVE storage ID where the vzdump archive should be written."
|
|
1105
1166
|
}),
|
|
1106
|
-
mode:
|
|
1107
|
-
|
|
1108
|
-
[
|
|
1167
|
+
mode: Type18.Optional(
|
|
1168
|
+
Type18.Union(
|
|
1169
|
+
[Type18.Literal("snapshot"), Type18.Literal("suspend"), Type18.Literal("stop")],
|
|
1109
1170
|
{ description: "Backup mode. Defaults to 'snapshot'." }
|
|
1110
1171
|
)
|
|
1111
1172
|
),
|
|
1112
|
-
confirm:
|
|
1173
|
+
confirm: Type18.Boolean({
|
|
1113
1174
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1114
|
-
})
|
|
1175
|
+
}),
|
|
1176
|
+
...taskWaitFields
|
|
1115
1177
|
},
|
|
1116
1178
|
{ additionalProperties: false }
|
|
1117
1179
|
);
|
|
@@ -1134,23 +1196,25 @@ function createProxmoxRunBackupTool(getClient) {
|
|
|
1134
1196
|
mode,
|
|
1135
1197
|
compress: "zstd"
|
|
1136
1198
|
});
|
|
1199
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1137
1200
|
return jsonToolResult({
|
|
1138
1201
|
vmid: args.vmid,
|
|
1139
1202
|
node,
|
|
1140
1203
|
storage: args.storage,
|
|
1141
1204
|
mode,
|
|
1142
|
-
upid
|
|
1205
|
+
upid,
|
|
1206
|
+
...task ? { task } : {}
|
|
1143
1207
|
});
|
|
1144
1208
|
}
|
|
1145
1209
|
};
|
|
1146
1210
|
}
|
|
1147
1211
|
|
|
1148
1212
|
// src/tools/proxmox_get_task_status.ts
|
|
1149
|
-
import { Type as
|
|
1213
|
+
import { Type as Type19 } from "@sinclair/typebox";
|
|
1150
1214
|
var NAME15 = "proxmox_get_task_status";
|
|
1151
|
-
var Schema18 =
|
|
1215
|
+
var Schema18 = Type19.Object(
|
|
1152
1216
|
{
|
|
1153
|
-
upid:
|
|
1217
|
+
upid: Type19.String({
|
|
1154
1218
|
minLength: 1,
|
|
1155
1219
|
description: "Task UPID returned by a prior write tool (e.g. start, stop, snapshot, backup)."
|
|
1156
1220
|
})
|
|
@@ -1176,19 +1240,19 @@ function createProxmoxGetTaskStatusTool(getClient) {
|
|
|
1176
1240
|
}
|
|
1177
1241
|
|
|
1178
1242
|
// src/tools/proxmox_get_task_log.ts
|
|
1179
|
-
import { Type as
|
|
1243
|
+
import { Type as Type20 } from "@sinclair/typebox";
|
|
1180
1244
|
var NAME16 = "proxmox_get_task_log";
|
|
1181
|
-
var Schema19 =
|
|
1245
|
+
var Schema19 = Type20.Object(
|
|
1182
1246
|
{
|
|
1183
|
-
upid:
|
|
1247
|
+
upid: Type20.String({
|
|
1184
1248
|
minLength: 1,
|
|
1185
1249
|
description: "Task UPID returned by a prior write tool."
|
|
1186
1250
|
}),
|
|
1187
|
-
start:
|
|
1188
|
-
|
|
1251
|
+
start: Type20.Optional(
|
|
1252
|
+
Type20.Integer({ minimum: 0, description: "Line offset to start from (default 0)." })
|
|
1189
1253
|
),
|
|
1190
|
-
limit:
|
|
1191
|
-
|
|
1254
|
+
limit: Type20.Optional(
|
|
1255
|
+
Type20.Integer({
|
|
1192
1256
|
minimum: 1,
|
|
1193
1257
|
maximum: 500,
|
|
1194
1258
|
description: "Max lines to return (default 50, max 500)."
|
|
@@ -1218,19 +1282,19 @@ function createProxmoxGetTaskLogTool(getClient) {
|
|
|
1218
1282
|
}
|
|
1219
1283
|
|
|
1220
1284
|
// src/tools/proxmox_list_templates.ts
|
|
1221
|
-
import { Type as
|
|
1285
|
+
import { Type as Type21 } from "@sinclair/typebox";
|
|
1222
1286
|
var NAME17 = "proxmox_list_templates";
|
|
1223
|
-
var Schema20 =
|
|
1287
|
+
var Schema20 = Type21.Object(
|
|
1224
1288
|
{
|
|
1225
|
-
node:
|
|
1226
|
-
|
|
1289
|
+
node: Type21.Optional(
|
|
1290
|
+
Type21.String({ minLength: 1, description: "Node to query (defaults to first node)." })
|
|
1227
1291
|
),
|
|
1228
|
-
storage:
|
|
1229
|
-
|
|
1292
|
+
storage: Type21.Optional(
|
|
1293
|
+
Type21.String({ minLength: 1, description: "Storage to query (defaults to 'local')." })
|
|
1230
1294
|
),
|
|
1231
|
-
kind:
|
|
1232
|
-
|
|
1233
|
-
[
|
|
1295
|
+
kind: Type21.Optional(
|
|
1296
|
+
Type21.Union(
|
|
1297
|
+
[Type21.Literal("vztmpl"), Type21.Literal("iso"), Type21.Literal("both")],
|
|
1234
1298
|
{ description: "Template kind: 'vztmpl' (CT templates), 'iso' (VM ISOs), or 'both'. Defaults to 'both'." }
|
|
1235
1299
|
)
|
|
1236
1300
|
)
|
|
@@ -1278,11 +1342,11 @@ function createProxmoxListTemplatesTool(getClient) {
|
|
|
1278
1342
|
}
|
|
1279
1343
|
|
|
1280
1344
|
// src/tools/proxmox_list_storage.ts
|
|
1281
|
-
import { Type as
|
|
1282
|
-
var Schema21 =
|
|
1345
|
+
import { Type as Type22 } from "@sinclair/typebox";
|
|
1346
|
+
var Schema21 = Type22.Object(
|
|
1283
1347
|
{
|
|
1284
|
-
node:
|
|
1285
|
-
|
|
1348
|
+
node: Type22.Optional(
|
|
1349
|
+
Type22.String({ minLength: 1, description: "Node to query. Defaults to all nodes." })
|
|
1286
1350
|
)
|
|
1287
1351
|
},
|
|
1288
1352
|
{ additionalProperties: false }
|
|
@@ -1316,10 +1380,10 @@ function createProxmoxListStorageTool(getClient) {
|
|
|
1316
1380
|
}
|
|
1317
1381
|
|
|
1318
1382
|
// src/tools/proxmox_list_snapshots.ts
|
|
1319
|
-
import { Type as
|
|
1320
|
-
var Schema22 =
|
|
1383
|
+
import { Type as Type23 } from "@sinclair/typebox";
|
|
1384
|
+
var Schema22 = Type23.Object(
|
|
1321
1385
|
{
|
|
1322
|
-
vmid:
|
|
1386
|
+
vmid: Type23.Integer({ minimum: 1, description: "Container or VM ID." })
|
|
1323
1387
|
},
|
|
1324
1388
|
{ additionalProperties: false }
|
|
1325
1389
|
);
|
|
@@ -1341,10 +1405,10 @@ function createProxmoxListSnapshotsTool(getClient) {
|
|
|
1341
1405
|
}
|
|
1342
1406
|
|
|
1343
1407
|
// src/tools/proxmox_guest_network.ts
|
|
1344
|
-
import { Type as
|
|
1345
|
-
var Schema23 =
|
|
1408
|
+
import { Type as Type24 } from "@sinclair/typebox";
|
|
1409
|
+
var Schema23 = Type24.Object(
|
|
1346
1410
|
{
|
|
1347
|
-
vmid:
|
|
1411
|
+
vmid: Type24.Integer({ minimum: 1, description: "Container or VM ID." })
|
|
1348
1412
|
},
|
|
1349
1413
|
{ additionalProperties: false }
|
|
1350
1414
|
);
|
|
@@ -1383,15 +1447,15 @@ function createProxmoxGuestNetworkTool(getClient) {
|
|
|
1383
1447
|
}
|
|
1384
1448
|
|
|
1385
1449
|
// src/tools/proxmox_wait_task.ts
|
|
1386
|
-
import { Type as
|
|
1387
|
-
var Schema24 =
|
|
1450
|
+
import { Type as Type25 } from "@sinclair/typebox";
|
|
1451
|
+
var Schema24 = Type25.Object(
|
|
1388
1452
|
{
|
|
1389
|
-
upid:
|
|
1390
|
-
timeoutSeconds:
|
|
1391
|
-
|
|
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." })
|
|
1392
1456
|
),
|
|
1393
|
-
intervalMs:
|
|
1394
|
-
|
|
1457
|
+
intervalMs: Type25.Optional(
|
|
1458
|
+
Type25.Integer({ minimum: 100, maximum: 1e4, description: "Polling interval in milliseconds. Default 1000." })
|
|
1395
1459
|
)
|
|
1396
1460
|
},
|
|
1397
1461
|
{ additionalProperties: false }
|
|
@@ -1420,19 +1484,19 @@ function createProxmoxWaitTaskTool(getClient) {
|
|
|
1420
1484
|
if (lastStatus.status === "stopped" || lastStatus.exitstatus) {
|
|
1421
1485
|
return jsonToolResult({ upid: args.upid, node, done: true, polls, status: lastStatus });
|
|
1422
1486
|
}
|
|
1423
|
-
await
|
|
1487
|
+
await sleep3(Math.min(intervalMs, Math.max(0, deadline - Date.now())));
|
|
1424
1488
|
}
|
|
1425
1489
|
return jsonToolResult({ upid: args.upid, node, done: false, polls, status: lastStatus });
|
|
1426
1490
|
}
|
|
1427
1491
|
};
|
|
1428
1492
|
}
|
|
1429
|
-
function
|
|
1493
|
+
function sleep3(ms) {
|
|
1430
1494
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1431
1495
|
}
|
|
1432
1496
|
|
|
1433
1497
|
// src/tools/proxmox_next_vmid.ts
|
|
1434
|
-
import { Type as
|
|
1435
|
-
var Schema25 =
|
|
1498
|
+
import { Type as Type26 } from "@sinclair/typebox";
|
|
1499
|
+
var Schema25 = Type26.Object({}, { additionalProperties: false });
|
|
1436
1500
|
var NAME22 = "proxmox_next_vmid";
|
|
1437
1501
|
function createProxmoxNextVmidTool(getClient) {
|
|
1438
1502
|
return {
|
|
@@ -1449,11 +1513,11 @@ function createProxmoxNextVmidTool(getClient) {
|
|
|
1449
1513
|
}
|
|
1450
1514
|
|
|
1451
1515
|
// src/tools/proxmox_list_pool_resources.ts
|
|
1452
|
-
import { Type as
|
|
1453
|
-
var Schema26 =
|
|
1516
|
+
import { Type as Type27 } from "@sinclair/typebox";
|
|
1517
|
+
var Schema26 = Type27.Object(
|
|
1454
1518
|
{
|
|
1455
|
-
pool:
|
|
1456
|
-
|
|
1519
|
+
pool: Type27.Optional(
|
|
1520
|
+
Type27.String({ minLength: 1, description: "Pool ID to inspect (default mcp-smoke)." })
|
|
1457
1521
|
)
|
|
1458
1522
|
},
|
|
1459
1523
|
{ additionalProperties: false }
|
|
@@ -1481,69 +1545,70 @@ function createProxmoxListPoolResourcesTool(getClient) {
|
|
|
1481
1545
|
}
|
|
1482
1546
|
|
|
1483
1547
|
// src/tools/proxmox_create_container.ts
|
|
1484
|
-
import { Type as
|
|
1485
|
-
var Schema27 =
|
|
1548
|
+
import { Type as Type28 } from "@sinclair/typebox";
|
|
1549
|
+
var Schema27 = Type28.Object(
|
|
1486
1550
|
{
|
|
1487
|
-
vmid:
|
|
1488
|
-
hostname:
|
|
1489
|
-
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({
|
|
1490
1554
|
minLength: 1,
|
|
1491
1555
|
description: "OS template volid (e.g. 'local:vztmpl/ubuntu-24.04-standard_*.tar.zst')."
|
|
1492
1556
|
}),
|
|
1493
|
-
node:
|
|
1494
|
-
|
|
1557
|
+
node: Type28.Optional(
|
|
1558
|
+
Type28.String({ minLength: 1, description: "Node to create on (defaults to first node)." })
|
|
1495
1559
|
),
|
|
1496
|
-
storage:
|
|
1497
|
-
|
|
1560
|
+
storage: Type28.Optional(
|
|
1561
|
+
Type28.String({ minLength: 1, description: "Root storage (default 'local-lvm')." })
|
|
1498
1562
|
),
|
|
1499
|
-
memory:
|
|
1500
|
-
|
|
1563
|
+
memory: Type28.Optional(
|
|
1564
|
+
Type28.Integer({ minimum: 16, description: "Memory in MiB (default 512)." })
|
|
1501
1565
|
),
|
|
1502
|
-
cores:
|
|
1503
|
-
|
|
1566
|
+
cores: Type28.Optional(
|
|
1567
|
+
Type28.Integer({ minimum: 1, description: "CPU cores (default 1)." })
|
|
1504
1568
|
),
|
|
1505
|
-
rootfs_size:
|
|
1506
|
-
|
|
1569
|
+
rootfs_size: Type28.Optional(
|
|
1570
|
+
Type28.String({ minLength: 1, description: "Root filesystem size in GB (default '8')." })
|
|
1507
1571
|
),
|
|
1508
|
-
net:
|
|
1509
|
-
|
|
1572
|
+
net: Type28.Optional(
|
|
1573
|
+
Type28.String({
|
|
1510
1574
|
minLength: 1,
|
|
1511
1575
|
description: "Network config for net0 (default 'name=eth0,bridge=vmbr0,ip=dhcp')."
|
|
1512
1576
|
})
|
|
1513
1577
|
),
|
|
1514
|
-
start:
|
|
1515
|
-
|
|
1578
|
+
start: Type28.Optional(
|
|
1579
|
+
Type28.Boolean({ description: "Start after create (default false)." })
|
|
1516
1580
|
),
|
|
1517
|
-
pool:
|
|
1518
|
-
|
|
1581
|
+
pool: Type28.Optional(
|
|
1582
|
+
Type28.String({ minLength: 1, description: "Optional resource pool ID to place the container into." })
|
|
1519
1583
|
),
|
|
1520
|
-
onboot:
|
|
1521
|
-
|
|
1584
|
+
onboot: Type28.Optional(
|
|
1585
|
+
Type28.Boolean({ description: "Start container on host boot (default false)." })
|
|
1522
1586
|
),
|
|
1523
|
-
unprivileged:
|
|
1524
|
-
|
|
1587
|
+
unprivileged: Type28.Optional(
|
|
1588
|
+
Type28.Boolean({ description: "Create an unprivileged container (default true)." })
|
|
1525
1589
|
),
|
|
1526
|
-
protection:
|
|
1527
|
-
|
|
1590
|
+
protection: Type28.Optional(
|
|
1591
|
+
Type28.Boolean({ description: "Enable Proxmox protection flag (default false)." })
|
|
1528
1592
|
),
|
|
1529
|
-
features:
|
|
1530
|
-
|
|
1593
|
+
features: Type28.Optional(
|
|
1594
|
+
Type28.String({ minLength: 1, description: "Optional LXC features string, e.g. 'nesting=1'." })
|
|
1531
1595
|
),
|
|
1532
|
-
description:
|
|
1533
|
-
|
|
1596
|
+
description: Type28.Optional(
|
|
1597
|
+
Type28.String({ description: "Optional container description." })
|
|
1534
1598
|
),
|
|
1535
|
-
tags:
|
|
1536
|
-
|
|
1599
|
+
tags: Type28.Optional(
|
|
1600
|
+
Type28.String({ minLength: 1, description: "Optional semicolon-delimited Proxmox tags." })
|
|
1537
1601
|
),
|
|
1538
|
-
password:
|
|
1539
|
-
|
|
1602
|
+
password: Type28.Optional(
|
|
1603
|
+
Type28.String({ description: "Root password (optional)." })
|
|
1540
1604
|
),
|
|
1541
|
-
ssh_public_keys:
|
|
1542
|
-
|
|
1605
|
+
ssh_public_keys: Type28.Optional(
|
|
1606
|
+
Type28.String({ description: "SSH public keys (optional)." })
|
|
1543
1607
|
),
|
|
1544
|
-
confirm:
|
|
1608
|
+
confirm: Type28.Boolean({
|
|
1545
1609
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1546
|
-
})
|
|
1610
|
+
}),
|
|
1611
|
+
...taskWaitFields
|
|
1547
1612
|
},
|
|
1548
1613
|
{ additionalProperties: false }
|
|
1549
1614
|
);
|
|
@@ -1562,7 +1627,9 @@ function createProxmoxCreateContainerTool(getClient) {
|
|
|
1562
1627
|
}
|
|
1563
1628
|
const client = getClient();
|
|
1564
1629
|
let node = args.node;
|
|
1565
|
-
if (
|
|
1630
|
+
if (node) {
|
|
1631
|
+
assertSafePathSegment(node, "node");
|
|
1632
|
+
} else {
|
|
1566
1633
|
const nodes = await client.get("/cluster/resources?type=node");
|
|
1567
1634
|
if (nodes.length === 0) throw new Error("no nodes found in cluster resources");
|
|
1568
1635
|
node = nodes[0].node;
|
|
@@ -1600,109 +1667,112 @@ function createProxmoxCreateContainerTool(getClient) {
|
|
|
1600
1667
|
body.tags = args.tags;
|
|
1601
1668
|
}
|
|
1602
1669
|
const upid = await client.post(`/nodes/${node}/lxc`, body);
|
|
1670
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1603
1671
|
return jsonToolResult({
|
|
1604
1672
|
vmid: args.vmid,
|
|
1605
1673
|
node,
|
|
1606
1674
|
hostname: args.hostname,
|
|
1607
|
-
upid
|
|
1675
|
+
upid,
|
|
1676
|
+
...task ? { task } : {}
|
|
1608
1677
|
});
|
|
1609
1678
|
}
|
|
1610
1679
|
};
|
|
1611
1680
|
}
|
|
1612
1681
|
|
|
1613
1682
|
// src/tools/proxmox_create_vm.ts
|
|
1614
|
-
import { Type as
|
|
1615
|
-
var Schema28 =
|
|
1683
|
+
import { Type as Type29 } from "@sinclair/typebox";
|
|
1684
|
+
var Schema28 = Type29.Object(
|
|
1616
1685
|
{
|
|
1617
|
-
vmid:
|
|
1618
|
-
name:
|
|
1619
|
-
node:
|
|
1620
|
-
|
|
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)." })
|
|
1621
1690
|
),
|
|
1622
|
-
memory:
|
|
1623
|
-
|
|
1691
|
+
memory: Type29.Optional(
|
|
1692
|
+
Type29.Integer({ minimum: 16, description: "Memory in MiB (default 2048)." })
|
|
1624
1693
|
),
|
|
1625
|
-
cores:
|
|
1626
|
-
|
|
1694
|
+
cores: Type29.Optional(
|
|
1695
|
+
Type29.Integer({ minimum: 1, description: "CPU cores (default 2)." })
|
|
1627
1696
|
),
|
|
1628
|
-
iso:
|
|
1629
|
-
|
|
1697
|
+
iso: Type29.Optional(
|
|
1698
|
+
Type29.String({
|
|
1630
1699
|
minLength: 1,
|
|
1631
1700
|
description: "ISO volid for install media (e.g. 'local:iso/ubuntu-24.04.iso'). If set, attaches as ide2 cdrom."
|
|
1632
1701
|
})
|
|
1633
1702
|
),
|
|
1634
|
-
disk_size:
|
|
1635
|
-
|
|
1703
|
+
disk_size: Type29.Optional(
|
|
1704
|
+
Type29.String({ minLength: 1, description: "Primary disk size in GB on scsi0 (default '32')." })
|
|
1636
1705
|
),
|
|
1637
|
-
storage:
|
|
1638
|
-
|
|
1706
|
+
storage: Type29.Optional(
|
|
1707
|
+
Type29.String({ minLength: 1, description: "Disk storage (default 'local-lvm')." })
|
|
1639
1708
|
),
|
|
1640
|
-
net:
|
|
1641
|
-
|
|
1709
|
+
net: Type29.Optional(
|
|
1710
|
+
Type29.String({
|
|
1642
1711
|
minLength: 1,
|
|
1643
1712
|
description: "Network config for net0 (default 'model=virtio,bridge=vmbr0')."
|
|
1644
1713
|
})
|
|
1645
1714
|
),
|
|
1646
|
-
start:
|
|
1647
|
-
|
|
1715
|
+
start: Type29.Optional(
|
|
1716
|
+
Type29.Boolean({ description: "Start after create (default false)." })
|
|
1648
1717
|
),
|
|
1649
|
-
pool:
|
|
1650
|
-
|
|
1718
|
+
pool: Type29.Optional(
|
|
1719
|
+
Type29.String({ minLength: 1, description: "Optional resource pool ID to place the VM into." })
|
|
1651
1720
|
),
|
|
1652
|
-
onboot:
|
|
1653
|
-
|
|
1721
|
+
onboot: Type29.Optional(
|
|
1722
|
+
Type29.Boolean({ description: "Start VM on host boot (default false)." })
|
|
1654
1723
|
),
|
|
1655
|
-
protection:
|
|
1656
|
-
|
|
1724
|
+
protection: Type29.Optional(
|
|
1725
|
+
Type29.Boolean({ description: "Enable Proxmox protection flag (default false)." })
|
|
1657
1726
|
),
|
|
1658
|
-
agent:
|
|
1659
|
-
|
|
1727
|
+
agent: Type29.Optional(
|
|
1728
|
+
Type29.Boolean({ description: "Enable QEMU guest agent in VM config (default false)." })
|
|
1660
1729
|
),
|
|
1661
|
-
scsihw:
|
|
1662
|
-
|
|
1730
|
+
scsihw: Type29.Optional(
|
|
1731
|
+
Type29.String({ minLength: 1, description: "Optional SCSI controller, e.g. 'virtio-scsi-pci'." })
|
|
1663
1732
|
),
|
|
1664
|
-
boot:
|
|
1665
|
-
|
|
1733
|
+
boot: Type29.Optional(
|
|
1734
|
+
Type29.String({ minLength: 1, description: "Optional boot order string." })
|
|
1666
1735
|
),
|
|
1667
|
-
bios:
|
|
1668
|
-
|
|
1736
|
+
bios: Type29.Optional(
|
|
1737
|
+
Type29.Union([Type29.Literal("seabios"), Type29.Literal("ovmf")], { description: "Optional VM BIOS type." })
|
|
1669
1738
|
),
|
|
1670
|
-
machine:
|
|
1671
|
-
|
|
1739
|
+
machine: Type29.Optional(
|
|
1740
|
+
Type29.String({ minLength: 1, description: "Optional machine type." })
|
|
1672
1741
|
),
|
|
1673
|
-
cpu:
|
|
1674
|
-
|
|
1742
|
+
cpu: Type29.Optional(
|
|
1743
|
+
Type29.String({ minLength: 1, description: "Optional CPU type." })
|
|
1675
1744
|
),
|
|
1676
|
-
sockets:
|
|
1677
|
-
|
|
1745
|
+
sockets: Type29.Optional(
|
|
1746
|
+
Type29.Integer({ minimum: 1, description: "Optional socket count." })
|
|
1678
1747
|
),
|
|
1679
|
-
description:
|
|
1680
|
-
|
|
1748
|
+
description: Type29.Optional(
|
|
1749
|
+
Type29.String({ description: "Optional VM description." })
|
|
1681
1750
|
),
|
|
1682
|
-
tags:
|
|
1683
|
-
|
|
1751
|
+
tags: Type29.Optional(
|
|
1752
|
+
Type29.String({ minLength: 1, description: "Optional semicolon-delimited Proxmox tags." })
|
|
1684
1753
|
),
|
|
1685
|
-
ciuser:
|
|
1686
|
-
|
|
1754
|
+
ciuser: Type29.Optional(
|
|
1755
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init username." })
|
|
1687
1756
|
),
|
|
1688
|
-
cipassword:
|
|
1689
|
-
|
|
1757
|
+
cipassword: Type29.Optional(
|
|
1758
|
+
Type29.String({ description: "Optional cloud-init password." })
|
|
1690
1759
|
),
|
|
1691
|
-
sshkeys:
|
|
1692
|
-
|
|
1760
|
+
sshkeys: Type29.Optional(
|
|
1761
|
+
Type29.String({ description: "Optional cloud-init SSH public keys." })
|
|
1693
1762
|
),
|
|
1694
|
-
ipconfig0:
|
|
1695
|
-
|
|
1763
|
+
ipconfig0: Type29.Optional(
|
|
1764
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init ipconfig0, e.g. 'ip=dhcp'." })
|
|
1696
1765
|
),
|
|
1697
|
-
nameserver:
|
|
1698
|
-
|
|
1766
|
+
nameserver: Type29.Optional(
|
|
1767
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init DNS server list." })
|
|
1699
1768
|
),
|
|
1700
|
-
searchdomain:
|
|
1701
|
-
|
|
1769
|
+
searchdomain: Type29.Optional(
|
|
1770
|
+
Type29.String({ minLength: 1, description: "Optional cloud-init DNS search domain." })
|
|
1702
1771
|
),
|
|
1703
|
-
confirm:
|
|
1772
|
+
confirm: Type29.Boolean({
|
|
1704
1773
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1705
|
-
})
|
|
1774
|
+
}),
|
|
1775
|
+
...taskWaitFields
|
|
1706
1776
|
},
|
|
1707
1777
|
{ additionalProperties: false }
|
|
1708
1778
|
);
|
|
@@ -1721,7 +1791,9 @@ function createProxmoxCreateVmTool(getClient) {
|
|
|
1721
1791
|
}
|
|
1722
1792
|
const client = getClient();
|
|
1723
1793
|
let node = args.node;
|
|
1724
|
-
if (
|
|
1794
|
+
if (node) {
|
|
1795
|
+
assertSafePathSegment(node, "node");
|
|
1796
|
+
} else {
|
|
1725
1797
|
const nodes = await client.get("/cluster/resources?type=node");
|
|
1726
1798
|
if (nodes.length === 0) throw new Error("no nodes found in cluster resources");
|
|
1727
1799
|
node = nodes[0].node;
|
|
@@ -1749,44 +1821,47 @@ function createProxmoxCreateVmTool(getClient) {
|
|
|
1749
1821
|
}
|
|
1750
1822
|
if (typeof args.sockets === "number") body.sockets = args.sockets;
|
|
1751
1823
|
const upid = await client.post(`/nodes/${node}/qemu`, body);
|
|
1824
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1752
1825
|
return jsonToolResult({
|
|
1753
1826
|
vmid: args.vmid,
|
|
1754
1827
|
node,
|
|
1755
1828
|
name: args.name,
|
|
1756
|
-
upid
|
|
1829
|
+
upid,
|
|
1830
|
+
...task ? { task } : {}
|
|
1757
1831
|
});
|
|
1758
1832
|
}
|
|
1759
1833
|
};
|
|
1760
1834
|
}
|
|
1761
1835
|
|
|
1762
1836
|
// src/tools/proxmox_clone_resource.ts
|
|
1763
|
-
import { Type as
|
|
1764
|
-
var Schema29 =
|
|
1837
|
+
import { Type as Type30 } from "@sinclair/typebox";
|
|
1838
|
+
var Schema29 = Type30.Object(
|
|
1765
1839
|
{
|
|
1766
|
-
source_vmid:
|
|
1767
|
-
new_vmid:
|
|
1768
|
-
name:
|
|
1769
|
-
full:
|
|
1770
|
-
|
|
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." })
|
|
1771
1845
|
),
|
|
1772
|
-
storage:
|
|
1773
|
-
|
|
1846
|
+
storage: Type30.Optional(
|
|
1847
|
+
Type30.String({ minLength: 1, description: "Target storage (default: same as source)." })
|
|
1774
1848
|
),
|
|
1775
|
-
target_node:
|
|
1776
|
-
|
|
1849
|
+
target_node: Type30.Optional(
|
|
1850
|
+
Type30.String({ minLength: 1, description: "Optional target node for the clone." })
|
|
1777
1851
|
),
|
|
1778
|
-
pool:
|
|
1779
|
-
|
|
1852
|
+
pool: Type30.Optional(
|
|
1853
|
+
Type30.String({ minLength: 1, description: "Optional resource pool ID for the clone." })
|
|
1780
1854
|
),
|
|
1781
|
-
snapname:
|
|
1782
|
-
|
|
1855
|
+
snapname: Type30.Optional(
|
|
1856
|
+
Type30.String({ minLength: 1, description: "Clone from a named snapshot (optional)." })
|
|
1783
1857
|
),
|
|
1784
|
-
description:
|
|
1785
|
-
|
|
1858
|
+
description: Type30.Optional(
|
|
1859
|
+
Type30.String({ description: "Optional description for the clone." })
|
|
1786
1860
|
),
|
|
1787
|
-
confirm:
|
|
1861
|
+
confirm: Type30.Boolean({
|
|
1788
1862
|
description: "Must be true to write. Tier-2 safe-write gate."
|
|
1789
|
-
})
|
|
1863
|
+
}),
|
|
1864
|
+
...taskWaitFields
|
|
1790
1865
|
},
|
|
1791
1866
|
{ additionalProperties: false }
|
|
1792
1867
|
);
|
|
@@ -1826,39 +1901,42 @@ function createProxmoxCloneResourceTool(getClient) {
|
|
|
1826
1901
|
`/nodes/${node}/${type}/${args.source_vmid}/clone`,
|
|
1827
1902
|
body
|
|
1828
1903
|
);
|
|
1904
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1829
1905
|
return jsonToolResult({
|
|
1830
1906
|
source_vmid: args.source_vmid,
|
|
1831
1907
|
new_vmid: args.new_vmid,
|
|
1832
1908
|
node,
|
|
1833
1909
|
type,
|
|
1834
1910
|
name: args.name,
|
|
1835
|
-
upid
|
|
1911
|
+
upid,
|
|
1912
|
+
...task ? { task } : {}
|
|
1836
1913
|
});
|
|
1837
1914
|
}
|
|
1838
1915
|
};
|
|
1839
1916
|
}
|
|
1840
1917
|
|
|
1841
1918
|
// src/tools/proxmox_destroy_resource.ts
|
|
1842
|
-
import { Type as
|
|
1843
|
-
var Schema30 =
|
|
1919
|
+
import { Type as Type31 } from "@sinclair/typebox";
|
|
1920
|
+
var Schema30 = Type31.Object(
|
|
1844
1921
|
{
|
|
1845
|
-
vmid:
|
|
1846
|
-
purge:
|
|
1847
|
-
|
|
1922
|
+
vmid: Type31.Integer({ minimum: 1, description: "Container or VM ID to destroy." }),
|
|
1923
|
+
purge: Type31.Optional(
|
|
1924
|
+
Type31.Boolean({
|
|
1848
1925
|
description: "Remove from PVE backup/replication config too (default true)."
|
|
1849
1926
|
})
|
|
1850
1927
|
),
|
|
1851
|
-
force:
|
|
1852
|
-
|
|
1928
|
+
force: Type31.Optional(
|
|
1929
|
+
Type31.Boolean({
|
|
1853
1930
|
description: "Allow destroying a running VM (default false)."
|
|
1854
1931
|
})
|
|
1855
1932
|
),
|
|
1856
|
-
confirm:
|
|
1933
|
+
confirm: Type31.Boolean({
|
|
1857
1934
|
description: "Must be true. Tier-3 destructive gate."
|
|
1858
1935
|
}),
|
|
1859
|
-
destructive:
|
|
1936
|
+
destructive: Type31.Boolean({
|
|
1860
1937
|
description: "Must be true. Tier-3 destructive gate."
|
|
1861
|
-
})
|
|
1938
|
+
}),
|
|
1939
|
+
...taskWaitFields
|
|
1862
1940
|
},
|
|
1863
1941
|
{ additionalProperties: false }
|
|
1864
1942
|
);
|
|
@@ -1886,46 +1964,47 @@ function createProxmoxDestroyResourceTool(getClient) {
|
|
|
1886
1964
|
const qs = params.toString();
|
|
1887
1965
|
const path2 = qs.length > 0 ? `/nodes/${node}/${type}/${args.vmid}?${qs}` : `/nodes/${node}/${type}/${args.vmid}`;
|
|
1888
1966
|
const upid = await client.delete(path2);
|
|
1889
|
-
|
|
1967
|
+
const task = await resolveTaskWait(client, upid, args);
|
|
1968
|
+
return jsonToolResult({ vmid: args.vmid, node, type, upid, ...task ? { task } : {} });
|
|
1890
1969
|
}
|
|
1891
1970
|
};
|
|
1892
1971
|
}
|
|
1893
1972
|
|
|
1894
1973
|
// src/tools/proxmox_cleanup_smoke_resources.ts
|
|
1895
|
-
import { Type as
|
|
1896
|
-
var Schema31 =
|
|
1974
|
+
import { Type as Type32 } from "@sinclair/typebox";
|
|
1975
|
+
var Schema31 = Type32.Object(
|
|
1897
1976
|
{
|
|
1898
|
-
pool:
|
|
1899
|
-
|
|
1977
|
+
pool: Type32.Optional(
|
|
1978
|
+
Type32.String({ minLength: 1, description: "Pool ID to clean up (default mcp-smoke)." })
|
|
1900
1979
|
),
|
|
1901
|
-
name_prefix:
|
|
1902
|
-
|
|
1980
|
+
name_prefix: Type32.Optional(
|
|
1981
|
+
Type32.String({
|
|
1903
1982
|
minLength: 1,
|
|
1904
1983
|
description: "Only delete guest names starting with this prefix (default mcp-smoke-)."
|
|
1905
1984
|
})
|
|
1906
1985
|
),
|
|
1907
|
-
force:
|
|
1908
|
-
|
|
1986
|
+
force: Type32.Optional(
|
|
1987
|
+
Type32.Boolean({
|
|
1909
1988
|
description: "Allow deleting running smoke guests. Also passes force=1 for LXC cleanup (default false)."
|
|
1910
1989
|
})
|
|
1911
1990
|
),
|
|
1912
|
-
dry_run:
|
|
1913
|
-
|
|
1991
|
+
dry_run: Type32.Optional(
|
|
1992
|
+
Type32.Boolean({ description: "Preview matching targets without deleting them (default true)." })
|
|
1914
1993
|
),
|
|
1915
|
-
wait:
|
|
1916
|
-
|
|
1994
|
+
wait: Type32.Optional(
|
|
1995
|
+
Type32.Boolean({ description: "Wait for delete tasks to finish when dry_run:false (default true)." })
|
|
1917
1996
|
),
|
|
1918
|
-
confirm:
|
|
1919
|
-
|
|
1997
|
+
confirm: Type32.Optional(
|
|
1998
|
+
Type32.Boolean({ description: "Must be true when dry_run:false. Tier-3 destructive gate." })
|
|
1920
1999
|
),
|
|
1921
|
-
destructive:
|
|
1922
|
-
|
|
2000
|
+
destructive: Type32.Optional(
|
|
2001
|
+
Type32.Boolean({ description: "Must be true when dry_run:false. Tier-3 destructive gate." })
|
|
1923
2002
|
),
|
|
1924
|
-
timeoutSeconds:
|
|
1925
|
-
|
|
2003
|
+
timeoutSeconds: Type32.Optional(
|
|
2004
|
+
Type32.Integer({ minimum: 1, maximum: 3600, description: "Max seconds to wait per delete task (default 180)." })
|
|
1926
2005
|
),
|
|
1927
|
-
intervalMs:
|
|
1928
|
-
|
|
2006
|
+
intervalMs: Type32.Optional(
|
|
2007
|
+
Type32.Integer({ minimum: 100, maximum: 1e4, description: "Task polling interval in milliseconds (default 1000)." })
|
|
1929
2008
|
)
|
|
1930
2009
|
},
|
|
1931
2010
|
{ additionalProperties: false }
|
|
@@ -2025,18 +2104,18 @@ function createProxmoxCleanupSmokeResourcesTool(getClient) {
|
|
|
2025
2104
|
}
|
|
2026
2105
|
|
|
2027
2106
|
// src/tools/proxmox_delete_snapshot.ts
|
|
2028
|
-
import { Type as
|
|
2029
|
-
var Schema32 =
|
|
2107
|
+
import { Type as Type33 } from "@sinclair/typebox";
|
|
2108
|
+
var Schema32 = Type33.Object(
|
|
2030
2109
|
{
|
|
2031
|
-
vmid:
|
|
2032
|
-
snapname:
|
|
2110
|
+
vmid: Type33.Integer({ minimum: 1, description: "Container or VM ID." }),
|
|
2111
|
+
snapname: Type33.String({
|
|
2033
2112
|
minLength: 1,
|
|
2034
2113
|
description: "Snapshot name to delete."
|
|
2035
2114
|
}),
|
|
2036
|
-
confirm:
|
|
2115
|
+
confirm: Type33.Boolean({
|
|
2037
2116
|
description: "Must be true. Tier-3 destructive gate."
|
|
2038
2117
|
}),
|
|
2039
|
-
destructive:
|
|
2118
|
+
destructive: Type33.Boolean({
|
|
2040
2119
|
description: "Must be true. Tier-3 destructive gate."
|
|
2041
2120
|
})
|
|
2042
2121
|
},
|
|
@@ -2068,14 +2147,14 @@ function createProxmoxDeleteSnapshotTool(getClient) {
|
|
|
2068
2147
|
}
|
|
2069
2148
|
|
|
2070
2149
|
// src/tools/proxmox_force_stop_resource.ts
|
|
2071
|
-
import { Type as
|
|
2072
|
-
var Schema33 =
|
|
2150
|
+
import { Type as Type34 } from "@sinclair/typebox";
|
|
2151
|
+
var Schema33 = Type34.Object(
|
|
2073
2152
|
{
|
|
2074
|
-
vmid:
|
|
2075
|
-
confirm:
|
|
2153
|
+
vmid: Type34.Integer({ minimum: 1, description: "Container or VM ID to hard-stop." }),
|
|
2154
|
+
confirm: Type34.Boolean({
|
|
2076
2155
|
description: "Must be true. Tier-3 destructive gate."
|
|
2077
2156
|
}),
|
|
2078
|
-
destructive:
|
|
2157
|
+
destructive: Type34.Boolean({
|
|
2079
2158
|
description: "Must be true. Tier-3 destructive gate."
|
|
2080
2159
|
})
|
|
2081
2160
|
},
|
|
@@ -2104,7 +2183,41 @@ function createProxmoxForceStopResourceTool(getClient) {
|
|
|
2104
2183
|
}
|
|
2105
2184
|
|
|
2106
2185
|
// src/tools/proxmox_exec.ts
|
|
2107
|
-
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
|
+
}
|
|
2108
2221
|
|
|
2109
2222
|
// src/tools/ssh-target.ts
|
|
2110
2223
|
function nonEmptyEnv(key) {
|
|
@@ -2152,15 +2265,44 @@ function missingQemuSshHostMessage(vmid) {
|
|
|
2152
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.`;
|
|
2153
2266
|
}
|
|
2154
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
|
+
|
|
2155
2297
|
// src/tools/proxmox_exec.ts
|
|
2156
|
-
var Schema34 =
|
|
2298
|
+
var Schema34 = Type35.Object(
|
|
2157
2299
|
{
|
|
2158
|
-
vmid:
|
|
2159
|
-
command:
|
|
2160
|
-
timeout:
|
|
2161
|
-
|
|
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)." })
|
|
2162
2304
|
),
|
|
2163
|
-
confirm:
|
|
2305
|
+
confirm: Type35.Boolean({ description: "Must be true to execute. Tier-2 safe-write gate." })
|
|
2164
2306
|
},
|
|
2165
2307
|
{ additionalProperties: false }
|
|
2166
2308
|
);
|
|
@@ -2169,7 +2311,7 @@ function createProxmoxExecTool(getClient, getSsh, vmDefaults) {
|
|
|
2169
2311
|
return {
|
|
2170
2312
|
name: NAME31,
|
|
2171
2313
|
label: "proxmox: exec in container or VM",
|
|
2172
|
-
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.",
|
|
2173
2315
|
parameters: Schema34,
|
|
2174
2316
|
execute: async (_id, raw) => {
|
|
2175
2317
|
assertConfirmedWrite(raw, NAME31);
|
|
@@ -2188,12 +2330,7 @@ function createProxmoxExecTool(getClient, getSsh, vmDefaults) {
|
|
|
2188
2330
|
exit_code: result2.exitCode
|
|
2189
2331
|
});
|
|
2190
2332
|
}
|
|
2191
|
-
const
|
|
2192
|
-
if (!host) {
|
|
2193
|
-
throw new Error(missingQemuSshHostMessage(args.vmid));
|
|
2194
|
-
}
|
|
2195
|
-
const target = qemuSshTarget(args.vmid, host, vmDefaults);
|
|
2196
|
-
const result = await ssh.execViaDirectSsh(target, args.command, timeoutMs);
|
|
2333
|
+
const result = await execInQemuGuest(client, ssh, node, args.vmid, args.command, timeoutMs, vmDefaults);
|
|
2197
2334
|
return jsonToolResult({
|
|
2198
2335
|
vmid: args.vmid,
|
|
2199
2336
|
type,
|
|
@@ -2206,20 +2343,20 @@ function createProxmoxExecTool(getClient, getSsh, vmDefaults) {
|
|
|
2206
2343
|
}
|
|
2207
2344
|
|
|
2208
2345
|
// src/tools/proxmox_read_file.ts
|
|
2209
|
-
import { Type as
|
|
2210
|
-
var Schema35 =
|
|
2346
|
+
import { Type as Type36 } from "@sinclair/typebox";
|
|
2347
|
+
var Schema35 = Type36.Object(
|
|
2211
2348
|
{
|
|
2212
|
-
vmid:
|
|
2213
|
-
path:
|
|
2214
|
-
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." })
|
|
2215
2352
|
},
|
|
2216
2353
|
{ additionalProperties: false }
|
|
2217
2354
|
);
|
|
2218
2355
|
var NAME32 = "proxmox_read_file";
|
|
2219
|
-
function
|
|
2356
|
+
function shellSingleQuote2(s) {
|
|
2220
2357
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2221
2358
|
}
|
|
2222
|
-
function
|
|
2359
|
+
function assertAbsoluteGuestPath2(path2, toolName) {
|
|
2223
2360
|
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2224
2361
|
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2225
2362
|
}
|
|
@@ -2232,21 +2369,17 @@ function createProxmoxReadFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2232
2369
|
execute: async (_id, raw) => {
|
|
2233
2370
|
assertConfirmedWrite(raw, NAME32);
|
|
2234
2371
|
const args = validateToolArgs(Schema35, raw, NAME32);
|
|
2235
|
-
|
|
2372
|
+
assertAbsoluteGuestPath2(args.path, NAME32);
|
|
2236
2373
|
const client = getClient();
|
|
2237
2374
|
const { node, type } = await resolveResource(client, args.vmid);
|
|
2238
|
-
const command = `cat -- ${
|
|
2375
|
+
const command = `cat -- ${shellSingleQuote2(args.path)}`;
|
|
2239
2376
|
const ssh = getSsh();
|
|
2240
2377
|
const timeoutMs = 3e4;
|
|
2241
2378
|
let result;
|
|
2242
2379
|
if (type === "lxc") {
|
|
2243
2380
|
result = await ssh.execInLxc(args.vmid, command, timeoutMs);
|
|
2244
2381
|
} else {
|
|
2245
|
-
|
|
2246
|
-
if (!host) {
|
|
2247
|
-
throw new Error(missingQemuSshHostMessage(args.vmid));
|
|
2248
|
-
}
|
|
2249
|
-
result = await ssh.execViaDirectSsh(qemuSshTarget(args.vmid, host, vmDefaults), command, timeoutMs);
|
|
2382
|
+
result = await execInQemuGuest(client, ssh, node, args.vmid, command, timeoutMs, vmDefaults);
|
|
2250
2383
|
}
|
|
2251
2384
|
if (result.exitCode !== 0) {
|
|
2252
2385
|
throw new Error(result.stderr.trim() || `read_file failed with exit code ${result.exitCode}`);
|
|
@@ -2257,22 +2390,22 @@ function createProxmoxReadFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2257
2390
|
}
|
|
2258
2391
|
|
|
2259
2392
|
// src/tools/proxmox_write_file.ts
|
|
2260
|
-
import { Type as
|
|
2393
|
+
import { Type as Type37 } from "@sinclair/typebox";
|
|
2261
2394
|
import path from "path";
|
|
2262
|
-
var Schema36 =
|
|
2395
|
+
var Schema36 = Type37.Object(
|
|
2263
2396
|
{
|
|
2264
|
-
vmid:
|
|
2265
|
-
path:
|
|
2266
|
-
content:
|
|
2267
|
-
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." })
|
|
2268
2401
|
},
|
|
2269
2402
|
{ additionalProperties: false }
|
|
2270
2403
|
);
|
|
2271
2404
|
var NAME33 = "proxmox_write_file";
|
|
2272
|
-
function
|
|
2405
|
+
function shellSingleQuote3(s) {
|
|
2273
2406
|
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2274
2407
|
}
|
|
2275
|
-
function
|
|
2408
|
+
function assertAbsoluteGuestPath3(path2, toolName) {
|
|
2276
2409
|
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2277
2410
|
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2278
2411
|
}
|
|
@@ -2285,23 +2418,19 @@ function createProxmoxWriteFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2285
2418
|
execute: async (_id, raw) => {
|
|
2286
2419
|
assertConfirmedWrite(raw, NAME33);
|
|
2287
2420
|
const args = validateToolArgs(Schema36, raw, NAME33);
|
|
2288
|
-
|
|
2421
|
+
assertAbsoluteGuestPath3(args.path, NAME33);
|
|
2289
2422
|
const client = getClient();
|
|
2290
2423
|
const { node, type } = await resolveResource(client, args.vmid);
|
|
2291
2424
|
const ssh = getSsh();
|
|
2292
2425
|
const timeoutMs = 3e4;
|
|
2293
2426
|
const parent = path.posix.dirname(args.path);
|
|
2294
|
-
const mkdirCmd = `mkdir -p -- ${
|
|
2295
|
-
const writeCmd = `cat > ${
|
|
2427
|
+
const mkdirCmd = `mkdir -p -- ${shellSingleQuote3(parent)}`;
|
|
2428
|
+
const writeCmd = `cat > ${shellSingleQuote3(args.path)}`;
|
|
2296
2429
|
const runOne = async (command, stdin) => {
|
|
2297
2430
|
if (type === "lxc") {
|
|
2298
2431
|
return ssh.execInLxc(args.vmid, command, timeoutMs, stdin);
|
|
2299
2432
|
}
|
|
2300
|
-
|
|
2301
|
-
if (!host) {
|
|
2302
|
-
throw new Error(missingQemuSshHostMessage(args.vmid));
|
|
2303
|
-
}
|
|
2304
|
-
return ssh.execViaDirectSsh(qemuSshTarget(args.vmid, host, vmDefaults), command, timeoutMs, stdin);
|
|
2433
|
+
return execInQemuGuest(client, ssh, node, args.vmid, command, timeoutMs, vmDefaults, stdin);
|
|
2305
2434
|
};
|
|
2306
2435
|
const mkdirResult = await runOne(mkdirCmd);
|
|
2307
2436
|
if (mkdirResult.exitCode !== 0) {
|
|
@@ -2321,33 +2450,12 @@ function createProxmoxWriteFileTool(getClient, getSsh, vmDefaults) {
|
|
|
2321
2450
|
}
|
|
2322
2451
|
|
|
2323
2452
|
// src/tools/proxmox_stat_path.ts
|
|
2324
|
-
import { Type as
|
|
2325
|
-
|
|
2326
|
-
// src/tools/guest-command.ts
|
|
2327
|
-
function shellSingleQuote3(s) {
|
|
2328
|
-
return `'${s.replace(/'/g, `'\\''`)}'`;
|
|
2329
|
-
}
|
|
2330
|
-
function assertAbsoluteGuestPath3(path2, toolName) {
|
|
2331
|
-
if (!path2.startsWith("/")) throw new Error(`${toolName} path must be absolute`);
|
|
2332
|
-
if (path2.includes("\0")) throw new Error(`${toolName} path cannot contain NUL bytes`);
|
|
2333
|
-
}
|
|
2334
|
-
async function runGuestCommand(client, ssh, vmDefaults, vmid, command, timeoutMs, stdin) {
|
|
2335
|
-
const { node, type } = await resolveResource(client, vmid);
|
|
2336
|
-
if (type === "lxc") {
|
|
2337
|
-
return { node, type, result: await ssh.execInLxc(vmid, command, timeoutMs, stdin) };
|
|
2338
|
-
}
|
|
2339
|
-
const host = await resolveQemuSshHost(client, node, vmid);
|
|
2340
|
-
if (!host) throw new Error(missingQemuSshHostMessage(vmid));
|
|
2341
|
-
const target = qemuSshTarget(vmid, host, vmDefaults);
|
|
2342
|
-
return { node, type, result: await ssh.execViaDirectSsh(target, command, timeoutMs, stdin) };
|
|
2343
|
-
}
|
|
2344
|
-
|
|
2345
|
-
// src/tools/proxmox_stat_path.ts
|
|
2346
|
-
var Schema37 = Type37.Object(
|
|
2453
|
+
import { Type as Type38 } from "@sinclair/typebox";
|
|
2454
|
+
var Schema37 = Type38.Object(
|
|
2347
2455
|
{
|
|
2348
|
-
vmid:
|
|
2349
|
-
path:
|
|
2350
|
-
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." })
|
|
2351
2459
|
},
|
|
2352
2460
|
{ additionalProperties: false }
|
|
2353
2461
|
);
|
|
@@ -2378,8 +2486,8 @@ function createProxmoxStatPathTool(getClient, getSsh, vmDefaults) {
|
|
|
2378
2486
|
execute: async (_id, raw) => {
|
|
2379
2487
|
assertConfirmedWrite(raw, NAME34);
|
|
2380
2488
|
const args = validateToolArgs(Schema37, raw, NAME34);
|
|
2381
|
-
|
|
2382
|
-
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)}`;
|
|
2383
2491
|
const { node, type, result } = await runGuestCommand(
|
|
2384
2492
|
getClient(),
|
|
2385
2493
|
getSsh(),
|
|
@@ -2402,12 +2510,12 @@ function createProxmoxStatPathTool(getClient, getSsh, vmDefaults) {
|
|
|
2402
2510
|
}
|
|
2403
2511
|
|
|
2404
2512
|
// src/tools/proxmox_list_directory.ts
|
|
2405
|
-
import { Type as
|
|
2406
|
-
var Schema38 =
|
|
2513
|
+
import { Type as Type39 } from "@sinclair/typebox";
|
|
2514
|
+
var Schema38 = Type39.Object(
|
|
2407
2515
|
{
|
|
2408
|
-
vmid:
|
|
2409
|
-
path:
|
|
2410
|
-
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." })
|
|
2411
2519
|
},
|
|
2412
2520
|
{ additionalProperties: false }
|
|
2413
2521
|
);
|
|
@@ -2440,8 +2548,8 @@ function createProxmoxListDirectoryTool(getClient, getSsh, vmDefaults) {
|
|
|
2440
2548
|
execute: async (_id, raw) => {
|
|
2441
2549
|
assertConfirmedWrite(raw, NAME35);
|
|
2442
2550
|
const args = validateToolArgs(Schema38, raw, NAME35);
|
|
2443
|
-
|
|
2444
|
-
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'`;
|
|
2445
2553
|
const { node, type, result } = await runGuestCommand(
|
|
2446
2554
|
getClient(),
|
|
2447
2555
|
getSsh(),
|
|
@@ -2460,12 +2568,12 @@ function createProxmoxListDirectoryTool(getClient, getSsh, vmDefaults) {
|
|
|
2460
2568
|
}
|
|
2461
2569
|
|
|
2462
2570
|
// src/tools/proxmox_service_status.ts
|
|
2463
|
-
import { Type as
|
|
2464
|
-
var Schema39 =
|
|
2571
|
+
import { Type as Type40 } from "@sinclair/typebox";
|
|
2572
|
+
var Schema39 = Type40.Object(
|
|
2465
2573
|
{
|
|
2466
|
-
vmid:
|
|
2467
|
-
service:
|
|
2468
|
-
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." })
|
|
2469
2577
|
},
|
|
2470
2578
|
{ additionalProperties: false }
|
|
2471
2579
|
);
|
|
@@ -2489,7 +2597,7 @@ function createProxmoxServiceStatusTool(getClient, getSsh, vmDefaults) {
|
|
|
2489
2597
|
assertConfirmedWrite(raw, NAME36);
|
|
2490
2598
|
const args = validateToolArgs(Schema39, raw, NAME36);
|
|
2491
2599
|
if (args.service.includes("\0")) throw new Error(`${NAME36} service cannot contain NUL bytes`);
|
|
2492
|
-
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)}`;
|
|
2493
2601
|
const { node, type, result } = await runGuestCommand(
|
|
2494
2602
|
getClient(),
|
|
2495
2603
|
getSsh(),
|
|
@@ -2508,7 +2616,7 @@ function createProxmoxServiceStatusTool(getClient, getSsh, vmDefaults) {
|
|
|
2508
2616
|
}
|
|
2509
2617
|
|
|
2510
2618
|
// src/tools/service-action.ts
|
|
2511
|
-
import { Type as
|
|
2619
|
+
import { Type as Type41 } from "@sinclair/typebox";
|
|
2512
2620
|
function parseSystemctlShow2(stdout) {
|
|
2513
2621
|
const out = {};
|
|
2514
2622
|
for (const line of stdout.trimEnd().split("\n")) {
|
|
@@ -2519,11 +2627,11 @@ function parseSystemctlShow2(stdout) {
|
|
|
2519
2627
|
return out;
|
|
2520
2628
|
}
|
|
2521
2629
|
function schemaFor(action) {
|
|
2522
|
-
return
|
|
2630
|
+
return Type41.Object(
|
|
2523
2631
|
{
|
|
2524
|
-
vmid:
|
|
2525
|
-
service:
|
|
2526
|
-
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.` })
|
|
2527
2635
|
},
|
|
2528
2636
|
{ additionalProperties: false }
|
|
2529
2637
|
);
|
|
@@ -2540,7 +2648,7 @@ function createServiceActionTool(action, getClient, getSsh, vmDefaults) {
|
|
|
2540
2648
|
assertConfirmedWrite(raw, name);
|
|
2541
2649
|
const args = validateToolArgs(schema, raw, name);
|
|
2542
2650
|
if (args.service.includes("\0")) throw new Error(`${name} service cannot contain NUL bytes`);
|
|
2543
|
-
const quoted =
|
|
2651
|
+
const quoted = shellSingleQuote(args.service);
|
|
2544
2652
|
const command = `systemctl ${action} -- ${quoted} && systemctl show --no-pager --property=Id,LoadState,ActiveState,SubState,UnitFileState,Description -- ${quoted}`;
|
|
2545
2653
|
const { node, type, result } = await runGuestCommand(
|
|
2546
2654
|
getClient(),
|
|
@@ -2580,30 +2688,1928 @@ function createProxmoxServiceRestartTool(getClient, getSsh, vmDefaults) {
|
|
|
2580
2688
|
return createServiceActionTool("restart", getClient, getSsh, vmDefaults);
|
|
2581
2689
|
}
|
|
2582
2690
|
|
|
2583
|
-
// src/
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
}
|
|
2593
|
-
|
|
2594
|
-
|
|
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);
|
|
2595
2744
|
}
|
|
2596
|
-
if (
|
|
2597
|
-
|
|
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
|
+
}
|
|
2598
2752
|
}
|
|
2599
|
-
|
|
2600
|
-
|
|
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
|
+
}
|
|
2601
2758
|
}
|
|
2602
|
-
if (
|
|
2603
|
-
|
|
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
|
+
);
|
|
2604
2766
|
}
|
|
2605
|
-
|
|
2606
|
-
|
|
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 };
|
|
2607
4613
|
}
|
|
2608
4614
|
if (/task did not finish OK/i.test(err.message) || /task failed/i.test(err.message)) {
|
|
2609
4615
|
return { error: err.message, code: "TASK_FAILED", name: err.name };
|
|
@@ -2611,11 +4617,421 @@ function classifyToolError(error) {
|
|
|
2611
4617
|
return { error: err.message, code: "TOOL_ERROR", name: err.name };
|
|
2612
4618
|
}
|
|
2613
4619
|
|
|
2614
|
-
//
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
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)) {
|
|
2619
5035
|
registerSecret(cfg.tokenId);
|
|
2620
5036
|
registerSecret(cfg.tokenSecret);
|
|
2621
5037
|
registerSecret(`PVEAPIToken=${cfg.tokenId}=${cfg.tokenSecret}`);
|
|
@@ -2673,14 +5089,122 @@ async function startServer() {
|
|
|
2673
5089
|
createProxmoxServiceStatusTool(getClient, getSsh, vmDefaults),
|
|
2674
5090
|
createProxmoxServiceStartTool(getClient, getSsh, vmDefaults),
|
|
2675
5091
|
createProxmoxServiceStopTool(getClient, getSsh, vmDefaults),
|
|
2676
|
-
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)
|
|
2677
5147
|
];
|
|
2678
5148
|
const toolMap = new Map(tools.map((t) => [t.name, t]));
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
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
|
+
});
|
|
2683
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
|
+
}
|
|
2684
5208
|
const t = toolMap.get(req.params.name);
|
|
2685
5209
|
if (!t) {
|
|
2686
5210
|
return {
|
|
@@ -2695,6 +5219,7 @@ async function startServer() {
|
|
|
2695
5219
|
isError: true
|
|
2696
5220
|
};
|
|
2697
5221
|
}
|
|
5222
|
+
if (deferred && session !== null) session.load([t.name]);
|
|
2698
5223
|
try {
|
|
2699
5224
|
return await t.execute(req.params.name, req.params.arguments ?? {});
|
|
2700
5225
|
} catch (e) {
|
|
@@ -2702,12 +5227,16 @@ async function startServer() {
|
|
|
2702
5227
|
return { content: [{ type: "text", text: JSON.stringify(payload) }], isError: true };
|
|
2703
5228
|
}
|
|
2704
5229
|
});
|
|
5230
|
+
return server;
|
|
5231
|
+
}
|
|
5232
|
+
async function startServer() {
|
|
5233
|
+
const server = createMcpServer();
|
|
2705
5234
|
const transport = new StdioServerTransport();
|
|
2706
5235
|
const __send = transport.send.bind(transport);
|
|
2707
5236
|
transport.send = (message) => {
|
|
2708
|
-
const
|
|
2709
|
-
if (Array.isArray(
|
|
2710
|
-
for (const t of
|
|
5237
|
+
const tools = message?.result?.tools;
|
|
5238
|
+
if (Array.isArray(tools)) {
|
|
5239
|
+
for (const t of tools) {
|
|
2711
5240
|
if (t?.inputSchema) delete t.inputSchema.$schema;
|
|
2712
5241
|
if (t?.outputSchema) delete t.outputSchema.$schema;
|
|
2713
5242
|
}
|
|
@@ -2716,31 +5245,248 @@ async function startServer() {
|
|
|
2716
5245
|
};
|
|
2717
5246
|
await server.connect(transport);
|
|
2718
5247
|
}
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
5248
|
+
|
|
5249
|
+
// src/http.ts
|
|
5250
|
+
import { createHash, randomUUID, timingSafeEqual } from "crypto";
|
|
5251
|
+
import { createServer } from "http";
|
|
5252
|
+
import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
|
|
5253
|
+
import { isInitializeRequest } from "@modelcontextprotocol/sdk/types.js";
|
|
5254
|
+
var MAX_BODY_BYTES = 1048576;
|
|
5255
|
+
var MAX_SESSIONS = 128;
|
|
5256
|
+
var SESSION_IDLE_MS = 30 * 6e4;
|
|
5257
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
|
|
5258
|
+
function equalSecret(a, b) {
|
|
5259
|
+
return timingSafeEqual(createHash("sha256").update(a).digest(), createHash("sha256").update(b).digest());
|
|
5260
|
+
}
|
|
5261
|
+
function send(response, status, body) {
|
|
5262
|
+
if (response.headersSent || response.destroyed) return;
|
|
5263
|
+
response.writeHead(status, { "content-type": "text/plain; charset=utf-8", connection: "close" });
|
|
5264
|
+
response.end(body);
|
|
5265
|
+
}
|
|
5266
|
+
function validHost(value, boundHost) {
|
|
5267
|
+
if (!value) return false;
|
|
2722
5268
|
try {
|
|
2723
|
-
|
|
5269
|
+
const url = new URL(`http://${value}`);
|
|
5270
|
+
if (!/^(\[[a-f\d:]+\]|[a-z\d.-]+)(:\d+)?$/i.test(value)) return false;
|
|
5271
|
+
return LOOPBACK_HOSTS.has(url.hostname) || url.hostname === (boundHost.includes(":") ? `[${boundHost}]` : boundHost).toLowerCase();
|
|
2724
5272
|
} catch {
|
|
2725
5273
|
return false;
|
|
2726
5274
|
}
|
|
2727
|
-
}
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
5275
|
+
}
|
|
5276
|
+
function validOrigin(value) {
|
|
5277
|
+
if (value === void 0) return true;
|
|
5278
|
+
try {
|
|
5279
|
+
const url = new URL(value);
|
|
5280
|
+
return (url.protocol === "http:" || url.protocol === "https:") && url.origin === value && LOOPBACK_HOSTS.has(url.hostname);
|
|
5281
|
+
} catch {
|
|
5282
|
+
return false;
|
|
5283
|
+
}
|
|
5284
|
+
}
|
|
5285
|
+
var RequestError = class extends Error {
|
|
5286
|
+
constructor(status, message) {
|
|
5287
|
+
super(message);
|
|
5288
|
+
this.status = status;
|
|
5289
|
+
}
|
|
5290
|
+
};
|
|
5291
|
+
async function readBody(request) {
|
|
5292
|
+
const length = request.headers["content-length"];
|
|
5293
|
+
if (length !== void 0 && (!/^\d+$/.test(length) || Number(length) > MAX_BODY_BYTES)) {
|
|
5294
|
+
throw new RequestError(413, "Request body too large");
|
|
5295
|
+
}
|
|
5296
|
+
const chunks = [];
|
|
5297
|
+
let size = 0;
|
|
5298
|
+
for await (const chunk of request.iterator({ destroyOnReturn: false })) {
|
|
5299
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
5300
|
+
size += bytes.length;
|
|
5301
|
+
if (size > MAX_BODY_BYTES) throw new RequestError(413, "Request body too large");
|
|
5302
|
+
chunks.push(bytes);
|
|
5303
|
+
}
|
|
5304
|
+
try {
|
|
5305
|
+
return JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
5306
|
+
} catch {
|
|
5307
|
+
throw new RequestError(400, "Invalid JSON");
|
|
5308
|
+
}
|
|
5309
|
+
}
|
|
5310
|
+
async function createHttpServer() {
|
|
5311
|
+
const env = process.env;
|
|
5312
|
+
const token = (env.PROXMOX_MCP_HTTP_TOKEN ?? "").trim();
|
|
5313
|
+
if (!token) throw new Error("PROXMOX_MCP_HTTP_TOKEN is required and must not be blank");
|
|
5314
|
+
if (token.length < 32) throw new Error("PROXMOX_MCP_HTTP_TOKEN must be at least 32 characters (e.g. openssl rand -hex 32)");
|
|
5315
|
+
const cfg = resolveConfig(env);
|
|
5316
|
+
const url = new URL(cfg.url);
|
|
5317
|
+
const credentials = [
|
|
5318
|
+
cfg.tokenId,
|
|
5319
|
+
cfg.tokenSecret,
|
|
5320
|
+
`PVEAPIToken=${cfg.tokenId}=${cfg.tokenSecret}`,
|
|
5321
|
+
decodeURIComponent(url.username),
|
|
5322
|
+
decodeURIComponent(url.password)
|
|
5323
|
+
];
|
|
5324
|
+
if (credentials.some((credential) => credential && equalSecret(token, credential))) {
|
|
5325
|
+
throw new Error("PROXMOX_MCP_HTTP_TOKEN must differ from all Proxmox credentials");
|
|
5326
|
+
}
|
|
5327
|
+
registerSecret(token);
|
|
5328
|
+
const host = env.PROXMOX_MCP_HTTP_HOST ?? "127.0.0.1";
|
|
5329
|
+
if (!host.trim() || host.includes("/") || host.includes("@")) {
|
|
5330
|
+
throw new Error("PROXMOX_MCP_HTTP_HOST must be a host name or address");
|
|
5331
|
+
}
|
|
5332
|
+
if (["0.0.0.0", "::", "[::]"].includes(host.trim())) {
|
|
5333
|
+
throw new Error("PROXMOX_MCP_HTTP_HOST must be a specific address, not a wildcard; bind the interface clients will use");
|
|
5334
|
+
}
|
|
5335
|
+
const portValue = env.PROXMOX_MCP_HTTP_PORT ?? "3100";
|
|
5336
|
+
if (!/^\d+$/.test(portValue) || Number(portValue) > 65535) {
|
|
5337
|
+
throw new Error("PROXMOX_MCP_HTTP_PORT must be an integer from 0 to 65535");
|
|
5338
|
+
}
|
|
5339
|
+
const port = Number(portValue);
|
|
5340
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
5341
|
+
const resources = /* @__PURE__ */ new Set();
|
|
5342
|
+
let closing = false;
|
|
5343
|
+
const dispose = async (session) => {
|
|
5344
|
+
resources.delete(session);
|
|
5345
|
+
if (session.transport.sessionId) sessions.delete(session.transport.sessionId);
|
|
5346
|
+
await session.server.close();
|
|
5347
|
+
};
|
|
5348
|
+
const handle = async (request, response) => {
|
|
5349
|
+
if (closing) return send(response, 503, "Service unavailable");
|
|
5350
|
+
if (!validHost(request.headers.host, host) || !validOrigin(request.headers.origin)) {
|
|
5351
|
+
return send(response, 403, "Forbidden");
|
|
5352
|
+
}
|
|
5353
|
+
if (request.method === "GET" && request.url === "/healthz") {
|
|
5354
|
+
response.writeHead(200, { "content-type": "application/json" }).end(JSON.stringify({ status: "ok" }));
|
|
5355
|
+
return;
|
|
5356
|
+
}
|
|
5357
|
+
if (request.url !== "/mcp") return send(response, 404, "Not found");
|
|
5358
|
+
const supplied = request.headers.authorization?.match(/^Bearer (.+)$/i)?.[1] ?? "";
|
|
5359
|
+
if (!equalSecret(supplied, token)) {
|
|
5360
|
+
response.setHeader("www-authenticate", "Bearer");
|
|
5361
|
+
return send(response, 401, "Unauthorized");
|
|
5362
|
+
}
|
|
5363
|
+
if (!["GET", "POST", "DELETE"].includes(request.method ?? "")) {
|
|
5364
|
+
response.setHeader("allow", "GET, POST, DELETE");
|
|
5365
|
+
return send(response, 405, "Method not allowed");
|
|
5366
|
+
}
|
|
5367
|
+
const body = request.method === "POST" ? await readBody(request) : void 0;
|
|
5368
|
+
if (closing) return send(response, 503, "Service unavailable");
|
|
5369
|
+
const id = request.headers["mcp-session-id"];
|
|
5370
|
+
let session = typeof id === "string" ? sessions.get(id) : void 0;
|
|
5371
|
+
if (id !== void 0 && !session) return send(response, 404, "Session not found");
|
|
5372
|
+
let created = false;
|
|
5373
|
+
if (!session) {
|
|
5374
|
+
if (request.method !== "POST" || !isInitializeRequest(body)) return send(response, 400, "Initialize a session first");
|
|
5375
|
+
if (resources.size >= MAX_SESSIONS) return send(response, 503, "Service unavailable");
|
|
5376
|
+
const server = createMcpServer(cfg);
|
|
5377
|
+
const transport = new StreamableHTTPServerTransport({
|
|
5378
|
+
sessionIdGenerator: randomUUID,
|
|
5379
|
+
enableJsonResponse: true,
|
|
5380
|
+
onsessioninitialized: (sessionId) => {
|
|
5381
|
+
sessions.set(sessionId, entry);
|
|
5382
|
+
}
|
|
5383
|
+
});
|
|
5384
|
+
const entry = { server, transport, lastUsed: Date.now(), active: 0 };
|
|
5385
|
+
session = entry;
|
|
5386
|
+
resources.add(entry);
|
|
5387
|
+
created = true;
|
|
5388
|
+
try {
|
|
5389
|
+
await server.connect(transport);
|
|
5390
|
+
} catch (error) {
|
|
5391
|
+
await dispose(entry);
|
|
5392
|
+
throw error;
|
|
5393
|
+
}
|
|
5394
|
+
const onclose = transport.onclose;
|
|
5395
|
+
transport.onclose = () => {
|
|
5396
|
+
resources.delete(entry);
|
|
5397
|
+
if (transport.sessionId) sessions.delete(transport.sessionId);
|
|
5398
|
+
onclose?.();
|
|
5399
|
+
};
|
|
5400
|
+
}
|
|
5401
|
+
session.lastUsed = Date.now();
|
|
5402
|
+
const activeCall = request.method === "POST";
|
|
5403
|
+
if (activeCall) session.active++;
|
|
5404
|
+
try {
|
|
5405
|
+
await session.transport.handleRequest(request, response, body);
|
|
5406
|
+
} finally {
|
|
5407
|
+
if (activeCall) session.active--;
|
|
5408
|
+
session.lastUsed = Date.now();
|
|
5409
|
+
if (created && !session.transport.sessionId) await dispose(session);
|
|
5410
|
+
}
|
|
5411
|
+
};
|
|
5412
|
+
const listener = createServer((request, response) => {
|
|
5413
|
+
void handle(request, response).catch((error) => {
|
|
5414
|
+
send(
|
|
5415
|
+
response,
|
|
5416
|
+
error instanceof RequestError ? error.status : 500,
|
|
5417
|
+
error instanceof RequestError ? error.message : "Internal server error"
|
|
5418
|
+
);
|
|
5419
|
+
});
|
|
5420
|
+
});
|
|
5421
|
+
listener.requestTimeout = 3e4;
|
|
5422
|
+
listener.headersTimeout = 1e4;
|
|
5423
|
+
await new Promise((resolve, reject) => {
|
|
5424
|
+
listener.once("error", reject);
|
|
5425
|
+
listener.listen(port, host, () => {
|
|
5426
|
+
listener.off("error", reject);
|
|
5427
|
+
resolve();
|
|
5428
|
+
});
|
|
2732
5429
|
});
|
|
5430
|
+
const address = listener.address();
|
|
5431
|
+
if (!address || typeof address === "string") throw new Error("HTTP listener did not bind a TCP port");
|
|
5432
|
+
const reaper = setInterval(() => {
|
|
5433
|
+
for (const session of resources) {
|
|
5434
|
+
if (session.active === 0 && Date.now() - session.lastUsed > SESSION_IDLE_MS) {
|
|
5435
|
+
void dispose(session).catch(() => void 0);
|
|
5436
|
+
}
|
|
5437
|
+
}
|
|
5438
|
+
}, 6e4);
|
|
5439
|
+
reaper.unref();
|
|
5440
|
+
let closePromise;
|
|
5441
|
+
return {
|
|
5442
|
+
host: address.address,
|
|
5443
|
+
port: address.port,
|
|
5444
|
+
close() {
|
|
5445
|
+
closePromise ??= (async () => {
|
|
5446
|
+
closing = true;
|
|
5447
|
+
clearInterval(reaper);
|
|
5448
|
+
const stopped = new Promise((resolve, reject) => {
|
|
5449
|
+
listener.close((error) => error ? reject(error) : resolve());
|
|
5450
|
+
});
|
|
5451
|
+
const deadline = setTimeout(() => listener.closeAllConnections(), 5e3);
|
|
5452
|
+
deadline.unref();
|
|
5453
|
+
try {
|
|
5454
|
+
await Promise.allSettled([...resources].map(dispose));
|
|
5455
|
+
listener.closeIdleConnections();
|
|
5456
|
+
await stopped;
|
|
5457
|
+
} finally {
|
|
5458
|
+
clearTimeout(deadline);
|
|
5459
|
+
}
|
|
5460
|
+
})();
|
|
5461
|
+
return closePromise;
|
|
5462
|
+
}
|
|
5463
|
+
};
|
|
5464
|
+
}
|
|
5465
|
+
async function startHttpServer() {
|
|
5466
|
+
const http = await createHttpServer();
|
|
5467
|
+
const host = http.host.includes(":") ? `[${http.host}]` : http.host;
|
|
5468
|
+
console.error(`proxmox-mcp HTTP listening on http://${host}:${http.port}/mcp`);
|
|
5469
|
+
const shutdown = () => {
|
|
5470
|
+
void http.close().then(() => {
|
|
5471
|
+
process.off("SIGTERM", shutdown);
|
|
5472
|
+
process.off("SIGINT", shutdown);
|
|
5473
|
+
}).catch(() => {
|
|
5474
|
+
process.exitCode = 1;
|
|
5475
|
+
});
|
|
5476
|
+
};
|
|
5477
|
+
process.on("SIGTERM", shutdown);
|
|
5478
|
+
process.on("SIGINT", shutdown);
|
|
2733
5479
|
}
|
|
2734
5480
|
|
|
2735
5481
|
// package.json
|
|
2736
5482
|
var package_default = {
|
|
2737
5483
|
name: "@solomonneas/proxmox-mcp",
|
|
2738
|
-
version: "0.
|
|
2739
|
-
description: "Proxmox VE
|
|
5484
|
+
version: "0.12.0",
|
|
5485
|
+
description: "MCP server exposing Proxmox VE read + safe-write tools (incl. in-container exec)",
|
|
2740
5486
|
type: "module",
|
|
2741
5487
|
openclaw: {
|
|
2742
5488
|
extensions: [
|
|
2743
|
-
"./index.
|
|
5489
|
+
"./dist/index.js"
|
|
2744
5490
|
],
|
|
2745
5491
|
compat: {
|
|
2746
5492
|
pluginApi: ">=2026.3.24-beta.2",
|
|
@@ -2752,7 +5498,6 @@ var package_default = {
|
|
|
2752
5498
|
}
|
|
2753
5499
|
},
|
|
2754
5500
|
bin: {
|
|
2755
|
-
proxmoxctrl: "dist/cli.js",
|
|
2756
5501
|
proxmoxctl: "dist/cli.js",
|
|
2757
5502
|
proxops: "dist/cli.js",
|
|
2758
5503
|
"proxmox-mcp": "dist/mcp-bin.js"
|
|
@@ -2792,12 +5537,9 @@ var package_default = {
|
|
|
2792
5537
|
openclaw: "^2026.4.22",
|
|
2793
5538
|
tsup: "^8.4.0",
|
|
2794
5539
|
tsx: "^4.19.0",
|
|
2795
|
-
typescript: "^
|
|
5540
|
+
typescript: "^7.0.2",
|
|
2796
5541
|
vitest: "^4.1.5"
|
|
2797
5542
|
},
|
|
2798
|
-
overrides: {
|
|
2799
|
-
esbuild: "0.28.1"
|
|
2800
|
-
},
|
|
2801
5543
|
engines: {
|
|
2802
5544
|
node: ">=20"
|
|
2803
5545
|
},
|
|
@@ -2806,7 +5548,6 @@ var package_default = {
|
|
|
2806
5548
|
type: "git",
|
|
2807
5549
|
url: "git+https://github.com/lidless-labs/proxmox-mcp.git"
|
|
2808
5550
|
},
|
|
2809
|
-
packageManager: "npm@10.9.7",
|
|
2810
5551
|
publishConfig: {
|
|
2811
5552
|
access: "public"
|
|
2812
5553
|
}
|
|
@@ -2845,13 +5586,28 @@ var COMMANDS = {
|
|
|
2845
5586
|
"task status": { create: createProxmoxGetTaskStatusTool, build: (p) => ({ upid: reqStr(p[0], "upid") }) },
|
|
2846
5587
|
"recent-tasks": { create: createProxmoxRecentTasksTool, build: (_p, f) => strip({ limit: flagInt(f, "limit"), vmid: flagInt(f, "vmid") }) },
|
|
2847
5588
|
"next-vmid": { create: createProxmoxNextVmidTool, build: () => ({}) },
|
|
2848
|
-
"guest-network": { create: createProxmoxGuestNetworkTool, build: (p) => ({ vmid: reqInt(p[0], "vmid") }) }
|
|
5589
|
+
"guest-network": { create: createProxmoxGuestNetworkTool, build: (p) => ({ vmid: reqInt(p[0], "vmid") }) },
|
|
5590
|
+
"storage content": {
|
|
5591
|
+
create: createProxmoxListStorageContentTool,
|
|
5592
|
+
build: (p, f) => strip({ node: reqFlagStr(f, "node"), storage: reqStr(p[0], "storage"), content: flagStr(f, "content"), vmid: flagInt(f, "vmid") })
|
|
5593
|
+
},
|
|
5594
|
+
"disks list": { create: createProxmoxListDisksTool, build: (_p, f) => ({ node: reqFlagStr(f, "node") }) },
|
|
5595
|
+
"services list": { create: createProxmoxListNodeServicesTool, build: (_p, f) => ({ node: reqFlagStr(f, "node") }) },
|
|
5596
|
+
"updates list": { create: createProxmoxListUpdatesTool, build: (_p, f) => ({ node: reqFlagStr(f, "node") }) },
|
|
5597
|
+
"firewall rules": {
|
|
5598
|
+
create: createProxmoxListFirewallRulesTool,
|
|
5599
|
+
build: (_p, f) => strip({ scope: reqFlagStr(f, "scope"), node: flagStr(f, "node"), vmid: flagInt(f, "vmid") })
|
|
5600
|
+
},
|
|
5601
|
+
"firewall options": {
|
|
5602
|
+
create: createProxmoxGetFirewallOptionsTool,
|
|
5603
|
+
build: (_p, f) => strip({ scope: reqFlagStr(f, "scope"), node: flagStr(f, "node"), vmid: flagInt(f, "vmid") })
|
|
5604
|
+
}
|
|
2849
5605
|
};
|
|
2850
|
-
var TWO_WORD = /* @__PURE__ */ new Set(["vms", "containers", "vm", "container", "resource", "storage", "backups", "snapshots", "templates", "task"]);
|
|
2851
|
-
var HELP = `
|
|
5606
|
+
var TWO_WORD = /* @__PURE__ */ new Set(["vms", "containers", "vm", "container", "resource", "storage", "backups", "snapshots", "templates", "task", "disks", "services", "updates", "firewall"]);
|
|
5607
|
+
var HELP = `proxmoxctl - read-only Proxmox VE control CLI (alias: proxops; shares the proxmox-mcp core)
|
|
2852
5608
|
|
|
2853
5609
|
Usage:
|
|
2854
|
-
|
|
5610
|
+
proxmoxctl <command> [options]
|
|
2855
5611
|
|
|
2856
5612
|
Inventory:
|
|
2857
5613
|
status PVE version + per-node status (exit 1 if a node is offline)
|
|
@@ -2868,6 +5624,12 @@ Inventory:
|
|
|
2868
5624
|
pool-resources [<pool>] Members of a resource pool
|
|
2869
5625
|
next-vmid Next free VMID
|
|
2870
5626
|
guest-network <vmid> LXC network interfaces
|
|
5627
|
+
storage content <storage> Volumes on a storage --node <node> [--content backup|iso|vztmpl|images] [--vmid <id>]
|
|
5628
|
+
disks list Physical disks + SMART health --node <node>
|
|
5629
|
+
services list Host systemd services --node <node>
|
|
5630
|
+
updates list Pending APT updates --node <node> (needs a Sys.Modify token)
|
|
5631
|
+
firewall rules Firewall rules --scope cluster|node|guest [--node <node>] [--vmid <id>]
|
|
5632
|
+
firewall options Firewall options --scope cluster|node|guest [--node <node>] [--vmid <id>]
|
|
2871
5633
|
|
|
2872
5634
|
Audit / tasks:
|
|
2873
5635
|
audit-permissions Token privilege audit on common paths [--pool <pool>]
|
|
@@ -2876,7 +5638,7 @@ Audit / tasks:
|
|
|
2876
5638
|
task log <upid> Log of a task [--limit <n>] [--start <n>]
|
|
2877
5639
|
|
|
2878
5640
|
Server:
|
|
2879
|
-
mcp
|
|
5641
|
+
mcp [--http] Start MCP over stdio, or authenticated HTTP
|
|
2880
5642
|
help Show this help
|
|
2881
5643
|
|
|
2882
5644
|
Global options:
|
|
@@ -2902,6 +5664,11 @@ function flagStr(flags, name) {
|
|
|
2902
5664
|
const v = flags[name];
|
|
2903
5665
|
return typeof v === "string" ? v : void 0;
|
|
2904
5666
|
}
|
|
5667
|
+
function reqFlagStr(flags, name) {
|
|
5668
|
+
const v = flagStr(flags, name);
|
|
5669
|
+
if (v === void 0) throw new UsageError(`--${name} is required`);
|
|
5670
|
+
return v;
|
|
5671
|
+
}
|
|
2905
5672
|
function flagInt(flags, name) {
|
|
2906
5673
|
const v = flagStr(flags, name);
|
|
2907
5674
|
if (v === void 0) return void 0;
|
|
@@ -2942,7 +5709,10 @@ function parseArgs(argv) {
|
|
|
2942
5709
|
}
|
|
2943
5710
|
const first = tokens[0];
|
|
2944
5711
|
if (!first || first === "help") return { kind: "help" };
|
|
2945
|
-
if (first === "mcp")
|
|
5712
|
+
if (first === "mcp") {
|
|
5713
|
+
if (flags.http !== void 0 && flags.http !== true) throw new UsageError("--http does not take a value");
|
|
5714
|
+
return { kind: flags.http === true ? "mcp-http" : "mcp" };
|
|
5715
|
+
}
|
|
2946
5716
|
let command;
|
|
2947
5717
|
let positionals;
|
|
2948
5718
|
if (TWO_WORD.has(first)) {
|
|
@@ -3009,6 +5779,10 @@ async function run(argv, deps) {
|
|
|
3009
5779
|
deps.out(package_default.version);
|
|
3010
5780
|
return 0;
|
|
3011
5781
|
}
|
|
5782
|
+
if (parsed.kind === "mcp-http") {
|
|
5783
|
+
await startHttpServer();
|
|
5784
|
+
return 0;
|
|
5785
|
+
}
|
|
3012
5786
|
if (parsed.kind === "mcp") {
|
|
3013
5787
|
await deps.serve();
|
|
3014
5788
|
return 0;
|
|
@@ -3027,16 +5801,16 @@ async function run(argv, deps) {
|
|
|
3027
5801
|
return 1;
|
|
3028
5802
|
}
|
|
3029
5803
|
}
|
|
3030
|
-
var
|
|
5804
|
+
var isEntrypoint = (() => {
|
|
3031
5805
|
const arg = process.argv[1];
|
|
3032
5806
|
if (typeof arg !== "string") return false;
|
|
3033
5807
|
try {
|
|
3034
|
-
return import.meta.url ===
|
|
5808
|
+
return import.meta.url === pathToFileURL(realpathSync(arg)).href;
|
|
3035
5809
|
} catch {
|
|
3036
5810
|
return false;
|
|
3037
5811
|
}
|
|
3038
5812
|
})();
|
|
3039
|
-
if (
|
|
5813
|
+
if (isEntrypoint) {
|
|
3040
5814
|
run(process.argv.slice(2), {
|
|
3041
5815
|
out: (s) => process.stdout.write(`${s}
|
|
3042
5816
|
`),
|