hcloud-mcp 0.3.0 → 0.4.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 +6 -5
- package/dist/action-gap-tools.js +94 -42
- package/dist/certificate-tools.js +48 -24
- package/dist/dns-tools.js +123 -39
- package/dist/extra-tools.js +30 -18
- package/dist/hcloud-api.js +16 -6
- package/dist/image-tools.js +63 -31
- package/dist/index.js +2 -5
- package/dist/register-tools.js +719 -456
- package/dist/server-ops-tools.js +41 -17
- package/dist/storage-box-tools.js +181 -61
- package/dist/tool-helpers.js +17 -26
- package/package.json +3 -5
- package/skills/hetzner-cloud/SKILL.md +2 -0
package/README.md
CHANGED
|
@@ -128,6 +128,7 @@ Updated in 0.2.0 for Hetzner Cloud API changes through November 2026 ([changelog
|
|
|
128
128
|
- `create_primary_ip` takes `location` instead of `datacenter`.
|
|
129
129
|
- `delete_load_balancer` now returns the deletion Action.
|
|
130
130
|
- `add_network_subnet` no longer offers the deprecated `server` type. Use `cloud`.
|
|
131
|
+
- **0.3.1:** `create_volume` and `attach_volume` send `assignee: {type: "server", id}` instead of the deprecated `server` field, which the API removes on 2027-10-27. Tool inputs are unchanged. Read `assignee` in volume responses.
|
|
131
132
|
- List tools now return every page. Previously they silently stopped at the first 25 items.
|
|
132
133
|
- Floating IPs and Primary IPs must be unassigned before you delete them.
|
|
133
134
|
- `list_actions` requires `id`, because Hetzner removed project-wide action listing. Use `get_action` to poll.
|
|
@@ -167,10 +168,10 @@ With the MCP client connected, you can ask the agent to run tools using natural
|
|
|
167
168
|
| File | Purpose |
|
|
168
169
|
| ----------------------- | ----------------------------------------------------------- |
|
|
169
170
|
| `src/index.ts` | Entry point, stdio transport, `HCLOUD_TOKEN` check |
|
|
170
|
-
| `src/register-tools.ts` |
|
|
171
|
+
| `src/register-tools.ts` | Core tools: servers, LBs, networks, volumes, firewalls, IPs, SSH keys, info |
|
|
171
172
|
| `src/extra-tools.ts` | Newer Cloud API endpoints (reverse DNS, rebuild, network members) |
|
|
172
|
-
| `src/dns-tools.ts` | DNS zone/RRSet tools
|
|
173
|
-
| `src/hcloud-api.ts` | Minimal fetch client for
|
|
173
|
+
| `src/dns-tools.ts` | DNS zone/RRSet tools |
|
|
174
|
+
| `src/hcloud-api.ts` | Minimal fetch client for the Hetzner APIs (no SDK dependency) |
|
|
174
175
|
| `src/action-gap-tools.ts` | Placement groups, alias IPs, LB network/type/algorithm/public interface, routes, ISOs |
|
|
175
176
|
| `src/image-tools.ts` | Snapshots, backups, image management, `change_protection` |
|
|
176
177
|
| `src/server-ops-tools.ts` | Rescue, console, root password, server/LB metrics |
|
|
@@ -185,9 +186,9 @@ With the MCP client connected, you can ask the agent to run tools using natural
|
|
|
185
186
|
npm run build # compile
|
|
186
187
|
npm run start # run (requires HCLOUD_TOKEN)
|
|
187
188
|
npm run dev # watch and recompile
|
|
188
|
-
npm run test:
|
|
189
|
+
npm run test:smoke # offline: server starts, tools register, toolsets work (runs in CI)
|
|
190
|
+
npm run test:api # read-only checks of the API client: pagination, error format (requires HCLOUD_TOKEN, run build first)
|
|
189
191
|
npm run test:mcp # integration test: MCP client calls list_locations (requires HCLOUD_TOKEN)
|
|
190
|
-
npm run audit:api # verify create_* request body shapes (DRY_RUN=1, no resources created)
|
|
191
192
|
npm run test:live:dns # DNS create→teardown on a throwaway zone (free)
|
|
192
193
|
npm run test:live:images # snapshots, backups, protection (costs cents)
|
|
193
194
|
npm run test:live:ops # rescue, console, root password, metrics (costs cents)
|
package/dist/action-gap-tools.js
CHANGED
|
@@ -1,66 +1,118 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { hcloudRequest } from "./hcloud-api.js";
|
|
3
|
-
import { json, listAll, withToolError } from "./tool-helpers.js";
|
|
3
|
+
import { ADDITIVE_IDEMPOTENT, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, json, listAll, withToolError } from "./tool-helpers.js";
|
|
4
4
|
const action = (path, body) => withToolError(async () => json(await hcloudRequest("POST", path, { body: body ?? {} })));
|
|
5
5
|
export function registerActionGapTools(server) {
|
|
6
6
|
// --- Servers ---
|
|
7
|
-
server.
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
server.registerTool("add_server_to_placement_group", {
|
|
8
|
+
description: "Add a server to a placement group. The server must be powered off (422 server_not_stopped) and not already in a placement group (422 already_in_placement_group). Returns an Action",
|
|
9
|
+
inputSchema: {
|
|
10
|
+
id: z.number().describe("Server ID"),
|
|
11
|
+
placement_group: z.number().describe("Placement group ID"),
|
|
12
|
+
},
|
|
13
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
10
14
|
}, async ({ id, placement_group }) => action(`/servers/${id}/actions/add_to_placement_group`, { placement_group }));
|
|
11
|
-
server.
|
|
12
|
-
|
|
13
|
-
id: z.number().describe("Server ID"),
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
server.registerTool("remove_server_from_placement_group", {
|
|
16
|
+
description: "Remove a server from its placement group. Returns an Action",
|
|
17
|
+
inputSchema: { id: z.number().describe("Server ID") },
|
|
18
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
19
|
+
}, async ({ id }) => action(`/servers/${id}/actions/remove_from_placement_group`));
|
|
20
|
+
server.registerTool("change_server_alias_ips", {
|
|
21
|
+
description: "Set the alias IPs of a server on a network it is already attached to. REPLACES the existing alias list for that network: to add one, pass the current alias_ips (get_server private_net) plus the new IP; pass [] to remove all. Returns an Action",
|
|
22
|
+
inputSchema: {
|
|
23
|
+
id: z.number().describe("Server ID"),
|
|
24
|
+
network: z.number().describe("ID of a network already attached to the server"),
|
|
25
|
+
alias_ips: z.array(z.string()).describe("Complete new list of alias IPs, e.g. [\"10.0.1.50\"]"),
|
|
26
|
+
},
|
|
27
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
16
28
|
}, async ({ id, network, alias_ips }) => action(`/servers/${id}/actions/change_alias_ips`, { network, alias_ips }));
|
|
17
29
|
// --- Load balancers ---
|
|
18
|
-
server.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
30
|
+
server.registerTool("attach_load_balancer_to_network", {
|
|
31
|
+
description: "Attach a load balancer to a network (one network per load balancer). Optionally request a specific private ip, or ip_range to auto-assign from a specific subnet; ip must lie within ip_range if both are given. Returns an Action",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
id: z.number().describe("Load balancer ID"),
|
|
34
|
+
network: z.number().describe("Network ID"),
|
|
35
|
+
ip: z.string().optional().describe("Private IP to assign; auto-assigned if omitted"),
|
|
36
|
+
ip_range: z.string().optional().describe("Subnet ip_range (CIDR) to auto-assign the IP from, e.g. 10.0.1.0/24"),
|
|
37
|
+
},
|
|
38
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
23
39
|
}, async ({ id, network, ip, ip_range }) => action(`/load_balancers/${id}/actions/attach_to_network`, { network, ip, ip_range }));
|
|
24
|
-
server.
|
|
25
|
-
|
|
26
|
-
|
|
40
|
+
server.registerTool("detach_load_balancer_from_network", {
|
|
41
|
+
description: "Detach a load balancer from a network. Re-enable the public interface first if it was disabled, or the load balancer becomes unreachable. Returns an Action",
|
|
42
|
+
inputSchema: {
|
|
43
|
+
id: z.number().describe("Load balancer ID"),
|
|
44
|
+
network: z.number().describe("Network ID"),
|
|
45
|
+
},
|
|
46
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
27
47
|
}, async ({ id, network }) => action(`/load_balancers/${id}/actions/detach_from_network`, { network }));
|
|
28
|
-
server.
|
|
29
|
-
|
|
30
|
-
|
|
48
|
+
server.registerTool("change_load_balancer_algorithm", {
|
|
49
|
+
description: "Change how a load balancer distributes new requests across targets. Returns an Action",
|
|
50
|
+
inputSchema: {
|
|
51
|
+
id: z.number().describe("Load balancer ID"),
|
|
52
|
+
type: z.enum(["round_robin", "least_connections"]),
|
|
53
|
+
},
|
|
54
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
31
55
|
}, async ({ id, type }) => action(`/load_balancers/${id}/actions/change_algorithm`, { type }));
|
|
32
|
-
server.
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
server.registerTool("change_load_balancer_type", {
|
|
57
|
+
description: "Change a load balancer's type (max services / targets / connections; price changes accordingly — check get_pricing). Fails with invalid_load_balancer_type if the current config exceeds the new type's limits. Returns an Action",
|
|
58
|
+
inputSchema: {
|
|
59
|
+
id: z.number().describe("Load balancer ID"),
|
|
60
|
+
load_balancer_type: z.string().describe("Type name or ID, e.g. lb11, lb21, lb31"),
|
|
61
|
+
},
|
|
62
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
35
63
|
}, async ({ id, load_balancer_type }) => action(`/load_balancers/${id}/actions/change_type`, { load_balancer_type }));
|
|
36
|
-
server.
|
|
37
|
-
|
|
64
|
+
server.registerTool("enable_load_balancer_public_interface", {
|
|
65
|
+
description: "Enable a load balancer's public interface so it is reachable from the internet via its public IPs. Returns an Action",
|
|
66
|
+
inputSchema: { id: z.number().describe("Load balancer ID") },
|
|
67
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
68
|
+
}, async ({ id }) => action(`/load_balancers/${id}/actions/enable_public_interface`));
|
|
69
|
+
server.registerTool("disable_load_balancer_public_interface", {
|
|
70
|
+
description: "Disable a load balancer's public interface (private-network only). Requires the load balancer to be attached to a network (load_balancer_not_attached_to_network) and all targets to use_private_ip (targets_without_use_private_ip). Returns an Action",
|
|
71
|
+
inputSchema: { id: z.number().describe("Load balancer ID") },
|
|
72
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
73
|
+
}, async ({ id }) => action(`/load_balancers/${id}/actions/disable_public_interface`));
|
|
38
74
|
// --- Networks ---
|
|
39
|
-
server.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
75
|
+
server.registerTool("add_network_route", {
|
|
76
|
+
description: "Add a route to a network: traffic for destination is sent to gateway. destination must be an RFC1918 range or 0.0.0.0/0 and must not overlap subnets or other routes; gateway must be an IP inside the network (not its first IP, not 172.31.1.1). Returns an Action",
|
|
77
|
+
inputSchema: {
|
|
78
|
+
id: z.number().describe("Network ID"),
|
|
79
|
+
destination: z.string().describe("Destination CIDR, e.g. 10.100.1.0/24 or 0.0.0.0/0"),
|
|
80
|
+
gateway: z.string().describe("Gateway IP inside the network, e.g. a server's private IP 10.0.1.2"),
|
|
81
|
+
},
|
|
82
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
43
83
|
}, async ({ id, destination, gateway }) => action(`/networks/${id}/actions/add_route`, { destination, gateway }));
|
|
44
|
-
server.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
84
|
+
server.registerTool("delete_network_route", {
|
|
85
|
+
description: "Delete a route from a network. destination and gateway must match the existing route exactly (see get_network routes). Returns an Action",
|
|
86
|
+
inputSchema: {
|
|
87
|
+
id: z.number().describe("Network ID"),
|
|
88
|
+
destination: z.string().describe("Destination CIDR of the route"),
|
|
89
|
+
gateway: z.string().describe("Gateway IP of the route"),
|
|
90
|
+
},
|
|
91
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
48
92
|
}, async ({ id, destination, gateway }) => action(`/networks/${id}/actions/delete_route`, { destination, gateway }));
|
|
49
|
-
server.
|
|
50
|
-
|
|
51
|
-
|
|
93
|
+
server.registerTool("change_network_ip_range", {
|
|
94
|
+
description: "Change a network's IP range. Can only be extended by shortening the netmask with the same base address (10.0.0.0/16 -> 10.0.0.0/15), never shrunk. The network must have NO attached servers or load balancers (detach them first). Returns an Action",
|
|
95
|
+
inputSchema: {
|
|
96
|
+
id: z.number().describe("Network ID"),
|
|
97
|
+
ip_range: z.string().describe("New range in CIDR, same start IP as the current range, e.g. 10.0.0.0/15"),
|
|
98
|
+
},
|
|
99
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
52
100
|
}, async ({ id, ip_range }) => action(`/networks/${id}/actions/change_ip_range`, { ip_range }));
|
|
53
101
|
// --- ISOs ---
|
|
54
|
-
server.
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
.
|
|
102
|
+
server.registerTool("list_isos", {
|
|
103
|
+
description: "List ISOs available to attach_iso (public and private). name is an exact match. architecture filters x86/arm; include_architecture_wildcard (requires architecture) also includes ISOs with no architecture. Check deprecation before use. All pages",
|
|
104
|
+
inputSchema: {
|
|
105
|
+
name: z.string().optional().describe("Exact ISO name"),
|
|
106
|
+
architecture: z.enum(["x86", "arm"]).optional(),
|
|
107
|
+
include_architecture_wildcard: z.boolean().optional()
|
|
108
|
+
.describe("Also include ISOs with architecture null; only valid together with architecture"),
|
|
109
|
+
},
|
|
110
|
+
annotations: READ_ONLY,
|
|
59
111
|
}, async (filters) => withToolError(async () => {
|
|
60
112
|
if (filters.include_architecture_wildcard !== undefined && !filters.architecture) {
|
|
61
113
|
throw new Error("include_architecture_wildcard requires architecture");
|
|
62
114
|
}
|
|
63
|
-
const isos = await listAll((p) => hcloudRequest("GET", "/isos", { query: { ...filters,
|
|
115
|
+
const isos = await listAll((p) => hcloudRequest("GET", "/isos", { query: { ...filters, ...p } }), "isos");
|
|
64
116
|
return json(isos);
|
|
65
117
|
}));
|
|
66
118
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { hcloudRequest } from "./hcloud-api.js";
|
|
3
|
-
import { json, listAll, withToolError } from "./tool-helpers.js";
|
|
3
|
+
import { ADDITIVE, ADDITIVE_IDEMPOTENT, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, json, listAll, withToolError } from "./tool-helpers.js";
|
|
4
4
|
const certId = z.number().int().describe("Certificate ID");
|
|
5
5
|
const certType = z.enum(["uploaded", "managed"]);
|
|
6
6
|
const labels = z.record(z.string());
|
|
@@ -10,27 +10,39 @@ const MANAGED_REQUIREMENTS = "Managed (Let's Encrypt) certificates are validated
|
|
|
10
10
|
"caa_record_does_not_allow_ca, ca_dns_validation_failed, Let's Encrypt rate limits";
|
|
11
11
|
const USAGE = "Certificates are referenced by ID in Load Balancer HTTPS services: http.certificates in add_load_balancer_service / update_load_balancer_service";
|
|
12
12
|
export function registerCertificateTools(server) {
|
|
13
|
-
server.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
server.registerTool("list_certificates", {
|
|
14
|
+
description: "List TLS certificates (all pages). Optional filters: name, label_selector, type. Each includes domain_names, not_valid_after, fingerprint, managed status and used_by (load balancers using it)",
|
|
15
|
+
inputSchema: {
|
|
16
|
+
name: z.string().optional().describe("Exact certificate name"),
|
|
17
|
+
label_selector: z.string().optional().describe("Label selector, e.g. env=prod"),
|
|
18
|
+
type: z.array(certType).optional().describe("Filter by type(s)"),
|
|
19
|
+
},
|
|
20
|
+
annotations: READ_ONLY,
|
|
17
21
|
}, async (args) => withToolError(async () => {
|
|
18
|
-
const certs = await listAll((p) => hcloudRequest("GET", "/certificates", { query: { ...args,
|
|
22
|
+
const certs = await listAll((p) => hcloudRequest("GET", "/certificates", { query: { ...args, ...p } }), "certificates");
|
|
19
23
|
return json(certs);
|
|
20
24
|
}));
|
|
21
|
-
server.
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
server.registerTool("get_certificate", {
|
|
26
|
+
description: "Get a TLS certificate: PEM chain (public), domain_names, validity window, fingerprint, used_by, and for managed certs status.issuance / status.renewal / status.error",
|
|
27
|
+
inputSchema: { id: certId },
|
|
28
|
+
annotations: READ_ONLY,
|
|
29
|
+
}, async ({ id }) => withToolError(async () => json((await hcloudRequest("GET", `/certificates/${id}`)).certificate)));
|
|
30
|
+
server.registerTool("create_certificate", {
|
|
31
|
+
description: "Create a TLS certificate. type \"uploaded\" (default): provide certificate (PEM, leaf first then chain) and private_key (PEM); " +
|
|
32
|
+
"supported keys RSA 2048/3072/4096 or ECDSA P-256/P-384; you must renew it yourself before not_valid_after. " +
|
|
33
|
+
"type \"managed\": provide domain_names; Hetzner requests and auto-renews a Let's Encrypt cert. " +
|
|
34
|
+
MANAGED_REQUIREMENTS +
|
|
35
|
+
". Returns {certificate, action}: action tracks managed issuance (poll get_action), null for uploaded. " +
|
|
36
|
+
USAGE,
|
|
37
|
+
inputSchema: {
|
|
38
|
+
name: z.string().describe("Unique name within the project"),
|
|
39
|
+
type: certType.default("uploaded"),
|
|
40
|
+
certificate: z.string().optional().describe("uploaded only: certificate + chain in PEM, each cert certifying the preceding one"),
|
|
41
|
+
private_key: z.string().optional().describe("uploaded only: private key in PEM. Sent to the API only; never returned"),
|
|
42
|
+
domain_names: z.array(z.string()).optional().describe('managed only: domains to include, e.g. ["example.com", "www.example.com"]'),
|
|
43
|
+
labels: labels.optional(),
|
|
44
|
+
},
|
|
45
|
+
annotations: ADDITIVE,
|
|
34
46
|
}, async (args) => withToolError(async () => {
|
|
35
47
|
const { name, type, certificate, private_key, domain_names, labels } = args;
|
|
36
48
|
let body;
|
|
@@ -50,16 +62,28 @@ export function registerCertificateTools(server) {
|
|
|
50
62
|
}
|
|
51
63
|
return json(await hcloudRequest("POST", "/certificates", { body }));
|
|
52
64
|
}));
|
|
53
|
-
server.
|
|
65
|
+
server.registerTool("update_certificate", {
|
|
66
|
+
description: "Rename a certificate and/or replace its labels (labels overwrite the whole set). The certificate content cannot be changed; to rotate an uploaded cert, create a new one, point the load balancer service at it, then delete the old one",
|
|
67
|
+
inputSchema: { id: certId, name: z.string().optional(), labels: labels.optional() },
|
|
68
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
69
|
+
}, async ({ id, name, labels }) => withToolError(async () => {
|
|
54
70
|
if (name === undefined && labels === undefined)
|
|
55
71
|
throw new Error("Provide name and/or labels");
|
|
56
72
|
return json((await hcloudRequest("PUT", `/certificates/${id}`, { body: { name, labels } })).certificate);
|
|
57
73
|
}));
|
|
58
|
-
server.
|
|
74
|
+
server.registerTool("delete_certificate", {
|
|
75
|
+
description: "Delete a certificate. Irreversible; confirm with the user first. Check used_by (get_certificate) first: load balancer HTTPS services referencing it should be switched to another certificate",
|
|
76
|
+
inputSchema: { id: certId },
|
|
77
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
78
|
+
}, async ({ id }) => withToolError(async () => {
|
|
59
79
|
await hcloudRequest("DELETE", `/certificates/${id}`);
|
|
60
80
|
return json({ deleted: id });
|
|
61
81
|
}));
|
|
62
|
-
server.
|
|
63
|
-
|
|
64
|
-
|
|
82
|
+
server.registerTool("retry_certificate", {
|
|
83
|
+
description: "Retry a failed issuance or renewal of a managed certificate (only when status.issuance or status.renewal is \"failed\"; see status.error for the cause and fix it first). " +
|
|
84
|
+
MANAGED_REQUIREMENTS +
|
|
85
|
+
". Returns an Action (poll get_action)",
|
|
86
|
+
inputSchema: { id: certId },
|
|
87
|
+
annotations: ADDITIVE,
|
|
88
|
+
}, async ({ id }) => withToolError(async () => json(await hcloudRequest("POST", `/certificates/${id}/actions/retry`))));
|
|
65
89
|
}
|
package/dist/dns-tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { hcloudRequest, seg } from "./hcloud-api.js";
|
|
3
|
-
import { json, listAll, withToolError } from "./tool-helpers.js";
|
|
3
|
+
import { ADDITIVE, ADDITIVE_IDEMPOTENT, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, json, listAll, withToolError } from "./tool-helpers.js";
|
|
4
4
|
const zoneRef = z.string().describe("Zone ID or name, e.g. example.com");
|
|
5
5
|
const rrName = z
|
|
6
6
|
.string()
|
|
@@ -27,26 +27,38 @@ const nameserver = z.object({
|
|
|
27
27
|
const rrsetPath = (zone, name, type) => `/zones/${seg(zone)}/rrsets/${seg(name)}/${seg(type)}`;
|
|
28
28
|
export function registerDnsTools(server) {
|
|
29
29
|
// --- Zones ---
|
|
30
|
-
server.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
server.registerTool("list_zones", {
|
|
31
|
+
description: "List DNS zones (all pages). Optional filters by name, mode, label selector",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
name: z.string().optional(),
|
|
34
|
+
mode: z.enum(["primary", "secondary"]).optional(),
|
|
35
|
+
label_selector: labelSelector,
|
|
36
|
+
},
|
|
37
|
+
annotations: READ_ONLY,
|
|
34
38
|
}, async (args) => withToolError(async () => {
|
|
35
|
-
const zones = await listAll((p) => hcloudRequest("GET", "/zones", { query: { ...args,
|
|
39
|
+
const zones = await listAll((p) => hcloudRequest("GET", "/zones", { query: { ...args, ...p } }), "zones");
|
|
36
40
|
return json(zones);
|
|
37
41
|
}));
|
|
38
|
-
server.
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
.describe("
|
|
49
|
-
|
|
42
|
+
server.registerTool("get_zone", {
|
|
43
|
+
description: "Get a DNS zone (status, nameservers it is authoritative on, delegation status, record count)",
|
|
44
|
+
inputSchema: { zone: zoneRef },
|
|
45
|
+
annotations: READ_ONLY,
|
|
46
|
+
}, async ({ zone }) => withToolError(async () => json((await hcloudRequest("GET", `/zones/${seg(zone)}`)).zone)));
|
|
47
|
+
server.registerTool("create_zone", {
|
|
48
|
+
description: 'Create a DNS zone. mode "primary" = Hetzner hosts the records (optionally seed with rrsets or a zonefile); "secondary" = Hetzner pulls from primary_nameservers via AXFR. Returns zone + Action. After creating, delegate the domain to the zone\'s authoritative_nameservers at your registrar',
|
|
49
|
+
inputSchema: {
|
|
50
|
+
name: z.string().describe("Domain name, e.g. example.com (no trailing dot)"),
|
|
51
|
+
mode: z.enum(["primary", "secondary"]).default("primary"),
|
|
52
|
+
ttl: ttl.optional().describe("Default TTL for records without their own TTL (default 3600)"),
|
|
53
|
+
labels: labels.optional(),
|
|
54
|
+
primary_nameservers: z.array(nameserver).optional().describe("Required for mode=secondary"),
|
|
55
|
+
rrsets: z
|
|
56
|
+
.array(z.object({ name: rrName, type: rrType, ttl: ttl.nullable().optional(), records, labels: labels.optional() }))
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Initial RRSets (primary only; mutually exclusive with zonefile)"),
|
|
59
|
+
zonefile: z.string().optional().describe("BIND zone file to import (primary only; mutually exclusive with rrsets)"),
|
|
60
|
+
},
|
|
61
|
+
annotations: ADDITIVE,
|
|
50
62
|
}, async (args) => withToolError(async () => {
|
|
51
63
|
if (args.rrsets && args.zonefile)
|
|
52
64
|
throw new Error("Provide rrsets OR zonefile, not both");
|
|
@@ -55,32 +67,104 @@ export function registerDnsTools(server) {
|
|
|
55
67
|
}
|
|
56
68
|
return json(await hcloudRequest("POST", "/zones", { body: args }));
|
|
57
69
|
}));
|
|
58
|
-
server.
|
|
59
|
-
|
|
60
|
-
|
|
70
|
+
server.registerTool("update_zone", {
|
|
71
|
+
description: "Update a zone's labels (replaces all labels)",
|
|
72
|
+
inputSchema: { zone: zoneRef, labels },
|
|
73
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
74
|
+
}, async ({ zone, labels }) => withToolError(async () => json((await hcloudRequest("PUT", `/zones/${seg(zone)}`, { body: { labels } })).zone)));
|
|
75
|
+
server.registerTool("delete_zone", {
|
|
76
|
+
description: "Delete a DNS zone and ALL its records. Irreversible; confirm with the user first. Returns an Action",
|
|
77
|
+
inputSchema: { zone: zoneRef },
|
|
78
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
79
|
+
}, async ({ zone }) => withToolError(async () => json(await hcloudRequest("DELETE", `/zones/${seg(zone)}`))));
|
|
80
|
+
server.registerTool("export_zonefile", {
|
|
81
|
+
description: "Export a primary zone as a BIND zone file (good for backups or reviewing all records at once)",
|
|
82
|
+
inputSchema: { zone: zoneRef },
|
|
83
|
+
annotations: READ_ONLY,
|
|
84
|
+
}, async ({ zone }) => withToolError(async () => {
|
|
61
85
|
const res = await hcloudRequest("GET", `/zones/${seg(zone)}/zonefile`);
|
|
62
86
|
return { content: [{ type: "text", text: res.zonefile ?? JSON.stringify(res, null, 2) }] };
|
|
63
87
|
}));
|
|
64
|
-
server.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
88
|
+
server.registerTool("import_zonefile", {
|
|
89
|
+
description: "Replace ALL records of a primary zone with a BIND zone file. Destructive for records not in the file; export_zonefile first as a backup. Returns an Action",
|
|
90
|
+
inputSchema: { zone: zoneRef, zonefile: z.string() },
|
|
91
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
92
|
+
}, async ({ zone, zonefile }) => withToolError(async () => json(await hcloudRequest("POST", `/zones/${seg(zone)}/actions/import_zonefile`, { body: { zonefile } }))));
|
|
93
|
+
server.registerTool("change_zone_ttl", {
|
|
94
|
+
description: "Change a zone's default TTL (applies to RRSets without their own TTL). Returns an Action",
|
|
95
|
+
inputSchema: { zone: zoneRef, ttl },
|
|
96
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
97
|
+
}, async ({ zone, ttl }) => withToolError(async () => json(await hcloudRequest("POST", `/zones/${seg(zone)}/actions/change_ttl`, { body: { ttl } }))));
|
|
98
|
+
server.registerTool("change_zone_primary_nameservers", {
|
|
99
|
+
description: "Set the primary nameservers a secondary zone transfers from (replaces the list). Returns an Action",
|
|
100
|
+
inputSchema: { zone: zoneRef, primary_nameservers: z.array(nameserver).min(1) },
|
|
101
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
102
|
+
}, async ({ zone, primary_nameservers }) => withToolError(async () => json(await hcloudRequest("POST", `/zones/${seg(zone)}/actions/change_primary_nameservers`, { body: { primary_nameservers } }))));
|
|
103
|
+
server.registerTool("change_zone_protection", {
|
|
104
|
+
description: "Enable/disable delete protection on a zone. Returns an Action",
|
|
105
|
+
inputSchema: { zone: zoneRef, delete: z.boolean() },
|
|
106
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
107
|
+
}, async ({ zone, delete: del }) => withToolError(async () => json(await hcloudRequest("POST", `/zones/${seg(zone)}/actions/change_protection`, { body: { delete: del } }))));
|
|
68
108
|
// --- RRSets ---
|
|
69
|
-
server.
|
|
70
|
-
|
|
109
|
+
server.registerTool("list_rrsets", {
|
|
110
|
+
description: "List record sets (RRSets) in a zone (all pages). Filter by name and/or type",
|
|
111
|
+
inputSchema: { zone: zoneRef, name: z.string().optional(), type: rrType.optional(), label_selector: labelSelector },
|
|
112
|
+
annotations: READ_ONLY,
|
|
113
|
+
}, async ({ zone, ...filters }) => withToolError(async () => {
|
|
114
|
+
const rrsets = await listAll((p) => hcloudRequest("GET", `/zones/${seg(zone)}/rrsets`, { query: { ...filters, ...p } }), "rrsets");
|
|
71
115
|
return json(rrsets);
|
|
72
116
|
}));
|
|
73
|
-
server.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
server.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
117
|
+
server.registerTool("get_rrset", {
|
|
118
|
+
description: "Get one RRSet by name and type",
|
|
119
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType },
|
|
120
|
+
annotations: READ_ONLY,
|
|
121
|
+
}, async ({ zone, name, type }) => withToolError(async () => json((await hcloudRequest("GET", rrsetPath(zone, name, type))).rrset)));
|
|
122
|
+
server.registerTool("create_rrset", {
|
|
123
|
+
description: "Create an RRSet (all records sharing one name+type). Fails if it already exists; use add_rrset_records or set_rrset_records to change an existing one. Returns rrset + Action",
|
|
124
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, records, ttl: ttl.nullable().optional().describe("Omit/null = zone default"), labels: labels.optional() },
|
|
125
|
+
annotations: ADDITIVE,
|
|
126
|
+
}, async ({ zone, ...body }) => withToolError(async () => json(await hcloudRequest("POST", `/zones/${seg(zone)}/rrsets`, { body }))));
|
|
127
|
+
server.registerTool("update_rrset", {
|
|
128
|
+
description: "Update an RRSet's labels (replaces all labels). To change records use set/add/remove_rrset_records",
|
|
129
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, labels },
|
|
130
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
131
|
+
}, async ({ zone, name, type, labels }) => withToolError(async () => json((await hcloudRequest("PUT", rrsetPath(zone, name, type), { body: { labels } })).rrset)));
|
|
132
|
+
server.registerTool("delete_rrset", {
|
|
133
|
+
description: "Delete an RRSet and all its records. Returns an Action",
|
|
134
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType },
|
|
135
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
136
|
+
}, async ({ zone, name, type }) => withToolError(async () => json(await hcloudRequest("DELETE", rrsetPath(zone, name, type)))));
|
|
137
|
+
server.registerTool("set_rrset_records", {
|
|
138
|
+
description: "Replace all records of an RRSet with the given list. Returns an Action",
|
|
139
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, records },
|
|
140
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
141
|
+
}, async ({ zone, name, type, records }) => withToolError(async () => json(await hcloudRequest("POST", `${rrsetPath(zone, name, type)}/actions/set_records`, { body: { records } }))));
|
|
142
|
+
server.registerTool("add_rrset_records", {
|
|
143
|
+
description: "Add records to an RRSet, creating the RRSet if it does not exist. Returns an Action",
|
|
144
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, records, ttl: ttl.nullable().optional().describe("Used only if the RRSet is created") },
|
|
145
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
146
|
+
}, async ({ zone, name, type, records, ttl }) => withToolError(async () => json(await hcloudRequest("POST", `${rrsetPath(zone, name, type)}/actions/add_records`, { body: { records, ttl } }))));
|
|
147
|
+
server.registerTool("remove_rrset_records", {
|
|
148
|
+
description: "Remove specific records (matched by value) from an RRSet. Removing the last record deletes the RRSet. Returns an Action",
|
|
149
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, records },
|
|
150
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
151
|
+
}, async ({ zone, name, type, records }) => withToolError(async () => json(await hcloudRequest("POST", `${rrsetPath(zone, name, type)}/actions/remove_records`, { body: { records } }))));
|
|
152
|
+
server.registerTool("update_rrset_records", {
|
|
153
|
+
description: "Update the comments of existing records (matched by value). Cannot change values; use set_rrset_records for that",
|
|
154
|
+
inputSchema: {
|
|
155
|
+
zone: zoneRef, name: rrName, type: rrType,
|
|
156
|
+
records: z.array(z.object({ value: z.string(), comment: z.string() })).min(1),
|
|
157
|
+
},
|
|
158
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
83
159
|
}, async ({ zone, name, type, records }) => withToolError(async () => json(await hcloudRequest("POST", `${rrsetPath(zone, name, type)}/actions/update_records`, { body: { records } }))));
|
|
84
|
-
server.
|
|
85
|
-
|
|
160
|
+
server.registerTool("change_rrset_ttl", {
|
|
161
|
+
description: "Change an RRSet's TTL. ttl is required: a number of seconds, or null to fall back to the zone default. Returns an Action",
|
|
162
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, ttl: ttl.nullable() },
|
|
163
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
164
|
+
}, async ({ zone, name, type, ttl }) => withToolError(async () => json(await hcloudRequest("POST", `${rrsetPath(zone, name, type)}/actions/change_ttl`, { body: { ttl } }))));
|
|
165
|
+
server.registerTool("change_rrset_protection", {
|
|
166
|
+
description: "Enable/disable change protection on an RRSet (protected RRSets cannot be modified or deleted). Returns an Action",
|
|
167
|
+
inputSchema: { zone: zoneRef, name: rrName, type: rrType, change: z.boolean() },
|
|
168
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
169
|
+
}, async ({ zone, name, type, change }) => withToolError(async () => json(await hcloudRequest("POST", `${rrsetPath(zone, name, type)}/actions/change_protection`, { body: { change } }))));
|
|
86
170
|
}
|
package/dist/extra-tools.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { hcloudRequest } from "./hcloud-api.js";
|
|
3
|
-
import { json, listAll, withToolError } from "./tool-helpers.js";
|
|
3
|
+
import { ADDITIVE_IDEMPOTENT, DESTRUCTIVE, READ_ONLY, json, listAll, withToolError } from "./tool-helpers.js";
|
|
4
4
|
const PTR_RESOURCES = {
|
|
5
5
|
server: "servers",
|
|
6
6
|
primary_ip: "primary_ips",
|
|
@@ -8,26 +8,38 @@ const PTR_RESOURCES = {
|
|
|
8
8
|
load_balancer: "load_balancers",
|
|
9
9
|
};
|
|
10
10
|
export function registerExtraTools(server) {
|
|
11
|
-
server.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
server.registerTool("change_dns_ptr", {
|
|
12
|
+
description: "Set or reset reverse DNS (PTR) for a public IP of a server, Primary IP, Floating IP, or load balancer. dns_ptr is always required: pass a hostname to set it, or null to reset it to the Hetzner default. Returns an Action",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
resource: z.enum(["server", "primary_ip", "floating_ip", "load_balancer"]),
|
|
15
|
+
id: z.number().describe("ID of the server / Primary IP / Floating IP / load balancer"),
|
|
16
|
+
ip: z.string().describe("The public IP to set the PTR for (IPv4, or a single IPv6 address within the resource's /64)"),
|
|
17
|
+
dns_ptr: z.string().nullable().describe("Hostname, e.g. mail.example.com; null resets to default"),
|
|
18
|
+
},
|
|
19
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
16
20
|
}, async ({ resource, id, ip, dns_ptr }) => withToolError(async () => json(await hcloudRequest("POST", `/${PTR_RESOURCES[resource]}/${id}/actions/change_dns_ptr`, { body: { ip, dns_ptr } }))));
|
|
17
|
-
server.
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
server.registerTool("rebuild_server", {
|
|
22
|
+
description: "Reinstall a server from an image, WIPING ALL DATA on its disk (attached volumes are kept). The server keeps its ID and IPs. Optional user_data (cloud-init) overrides the original. Returns an Action and, for images that use one, a new root_password. Irreversible; confirm with the user first",
|
|
23
|
+
inputSchema: {
|
|
24
|
+
id: z.number().describe("Server ID"),
|
|
25
|
+
image: z.string().describe("Image name or ID, e.g. ubuntu-24.04 (check list_images deprecation)"),
|
|
26
|
+
user_data: z.string().optional().describe("Cloud-Init user data (max 32KiB)"),
|
|
27
|
+
},
|
|
28
|
+
annotations: DESTRUCTIVE,
|
|
21
29
|
}, async ({ id, image, user_data }) => withToolError(async () => json(await hcloudRequest("POST", `/servers/${id}/actions/rebuild`, { body: { image, user_data } }))));
|
|
22
|
-
server.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
.describe("
|
|
30
|
+
server.registerTool("list_network_members", {
|
|
31
|
+
description: "List resources attached to a network (servers and load balancers) with their private IP, alias IPs, subnet and attachment status. All pages",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
id: z.number().describe("Network ID"),
|
|
34
|
+
// Each filter may be given multiple times (OR within a filter), per the API spec.
|
|
35
|
+
type: z.array(z.enum(["server", "load_balancer"])).optional(),
|
|
36
|
+
subnet: z.array(z.string()).optional().describe("Subnet IP ranges in CIDR, e.g. [\"10.0.1.0/24\"]"),
|
|
37
|
+
status: z.array(z.enum(["ok", "attaching", "detaching", "updating", "error"])).optional()
|
|
38
|
+
.describe("Attachment status (spec enum: ok, attaching, detaching, updating, error)"),
|
|
39
|
+
},
|
|
40
|
+
annotations: READ_ONLY,
|
|
29
41
|
}, async ({ id, ...filters }) => withToolError(async () => {
|
|
30
|
-
const members = await listAll((p) => hcloudRequest("GET", `/networks/${id}/members`, { query: { ...filters,
|
|
42
|
+
const members = await listAll((p) => hcloudRequest("GET", `/networks/${id}/members`, { query: { ...filters, ...p } }), "members");
|
|
31
43
|
return json(members);
|
|
32
44
|
}));
|
|
33
45
|
}
|