hcloud-mcp 0.2.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 +49 -7
- package/dist/action-gap-tools.js +118 -0
- package/dist/certificate-tools.js +89 -0
- package/dist/dns-tools.js +170 -0
- package/dist/extra-tools.js +45 -0
- package/dist/hcloud-api.js +62 -0
- package/dist/image-tools.js +117 -0
- package/dist/index.js +32 -6
- package/dist/instructions.js +10 -1
- package/dist/register-tools.js +719 -482
- package/dist/server-ops-tools.js +115 -0
- package/dist/storage-box-tools.js +251 -0
- package/dist/tool-helpers.js +39 -0
- package/package.json +18 -6
- package/skills/hetzner-cloud/SKILL.md +48 -2
- package/dist/mcp-server.js +0 -45
- package/scripts/audit-api-shapes.mjs +0 -160
- package/scripts/test-list-api.mjs +0 -39
- package/scripts/test-live-lifecycle.mjs +0 -187
- package/scripts/test-mcp-list.mjs +0 -62
package/dist/register-tools.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { ServersService, LoadBalancersService, NetworksService, VolumesService, FirewallsService, FirewallActionsService, FloatingIPsService, SshKeysService, ImagesService, LocationsService, ServerTypesService, PlacementGroupsService, PrimaryIPsService, ServerActionsService, VolumeActionsService, FloatingIpActionsService, LoadBalancerActionsService, NetworkActionsService, PricingService, ActionsService, LoadBalancerTypesService, PrimaryIpActionsService, } from "hetzner-sdk-ts";
|
|
2
1
|
import { z } from "zod";
|
|
2
|
+
import { ADDITIVE, ADDITIVE_IDEMPOTENT, DESTRUCTIVE, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, listAll, withToolError } from "./tool-helpers.js";
|
|
3
|
+
import { hcloudRequest } from "./hcloud-api.js";
|
|
3
4
|
// Firewall rule: direction, protocol required; source_ips for 'in', destination_ips for 'out'; port for tcp/udp
|
|
4
5
|
const firewallRuleSchema = z.object({
|
|
5
6
|
direction: z.enum(["in", "out"]),
|
|
@@ -14,65 +15,49 @@ const firewallApplyToSchema = z.object({
|
|
|
14
15
|
server: z.object({ id: z.number() }).optional(),
|
|
15
16
|
label_selector: z.object({ selector: z.string() }).optional(),
|
|
16
17
|
});
|
|
17
|
-
const formatError = (error) => {
|
|
18
|
-
if (error instanceof Error) {
|
|
19
|
-
return error.message;
|
|
20
|
-
}
|
|
21
|
-
return String(error);
|
|
22
|
-
};
|
|
23
|
-
async function withToolError(run) {
|
|
24
|
-
try {
|
|
25
|
-
return await run();
|
|
26
|
-
}
|
|
27
|
-
catch (error) {
|
|
28
|
-
return { content: [{ type: "text", text: `Error: ${formatError(error)}` }], isError: true };
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Hetzner list endpoints are paginated (default 25, max 50 per page). Follow
|
|
32
|
-
// meta.pagination.next_page so list tools return every item, not just page 1.
|
|
33
|
-
// (Link headers are deprecated by Hetzner; meta.pagination is the supported mechanism.)
|
|
34
|
-
async function listAll(fetchPage, key) {
|
|
35
|
-
const items = [];
|
|
36
|
-
let page = 1;
|
|
37
|
-
while (page != null) {
|
|
38
|
-
const response = await fetchPage({ page, perPage: 50 });
|
|
39
|
-
items.push(...(response?.[key] ?? []));
|
|
40
|
-
const next = response?.meta?.pagination?.next_page ?? null;
|
|
41
|
-
page = next != null && next > page ? next : null; // guard against non-advancing pagination
|
|
42
|
-
}
|
|
43
|
-
return items;
|
|
44
|
-
}
|
|
45
18
|
export function registerTools(server) {
|
|
46
19
|
// --- Servers ---
|
|
47
|
-
server.
|
|
48
|
-
|
|
20
|
+
server.registerTool("list_servers", {
|
|
21
|
+
description: "List all servers",
|
|
22
|
+
inputSchema: {},
|
|
23
|
+
annotations: READ_ONLY,
|
|
24
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
25
|
+
const items = await listAll((p) => hcloudRequest("GET", "/servers", { query: p }), "servers");
|
|
49
26
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
50
27
|
}));
|
|
51
|
-
server.
|
|
52
|
-
|
|
28
|
+
server.registerTool("get_server", {
|
|
29
|
+
description: "Get a single server by ID",
|
|
30
|
+
inputSchema: { id: z.number() },
|
|
31
|
+
annotations: READ_ONLY,
|
|
32
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
33
|
+
const response = await hcloudRequest("GET", `/servers/${id}`);
|
|
53
34
|
return { content: [{ type: "text", text: JSON.stringify(response.server, null, 2) }] };
|
|
54
35
|
}));
|
|
55
|
-
server.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
.
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
36
|
+
server.registerTool("create_server", {
|
|
37
|
+
description: "Create a new server",
|
|
38
|
+
inputSchema: {
|
|
39
|
+
name: z.string(),
|
|
40
|
+
server_type: z.string(),
|
|
41
|
+
image: z.string(),
|
|
42
|
+
location: z.string().optional().describe("Location name or ID, e.g. fsn1, nbg1, hel1, ash, hil, sin. Check list_server_types locations[].available first"),
|
|
43
|
+
start_after_create: z.boolean().optional(),
|
|
44
|
+
ssh_keys: z.array(z.union([z.string(), z.number()])).optional().describe("List of SSH key names or IDs"),
|
|
45
|
+
firewalls: z.array(z.object({ firewall: z.number() })).optional(),
|
|
46
|
+
networks: z.array(z.number()).optional(),
|
|
47
|
+
placement_group: z.number().optional().describe("ID of placement group"),
|
|
48
|
+
public_net: z
|
|
49
|
+
.object({
|
|
50
|
+
enable_ipv4: z.boolean().optional(),
|
|
51
|
+
enable_ipv6: z.boolean().optional(),
|
|
52
|
+
ipv4: z.number().nullable().optional(),
|
|
53
|
+
ipv6: z.number().nullable().optional(),
|
|
54
|
+
})
|
|
55
|
+
.optional(),
|
|
56
|
+
user_data: z.string().optional().describe("Cloud-Init user data (max 32KiB)"),
|
|
57
|
+
volumes: z.array(z.number()).optional().describe("Volume IDs to attach at creation"),
|
|
58
|
+
labels: z.record(z.string()).optional(),
|
|
59
|
+
},
|
|
60
|
+
annotations: ADDITIVE,
|
|
76
61
|
}, async (args, _extra) => withToolError(async () => {
|
|
77
62
|
const requestBody = {
|
|
78
63
|
name: args.name,
|
|
@@ -89,266 +74,363 @@ export function registerTools(server) {
|
|
|
89
74
|
volumes: args.volumes,
|
|
90
75
|
labels: args.labels,
|
|
91
76
|
};
|
|
92
|
-
const response = await
|
|
77
|
+
const response = await hcloudRequest("POST", "/servers", { body: requestBody });
|
|
93
78
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
94
79
|
}));
|
|
95
|
-
server.
|
|
96
|
-
|
|
80
|
+
server.registerTool("delete_server", {
|
|
81
|
+
description: "Delete a server",
|
|
82
|
+
inputSchema: { id: z.number() },
|
|
83
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
84
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
85
|
+
const response = await hcloudRequest("DELETE", `/servers/${id}`);
|
|
97
86
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
98
87
|
}));
|
|
99
|
-
server.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
88
|
+
server.registerTool("change_server_type", {
|
|
89
|
+
description: "Change the type of a server (scales resources). Server must be powered off.",
|
|
90
|
+
inputSchema: {
|
|
91
|
+
id: z.number(),
|
|
92
|
+
server_type: z.string().describe("New server type (e.g. cx22)"),
|
|
93
|
+
upgrade_disk: z.boolean().default(true).describe("Whether to upgrade disk size. If true, cannot downgrade later."),
|
|
94
|
+
},
|
|
95
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
103
96
|
}, async ({ id, server_type, upgrade_disk }, _extra) => withToolError(async () => {
|
|
104
|
-
const response = await
|
|
105
|
-
id,
|
|
106
|
-
requestBody: { server_type, upgrade_disk }
|
|
107
|
-
});
|
|
97
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/change_type`, { body: { server_type, upgrade_disk } });
|
|
108
98
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
109
99
|
}));
|
|
110
|
-
server.
|
|
111
|
-
|
|
100
|
+
server.registerTool("power_on_server", {
|
|
101
|
+
description: "Power on a server",
|
|
102
|
+
inputSchema: { id: z.number() },
|
|
103
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
104
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
105
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/poweron`);
|
|
112
106
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
113
107
|
}));
|
|
114
|
-
server.
|
|
115
|
-
|
|
108
|
+
server.registerTool("power_off_server", {
|
|
109
|
+
description: "Power off a server (hard)",
|
|
110
|
+
inputSchema: { id: z.number() },
|
|
111
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
112
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
113
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/poweroff`);
|
|
116
114
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
117
115
|
}));
|
|
118
|
-
server.
|
|
119
|
-
|
|
116
|
+
server.registerTool("reboot_server", {
|
|
117
|
+
description: "Reboot a server (soft)",
|
|
118
|
+
inputSchema: { id: z.number() },
|
|
119
|
+
annotations: DESTRUCTIVE,
|
|
120
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
121
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/reboot`);
|
|
120
122
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
121
123
|
}));
|
|
122
|
-
server.
|
|
123
|
-
|
|
124
|
+
server.registerTool("shutdown_server", {
|
|
125
|
+
description: "Shutdown a server (soft)",
|
|
126
|
+
inputSchema: { id: z.number() },
|
|
127
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
128
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
129
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/shutdown`);
|
|
124
130
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
125
131
|
}));
|
|
126
|
-
server.
|
|
127
|
-
|
|
132
|
+
server.registerTool("reset_server", {
|
|
133
|
+
description: "Reset a server (hard)",
|
|
134
|
+
inputSchema: { id: z.number() },
|
|
135
|
+
annotations: DESTRUCTIVE,
|
|
136
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
137
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/reset`);
|
|
128
138
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
129
139
|
}));
|
|
130
|
-
server.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
140
|
+
server.registerTool("update_server", {
|
|
141
|
+
description: "Update a server (name, labels)",
|
|
142
|
+
inputSchema: {
|
|
143
|
+
id: z.number(),
|
|
144
|
+
name: z.string().optional(),
|
|
145
|
+
labels: z.record(z.string()).optional(),
|
|
146
|
+
},
|
|
147
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
134
148
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
135
|
-
const response = await
|
|
136
|
-
id,
|
|
137
|
-
requestBody: { name, labels }
|
|
138
|
-
});
|
|
149
|
+
const response = await hcloudRequest("PUT", `/servers/${id}`, { body: { name, labels } });
|
|
139
150
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
140
151
|
}));
|
|
141
|
-
server.
|
|
142
|
-
|
|
143
|
-
|
|
152
|
+
server.registerTool("attach_iso", {
|
|
153
|
+
description: "Attach an ISO to a server",
|
|
154
|
+
inputSchema: {
|
|
155
|
+
id: z.number(),
|
|
156
|
+
iso: z.string().describe("ID or name of the ISO"),
|
|
157
|
+
},
|
|
158
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
144
159
|
}, async ({ id, iso }, _extra) => withToolError(async () => {
|
|
145
|
-
const response = await
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/attach_iso`, { body: { iso } });
|
|
161
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
162
|
+
}));
|
|
163
|
+
server.registerTool("detach_iso", {
|
|
164
|
+
description: "Detach an ISO from a server",
|
|
165
|
+
inputSchema: { id: z.number() },
|
|
166
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
167
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
168
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/detach_iso`);
|
|
169
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
170
|
+
}));
|
|
171
|
+
server.registerTool("attach_server_to_network", {
|
|
172
|
+
description: "Attach a server to a network",
|
|
173
|
+
inputSchema: {
|
|
174
|
+
id: z.number(),
|
|
175
|
+
network: z.number().describe("ID of the network"),
|
|
176
|
+
ip: z.string().optional().describe("IP to request, otherwise auto-assigned"),
|
|
177
|
+
alias_ips: z.array(z.string()).optional(),
|
|
178
|
+
},
|
|
179
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
160
180
|
}, async ({ id, network, ip, alias_ips }, _extra) => withToolError(async () => {
|
|
161
|
-
const response = await
|
|
162
|
-
id,
|
|
163
|
-
requestBody: { network, ip, alias_ips }
|
|
164
|
-
});
|
|
181
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/attach_to_network`, { body: { network, ip, alias_ips } });
|
|
165
182
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
166
183
|
}));
|
|
167
|
-
server.
|
|
168
|
-
|
|
169
|
-
|
|
184
|
+
server.registerTool("detach_server_from_network", {
|
|
185
|
+
description: "Detach a server from a network",
|
|
186
|
+
inputSchema: {
|
|
187
|
+
id: z.number(),
|
|
188
|
+
network: z.number().describe("ID of the network"),
|
|
189
|
+
},
|
|
190
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
170
191
|
}, async ({ id, network }, _extra) => withToolError(async () => {
|
|
171
|
-
const response = await
|
|
172
|
-
id,
|
|
173
|
-
requestBody: { network }
|
|
174
|
-
});
|
|
192
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/detach_from_network`, { body: { network } });
|
|
175
193
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
176
194
|
}));
|
|
177
195
|
// --- Load Balancers ---
|
|
178
|
-
server.
|
|
179
|
-
|
|
196
|
+
server.registerTool("list_load_balancers", {
|
|
197
|
+
description: "List all load balancers",
|
|
198
|
+
inputSchema: {},
|
|
199
|
+
annotations: READ_ONLY,
|
|
200
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
201
|
+
const items = await listAll((p) => hcloudRequest("GET", "/load_balancers", { query: p }), "load_balancers");
|
|
180
202
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
181
203
|
}));
|
|
182
|
-
server.
|
|
183
|
-
|
|
204
|
+
server.registerTool("get_load_balancer", {
|
|
205
|
+
description: "Get a single load balancer by ID",
|
|
206
|
+
inputSchema: { id: z.number() },
|
|
207
|
+
annotations: READ_ONLY,
|
|
208
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
209
|
+
const response = await hcloudRequest("GET", `/load_balancers/${id}`);
|
|
184
210
|
return { content: [{ type: "text", text: JSON.stringify(response.load_balancer, null, 2) }] };
|
|
185
211
|
}));
|
|
186
|
-
server.
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
212
|
+
server.registerTool("create_load_balancer", {
|
|
213
|
+
description: "Create a load balancer in a location or network_zone. Optionally attach existing Primary IPs (public_net), join a private network, and define services/targets in one call. Returns load_balancer + Action. Primary IPs on an LB cannot be changed after creation and stay assigned for its lifetime",
|
|
214
|
+
inputSchema: {
|
|
215
|
+
name: z.string(),
|
|
216
|
+
load_balancer_type: z.string().describe("e.g. lb11 (see list_load_balancer_types)"),
|
|
217
|
+
location: z.string().optional().describe("Location name, e.g. fsn1. With public_net, pass the Primary IPs' location; a mismatch fails with primary_ip_location_mismatch"),
|
|
218
|
+
network_zone: z.string().optional().describe("e.g. eu-central; alternative to location"),
|
|
219
|
+
algorithm: z.object({ type: z.enum(["round_robin", "least_connections"]) }).optional(),
|
|
220
|
+
public_interface: z.boolean().optional().describe("Default true. false = private-only; then also pass network"),
|
|
221
|
+
public_net: z
|
|
222
|
+
.object({
|
|
223
|
+
ipv4: z.number().nullable().optional().describe("ID of an unassigned IPv4 Primary IP in the same location"),
|
|
224
|
+
ipv6: z.number().nullable().optional().describe("ID of an unassigned IPv6 Primary IP in the same location"),
|
|
225
|
+
})
|
|
226
|
+
.optional()
|
|
227
|
+
.describe("Use existing Primary IPs instead of auto-allocated addresses (only with the public interface enabled)"),
|
|
228
|
+
network: z.number().optional().describe("Private network ID to attach on creation"),
|
|
229
|
+
services: z
|
|
230
|
+
.array(z.object({
|
|
231
|
+
protocol: z.enum(["tcp", "http", "https"]),
|
|
232
|
+
listen_port: z.number().optional(),
|
|
233
|
+
destination_port: z.number().optional(),
|
|
234
|
+
proxyprotocol: z.boolean().default(false),
|
|
235
|
+
health_check: z.record(z.unknown()).optional().describe("Same shape as add_load_balancer_service.health_check"),
|
|
236
|
+
http: z.record(z.unknown()).optional().describe("Same shape as update_load_balancer_service.http (certificates, redirect_http, sticky_sessions, timeout_idle, ...)"),
|
|
237
|
+
}))
|
|
238
|
+
.optional(),
|
|
239
|
+
targets: z
|
|
240
|
+
.array(z.object({
|
|
241
|
+
type: z.enum(["server", "label_selector", "ip"]),
|
|
242
|
+
server: z.object({ id: z.number() }).optional(),
|
|
243
|
+
label_selector: z.object({ selector: z.string() }).optional(),
|
|
244
|
+
ip: z.object({ ip: z.string() }).optional(),
|
|
245
|
+
use_private_ip: z.boolean().optional(),
|
|
246
|
+
}))
|
|
247
|
+
.optional(),
|
|
248
|
+
labels: z.record(z.string()).optional(),
|
|
249
|
+
},
|
|
250
|
+
annotations: ADDITIVE,
|
|
193
251
|
}, async (args, _extra) => withToolError(async () => {
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
location
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
const response = await LoadBalancersService.postLoadBalancers({ requestBody });
|
|
252
|
+
const hasLocation = args.location != null && args.location !== "";
|
|
253
|
+
const hasZone = args.network_zone != null && args.network_zone !== "";
|
|
254
|
+
if (!hasLocation && !hasZone)
|
|
255
|
+
throw new Error("Provide location or network_zone");
|
|
256
|
+
if (args.public_net && args.public_interface === false) {
|
|
257
|
+
throw new Error("public_net requires the public interface (public_interface must not be false)");
|
|
258
|
+
}
|
|
259
|
+
const response = await hcloudRequest("POST", "/load_balancers", { body: args });
|
|
203
260
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
204
261
|
}));
|
|
205
|
-
server.
|
|
262
|
+
server.registerTool("delete_load_balancer", {
|
|
263
|
+
description: "Delete a load balancer. Returns a delete_load_balancer Action; poll get_action until it finishes",
|
|
264
|
+
inputSchema: { id: z.number() },
|
|
265
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
266
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
206
267
|
// Since 2026-10-05 this returns 201 + Action (previously 204 empty).
|
|
207
|
-
const response = await
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
268
|
+
const response = await hcloudRequest("DELETE", `/load_balancers/${id}`);
|
|
269
|
+
// hcloudRequest returns {} for a 204 (the pre-2026-10-05 empty response).
|
|
270
|
+
const deleted = Object.keys(response).length ? response : { deleted: true };
|
|
271
|
+
return { content: [{ type: "text", text: JSON.stringify(deleted, null, 2) }] };
|
|
272
|
+
}));
|
|
273
|
+
server.registerTool("update_load_balancer", {
|
|
274
|
+
description: "Update a load balancer (name, labels)",
|
|
275
|
+
inputSchema: {
|
|
276
|
+
id: z.number(),
|
|
277
|
+
name: z.string().optional(),
|
|
278
|
+
labels: z.record(z.string()).optional(),
|
|
279
|
+
},
|
|
280
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
214
281
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
215
|
-
const response = await
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
282
|
+
const response = await hcloudRequest("PUT", `/load_balancers/${id}`, { body: { name, labels } });
|
|
283
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
284
|
+
}));
|
|
285
|
+
server.registerTool("add_load_balancer_target", {
|
|
286
|
+
description: "Add a target to a load balancer",
|
|
287
|
+
inputSchema: {
|
|
288
|
+
id: z.number(),
|
|
289
|
+
type: z.enum(["server", "label_selector", "ip"]),
|
|
290
|
+
server: z.object({ id: z.number() }).optional(),
|
|
291
|
+
label_selector: z.object({ selector: z.string() }).optional(),
|
|
292
|
+
ip: z.object({ ip: z.string() }).optional(),
|
|
293
|
+
use_private_ip: z.boolean().optional(),
|
|
294
|
+
},
|
|
295
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
228
296
|
}, async ({ id, type, server, label_selector, ip, use_private_ip }, _extra) => withToolError(async () => {
|
|
229
|
-
const response = await
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
297
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/add_target`, { body: { type, server, label_selector, ip, use_private_ip } });
|
|
298
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
299
|
+
}));
|
|
300
|
+
server.registerTool("remove_load_balancer_target", {
|
|
301
|
+
description: "Remove a target from a load balancer",
|
|
302
|
+
inputSchema: {
|
|
303
|
+
id: z.number(),
|
|
304
|
+
type: z.enum(["server", "label_selector", "ip"]),
|
|
305
|
+
server: z.object({ id: z.number() }).optional(),
|
|
306
|
+
label_selector: z.object({ selector: z.string() }).optional(),
|
|
307
|
+
ip: z.object({ ip: z.string() }).optional(),
|
|
308
|
+
},
|
|
309
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
241
310
|
}, async ({ id, type, server, label_selector, ip }, _extra) => withToolError(async () => {
|
|
242
|
-
const response = await
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
311
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/remove_target`, { body: { type, server, label_selector, ip } });
|
|
312
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
313
|
+
}));
|
|
314
|
+
server.registerTool("add_load_balancer_service", {
|
|
315
|
+
description: "Add a service to a load balancer",
|
|
316
|
+
inputSchema: {
|
|
317
|
+
id: z.number(),
|
|
318
|
+
protocol: z.enum(["tcp", "http", "https"]),
|
|
319
|
+
listen_port: z.number(),
|
|
320
|
+
destination_port: z.number(),
|
|
321
|
+
proxyprotocol: z.boolean(),
|
|
322
|
+
health_check: z.object({
|
|
323
|
+
protocol: z.enum(["tcp", "http"]),
|
|
324
|
+
port: z.number(),
|
|
325
|
+
interval: z.number(),
|
|
326
|
+
timeout: z.number(),
|
|
327
|
+
retries: z.number(),
|
|
328
|
+
http: z.object({
|
|
329
|
+
domain: z.string().nullable().optional(),
|
|
330
|
+
path: z.string().optional(),
|
|
331
|
+
response: z.string().optional(),
|
|
332
|
+
status_codes: z.array(z.string()).optional(),
|
|
333
|
+
tls: z.boolean().optional(),
|
|
334
|
+
}).optional(),
|
|
335
|
+
}).optional(),
|
|
260
336
|
http: z.object({
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
337
|
+
cookie_name: z.string().optional(),
|
|
338
|
+
cookie_lifetime: z.number().optional(),
|
|
339
|
+
certificates: z.array(z.number()).optional(),
|
|
340
|
+
redirect_http: z.boolean().optional(),
|
|
341
|
+
sticky_sessions: z.boolean().optional(),
|
|
266
342
|
}).optional(),
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
cookie_name: z.string().optional(),
|
|
270
|
-
cookie_lifetime: z.number().optional(),
|
|
271
|
-
certificates: z.array(z.number()).optional(),
|
|
272
|
-
redirect_http: z.boolean().optional(),
|
|
273
|
-
sticky_sessions: z.boolean().optional(),
|
|
274
|
-
}).optional(),
|
|
343
|
+
},
|
|
344
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
275
345
|
}, async (args, _extra) => withToolError(async () => {
|
|
276
346
|
const { id, ...body } = args;
|
|
277
|
-
const response = await
|
|
278
|
-
id,
|
|
279
|
-
requestBody: body
|
|
280
|
-
});
|
|
347
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/add_service`, { body });
|
|
281
348
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
282
349
|
}));
|
|
283
|
-
server.
|
|
284
|
-
|
|
285
|
-
|
|
350
|
+
server.registerTool("delete_load_balancer_service", {
|
|
351
|
+
description: "Delete a service from a load balancer",
|
|
352
|
+
inputSchema: {
|
|
353
|
+
id: z.number(),
|
|
354
|
+
listen_port: z.number(),
|
|
355
|
+
},
|
|
356
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
286
357
|
}, async ({ id, listen_port }, _extra) => withToolError(async () => {
|
|
287
|
-
const response = await
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
358
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/delete_service`, { body: { listen_port } });
|
|
359
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
360
|
+
}));
|
|
361
|
+
server.registerTool("update_load_balancer_service", {
|
|
362
|
+
description: "Update a load balancer service (listen_port identifies the service)",
|
|
363
|
+
inputSchema: {
|
|
364
|
+
id: z.number().describe("Load balancer ID"),
|
|
365
|
+
listen_port: z.number().describe("Listen port of the service to update"),
|
|
366
|
+
destination_port: z.number().optional(),
|
|
367
|
+
protocol: z.enum(["tcp", "http", "https"]).optional(),
|
|
368
|
+
proxyprotocol: z.boolean().optional(),
|
|
369
|
+
health_check: z
|
|
370
|
+
.object({
|
|
371
|
+
protocol: z.enum(["tcp", "http"]),
|
|
372
|
+
port: z.number(),
|
|
373
|
+
interval: z.number(),
|
|
374
|
+
timeout: z.number(),
|
|
375
|
+
retries: z.number(),
|
|
376
|
+
http: z
|
|
377
|
+
.object({
|
|
378
|
+
domain: z.string().nullable().optional(),
|
|
379
|
+
path: z.string().optional(),
|
|
380
|
+
response: z.string().optional(),
|
|
381
|
+
status_codes: z.array(z.string()).optional(),
|
|
382
|
+
tls: z.boolean().optional(),
|
|
383
|
+
})
|
|
384
|
+
.optional(),
|
|
385
|
+
})
|
|
386
|
+
.optional(),
|
|
306
387
|
http: z
|
|
307
388
|
.object({
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
389
|
+
cookie_name: z.string().optional(),
|
|
390
|
+
cookie_lifetime: z.number().optional(),
|
|
391
|
+
certificates: z.array(z.number()).optional(),
|
|
392
|
+
redirect_http: z.boolean().optional(),
|
|
393
|
+
sticky_sessions: z.boolean().optional(),
|
|
394
|
+
timeout_idle: z.number().int().min(30).max(300).optional().describe("Idle timeout in seconds (30-300, default 50)"),
|
|
313
395
|
})
|
|
314
396
|
.optional(),
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
http: z
|
|
318
|
-
.object({
|
|
319
|
-
cookie_name: z.string().optional(),
|
|
320
|
-
cookie_lifetime: z.number().optional(),
|
|
321
|
-
certificates: z.array(z.number()).optional(),
|
|
322
|
-
redirect_http: z.boolean().optional(),
|
|
323
|
-
sticky_sessions: z.boolean().optional(),
|
|
324
|
-
})
|
|
325
|
-
.optional(),
|
|
397
|
+
},
|
|
398
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
326
399
|
}, async (args, _extra) => withToolError(async () => {
|
|
327
400
|
const { id, listen_port, ...body } = args;
|
|
328
|
-
const response = await
|
|
329
|
-
id,
|
|
330
|
-
requestBody: { listen_port, ...body }
|
|
331
|
-
});
|
|
401
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/update_service`, { body: { listen_port, ...body } });
|
|
332
402
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
333
403
|
}));
|
|
334
404
|
// --- Networks ---
|
|
335
|
-
server.
|
|
336
|
-
|
|
405
|
+
server.registerTool("list_networks", {
|
|
406
|
+
description: "List all networks",
|
|
407
|
+
inputSchema: {},
|
|
408
|
+
annotations: READ_ONLY,
|
|
409
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
410
|
+
const items = await listAll((p) => hcloudRequest("GET", "/networks", { query: p }), "networks");
|
|
337
411
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
338
412
|
}));
|
|
339
|
-
server.
|
|
340
|
-
|
|
413
|
+
server.registerTool("get_network", {
|
|
414
|
+
description: "Get a single network by ID",
|
|
415
|
+
inputSchema: { id: z.number() },
|
|
416
|
+
annotations: READ_ONLY,
|
|
417
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
418
|
+
const response = await hcloudRequest("GET", `/networks/${id}`);
|
|
341
419
|
return { content: [{ type: "text", text: JSON.stringify(response.network, null, 2) }] };
|
|
342
420
|
}));
|
|
343
|
-
server.
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
421
|
+
server.registerTool("create_network", {
|
|
422
|
+
description: "Create a new network",
|
|
423
|
+
inputSchema: {
|
|
424
|
+
name: z.string(),
|
|
425
|
+
ip_range: z.string(),
|
|
426
|
+
expose_routes_to_vswitch: z.boolean().optional(),
|
|
427
|
+
routes: z
|
|
428
|
+
.array(z.object({ destination: z.string(), gateway: z.string() }))
|
|
429
|
+
.optional()
|
|
430
|
+
.describe("Routes: destination (CIDR), gateway (IP)"),
|
|
431
|
+
labels: z.record(z.string()).optional(),
|
|
432
|
+
},
|
|
433
|
+
annotations: ADDITIVE,
|
|
352
434
|
}, async (args, _extra) => withToolError(async () => {
|
|
353
435
|
const requestBody = {
|
|
354
436
|
name: args.name,
|
|
@@ -357,122 +439,173 @@ export function registerTools(server) {
|
|
|
357
439
|
routes: args.routes,
|
|
358
440
|
labels: args.labels,
|
|
359
441
|
};
|
|
360
|
-
const response = await
|
|
442
|
+
const response = await hcloudRequest("POST", "/networks", { body: requestBody });
|
|
361
443
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
362
444
|
}));
|
|
363
|
-
server.
|
|
364
|
-
|
|
445
|
+
server.registerTool("delete_network", {
|
|
446
|
+
description: "Delete a network",
|
|
447
|
+
inputSchema: { id: z.number() },
|
|
448
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
449
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
450
|
+
await hcloudRequest("DELETE", `/networks/${id}`);
|
|
365
451
|
return { content: [{ type: "text", text: "Network deleted successfully" }] };
|
|
366
452
|
}));
|
|
367
|
-
server.
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
453
|
+
server.registerTool("update_network", {
|
|
454
|
+
description: "Update a network (name, labels)",
|
|
455
|
+
inputSchema: {
|
|
456
|
+
id: z.number(),
|
|
457
|
+
name: z.string().optional(),
|
|
458
|
+
labels: z.record(z.string()).optional(),
|
|
459
|
+
},
|
|
460
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
371
461
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
372
|
-
const response = await
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
462
|
+
const response = await hcloudRequest("PUT", `/networks/${id}`, { body: { name, labels } });
|
|
463
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
464
|
+
}));
|
|
465
|
+
server.registerTool("add_network_subnet", {
|
|
466
|
+
description: "Add a subnet to a network (e.g. for private networking 10.0.0.0/16 in a zone)",
|
|
467
|
+
inputSchema: {
|
|
468
|
+
id: z.number().describe("Network ID"),
|
|
469
|
+
// "server" type is deprecated (removal 2027-04-15) and equivalent to "cloud".
|
|
470
|
+
type: z.enum(["cloud", "vswitch"]),
|
|
471
|
+
network_zone: z.string().describe("Network zone, e.g. eu-central"),
|
|
472
|
+
ip_range: z.string().optional().describe("CIDR, e.g. 10.0.0.0/24; omit for auto /24"),
|
|
473
|
+
vswitch_id: z.number().optional().describe("Required if type is vswitch"),
|
|
474
|
+
},
|
|
475
|
+
annotations: ADDITIVE,
|
|
385
476
|
}, async ({ id, type, network_zone, ip_range, vswitch_id }, _extra) => withToolError(async () => {
|
|
386
|
-
const response = await
|
|
387
|
-
id,
|
|
388
|
-
requestBody: { type, network_zone, ip_range, vswitch_id }
|
|
389
|
-
});
|
|
477
|
+
const response = await hcloudRequest("POST", `/networks/${id}/actions/add_subnet`, { body: { type, network_zone, ip_range, vswitch_id } });
|
|
390
478
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
391
479
|
}));
|
|
392
|
-
server.
|
|
393
|
-
|
|
394
|
-
|
|
480
|
+
server.registerTool("delete_network_subnet", {
|
|
481
|
+
description: "Delete a subnet from a network (detach servers from it first)",
|
|
482
|
+
inputSchema: {
|
|
483
|
+
id: z.number().describe("Network ID"),
|
|
484
|
+
ip_range: z.string().describe("IP range of subnet to delete, e.g. 10.0.1.0/24"),
|
|
485
|
+
},
|
|
486
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
395
487
|
}, async ({ id, ip_range }, _extra) => withToolError(async () => {
|
|
396
|
-
const response = await
|
|
397
|
-
id,
|
|
398
|
-
requestBody: { ip_range }
|
|
399
|
-
});
|
|
488
|
+
const response = await hcloudRequest("POST", `/networks/${id}/actions/delete_subnet`, { body: { ip_range } });
|
|
400
489
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
401
490
|
}));
|
|
402
491
|
// --- Volumes ---
|
|
403
|
-
server.
|
|
404
|
-
|
|
492
|
+
server.registerTool("list_volumes", {
|
|
493
|
+
description: "List all volumes",
|
|
494
|
+
inputSchema: {},
|
|
495
|
+
annotations: READ_ONLY,
|
|
496
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
497
|
+
const items = await listAll((p) => hcloudRequest("GET", "/volumes", { query: p }), "volumes");
|
|
405
498
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
406
499
|
}));
|
|
407
|
-
server.
|
|
408
|
-
|
|
500
|
+
server.registerTool("get_volume", {
|
|
501
|
+
description: "Get a single volume by ID",
|
|
502
|
+
inputSchema: { id: z.number() },
|
|
503
|
+
annotations: READ_ONLY,
|
|
504
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
505
|
+
const response = await hcloudRequest("GET", `/volumes/${id}`);
|
|
409
506
|
return { content: [{ type: "text", text: JSON.stringify(response.volume, null, 2) }] };
|
|
410
507
|
}));
|
|
411
|
-
server.
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
508
|
+
server.registerTool("create_volume", {
|
|
509
|
+
description: "Create a new volume (size in GB, min 10). Give location, or server to create it in the server's location and attach it right away. In responses, read assignee ({type, id}); the old server field goes away on 2027-10-27",
|
|
510
|
+
inputSchema: {
|
|
511
|
+
name: z.string(),
|
|
512
|
+
size: z.number().describe("Size in GB (min 10)"),
|
|
513
|
+
automount: z.boolean().optional().describe("Only with server: mount automatically"),
|
|
514
|
+
format: z.enum(["xfs", "ext4"]).optional(),
|
|
515
|
+
location: z.string().optional().describe("Location name, e.g. fsn1 (omit if server set)"),
|
|
516
|
+
server: z.number().optional().describe("Server ID to attach to on creation (omit if location set)"),
|
|
517
|
+
labels: z.record(z.string()).optional(),
|
|
518
|
+
},
|
|
519
|
+
annotations: ADDITIVE,
|
|
419
520
|
}, async (args, _extra) => withToolError(async () => {
|
|
521
|
+
const hasLocation = args.location != null && args.location !== "";
|
|
522
|
+
if (hasLocation === (args.server != null)) {
|
|
523
|
+
throw new Error("Provide exactly one of location or server (mutually exclusive)");
|
|
524
|
+
}
|
|
525
|
+
if (args.automount && args.server == null)
|
|
526
|
+
throw new Error("automount requires server");
|
|
527
|
+
// Volume attachment is generalised to `assignee` (2026-10-27); the old
|
|
528
|
+
// `server` request field is removed on 2027-10-27. Tool input stays a server ID.
|
|
420
529
|
const requestBody = {
|
|
421
530
|
name: args.name,
|
|
422
531
|
size: args.size,
|
|
423
532
|
automount: args.automount,
|
|
424
533
|
format: args.format,
|
|
425
534
|
location: args.location,
|
|
426
|
-
server: args.server,
|
|
535
|
+
...(args.server != null ? { assignee: { type: "server", id: args.server } } : {}),
|
|
427
536
|
labels: args.labels,
|
|
428
537
|
};
|
|
429
|
-
const response = await
|
|
538
|
+
const response = await hcloudRequest("POST", "/volumes", { body: requestBody });
|
|
430
539
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
431
540
|
}));
|
|
432
|
-
server.
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
541
|
+
server.registerTool("update_volume", {
|
|
542
|
+
description: "Update a volume (name, labels)",
|
|
543
|
+
inputSchema: {
|
|
544
|
+
id: z.number(),
|
|
545
|
+
name: z.string().optional(),
|
|
546
|
+
labels: z.record(z.string()).optional(),
|
|
547
|
+
},
|
|
548
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
436
549
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
437
|
-
const response = await
|
|
438
|
-
id,
|
|
439
|
-
requestBody: { name, labels }
|
|
440
|
-
});
|
|
550
|
+
const response = await hcloudRequest("PUT", `/volumes/${id}`, { body: { name, labels } });
|
|
441
551
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
442
552
|
}));
|
|
443
|
-
server.
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
553
|
+
server.registerTool("attach_volume", {
|
|
554
|
+
description: "Attach a volume to a server (must be in the same location). Returns an Action",
|
|
555
|
+
inputSchema: {
|
|
556
|
+
id: z.number(),
|
|
557
|
+
server: z.number(),
|
|
558
|
+
automount: z.boolean().optional(),
|
|
559
|
+
},
|
|
560
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
447
561
|
}, async ({ id, server, automount }, _extra) => withToolError(async () => {
|
|
448
|
-
const response = await
|
|
449
|
-
id,
|
|
450
|
-
requestBody: { server, automount }
|
|
562
|
+
const response = await hcloudRequest("POST", `/volumes/${id}/actions/attach`, {
|
|
563
|
+
body: { assignee: { type: "server", id: server }, automount },
|
|
451
564
|
});
|
|
452
565
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
453
566
|
}));
|
|
454
|
-
server.
|
|
455
|
-
|
|
567
|
+
server.registerTool("detach_volume", {
|
|
568
|
+
description: "Detach a volume",
|
|
569
|
+
inputSchema: { id: z.number() },
|
|
570
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
571
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
572
|
+
const response = await hcloudRequest("POST", `/volumes/${id}/actions/detach`);
|
|
456
573
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
457
574
|
}));
|
|
458
|
-
server.
|
|
459
|
-
|
|
575
|
+
server.registerTool("delete_volume", {
|
|
576
|
+
description: "Delete a volume (must be detached; all data destroyed)",
|
|
577
|
+
inputSchema: { id: z.number() },
|
|
578
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
579
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
580
|
+
await hcloudRequest("DELETE", `/volumes/${id}`);
|
|
460
581
|
return { content: [{ type: "text", text: "Volume deleted successfully" }] };
|
|
461
582
|
}));
|
|
462
583
|
// --- Firewalls ---
|
|
463
|
-
server.
|
|
464
|
-
|
|
584
|
+
server.registerTool("list_firewalls", {
|
|
585
|
+
description: "List all firewalls",
|
|
586
|
+
inputSchema: {},
|
|
587
|
+
annotations: READ_ONLY,
|
|
588
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
589
|
+
const items = await listAll((p) => hcloudRequest("GET", "/firewalls", { query: p }), "firewalls");
|
|
465
590
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
466
591
|
}));
|
|
467
|
-
server.
|
|
468
|
-
|
|
592
|
+
server.registerTool("get_firewall", {
|
|
593
|
+
description: "Get a single firewall by ID",
|
|
594
|
+
inputSchema: { id: z.number() },
|
|
595
|
+
annotations: READ_ONLY,
|
|
596
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
597
|
+
const response = await hcloudRequest("GET", `/firewalls/${id}`);
|
|
469
598
|
return { content: [{ type: "text", text: JSON.stringify(response.firewall, null, 2) }] };
|
|
470
599
|
}));
|
|
471
|
-
server.
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
600
|
+
server.registerTool("create_firewall", {
|
|
601
|
+
description: "Create a new firewall. Rules: direction 'in'|'out', protocol 'tcp'|'udp'|'icmp'|'esp'|'gre'; use source_ips for in, destination_ips for out (CIDRs, e.g. 0.0.0.0/0); port optional for tcp/udp. Optionally apply_to servers or label_selector at creation.",
|
|
602
|
+
inputSchema: {
|
|
603
|
+
name: z.string(),
|
|
604
|
+
rules: z.array(firewallRuleSchema).optional(),
|
|
605
|
+
apply_to: z.array(firewallApplyToSchema).optional().describe("Apply firewall to these servers or label_selector after creation"),
|
|
606
|
+
labels: z.record(z.string()).optional(),
|
|
607
|
+
},
|
|
608
|
+
annotations: ADDITIVE,
|
|
476
609
|
}, async (args, _extra) => withToolError(async () => {
|
|
477
610
|
const body = {
|
|
478
611
|
name: args.name,
|
|
@@ -480,59 +613,84 @@ export function registerTools(server) {
|
|
|
480
613
|
labels: args.labels,
|
|
481
614
|
apply_to: args.apply_to,
|
|
482
615
|
};
|
|
483
|
-
const response = await
|
|
616
|
+
const response = await hcloudRequest("POST", "/firewalls", { body });
|
|
484
617
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
485
618
|
}));
|
|
486
|
-
server.
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
619
|
+
server.registerTool("update_firewall", {
|
|
620
|
+
description: "Update a firewall (name, labels)",
|
|
621
|
+
inputSchema: {
|
|
622
|
+
id: z.number(),
|
|
623
|
+
name: z.string().optional(),
|
|
624
|
+
labels: z.record(z.string()).optional(),
|
|
625
|
+
},
|
|
626
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
490
627
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
491
|
-
const response = await
|
|
492
|
-
id,
|
|
493
|
-
requestBody: { name, labels }
|
|
494
|
-
});
|
|
628
|
+
const response = await hcloudRequest("PUT", `/firewalls/${id}`, { body: { name, labels } });
|
|
495
629
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
496
630
|
}));
|
|
497
|
-
server.
|
|
498
|
-
|
|
631
|
+
server.registerTool("delete_firewall", {
|
|
632
|
+
description: "Delete a firewall (must not be in use)",
|
|
633
|
+
inputSchema: { id: z.number() },
|
|
634
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
635
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
636
|
+
await hcloudRequest("DELETE", `/firewalls/${id}`);
|
|
499
637
|
return { content: [{ type: "text", text: "Firewall deleted successfully" }] };
|
|
500
638
|
}));
|
|
501
|
-
server.
|
|
502
|
-
id:
|
|
503
|
-
|
|
639
|
+
server.registerTool("apply_firewall_to_resources", {
|
|
640
|
+
description: "Apply a firewall to servers or a label selector. Pass apply_to: [{ type: 'server', server: { id: 123 } }] or [{ type: 'label_selector', label_selector: { selector: 'env=web' } }].",
|
|
641
|
+
inputSchema: {
|
|
642
|
+
id: z.number().describe("Firewall ID"),
|
|
643
|
+
apply_to: z.array(firewallApplyToSchema),
|
|
644
|
+
},
|
|
645
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
504
646
|
}, async ({ id, apply_to }, _extra) => withToolError(async () => {
|
|
505
|
-
const response = await
|
|
506
|
-
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
507
|
-
}));
|
|
508
|
-
server.
|
|
509
|
-
id:
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
647
|
+
const response = await hcloudRequest("POST", `/firewalls/${id}/actions/apply_to_resources`, { body: { apply_to } });
|
|
648
|
+
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
649
|
+
}));
|
|
650
|
+
server.registerTool("remove_firewall_from_resources", {
|
|
651
|
+
description: "Remove a firewall from servers. Pass remove_from: [{ type: 'server', server: { id: 123 } }].",
|
|
652
|
+
inputSchema: {
|
|
653
|
+
id: z.number().describe("Firewall ID"),
|
|
654
|
+
remove_from: z.array(z.object({
|
|
655
|
+
type: z.literal("server"),
|
|
656
|
+
server: z.object({ id: z.number() }),
|
|
657
|
+
})),
|
|
658
|
+
},
|
|
659
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
514
660
|
}, async ({ id, remove_from }, _extra) => withToolError(async () => {
|
|
515
|
-
const response = await
|
|
661
|
+
const response = await hcloudRequest("POST", `/firewalls/${id}/actions/remove_from_resources`, { body: { remove_from } });
|
|
516
662
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
517
663
|
}));
|
|
518
|
-
server.
|
|
519
|
-
|
|
520
|
-
|
|
664
|
+
server.registerTool("set_firewall_rules", {
|
|
665
|
+
description: "Set rules on an existing firewall (overwrites all rules). Same rule format as create_firewall.",
|
|
666
|
+
inputSchema: {
|
|
667
|
+
id: z.number().describe("Firewall ID"),
|
|
668
|
+
rules: z.array(firewallRuleSchema),
|
|
669
|
+
},
|
|
670
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
521
671
|
}, async ({ id, rules }, _extra) => withToolError(async () => {
|
|
522
|
-
const response = await
|
|
672
|
+
const response = await hcloudRequest("POST", `/firewalls/${id}/actions/set_rules`, { body: { rules } });
|
|
523
673
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
524
674
|
}));
|
|
525
675
|
// --- Floating IPs ---
|
|
526
|
-
server.
|
|
527
|
-
|
|
676
|
+
server.registerTool("list_floating_ips", {
|
|
677
|
+
description: "List all floating IPs",
|
|
678
|
+
inputSchema: {},
|
|
679
|
+
annotations: READ_ONLY,
|
|
680
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
681
|
+
const items = await listAll((p) => hcloudRequest("GET", "/floating_ips", { query: p }), "floating_ips");
|
|
528
682
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
529
683
|
}));
|
|
530
|
-
server.
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
684
|
+
server.registerTool("create_floating_ip", {
|
|
685
|
+
description: "Create a floating IP",
|
|
686
|
+
inputSchema: {
|
|
687
|
+
type: z.enum(["ipv4", "ipv6"]),
|
|
688
|
+
home_location: z.string().optional(),
|
|
689
|
+
server: z.number().optional(),
|
|
690
|
+
description: z.string().optional(),
|
|
691
|
+
labels: z.record(z.string()).optional(),
|
|
692
|
+
},
|
|
693
|
+
annotations: ADDITIVE,
|
|
536
694
|
}, async (args, _extra) => withToolError(async () => {
|
|
537
695
|
const requestBody = {
|
|
538
696
|
type: args.type,
|
|
@@ -541,58 +699,75 @@ export function registerTools(server) {
|
|
|
541
699
|
description: args.description,
|
|
542
700
|
labels: args.labels,
|
|
543
701
|
};
|
|
544
|
-
const response = await
|
|
702
|
+
const response = await hcloudRequest("POST", "/floating_ips", { body: requestBody });
|
|
545
703
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
546
704
|
}));
|
|
547
|
-
server.
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
705
|
+
server.registerTool("update_floating_ip", {
|
|
706
|
+
description: "Update a floating IP (description, labels)",
|
|
707
|
+
inputSchema: {
|
|
708
|
+
id: z.number(),
|
|
709
|
+
description: z.string().optional(),
|
|
710
|
+
labels: z.record(z.string()).optional(),
|
|
711
|
+
},
|
|
712
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
551
713
|
}, async ({ id, description, labels }, _extra) => withToolError(async () => {
|
|
552
|
-
const response = await
|
|
553
|
-
id,
|
|
554
|
-
requestBody: { description, labels }
|
|
555
|
-
});
|
|
714
|
+
const response = await hcloudRequest("PUT", `/floating_ips/${id}`, { body: { description, labels } });
|
|
556
715
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
557
716
|
}));
|
|
558
|
-
server.
|
|
559
|
-
|
|
560
|
-
|
|
717
|
+
server.registerTool("assign_floating_ip", {
|
|
718
|
+
description: "Assign a floating IP to a server",
|
|
719
|
+
inputSchema: {
|
|
720
|
+
id: z.number(),
|
|
721
|
+
server: z.number(),
|
|
722
|
+
},
|
|
723
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
561
724
|
}, async ({ id, server }, _extra) => withToolError(async () => {
|
|
562
|
-
const response = await
|
|
563
|
-
id,
|
|
564
|
-
requestBody: { server }
|
|
565
|
-
});
|
|
725
|
+
const response = await hcloudRequest("POST", `/floating_ips/${id}/actions/assign`, { body: { server } });
|
|
566
726
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
567
727
|
}));
|
|
568
|
-
server.
|
|
569
|
-
|
|
728
|
+
server.registerTool("unassign_floating_ip", {
|
|
729
|
+
description: "Unassign a floating IP",
|
|
730
|
+
inputSchema: { id: z.number() },
|
|
731
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
732
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
733
|
+
const response = await hcloudRequest("POST", `/floating_ips/${id}/actions/unassign`);
|
|
570
734
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
571
735
|
}));
|
|
572
|
-
server.
|
|
573
|
-
|
|
736
|
+
server.registerTool("delete_floating_ip", {
|
|
737
|
+
description: "Delete a floating IP. Must be unassigned first (unassign_floating_ip), else fails with must_be_unassigned",
|
|
738
|
+
inputSchema: { id: z.number() },
|
|
739
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
740
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
741
|
+
await hcloudRequest("DELETE", `/floating_ips/${id}`);
|
|
574
742
|
return { content: [{ type: "text", text: "Floating IP deleted successfully" }] };
|
|
575
743
|
}));
|
|
576
744
|
// --- Primary IPs ---
|
|
577
|
-
server.
|
|
578
|
-
|
|
745
|
+
server.registerTool("list_primary_ips", {
|
|
746
|
+
description: "List all Primary IPs (static IPs bound to a location, assignable to one server)",
|
|
747
|
+
inputSchema: {},
|
|
748
|
+
annotations: READ_ONLY,
|
|
749
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
750
|
+
const items = await listAll((p) => hcloudRequest("GET", "/primary_ips", { query: p }), "primary_ips");
|
|
579
751
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
580
752
|
}));
|
|
581
|
-
server.
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
753
|
+
server.registerTool("create_primary_ip", {
|
|
754
|
+
description: "Create a Primary IP (location-scoped; server must be off to assign). Provide location OR assignee_id (server).",
|
|
755
|
+
inputSchema: {
|
|
756
|
+
name: z.string(),
|
|
757
|
+
type: z.enum(["ipv4", "ipv6"]),
|
|
758
|
+
location: z.string().optional().describe("Location name or ID, e.g. fsn1 (omit if assignee_id set)"),
|
|
759
|
+
assignee_id: z.number().optional().describe("Server ID to assign to immediately (omit if location set)"),
|
|
760
|
+
auto_delete: z.boolean().optional(),
|
|
761
|
+
labels: z.record(z.string()).optional(),
|
|
762
|
+
},
|
|
763
|
+
annotations: ADDITIVE,
|
|
588
764
|
}, async (args, _extra) => withToolError(async () => {
|
|
589
765
|
const hasLocation = args.location != null && args.location !== "";
|
|
590
766
|
const hasAssignee = args.assignee_id != null;
|
|
591
767
|
if (hasLocation === hasAssignee) {
|
|
592
768
|
throw new Error("Provide exactly one of location or assignee_id (mutually exclusive)");
|
|
593
769
|
}
|
|
594
|
-
//
|
|
595
|
-
// (since 2026-07-01) takes `location`. The SDK passes the body through as JSON.
|
|
770
|
+
// The API takes `location` (the `datacenter` field was removed 2026-07-01).
|
|
596
771
|
const requestBody = {
|
|
597
772
|
name: args.name,
|
|
598
773
|
type: args.type,
|
|
@@ -602,51 +777,73 @@ export function registerTools(server) {
|
|
|
602
777
|
auto_delete: args.auto_delete,
|
|
603
778
|
labels: args.labels,
|
|
604
779
|
};
|
|
605
|
-
const response = await
|
|
780
|
+
const response = await hcloudRequest("POST", "/primary_ips", { body: requestBody });
|
|
606
781
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
607
782
|
}));
|
|
608
|
-
server.
|
|
609
|
-
|
|
783
|
+
server.registerTool("get_primary_ip", {
|
|
784
|
+
description: "Get a single Primary IP by ID",
|
|
785
|
+
inputSchema: { id: z.number() },
|
|
786
|
+
annotations: READ_ONLY,
|
|
787
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
788
|
+
const response = await hcloudRequest("GET", `/primary_ips/${id}`);
|
|
610
789
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
611
790
|
}));
|
|
612
|
-
server.
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
791
|
+
server.registerTool("update_primary_ip", {
|
|
792
|
+
description: "Update a Primary IP (name, labels)",
|
|
793
|
+
inputSchema: {
|
|
794
|
+
id: z.number(),
|
|
795
|
+
name: z.string().optional(),
|
|
796
|
+
labels: z.record(z.string()).optional(),
|
|
797
|
+
},
|
|
798
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
616
799
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
617
|
-
const response = await
|
|
618
|
-
id,
|
|
619
|
-
requestBody: { name, labels }
|
|
620
|
-
});
|
|
800
|
+
const response = await hcloudRequest("PUT", `/primary_ips/${id}`, { body: { name, labels } });
|
|
621
801
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
622
802
|
}));
|
|
623
|
-
server.
|
|
624
|
-
|
|
803
|
+
server.registerTool("delete_primary_ip", {
|
|
804
|
+
description: "Delete a Primary IP. Must be unassigned first (unassign_primary_ip, server powered off), else fails with must_be_unassigned",
|
|
805
|
+
inputSchema: { id: z.number() },
|
|
806
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
807
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
808
|
+
await hcloudRequest("DELETE", `/primary_ips/${id}`);
|
|
625
809
|
return { content: [{ type: "text", text: "Primary IP deleted successfully" }] };
|
|
626
810
|
}));
|
|
627
|
-
server.
|
|
628
|
-
|
|
629
|
-
|
|
811
|
+
server.registerTool("assign_primary_ip", {
|
|
812
|
+
description: "Assign a Primary IP to a server (server must be powered off)",
|
|
813
|
+
inputSchema: {
|
|
814
|
+
id: z.number().describe("Primary IP ID"),
|
|
815
|
+
server: z.number().describe("Server ID"),
|
|
816
|
+
},
|
|
817
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
630
818
|
}, async ({ id, server }, _extra) => withToolError(async () => {
|
|
631
|
-
const response = await
|
|
632
|
-
id,
|
|
633
|
-
requestBody: { assignee_id: server, assignee_type: "server" }
|
|
634
|
-
});
|
|
819
|
+
const response = await hcloudRequest("POST", `/primary_ips/${id}/actions/assign`, { body: { assignee_id: server, assignee_type: "server" } });
|
|
635
820
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
636
821
|
}));
|
|
637
|
-
server.
|
|
638
|
-
|
|
822
|
+
server.registerTool("unassign_primary_ip", {
|
|
823
|
+
description: "Unassign a Primary IP from its server (server must be powered off)",
|
|
824
|
+
inputSchema: { id: z.number() },
|
|
825
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
826
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
827
|
+
const response = await hcloudRequest("POST", `/primary_ips/${id}/actions/unassign`);
|
|
639
828
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
640
829
|
}));
|
|
641
830
|
// --- SSH Keys ---
|
|
642
|
-
server.
|
|
643
|
-
|
|
831
|
+
server.registerTool("list_ssh_keys", {
|
|
832
|
+
description: "List all SSH keys",
|
|
833
|
+
inputSchema: {},
|
|
834
|
+
annotations: READ_ONLY,
|
|
835
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
836
|
+
const items = await listAll((p) => hcloudRequest("GET", "/ssh_keys", { query: p }), "ssh_keys");
|
|
644
837
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
645
838
|
}));
|
|
646
|
-
server.
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
839
|
+
server.registerTool("create_ssh_key", {
|
|
840
|
+
description: "Create a new SSH key (public_key is trimmed; the API rejects leading whitespace)",
|
|
841
|
+
inputSchema: {
|
|
842
|
+
name: z.string(),
|
|
843
|
+
public_key: z.string(),
|
|
844
|
+
labels: z.record(z.string()).optional(),
|
|
845
|
+
},
|
|
846
|
+
annotations: ADDITIVE,
|
|
650
847
|
}, async (args, _extra) => withToolError(async () => {
|
|
651
848
|
const requestBody = {
|
|
652
849
|
name: args.name,
|
|
@@ -654,102 +851,142 @@ export function registerTools(server) {
|
|
|
654
851
|
public_key: args.public_key.trim(),
|
|
655
852
|
labels: args.labels,
|
|
656
853
|
};
|
|
657
|
-
const response = await
|
|
854
|
+
const response = await hcloudRequest("POST", "/ssh_keys", { body: requestBody });
|
|
658
855
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
659
856
|
}));
|
|
660
|
-
server.
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
857
|
+
server.registerTool("update_ssh_key", {
|
|
858
|
+
description: "Update an SSH key (name, labels)",
|
|
859
|
+
inputSchema: {
|
|
860
|
+
id: z.number(),
|
|
861
|
+
name: z.string().optional(),
|
|
862
|
+
labels: z.record(z.string()).optional(),
|
|
863
|
+
},
|
|
864
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
664
865
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
665
|
-
const response = await
|
|
666
|
-
id,
|
|
667
|
-
requestBody: { name, labels }
|
|
668
|
-
});
|
|
866
|
+
const response = await hcloudRequest("PUT", `/ssh_keys/${id}`, { body: { name, labels } });
|
|
669
867
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
670
868
|
}));
|
|
671
|
-
server.
|
|
672
|
-
|
|
869
|
+
server.registerTool("delete_ssh_key", {
|
|
870
|
+
description: "Delete an SSH key",
|
|
871
|
+
inputSchema: { id: z.number() },
|
|
872
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
873
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
874
|
+
await hcloudRequest("DELETE", `/ssh_keys/${id}`);
|
|
673
875
|
return { content: [{ type: "text", text: "SSH key deleted successfully" }] };
|
|
674
876
|
}));
|
|
675
877
|
// --- General Info ---
|
|
676
|
-
server.
|
|
677
|
-
|
|
878
|
+
server.registerTool("list_locations", {
|
|
879
|
+
description: "List all locations",
|
|
880
|
+
inputSchema: {},
|
|
881
|
+
annotations: READ_ONLY,
|
|
882
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
883
|
+
const items = await listAll((p) => hcloudRequest("GET", "/locations", { query: p }), "locations");
|
|
678
884
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
679
885
|
}));
|
|
680
|
-
server.
|
|
681
|
-
|
|
886
|
+
server.registerTool("list_images", {
|
|
887
|
+
description: "List all images (check each image's `deprecation` field; deprecated images can stop being usable for new servers)",
|
|
888
|
+
inputSchema: {},
|
|
889
|
+
annotations: READ_ONLY,
|
|
890
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
891
|
+
const items = await listAll((p) => hcloudRequest("GET", "/images", { query: p }), "images");
|
|
682
892
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
683
893
|
}));
|
|
684
|
-
server.
|
|
685
|
-
|
|
894
|
+
server.registerTool("list_server_types", {
|
|
895
|
+
description: "List all server types. Per-location availability is in locations[]: available, recommended, deprecation (top-level `deprecated` was removed)",
|
|
896
|
+
inputSchema: {},
|
|
897
|
+
annotations: READ_ONLY,
|
|
898
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
899
|
+
const items = await listAll((p) => hcloudRequest("GET", "/server_types", { query: p }), "server_types");
|
|
686
900
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
687
901
|
}));
|
|
688
|
-
server.
|
|
689
|
-
|
|
902
|
+
server.registerTool("list_load_balancer_types", {
|
|
903
|
+
description: "List all load balancer types (for create_load_balancer load_balancer_type; check `deprecation`)",
|
|
904
|
+
inputSchema: {},
|
|
905
|
+
annotations: READ_ONLY,
|
|
906
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
907
|
+
const items = await listAll((p) => hcloudRequest("GET", "/load_balancer_types", { query: p }), "load_balancer_types");
|
|
690
908
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
691
909
|
}));
|
|
692
|
-
server.
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
.enum([
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
910
|
+
server.registerTool("list_actions", {
|
|
911
|
+
description: "Get an action by ID with optional status filter. Hetzner no longer supports listing all actions in a project, so id is required. Prefer get_action",
|
|
912
|
+
inputSchema: {
|
|
913
|
+
id: z.number().describe("Action ID (required by the API since 2025-01-30)"),
|
|
914
|
+
status: z.enum(["running", "success", "error"]).optional(),
|
|
915
|
+
sort: z
|
|
916
|
+
.enum([
|
|
917
|
+
"id", "id:asc", "id:desc", "command", "command:asc", "command:desc",
|
|
918
|
+
"status", "status:asc", "status:desc", "started", "started:asc", "started:desc",
|
|
919
|
+
"finished", "finished:asc", "finished:desc",
|
|
920
|
+
])
|
|
921
|
+
.optional(),
|
|
922
|
+
page: z.number().optional(),
|
|
923
|
+
per_page: z.number().optional(),
|
|
924
|
+
},
|
|
925
|
+
annotations: READ_ONLY,
|
|
704
926
|
}, async (args, _extra) => withToolError(async () => {
|
|
705
|
-
const response = await
|
|
706
|
-
id: args.id,
|
|
707
|
-
status: args.status,
|
|
708
|
-
sort: args.sort,
|
|
709
|
-
page: args.page,
|
|
710
|
-
perPage: args.per_page,
|
|
711
|
-
});
|
|
927
|
+
const response = await hcloudRequest("GET", "/actions", { query: { id: args.id, status: args.status, sort: args.sort, page: args.page, per_page: args.per_page } });
|
|
712
928
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
713
929
|
}));
|
|
714
|
-
server.
|
|
715
|
-
|
|
930
|
+
server.registerTool("get_action", {
|
|
931
|
+
description: "Get a single action by ID (e.g. to check progress or status after create/delete)",
|
|
932
|
+
inputSchema: { id: z.number() },
|
|
933
|
+
annotations: READ_ONLY,
|
|
934
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
935
|
+
const response = await hcloudRequest("GET", `/actions/${id}`);
|
|
716
936
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
717
937
|
}));
|
|
718
|
-
server.
|
|
719
|
-
|
|
938
|
+
server.registerTool("get_pricing", {
|
|
939
|
+
description: "Get all prices",
|
|
940
|
+
inputSchema: {},
|
|
941
|
+
annotations: READ_ONLY,
|
|
942
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
943
|
+
const response = await hcloudRequest("GET", "/pricing");
|
|
720
944
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
721
945
|
}));
|
|
722
946
|
// --- Placement Groups ---
|
|
723
|
-
server.
|
|
724
|
-
|
|
947
|
+
server.registerTool("list_placement_groups", {
|
|
948
|
+
description: "List all placement groups",
|
|
949
|
+
inputSchema: {},
|
|
950
|
+
annotations: READ_ONLY,
|
|
951
|
+
}, async (_args, _extra) => withToolError(async () => {
|
|
952
|
+
const items = await listAll((p) => hcloudRequest("GET", "/placement_groups", { query: p }), "placement_groups");
|
|
725
953
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
726
954
|
}));
|
|
727
|
-
server.
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
955
|
+
server.registerTool("create_placement_group", {
|
|
956
|
+
description: "Create a new placement group",
|
|
957
|
+
inputSchema: {
|
|
958
|
+
name: z.string(),
|
|
959
|
+
type: z.enum(["spread"]),
|
|
960
|
+
labels: z.record(z.string()).optional(),
|
|
961
|
+
},
|
|
962
|
+
annotations: ADDITIVE,
|
|
731
963
|
}, async (args, _extra) => withToolError(async () => {
|
|
732
964
|
const requestBody = {
|
|
733
965
|
name: args.name,
|
|
734
966
|
type: args.type,
|
|
735
967
|
labels: args.labels,
|
|
736
968
|
};
|
|
737
|
-
const response = await
|
|
969
|
+
const response = await hcloudRequest("POST", "/placement_groups", { body: requestBody });
|
|
738
970
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
739
971
|
}));
|
|
740
|
-
server.
|
|
741
|
-
|
|
972
|
+
server.registerTool("delete_placement_group", {
|
|
973
|
+
description: "Delete a placement group",
|
|
974
|
+
inputSchema: { id: z.number() },
|
|
975
|
+
annotations: DESTRUCTIVE_IDEMPOTENT,
|
|
976
|
+
}, async ({ id }, _extra) => withToolError(async () => {
|
|
977
|
+
await hcloudRequest("DELETE", `/placement_groups/${id}`);
|
|
742
978
|
return { content: [{ type: "text", text: "Placement Group deleted successfully" }] };
|
|
743
979
|
}));
|
|
744
|
-
server.
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
980
|
+
server.registerTool("update_placement_group", {
|
|
981
|
+
description: "Update a placement group (name, labels)",
|
|
982
|
+
inputSchema: {
|
|
983
|
+
id: z.number(),
|
|
984
|
+
name: z.string().optional(),
|
|
985
|
+
labels: z.record(z.string()).optional(),
|
|
986
|
+
},
|
|
987
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
748
988
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
749
|
-
const response = await
|
|
750
|
-
id,
|
|
751
|
-
requestBody: { name, labels }
|
|
752
|
-
});
|
|
989
|
+
const response = await hcloudRequest("PUT", `/placement_groups/${id}`, { body: { name, labels } });
|
|
753
990
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
754
991
|
}));
|
|
755
992
|
}
|