hcloud-mcp 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.tool("list_servers", "List all servers", {}, async (_args, _extra) => withToolError(async () => {
21
- const items = await listAll((p) => ServersService.getServers(p), "servers");
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.tool("get_server", "Get a single server by ID", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
25
- const response = await ServersService.getServers1({ id });
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.tool("create_server", "Create a new server", {
29
- name: z.string(),
30
- server_type: z.string(),
31
- image: z.string(),
32
- location: z.string().optional().describe("Location name or ID, e.g. fsn1, nbg1, hel1, ash, hil, sin. Check list_server_types locations[].available first"),
33
- start_after_create: z.boolean().optional(),
34
- ssh_keys: z.array(z.union([z.string(), z.number()])).optional().describe("List of SSH key names or IDs"),
35
- firewalls: z.array(z.object({ firewall: z.number() })).optional(),
36
- networks: z.array(z.number()).optional(),
37
- placement_group: z.number().optional().describe("ID of placement group"),
38
- public_net: z
39
- .object({
40
- enable_ipv4: z.boolean().optional(),
41
- enable_ipv6: z.boolean().optional(),
42
- ipv4: z.number().nullable().optional(),
43
- ipv6: z.number().nullable().optional(),
44
- })
45
- .optional(),
46
- user_data: z.string().optional().describe("Cloud-Init user data (max 32KiB)"),
47
- volumes: z.array(z.number()).optional().describe("Volume IDs to attach at creation"),
48
- labels: z.record(z.string()).optional(),
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 ServersService.postServers({ requestBody });
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.tool("delete_server", "Delete a server", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
69
- const response = await ServersService.deleteServers({ id });
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.tool("change_server_type", "Change the type of a server (scales resources). Server must be powered off.", {
73
- id: z.number(),
74
- server_type: z.string().describe("New server type (e.g. cx22)"),
75
- upgrade_disk: z.boolean().default(true).describe("Whether to upgrade disk size. If true, cannot downgrade later."),
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 ServerActionsService.postServersActionsChangeType({
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.tool("power_on_server", "Power on a server", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
84
- const response = await ServerActionsService.postServersActionsPoweron({ id });
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.tool("power_off_server", "Power off a server (hard)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
88
- const response = await ServerActionsService.postServersActionsPoweroff({ id });
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.tool("reboot_server", "Reboot a server (soft)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
92
- const response = await ServerActionsService.postServersActionsReboot({ id });
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.tool("shutdown_server", "Shutdown a server (soft)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
96
- const response = await ServerActionsService.postServersActionsShutdown({ id });
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.tool("reset_server", "Reset a server (hard)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
100
- const response = await ServerActionsService.postServersActionsReset({ id });
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.tool("update_server", "Update a server (name, labels)", {
104
- id: z.number(),
105
- name: z.string().optional(),
106
- labels: z.record(z.string()).optional(),
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 ServersService.putServers({
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.tool("attach_iso", "Attach an ISO to a server", {
115
- id: z.number(),
116
- iso: z.string().describe("ID or name of the ISO"),
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 ServerActionsService.postServersActionsAttachIso({
119
- id,
120
- requestBody: { iso }
121
- });
122
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
123
- }));
124
- server.tool("detach_iso", "Detach an ISO from a server", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
125
- const response = await ServerActionsService.postServersActionsDetachIso({ id });
126
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
127
- }));
128
- server.tool("attach_server_to_network", "Attach a server to a network", {
129
- id: z.number(),
130
- network: z.number().describe("ID of the network"),
131
- ip: z.string().optional().describe("IP to request, otherwise auto-assigned"),
132
- alias_ips: z.array(z.string()).optional(),
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 ServerActionsService.postServersActionsAttachToNetwork({
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.tool("detach_server_from_network", "Detach a server from a network", {
141
- id: z.number(),
142
- network: z.number().describe("ID of the network"),
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 ServerActionsService.postServersActionsDetachFromNetwork({
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.tool("list_load_balancers", "List all load balancers", {}, async (_args, _extra) => withToolError(async () => {
152
- const items = await listAll((p) => LoadBalancersService.getLoadBalancers(p), "load_balancers");
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.tool("get_load_balancer", "Get a single load balancer by ID", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
156
- const response = await LoadBalancersService.getLoadBalancers1({ id });
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.tool("create_load_balancer", "Create a new load balancer", {
160
- name: z.string(),
161
- algorithm: z.object({ type: z.enum(["round_robin", "least_connections"]) }).optional(),
162
- location: z.string(),
163
- load_balancer_type: z.string(),
164
- network_zone: z.string().optional(),
165
- labels: z.record(z.string()).optional(),
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 requestBody = {
168
- name: args.name,
169
- load_balancer_type: args.load_balancer_type,
170
- location: args.location,
171
- algorithm: args.algorithm,
172
- network_zone: args.network_zone,
173
- labels: args.labels,
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.tool("delete_load_balancer", "Delete a load balancer. Returns a delete_load_balancer Action; poll get_action until it finishes", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
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 LoadBalancersService.deleteLoadBalancers({ id });
181
- return { content: [{ type: "text", text: JSON.stringify(response ?? { deleted: true }, null, 2) }] };
182
- }));
183
- server.tool("update_load_balancer", "Update a load balancer (name, labels)", {
184
- id: z.number(),
185
- name: z.string().optional(),
186
- labels: z.record(z.string()).optional(),
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 LoadBalancersService.putLoadBalancers({
189
- id,
190
- requestBody: { name, labels }
191
- });
192
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
193
- }));
194
- server.tool("add_load_balancer_target", "Add a target to a load balancer", {
195
- id: z.number(),
196
- type: z.enum(["server", "label_selector", "ip"]),
197
- server: z.object({ id: z.number() }).optional(),
198
- label_selector: z.object({ selector: z.string() }).optional(),
199
- ip: z.object({ ip: z.string() }).optional(),
200
- use_private_ip: z.boolean().optional(),
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 LoadBalancerActionsService.postLoadBalancersActionsAddTarget({
203
- id,
204
- requestBody: { type, server, label_selector, ip, use_private_ip }
205
- });
206
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
207
- }));
208
- server.tool("remove_load_balancer_target", "Remove a target from a load balancer", {
209
- id: z.number(),
210
- type: z.enum(["server", "label_selector", "ip"]),
211
- server: z.object({ id: z.number() }).optional(),
212
- label_selector: z.object({ selector: z.string() }).optional(),
213
- ip: z.object({ ip: z.string() }).optional(),
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 LoadBalancerActionsService.postLoadBalancersActionsRemoveTarget({
216
- id,
217
- requestBody: { type, server, label_selector, ip }
218
- });
219
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
220
- }));
221
- server.tool("add_load_balancer_service", "Add a service to a load balancer", {
222
- id: z.number(),
223
- protocol: z.enum(["tcp", "http", "https"]),
224
- listen_port: z.number(),
225
- destination_port: z.number(),
226
- proxyprotocol: z.boolean(),
227
- health_check: z.object({
228
- protocol: z.enum(["tcp", "http"]),
229
- port: z.number(),
230
- interval: z.number(),
231
- timeout: z.number(),
232
- retries: z.number(),
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
- domain: z.string().nullable().optional(),
235
- path: z.string().optional(),
236
- response: z.string().optional(),
237
- status_codes: z.array(z.string()).optional(),
238
- tls: z.boolean().optional(),
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
- }).optional(),
241
- http: z.object({
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 LoadBalancerActionsService.postLoadBalancersActionsAddService({
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.tool("delete_load_balancer_service", "Delete a service from a load balancer", {
257
- id: z.number(),
258
- listen_port: z.number(),
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 LoadBalancerActionsService.postLoadBalancersActionsDeleteService({
261
- id,
262
- requestBody: { listen_port }
263
- });
264
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
265
- }));
266
- server.tool("update_load_balancer_service", "Update a load balancer service (listen_port identifies the service)", {
267
- id: z.number().describe("Load balancer ID"),
268
- listen_port: z.number().describe("Listen port of the service to update"),
269
- destination_port: z.number().optional(),
270
- protocol: z.enum(["tcp", "http", "https"]).optional(),
271
- proxyprotocol: z.boolean().optional(),
272
- health_check: z
273
- .object({
274
- protocol: z.enum(["tcp", "http"]),
275
- port: z.number(),
276
- interval: z.number(),
277
- timeout: z.number(),
278
- retries: z.number(),
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
- domain: z.string().nullable().optional(),
282
- path: z.string().optional(),
283
- response: z.string().optional(),
284
- status_codes: z.array(z.string()).optional(),
285
- tls: z.boolean().optional(),
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
- .optional(),
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 LoadBalancerActionsService.postLoadBalancersActionsUpdateService({
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.tool("list_networks", "List all networks", {}, async (_args, _extra) => withToolError(async () => {
310
- const items = await listAll((p) => NetworksService.getNetworks(p), "networks");
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.tool("get_network", "Get a single network by ID", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
314
- const response = await NetworksService.getNetworks1({ id });
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.tool("create_network", "Create a new network", {
318
- name: z.string(),
319
- ip_range: z.string(),
320
- expose_routes_to_vswitch: z.boolean().optional(),
321
- routes: z
322
- .array(z.object({ destination: z.string(), gateway: z.string() }))
323
- .optional()
324
- .describe("Routes: destination (CIDR), gateway (IP)"),
325
- labels: z.record(z.string()).optional(),
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 NetworksService.postNetworks({ requestBody });
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.tool("delete_network", "Delete a network", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
338
- await NetworksService.deleteNetworks({ id });
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.tool("update_network", "Update a network (name, labels)", {
342
- id: z.number(),
343
- name: z.string().optional(),
344
- labels: z.record(z.string()).optional(),
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 NetworksService.putNetworks({
347
- id,
348
- requestBody: { name, labels }
349
- });
350
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
351
- }));
352
- server.tool("add_network_subnet", "Add a subnet to a network (e.g. for private networking 10.0.0.0/16 in a zone)", {
353
- id: z.number().describe("Network ID"),
354
- // "server" type is deprecated (removal 2027-04-15) and equivalent to "cloud".
355
- type: z.enum(["cloud", "vswitch"]),
356
- network_zone: z.string().describe("Network zone, e.g. eu-central"),
357
- ip_range: z.string().optional().describe("CIDR, e.g. 10.0.0.0/24; omit for auto /24"),
358
- vswitch_id: z.number().optional().describe("Required if type is vswitch"),
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 NetworkActionsService.postNetworksActionsAddSubnet({
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.tool("delete_network_subnet", "Delete a subnet from a network (detach servers from it first)", {
367
- id: z.number().describe("Network ID"),
368
- ip_range: z.string().describe("IP range of subnet to delete, e.g. 10.0.1.0/24"),
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 NetworkActionsService.postNetworksActionsDeleteSubnet({
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.tool("list_volumes", "List all volumes", {}, async (_args, _extra) => withToolError(async () => {
378
- const items = await listAll((p) => VolumesService.getVolumes(p), "volumes");
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.tool("get_volume", "Get a single volume by ID", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
382
- const response = await VolumesService.getVolumes1({ id });
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.tool("create_volume", "Create a new volume", {
386
- name: z.string(),
387
- size: z.number(),
388
- automount: z.boolean().optional(),
389
- format: z.string().optional(),
390
- location: z.string().optional(),
391
- server: z.number().optional(),
392
- labels: z.record(z.string()).optional(),
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 VolumesService.postVolumes({ requestBody });
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.tool("update_volume", "Update a volume (name, labels)", {
407
- id: z.number(),
408
- name: z.string().optional(),
409
- labels: z.record(z.string()).optional(),
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 VolumesService.putVolumes({
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.tool("attach_volume", "Attach a volume to a server", {
418
- id: z.number(),
419
- server: z.number(),
420
- automount: z.boolean().optional(),
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 VolumeActionsService.postVolumesActionsAttach({
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.tool("detach_volume", "Detach a volume", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
429
- const response = await VolumeActionsService.postVolumesActionsDetach({ id });
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.tool("delete_volume", "Delete a volume (must be detached; all data destroyed)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
433
- await VolumesService.deleteVolumes({ id });
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.tool("list_firewalls", "List all firewalls", {}, async (_args, _extra) => withToolError(async () => {
438
- const items = await listAll((p) => FirewallsService.getFirewalls(p), "firewalls");
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.tool("get_firewall", "Get a single firewall by ID", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
442
- const response = await FirewallsService.getFirewalls1({ id });
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.tool("create_firewall", "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.", {
446
- name: z.string(),
447
- rules: z.array(firewallRuleSchema).optional(),
448
- apply_to: z.array(firewallApplyToSchema).optional().describe("Apply firewall to these servers or label_selector after creation"),
449
- labels: z.record(z.string()).optional(),
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 FirewallsService.postFirewalls({ requestBody: body });
616
+ const response = await hcloudRequest("POST", "/firewalls", { body });
458
617
  return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
459
618
  }));
460
- server.tool("update_firewall", "Update a firewall (name, labels)", {
461
- id: z.number(),
462
- name: z.string().optional(),
463
- labels: z.record(z.string()).optional(),
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 FirewallsService.putFirewalls({
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.tool("delete_firewall", "Delete a firewall (must not be in use)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
472
- await FirewallsService.deleteFirewalls({ id });
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.tool("apply_firewall_to_resources", "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' } }].", {
476
- id: z.number().describe("Firewall ID"),
477
- apply_to: z.array(firewallApplyToSchema),
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 FirewallActionsService.postFirewallsActionsApplyToResources({ id, requestBody: { apply_to } });
480
- return { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] };
481
- }));
482
- server.tool("remove_firewall_from_resources", "Remove a firewall from servers. Pass remove_from: [{ type: 'server', server: { id: 123 } }].", {
483
- id: z.number().describe("Firewall ID"),
484
- remove_from: z.array(z.object({
485
- type: z.literal("server"),
486
- server: z.object({ id: z.number() }),
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 FirewallActionsService.postFirewallsActionsRemoveFromResources({ id, requestBody: { remove_from } });
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.tool("set_firewall_rules", "Set rules on an existing firewall (overwrites all rules). Same rule format as create_firewall.", {
493
- id: z.number().describe("Firewall ID"),
494
- rules: z.array(firewallRuleSchema),
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 FirewallActionsService.postFirewallsActionsSetRules({ id, requestBody: { rules } });
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.tool("list_floating_ips", "List all floating IPs", {}, async (_args, _extra) => withToolError(async () => {
501
- const items = await listAll((p) => FloatingIPsService.getFloatingIps(p), "floating_ips");
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.tool("create_floating_ip", "Create a floating IP", {
505
- type: z.enum(["ipv4", "ipv6"]),
506
- home_location: z.string().optional(),
507
- server: z.number().optional(),
508
- description: z.string().optional(),
509
- labels: z.record(z.string()).optional(),
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 FloatingIPsService.postFloatingIps({ requestBody });
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.tool("update_floating_ip", "Update a floating IP (description, labels)", {
522
- id: z.number(),
523
- description: z.string().optional(),
524
- labels: z.record(z.string()).optional(),
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 FloatingIPsService.putFloatingIps({
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.tool("assign_floating_ip", "Assign a floating IP to a server", {
533
- id: z.number(),
534
- server: z.number(),
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 FloatingIpActionsService.postFloatingIpsActionsAssign({
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.tool("unassign_floating_ip", "Unassign a floating IP", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
543
- const response = await FloatingIpActionsService.postFloatingIpsActionsUnassign({ id });
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.tool("delete_floating_ip", "Delete a floating IP. Must be unassigned first (unassign_floating_ip), else fails with must_be_unassigned", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
547
- await FloatingIPsService.deleteFloatingIps({ id });
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.tool("list_primary_ips", "List all Primary IPs (static IPs bound to a location, assignable to one server)", {}, async (_args, _extra) => withToolError(async () => {
552
- const items = await listAll((p) => PrimaryIPsService.getPrimaryIps(p), "primary_ips");
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.tool("create_primary_ip", "Create a Primary IP (location-scoped; server must be off to assign). Provide location OR assignee_id (server).", {
556
- name: z.string(),
557
- type: z.enum(["ipv4", "ipv6"]),
558
- location: z.string().optional().describe("Location name or ID, e.g. fsn1 (omit if assignee_id set)"),
559
- assignee_id: z.number().optional().describe("Server ID to assign to immediately (omit if location set)"),
560
- auto_delete: z.boolean().optional(),
561
- labels: z.record(z.string()).optional(),
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
- // hetzner-sdk-ts 1.0.1 still models the removed `datacenter` field; the API
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 PrimaryIPsService.postPrimaryIps({ requestBody });
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.tool("get_primary_ip", "Get a single Primary IP by ID", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
583
- const response = await PrimaryIPsService.getPrimaryIps1({ id });
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.tool("update_primary_ip", "Update a Primary IP (name, labels)", {
587
- id: z.number(),
588
- name: z.string().optional(),
589
- labels: z.record(z.string()).optional(),
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 PrimaryIPsService.putPrimaryIps({
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.tool("delete_primary_ip", "Delete a Primary IP. Must be unassigned first (unassign_primary_ip, server powered off), else fails with must_be_unassigned", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
598
- await PrimaryIPsService.deletePrimaryIps({ id });
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.tool("assign_primary_ip", "Assign a Primary IP to a server (server must be powered off)", {
602
- id: z.number().describe("Primary IP ID"),
603
- server: z.number().describe("Server ID"),
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 PrimaryIpActionsService.postPrimaryIpsActionsAssign({
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.tool("unassign_primary_ip", "Unassign a Primary IP from its server (server must be powered off)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
612
- const response = await PrimaryIpActionsService.postPrimaryIpsActionsUnassign({ id });
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.tool("list_ssh_keys", "List all SSH keys", {}, async (_args, _extra) => withToolError(async () => {
617
- const items = await listAll((p) => SshKeysService.getSshKeys(p), "ssh_keys");
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.tool("create_ssh_key", "Create a new SSH key (public_key is trimmed; the API rejects leading whitespace)", {
621
- name: z.string(),
622
- public_key: z.string(),
623
- labels: z.record(z.string()).optional(),
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 SshKeysService.postSshKeys({ requestBody });
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.tool("update_ssh_key", "Update an SSH key (name, labels)", {
635
- id: z.number(),
636
- name: z.string().optional(),
637
- labels: z.record(z.string()).optional(),
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 SshKeysService.putSshKeys({
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.tool("delete_ssh_key", "Delete an SSH key", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
646
- await SshKeysService.deleteSshKeys({ id });
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.tool("list_locations", "List all locations", {}, async (_args, _extra) => withToolError(async () => {
651
- const items = await listAll((p) => LocationsService.getLocations(p), "locations");
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.tool("list_images", "List all images (check each image's `deprecation` field; deprecated images can stop being usable for new servers)", {}, async (_args, _extra) => withToolError(async () => {
655
- const items = await listAll((p) => ImagesService.getImages(p), "images");
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.tool("list_server_types", "List all server types. Per-location availability is in locations[]: available, recommended, deprecation (top-level `deprecated` was removed)", {}, async (_args, _extra) => withToolError(async () => {
659
- const items = await listAll((p) => ServerTypesService.getServerTypes(p), "server_types");
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.tool("list_load_balancer_types", "List all load balancer types (for create_load_balancer load_balancer_type; check `deprecation`)", {}, async (_args, _extra) => withToolError(async () => {
663
- const items = await listAll((p) => LoadBalancerTypesService.getLoadBalancerTypes(p), "load_balancer_types");
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.tool("list_actions", "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", {
667
- id: z.number().describe("Action ID (required by the API since 2025-01-30)"),
668
- status: z.enum(["running", "success", "error"]).optional(),
669
- sort: z
670
- .enum([
671
- "id", "id:asc", "id:desc", "command", "command:asc", "command:desc",
672
- "status", "status:asc", "status:desc", "started", "started:asc", "started:desc",
673
- "finished", "finished:asc", "finished:desc",
674
- ])
675
- .optional(),
676
- page: z.number().optional(),
677
- per_page: z.number().optional(),
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 ActionsService.getActions({
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.tool("get_action", "Get a single action by ID (e.g. to check progress or status after create/delete)", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
689
- const response = await ActionsService.getActions1({ id });
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.tool("get_pricing", "Get all prices", {}, async (_args, _extra) => withToolError(async () => {
693
- const response = await PricingService.getPricing();
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.tool("list_placement_groups", "List all placement groups", {}, async (_args, _extra) => withToolError(async () => {
698
- const items = await listAll((p) => PlacementGroupsService.getPlacementGroups(p), "placement_groups");
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.tool("create_placement_group", "Create a new placement group", {
702
- name: z.string(),
703
- type: z.enum(["spread"]),
704
- labels: z.record(z.string()).optional(),
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 PlacementGroupsService.postPlacementGroups({ requestBody });
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.tool("delete_placement_group", "Delete a placement group", { id: z.number() }, async ({ id }, _extra) => withToolError(async () => {
715
- await PlacementGroupsService.deletePlacementGroups({ id });
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.tool("update_placement_group", "Update a placement group (name, labels)", {
719
- id: z.number(),
720
- name: z.string().optional(),
721
- labels: z.record(z.string()).optional(),
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 PlacementGroupsService.putPlacementGroups({
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
  }