hcloud-mcp 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -22
- 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/dist/register-tools.js
CHANGED
|
@@ -1,6 +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";
|
|
3
|
-
import { listAll, withToolError } from "./tool-helpers.js";
|
|
2
|
+
import { ADDITIVE, ADDITIVE_IDEMPOTENT, DESTRUCTIVE, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, listAll, withToolError } from "./tool-helpers.js";
|
|
3
|
+
import { hcloudRequest } from "./hcloud-api.js";
|
|
4
4
|
// Firewall rule: direction, protocol required; source_ips for 'in', destination_ips for 'out'; port for tcp/udp
|
|
5
5
|
const firewallRuleSchema = z.object({
|
|
6
6
|
direction: z.enum(["in", "out"]),
|
|
@@ -17,35 +17,47 @@ const firewallApplyToSchema = z.object({
|
|
|
17
17
|
});
|
|
18
18
|
export function registerTools(server) {
|
|
19
19
|
// --- Servers ---
|
|
20
|
-
server.
|
|
21
|
-
|
|
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");
|
|
22
26
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
23
27
|
}));
|
|
24
|
-
server.
|
|
25
|
-
|
|
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}`);
|
|
26
34
|
return { content: [{ type: "text", text: JSON.stringify(response.server, null, 2) }] };
|
|
27
35
|
}));
|
|
28
|
-
server.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
.
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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,
|
|
49
61
|
}, async (args, _extra) => withToolError(async () => {
|
|
50
62
|
const requestBody = {
|
|
51
63
|
name: args.name,
|
|
@@ -62,267 +74,363 @@ export function registerTools(server) {
|
|
|
62
74
|
volumes: args.volumes,
|
|
63
75
|
labels: args.labels,
|
|
64
76
|
};
|
|
65
|
-
const response = await
|
|
77
|
+
const response = await hcloudRequest("POST", "/servers", { body: requestBody });
|
|
66
78
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
67
79
|
}));
|
|
68
|
-
server.
|
|
69
|
-
|
|
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}`);
|
|
70
86
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
71
87
|
}));
|
|
72
|
-
server.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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,
|
|
76
96
|
}, async ({ id, server_type, upgrade_disk }, _extra) => withToolError(async () => {
|
|
77
|
-
const response = await
|
|
78
|
-
id,
|
|
79
|
-
requestBody: { server_type, upgrade_disk }
|
|
80
|
-
});
|
|
97
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/change_type`, { body: { server_type, upgrade_disk } });
|
|
81
98
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
82
99
|
}));
|
|
83
|
-
server.
|
|
84
|
-
|
|
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`);
|
|
85
106
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
86
107
|
}));
|
|
87
|
-
server.
|
|
88
|
-
|
|
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`);
|
|
89
114
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
90
115
|
}));
|
|
91
|
-
server.
|
|
92
|
-
|
|
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`);
|
|
93
122
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
94
123
|
}));
|
|
95
|
-
server.
|
|
96
|
-
|
|
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`);
|
|
97
130
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
98
131
|
}));
|
|
99
|
-
server.
|
|
100
|
-
|
|
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`);
|
|
101
138
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
102
139
|
}));
|
|
103
|
-
server.
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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,
|
|
107
148
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
108
|
-
const response = await
|
|
109
|
-
id,
|
|
110
|
-
requestBody: { name, labels }
|
|
111
|
-
});
|
|
149
|
+
const response = await hcloudRequest("PUT", `/servers/${id}`, { body: { name, labels } });
|
|
112
150
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
113
151
|
}));
|
|
114
|
-
server.
|
|
115
|
-
|
|
116
|
-
|
|
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,
|
|
117
159
|
}, async ({ id, iso }, _extra) => withToolError(async () => {
|
|
118
|
-
const response = await
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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,
|
|
133
180
|
}, async ({ id, network, ip, alias_ips }, _extra) => withToolError(async () => {
|
|
134
|
-
const response = await
|
|
135
|
-
id,
|
|
136
|
-
requestBody: { network, ip, alias_ips }
|
|
137
|
-
});
|
|
181
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/attach_to_network`, { body: { network, ip, alias_ips } });
|
|
138
182
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
139
183
|
}));
|
|
140
|
-
server.
|
|
141
|
-
|
|
142
|
-
|
|
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,
|
|
143
191
|
}, async ({ id, network }, _extra) => withToolError(async () => {
|
|
144
|
-
const response = await
|
|
145
|
-
id,
|
|
146
|
-
requestBody: { network }
|
|
147
|
-
});
|
|
192
|
+
const response = await hcloudRequest("POST", `/servers/${id}/actions/detach_from_network`, { body: { network } });
|
|
148
193
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
149
194
|
}));
|
|
150
195
|
// --- Load Balancers ---
|
|
151
|
-
server.
|
|
152
|
-
|
|
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");
|
|
153
202
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
154
203
|
}));
|
|
155
|
-
server.
|
|
156
|
-
|
|
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}`);
|
|
157
210
|
return { content: [{ type: "text", text: JSON.stringify(response.load_balancer, null, 2) }] };
|
|
158
211
|
}));
|
|
159
|
-
server.
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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,
|
|
166
251
|
}, async (args, _extra) => withToolError(async () => {
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
location
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
};
|
|
175
|
-
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 });
|
|
176
260
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
177
261
|
}));
|
|
178
|
-
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 () => {
|
|
179
267
|
// Since 2026-10-05 this returns 201 + Action (previously 204 empty).
|
|
180
|
-
const response = await
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
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,
|
|
187
281
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
188
|
-
const response = await
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
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,
|
|
201
296
|
}, async ({ id, type, server, label_selector, ip, use_private_ip }, _extra) => withToolError(async () => {
|
|
202
|
-
const response = await
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
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,
|
|
214
310
|
}, async ({ id, type, server, label_selector, ip }, _extra) => withToolError(async () => {
|
|
215
|
-
const response = await
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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(),
|
|
233
336
|
http: z.object({
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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(),
|
|
239
342
|
}).optional(),
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
cookie_name: z.string().optional(),
|
|
243
|
-
cookie_lifetime: z.number().optional(),
|
|
244
|
-
certificates: z.array(z.number()).optional(),
|
|
245
|
-
redirect_http: z.boolean().optional(),
|
|
246
|
-
sticky_sessions: z.boolean().optional(),
|
|
247
|
-
}).optional(),
|
|
343
|
+
},
|
|
344
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
248
345
|
}, async (args, _extra) => withToolError(async () => {
|
|
249
346
|
const { id, ...body } = args;
|
|
250
|
-
const response = await
|
|
251
|
-
id,
|
|
252
|
-
requestBody: body
|
|
253
|
-
});
|
|
347
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/add_service`, { body });
|
|
254
348
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
255
349
|
}));
|
|
256
|
-
server.
|
|
257
|
-
|
|
258
|
-
|
|
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,
|
|
259
357
|
}, async ({ id, listen_port }, _extra) => withToolError(async () => {
|
|
260
|
-
const response = await
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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(),
|
|
279
387
|
http: z
|
|
280
388
|
.object({
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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)"),
|
|
286
395
|
})
|
|
287
396
|
.optional(),
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
http: z
|
|
291
|
-
.object({
|
|
292
|
-
cookie_name: z.string().optional(),
|
|
293
|
-
cookie_lifetime: z.number().optional(),
|
|
294
|
-
certificates: z.array(z.number()).optional(),
|
|
295
|
-
redirect_http: z.boolean().optional(),
|
|
296
|
-
sticky_sessions: z.boolean().optional(),
|
|
297
|
-
timeout_idle: z.number().int().min(30).max(300).optional().describe("Idle timeout in seconds (30-300, default 50)"),
|
|
298
|
-
})
|
|
299
|
-
.optional(),
|
|
397
|
+
},
|
|
398
|
+
annotations: ADDITIVE_IDEMPOTENT,
|
|
300
399
|
}, async (args, _extra) => withToolError(async () => {
|
|
301
400
|
const { id, listen_port, ...body } = args;
|
|
302
|
-
const response = await
|
|
303
|
-
id,
|
|
304
|
-
requestBody: { listen_port, ...body }
|
|
305
|
-
});
|
|
401
|
+
const response = await hcloudRequest("POST", `/load_balancers/${id}/actions/update_service`, { body: { listen_port, ...body } });
|
|
306
402
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
307
403
|
}));
|
|
308
404
|
// --- Networks ---
|
|
309
|
-
server.
|
|
310
|
-
|
|
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");
|
|
311
411
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
312
412
|
}));
|
|
313
|
-
server.
|
|
314
|
-
|
|
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}`);
|
|
315
419
|
return { content: [{ type: "text", text: JSON.stringify(response.network, null, 2) }] };
|
|
316
420
|
}));
|
|
317
|
-
server.
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
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,
|
|
326
434
|
}, async (args, _extra) => withToolError(async () => {
|
|
327
435
|
const requestBody = {
|
|
328
436
|
name: args.name,
|
|
@@ -331,122 +439,173 @@ export function registerTools(server) {
|
|
|
331
439
|
routes: args.routes,
|
|
332
440
|
labels: args.labels,
|
|
333
441
|
};
|
|
334
|
-
const response = await
|
|
442
|
+
const response = await hcloudRequest("POST", "/networks", { body: requestBody });
|
|
335
443
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
336
444
|
}));
|
|
337
|
-
server.
|
|
338
|
-
|
|
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}`);
|
|
339
451
|
return { content: [{ type: "text", text: "Network deleted successfully" }] };
|
|
340
452
|
}));
|
|
341
|
-
server.
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
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,
|
|
345
461
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
346
|
-
const response = await
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
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,
|
|
359
476
|
}, async ({ id, type, network_zone, ip_range, vswitch_id }, _extra) => withToolError(async () => {
|
|
360
|
-
const response = await
|
|
361
|
-
id,
|
|
362
|
-
requestBody: { type, network_zone, ip_range, vswitch_id }
|
|
363
|
-
});
|
|
477
|
+
const response = await hcloudRequest("POST", `/networks/${id}/actions/add_subnet`, { body: { type, network_zone, ip_range, vswitch_id } });
|
|
364
478
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
365
479
|
}));
|
|
366
|
-
server.
|
|
367
|
-
|
|
368
|
-
|
|
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,
|
|
369
487
|
}, async ({ id, ip_range }, _extra) => withToolError(async () => {
|
|
370
|
-
const response = await
|
|
371
|
-
id,
|
|
372
|
-
requestBody: { ip_range }
|
|
373
|
-
});
|
|
488
|
+
const response = await hcloudRequest("POST", `/networks/${id}/actions/delete_subnet`, { body: { ip_range } });
|
|
374
489
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
375
490
|
}));
|
|
376
491
|
// --- Volumes ---
|
|
377
|
-
server.
|
|
378
|
-
|
|
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");
|
|
379
498
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
380
499
|
}));
|
|
381
|
-
server.
|
|
382
|
-
|
|
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}`);
|
|
383
506
|
return { content: [{ type: "text", text: JSON.stringify(response.volume, null, 2) }] };
|
|
384
507
|
}));
|
|
385
|
-
server.
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
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,
|
|
393
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.
|
|
394
529
|
const requestBody = {
|
|
395
530
|
name: args.name,
|
|
396
531
|
size: args.size,
|
|
397
532
|
automount: args.automount,
|
|
398
533
|
format: args.format,
|
|
399
534
|
location: args.location,
|
|
400
|
-
server: args.server,
|
|
535
|
+
...(args.server != null ? { assignee: { type: "server", id: args.server } } : {}),
|
|
401
536
|
labels: args.labels,
|
|
402
537
|
};
|
|
403
|
-
const response = await
|
|
538
|
+
const response = await hcloudRequest("POST", "/volumes", { body: requestBody });
|
|
404
539
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
405
540
|
}));
|
|
406
|
-
server.
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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,
|
|
410
549
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
411
|
-
const response = await
|
|
412
|
-
id,
|
|
413
|
-
requestBody: { name, labels }
|
|
414
|
-
});
|
|
550
|
+
const response = await hcloudRequest("PUT", `/volumes/${id}`, { body: { name, labels } });
|
|
415
551
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
416
552
|
}));
|
|
417
|
-
server.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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,
|
|
421
561
|
}, async ({ id, server, automount }, _extra) => withToolError(async () => {
|
|
422
|
-
const response = await
|
|
423
|
-
id,
|
|
424
|
-
requestBody: { server, automount }
|
|
562
|
+
const response = await hcloudRequest("POST", `/volumes/${id}/actions/attach`, {
|
|
563
|
+
body: { assignee: { type: "server", id: server }, automount },
|
|
425
564
|
});
|
|
426
565
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
427
566
|
}));
|
|
428
|
-
server.
|
|
429
|
-
|
|
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`);
|
|
430
573
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
431
574
|
}));
|
|
432
|
-
server.
|
|
433
|
-
|
|
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}`);
|
|
434
581
|
return { content: [{ type: "text", text: "Volume deleted successfully" }] };
|
|
435
582
|
}));
|
|
436
583
|
// --- Firewalls ---
|
|
437
|
-
server.
|
|
438
|
-
|
|
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");
|
|
439
590
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
440
591
|
}));
|
|
441
|
-
server.
|
|
442
|
-
|
|
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}`);
|
|
443
598
|
return { content: [{ type: "text", text: JSON.stringify(response.firewall, null, 2) }] };
|
|
444
599
|
}));
|
|
445
|
-
server.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
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,
|
|
450
609
|
}, async (args, _extra) => withToolError(async () => {
|
|
451
610
|
const body = {
|
|
452
611
|
name: args.name,
|
|
@@ -454,59 +613,84 @@ export function registerTools(server) {
|
|
|
454
613
|
labels: args.labels,
|
|
455
614
|
apply_to: args.apply_to,
|
|
456
615
|
};
|
|
457
|
-
const response = await
|
|
616
|
+
const response = await hcloudRequest("POST", "/firewalls", { body });
|
|
458
617
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
459
618
|
}));
|
|
460
|
-
server.
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
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,
|
|
464
627
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
465
|
-
const response = await
|
|
466
|
-
id,
|
|
467
|
-
requestBody: { name, labels }
|
|
468
|
-
});
|
|
628
|
+
const response = await hcloudRequest("PUT", `/firewalls/${id}`, { body: { name, labels } });
|
|
469
629
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
470
630
|
}));
|
|
471
|
-
server.
|
|
472
|
-
|
|
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}`);
|
|
473
637
|
return { content: [{ type: "text", text: "Firewall deleted successfully" }] };
|
|
474
638
|
}));
|
|
475
|
-
server.
|
|
476
|
-
id:
|
|
477
|
-
|
|
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,
|
|
478
646
|
}, async ({ id, apply_to }, _extra) => withToolError(async () => {
|
|
479
|
-
const response = await
|
|
480
|
-
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
481
|
-
}));
|
|
482
|
-
server.
|
|
483
|
-
id:
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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,
|
|
488
660
|
}, async ({ id, remove_from }, _extra) => withToolError(async () => {
|
|
489
|
-
const response = await
|
|
661
|
+
const response = await hcloudRequest("POST", `/firewalls/${id}/actions/remove_from_resources`, { body: { remove_from } });
|
|
490
662
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
491
663
|
}));
|
|
492
|
-
server.
|
|
493
|
-
|
|
494
|
-
|
|
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,
|
|
495
671
|
}, async ({ id, rules }, _extra) => withToolError(async () => {
|
|
496
|
-
const response = await
|
|
672
|
+
const response = await hcloudRequest("POST", `/firewalls/${id}/actions/set_rules`, { body: { rules } });
|
|
497
673
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
498
674
|
}));
|
|
499
675
|
// --- Floating IPs ---
|
|
500
|
-
server.
|
|
501
|
-
|
|
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");
|
|
502
682
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
503
683
|
}));
|
|
504
|
-
server.
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
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,
|
|
510
694
|
}, async (args, _extra) => withToolError(async () => {
|
|
511
695
|
const requestBody = {
|
|
512
696
|
type: args.type,
|
|
@@ -515,58 +699,75 @@ export function registerTools(server) {
|
|
|
515
699
|
description: args.description,
|
|
516
700
|
labels: args.labels,
|
|
517
701
|
};
|
|
518
|
-
const response = await
|
|
702
|
+
const response = await hcloudRequest("POST", "/floating_ips", { body: requestBody });
|
|
519
703
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
520
704
|
}));
|
|
521
|
-
server.
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
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,
|
|
525
713
|
}, async ({ id, description, labels }, _extra) => withToolError(async () => {
|
|
526
|
-
const response = await
|
|
527
|
-
id,
|
|
528
|
-
requestBody: { description, labels }
|
|
529
|
-
});
|
|
714
|
+
const response = await hcloudRequest("PUT", `/floating_ips/${id}`, { body: { description, labels } });
|
|
530
715
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
531
716
|
}));
|
|
532
|
-
server.
|
|
533
|
-
|
|
534
|
-
|
|
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,
|
|
535
724
|
}, async ({ id, server }, _extra) => withToolError(async () => {
|
|
536
|
-
const response = await
|
|
537
|
-
id,
|
|
538
|
-
requestBody: { server }
|
|
539
|
-
});
|
|
725
|
+
const response = await hcloudRequest("POST", `/floating_ips/${id}/actions/assign`, { body: { server } });
|
|
540
726
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
541
727
|
}));
|
|
542
|
-
server.
|
|
543
|
-
|
|
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`);
|
|
544
734
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
545
735
|
}));
|
|
546
|
-
server.
|
|
547
|
-
|
|
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}`);
|
|
548
742
|
return { content: [{ type: "text", text: "Floating IP deleted successfully" }] };
|
|
549
743
|
}));
|
|
550
744
|
// --- Primary IPs ---
|
|
551
|
-
server.
|
|
552
|
-
|
|
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");
|
|
553
751
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
554
752
|
}));
|
|
555
|
-
server.
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
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,
|
|
562
764
|
}, async (args, _extra) => withToolError(async () => {
|
|
563
765
|
const hasLocation = args.location != null && args.location !== "";
|
|
564
766
|
const hasAssignee = args.assignee_id != null;
|
|
565
767
|
if (hasLocation === hasAssignee) {
|
|
566
768
|
throw new Error("Provide exactly one of location or assignee_id (mutually exclusive)");
|
|
567
769
|
}
|
|
568
|
-
//
|
|
569
|
-
// (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).
|
|
570
771
|
const requestBody = {
|
|
571
772
|
name: args.name,
|
|
572
773
|
type: args.type,
|
|
@@ -576,51 +777,73 @@ export function registerTools(server) {
|
|
|
576
777
|
auto_delete: args.auto_delete,
|
|
577
778
|
labels: args.labels,
|
|
578
779
|
};
|
|
579
|
-
const response = await
|
|
780
|
+
const response = await hcloudRequest("POST", "/primary_ips", { body: requestBody });
|
|
580
781
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
581
782
|
}));
|
|
582
|
-
server.
|
|
583
|
-
|
|
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}`);
|
|
584
789
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
585
790
|
}));
|
|
586
|
-
server.
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
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,
|
|
590
799
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
591
|
-
const response = await
|
|
592
|
-
id,
|
|
593
|
-
requestBody: { name, labels }
|
|
594
|
-
});
|
|
800
|
+
const response = await hcloudRequest("PUT", `/primary_ips/${id}`, { body: { name, labels } });
|
|
595
801
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
596
802
|
}));
|
|
597
|
-
server.
|
|
598
|
-
|
|
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}`);
|
|
599
809
|
return { content: [{ type: "text", text: "Primary IP deleted successfully" }] };
|
|
600
810
|
}));
|
|
601
|
-
server.
|
|
602
|
-
|
|
603
|
-
|
|
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,
|
|
604
818
|
}, async ({ id, server }, _extra) => withToolError(async () => {
|
|
605
|
-
const response = await
|
|
606
|
-
id,
|
|
607
|
-
requestBody: { assignee_id: server, assignee_type: "server" }
|
|
608
|
-
});
|
|
819
|
+
const response = await hcloudRequest("POST", `/primary_ips/${id}/actions/assign`, { body: { assignee_id: server, assignee_type: "server" } });
|
|
609
820
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
610
821
|
}));
|
|
611
|
-
server.
|
|
612
|
-
|
|
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`);
|
|
613
828
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
614
829
|
}));
|
|
615
830
|
// --- SSH Keys ---
|
|
616
|
-
server.
|
|
617
|
-
|
|
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");
|
|
618
837
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
619
838
|
}));
|
|
620
|
-
server.
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
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,
|
|
624
847
|
}, async (args, _extra) => withToolError(async () => {
|
|
625
848
|
const requestBody = {
|
|
626
849
|
name: args.name,
|
|
@@ -628,102 +851,142 @@ export function registerTools(server) {
|
|
|
628
851
|
public_key: args.public_key.trim(),
|
|
629
852
|
labels: args.labels,
|
|
630
853
|
};
|
|
631
|
-
const response = await
|
|
854
|
+
const response = await hcloudRequest("POST", "/ssh_keys", { body: requestBody });
|
|
632
855
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
633
856
|
}));
|
|
634
|
-
server.
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
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,
|
|
638
865
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
639
|
-
const response = await
|
|
640
|
-
id,
|
|
641
|
-
requestBody: { name, labels }
|
|
642
|
-
});
|
|
866
|
+
const response = await hcloudRequest("PUT", `/ssh_keys/${id}`, { body: { name, labels } });
|
|
643
867
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
644
868
|
}));
|
|
645
|
-
server.
|
|
646
|
-
|
|
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}`);
|
|
647
875
|
return { content: [{ type: "text", text: "SSH key deleted successfully" }] };
|
|
648
876
|
}));
|
|
649
877
|
// --- General Info ---
|
|
650
|
-
server.
|
|
651
|
-
|
|
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");
|
|
652
884
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
653
885
|
}));
|
|
654
|
-
server.
|
|
655
|
-
|
|
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");
|
|
656
892
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
657
893
|
}));
|
|
658
|
-
server.
|
|
659
|
-
|
|
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");
|
|
660
900
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
661
901
|
}));
|
|
662
|
-
server.
|
|
663
|
-
|
|
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");
|
|
664
908
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
665
909
|
}));
|
|
666
|
-
server.
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
.enum([
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
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,
|
|
678
926
|
}, async (args, _extra) => withToolError(async () => {
|
|
679
|
-
const response = await
|
|
680
|
-
id: args.id,
|
|
681
|
-
status: args.status,
|
|
682
|
-
sort: args.sort,
|
|
683
|
-
page: args.page,
|
|
684
|
-
perPage: args.per_page,
|
|
685
|
-
});
|
|
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 } });
|
|
686
928
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
687
929
|
}));
|
|
688
|
-
server.
|
|
689
|
-
|
|
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}`);
|
|
690
936
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
691
937
|
}));
|
|
692
|
-
server.
|
|
693
|
-
|
|
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");
|
|
694
944
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
695
945
|
}));
|
|
696
946
|
// --- Placement Groups ---
|
|
697
|
-
server.
|
|
698
|
-
|
|
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");
|
|
699
953
|
return { content: [{ type: "text", text: JSON.stringify(items, null, 2) }] };
|
|
700
954
|
}));
|
|
701
|
-
server.
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
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,
|
|
705
963
|
}, async (args, _extra) => withToolError(async () => {
|
|
706
964
|
const requestBody = {
|
|
707
965
|
name: args.name,
|
|
708
966
|
type: args.type,
|
|
709
967
|
labels: args.labels,
|
|
710
968
|
};
|
|
711
|
-
const response = await
|
|
969
|
+
const response = await hcloudRequest("POST", "/placement_groups", { body: requestBody });
|
|
712
970
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
713
971
|
}));
|
|
714
|
-
server.
|
|
715
|
-
|
|
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}`);
|
|
716
978
|
return { content: [{ type: "text", text: "Placement Group deleted successfully" }] };
|
|
717
979
|
}));
|
|
718
|
-
server.
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
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,
|
|
722
988
|
}, async ({ id, name, labels }, _extra) => withToolError(async () => {
|
|
723
|
-
const response = await
|
|
724
|
-
id,
|
|
725
|
-
requestBody: { name, labels }
|
|
726
|
-
});
|
|
989
|
+
const response = await hcloudRequest("PUT", `/placement_groups/${id}`, { body: { name, labels } });
|
|
727
990
|
return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
|
|
728
991
|
}));
|
|
729
992
|
}
|