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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Hcloud MCP server](https://mcprush.com/badge/hcloud-mcp/card.svg)](https://mcprush.com/to/hcloud-mcp?ref=badge)
4
4
 
5
- Standalone **MCP (Model Context Protocol) server** for the [Hetzner Cloud API](https://docs.hetzner.cloud/). Use it with any MCP client: Cursor, Claude Desktop, CLI tools, [smithery.ai](https://smithery.ai), or custom agents.
5
+ Standalone **MCP (Model Context Protocol) server** for the [Hetzner Cloud API](https://docs.hetzner.cloud/): servers, networking, load balancers, volumes, DNS, certificates, snapshots and Storage Boxes. It has 162 tools, and every tool tells the client whether it is read-only or destructive. Use it with any MCP client: Cursor, Claude Desktop, Claude Code, CLI tools, [smithery.ai](https://smithery.ai), or custom agents.
6
6
 
7
7
  - **Repository:** [github.com/Xodus-CO/hcloud-mcp](https://github.com/Xodus-CO/hcloud-mcp)
8
8
  - **Hetzner Cloud:** [Get started](https://hetzner.cloud/?ref=IAYKetqPnlq9) — new signups get €20 credit.
@@ -12,7 +12,9 @@ Standalone **MCP (Model Context Protocol) server** for the [Hetzner Cloud API](h
12
12
  ## Requirements
13
13
 
14
14
  - Node.js 18+
15
- - A Hetzner Cloud API token. [Generate one](https://docs.hetzner.com/cloud/api/getting-started/generating-api-token) in the console (project → Security → API Tokens). Set it as `HCLOUD_TOKEN` in the environment or in your MCP client config.
15
+ - A Hetzner Cloud API token. [Generate one](https://docs.hetzner.com/cloud/api/getting-started/generating-api-token) in the console (project → Security → API Tokens). Set it as `HCLOUD_TOKEN` in the environment or in your MCP client config. A token gives access to the whole project. If the agent only needs to look things up, create a **Read** token instead of Read & Write.
16
+
17
+ The server runs locally over stdio. Your token is only sent to Hetzner: `api.hetzner.cloud` for Cloud and DNS (DNS is part of the Cloud API), and `api.hetzner.com` for Storage Boxes. The legacy DNS Console API at `dns.hetzner.com` is not used.
16
18
 
17
19
  ## Installation
18
20
 
@@ -44,7 +46,7 @@ Add the server to your MCP client config. It uses MCP over **stdio** and require
44
46
  "mcpServers": {
45
47
  "hetzner-cloud": {
46
48
  "command": "npx",
47
- "args": ["hcloud-mcp"],
49
+ "args": ["-y", "hcloud-mcp@latest"],
48
50
  "env": {
49
51
  "HCLOUD_TOKEN": "your_hetzner_cloud_api_token"
50
52
  }
@@ -69,7 +71,7 @@ The server exposes Hetzner Cloud API operations as MCP tools:
69
71
  | Area | Tools |
70
72
  | ---------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
71
73
  | **Servers** | `list_servers`, `get_server`, `create_server`, `delete_server`, `update_server`, `change_server_type`; power: `power_on_server`, `power_off_server`, `reboot_server`, `shutdown_server`, `reset_server`; `attach_iso`, `detach_iso`; `attach_server_to_network`, `detach_server_from_network`; `rebuild_server`; reverse DNS: `change_dns_ptr` (also Primary/Floating IPs, LBs) |
72
- | **Load Balancers** | `list_load_balancers`, `get_load_balancer`, `create_load_balancer`, `update_load_balancer`, `delete_load_balancer`; `add_load_balancer_target`, `remove_load_balancer_target`; `add_load_balancer_service`, `update_load_balancer_service`, `delete_load_balancer_service`; `list_load_balancer_types` (`http.timeout_idle` on update) |
74
+ | **Load Balancers** | `list_load_balancers`, `get_load_balancer`, `create_load_balancer`, `update_load_balancer`, `delete_load_balancer`; `add_load_balancer_target`, `remove_load_balancer_target`; `add_load_balancer_service`, `update_load_balancer_service`, `delete_load_balancer_service`; `list_load_balancer_types`. `create_load_balancer` can set an existing Primary IP (`public_net`), a private network, services and targets in one call. `update_load_balancer_service` supports `http.timeout_idle` |
73
75
  | **Networks** | `list_networks`, `get_network`, `create_network`, `update_network`, `delete_network`; `add_network_subnet`, `delete_network_subnet`; `list_network_members` |
74
76
  | **Volumes** | `list_volumes`, `get_volume`, `create_volume`, `update_volume`, `delete_volume`; `attach_volume`, `detach_volume` |
75
77
  | **Firewalls** | `list_firewalls`, `get_firewall`, `create_firewall`, `update_firewall`, `delete_firewall`; `apply_firewall_to_resources`, `remove_firewall_from_resources`, `set_firewall_rules` |
@@ -91,7 +93,7 @@ The server exposes Hetzner Cloud API operations as MCP tools:
91
93
 
92
94
  ### Limiting tools (`HCLOUD_TOOLSETS`)
93
95
 
94
- The server exposes about 160 tools. Some MCP clients cap the total number of tools, or slow down with very many. Set `HCLOUD_TOOLSETS` to load only the groups you need. The `core` group is always loaded.
96
+ The server exposes 162 tools. Some MCP clients cap the total number of tools, or slow down with very many. Set `HCLOUD_TOOLSETS` to load only the groups you need. The `core` group is always loaded.
95
97
 
96
98
  | Toolset | Contents |
97
99
  |---|---|
@@ -102,7 +104,19 @@ The server exposes about 160 tools. Some MCP clients cap the total number of too
102
104
  | `certificates` | TLS certificates |
103
105
  | `storage_boxes` | Storage Boxes, subaccounts, snapshots |
104
106
 
105
- Example: `"env": { "HCLOUD_TOKEN": "...", "HCLOUD_TOOLSETS": "dns,images" }`. If you leave it unset, or set it to `all`, everything loads.
107
+ Example: `"env": { "HCLOUD_TOKEN": "...", "HCLOUD_TOOLSETS": "dns,images" }`. If you leave it unset, or set it to `all`, everything loads. `core` alone is 91 tools; `core` plus `dns` is 112.
108
+
109
+ ### Tool annotations
110
+
111
+ Every tool declares MCP [tool annotations](https://modelcontextprotocol.io/specification/2025-06-18/server/tools#tool-annotations), which clients can use to decide when to ask for confirmation:
112
+
113
+ | Annotation | Tools | Examples |
114
+ |---|---|---|
115
+ | `readOnlyHint` | 46 | Every `list_*`, `get_*` and `export_*` tool |
116
+ | `destructiveHint` | 57 | Deletes, `rebuild_server`, `power_off_server`, `import_zonefile`, `rollback_storage_box_snapshot`, `disable_server_backups` |
117
+ | `idempotentHint` | 92 | Changes that are safe to repeat, such as deletes, `power_off_server`, `set_firewall_rules` and `set_rrset_records` |
118
+
119
+ All tools also set `openWorldHint`, because they call an external API. These are hints, not guarantees. Keep confirmation turned on for destructive tools.
106
120
 
107
121
  ### Server instructions and agent skill
108
122
 
@@ -121,19 +135,27 @@ The skill is also included in the npm package.
121
135
 
122
136
  ## API compatibility
123
137
 
124
- Updated in 0.2.0 for Hetzner Cloud API changes through November 2026 ([changelog](https://docs.hetzner.cloud/changelog)):
138
+ The tools follow the Hetzner API as of November 2026 ([Hetzner changelog](https://docs.hetzner.cloud/changelog)):
125
139
 
126
- - `list_datacenters` is **removed**, because the endpoint now returns 410 Gone. Use `list_locations`.
127
- - `create_server` no longer accepts `datacenter`, because the API removed it on 2026-07-01. Use `location`.
128
- - `create_primary_ip` takes `location` instead of `datacenter`.
129
- - `delete_load_balancer` now returns the deletion Action.
130
- - `add_network_subnet` no longer offers the deprecated `server` type. Use `cloud`.
131
- - List tools now return every page. Previously they silently stopped at the first 25 items.
132
- - Floating IPs and Primary IPs must be unassigned before you delete them.
133
- - `list_actions` requires `id`, because Hetzner removed project-wide action listing. Use `get_action` to poll.
140
+ - **Locations, not datacenters.** `list_datacenters` is gone, because the endpoint returns 410 Gone. `create_server` and `create_primary_ip` take `location`.
141
+ - **Volumes:** `create_volume` and `attach_volume` send `assignee: {type: "server", id}`, because Hetzner removes the old `server` field on 2027-10-27. Read `assignee` in volume responses.
142
+ - **List tools return every page**, not just the first 25 items.
143
+ - **`list_actions` requires `id`**, because Hetzner removed project-wide action listing. Use `get_action` to poll an Action.
144
+ - **Unassign before deleting.** Floating IPs and Primary IPs must be unassigned before you delete them.
145
+ - **Errors** come back as `code (status): message`, for example `not_found (404): server not found`.
134
146
 
135
147
  Hetzner Robot (dedicated servers) is not covered yet; see [#21](https://github.com/Xodus-CO/hcloud-mcp/issues/21).
136
148
 
149
+ ## Changelog
150
+
151
+ See [GitHub Releases](https://github.com/Xodus-CO/hcloud-mcp/releases) for full notes.
152
+
153
+ - **0.4.1:** README update only (no code changes).
154
+ - **0.4.0:** Removed the Hetzner SDK dependency; every tool now calls the API through one small fetch client. Every tool declares MCP annotations. `create_load_balancer` accepts an existing Primary IP, a network, services and targets.
155
+ - **0.3.1:** Volumes use `assignee`. CI added. (Not published to npm separately; included in 0.4.0.)
156
+ - **0.3.0:** Added DNS, Storage Boxes, certificates, snapshots and backups, rescue and console, metrics, and the remaining server, network and load balancer actions. Added `HCLOUD_TOOLSETS`.
157
+ - **0.2.0:** Updated for 2026 Hetzner API changes (above). Added server instructions and the `hetzner-cloud` skill.
158
+
137
159
  ## Usage examples
138
160
 
139
161
  With the MCP client connected, you can ask the agent to run tools using natural language.
@@ -155,22 +177,25 @@ With the MCP client connected, you can ask the agent to run tools using natural
155
177
 
156
178
  - _Create a private network 10.0.0.0/16 in eu-central, add a subnet, then create two servers in that zone (e.g. fsn1 and nbg1) and attach them_
157
179
  - _Create a firewall for SSH and HTTP, attach to my web servers, then create a load balancer and add those servers as targets_
158
- - _Get status of action 12345_
159
180
  - _Create a Primary IP in ash, power off web-01, assign the IP, power back on_
160
181
  - _Create a 20GB volume and a small server in nbg1, attach the volume to the server, and show me the device path_
161
182
  - _Power off server 12345, change its type to cpx31, then power it back on_
162
183
  - _Add server web-02 as a target to my load balancer prod-lb_
184
+ - _Create a Primary IP in fsn1 and a load balancer that uses it, then add web-01 and web-02 as targets on port 80_
185
+ - _Snapshot web-01 before I rebuild it with Debian 12_
186
+ - _Create a Storage Box subaccount for backups with its own password and SSH access only_
163
187
  - _Tear down: detach/delete volumes, delete LB and firewall, unassign/delete floating IPs, delete servers web-01 and web-02_
164
188
 
165
189
  ## Development
166
190
 
167
191
  | File | Purpose |
168
192
  | ----------------------- | ----------------------------------------------------------- |
169
- | `src/index.ts` | Entry point, stdio transport, `HCLOUD_TOKEN` check |
170
- | `src/register-tools.ts` | Tool definitions and Hetzner API calls (uses SDK McpServer) |
193
+ | `src/index.ts` | Entry point, stdio transport, `HCLOUD_TOKEN` check, `HCLOUD_TOOLSETS` |
194
+ | `src/tool-helpers.ts` | Shared helpers: annotation presets, pagination (`listAll`), error formatting |
195
+ | `src/register-tools.ts` | Core tools: servers, LBs, networks, volumes, firewalls, IPs, SSH keys, info |
171
196
  | `src/extra-tools.ts` | Newer Cloud API endpoints (reverse DNS, rebuild, network members) |
172
- | `src/dns-tools.ts` | DNS zone/RRSet tools (direct API client, not in the SDK) |
173
- | `src/hcloud-api.ts` | Minimal fetch client for endpoints hetzner-sdk-ts lacks |
197
+ | `src/dns-tools.ts` | DNS zone/RRSet tools |
198
+ | `src/hcloud-api.ts` | Minimal fetch client for the Hetzner APIs (no SDK dependency) |
174
199
  | `src/action-gap-tools.ts` | Placement groups, alias IPs, LB network/type/algorithm/public interface, routes, ISOs |
175
200
  | `src/image-tools.ts` | Snapshots, backups, image management, `change_protection` |
176
201
  | `src/server-ops-tools.ts` | Rescue, console, root password, server/LB metrics |
@@ -185,9 +210,9 @@ With the MCP client connected, you can ask the agent to run tools using natural
185
210
  npm run build # compile
186
211
  npm run start # run (requires HCLOUD_TOKEN)
187
212
  npm run dev # watch and recompile
188
- npm run test:api # test list_* Hetzner API calls (requires HCLOUD_TOKEN)
213
+ npm run test:smoke # offline: server starts, 162 tools register with annotations, toolsets work (runs in CI)
214
+ npm run test:api # read-only checks of the API client: pagination, error format (requires HCLOUD_TOKEN, run build first)
189
215
  npm run test:mcp # integration test: MCP client calls list_locations (requires HCLOUD_TOKEN)
190
- npm run audit:api # verify create_* request body shapes (DRY_RUN=1, no resources created)
191
216
  npm run test:live:dns # DNS create→teardown on a throwaway zone (free)
192
217
  npm run test:live:images # snapshots, backups, protection (costs cents)
193
218
  npm run test:live:ops # rescue, console, root password, metrics (costs cents)
@@ -1,66 +1,118 @@
1
1
  import { z } from "zod";
2
2
  import { hcloudRequest } from "./hcloud-api.js";
3
- import { json, listAll, withToolError } from "./tool-helpers.js";
3
+ import { ADDITIVE_IDEMPOTENT, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, json, listAll, withToolError } from "./tool-helpers.js";
4
4
  const action = (path, body) => withToolError(async () => json(await hcloudRequest("POST", path, { body: body ?? {} })));
5
5
  export function registerActionGapTools(server) {
6
6
  // --- Servers ---
7
- server.tool("add_server_to_placement_group", "Add a server to a placement group. The server must be powered off (422 server_not_stopped) and not already in a placement group (422 already_in_placement_group). Returns an Action", {
8
- id: z.number().describe("Server ID"),
9
- placement_group: z.number().describe("Placement group ID"),
7
+ server.registerTool("add_server_to_placement_group", {
8
+ description: "Add a server to a placement group. The server must be powered off (422 server_not_stopped) and not already in a placement group (422 already_in_placement_group). Returns an Action",
9
+ inputSchema: {
10
+ id: z.number().describe("Server ID"),
11
+ placement_group: z.number().describe("Placement group ID"),
12
+ },
13
+ annotations: ADDITIVE_IDEMPOTENT,
10
14
  }, async ({ id, placement_group }) => action(`/servers/${id}/actions/add_to_placement_group`, { placement_group }));
11
- server.tool("remove_server_from_placement_group", "Remove a server from its placement group. Returns an Action", { id: z.number().describe("Server ID") }, async ({ id }) => action(`/servers/${id}/actions/remove_from_placement_group`));
12
- server.tool("change_server_alias_ips", "Set the alias IPs of a server on a network it is already attached to. REPLACES the existing alias list for that network: to add one, pass the current alias_ips (get_server private_net) plus the new IP; pass [] to remove all. Returns an Action", {
13
- id: z.number().describe("Server ID"),
14
- network: z.number().describe("ID of a network already attached to the server"),
15
- alias_ips: z.array(z.string()).describe("Complete new list of alias IPs, e.g. [\"10.0.1.50\"]"),
15
+ server.registerTool("remove_server_from_placement_group", {
16
+ description: "Remove a server from its placement group. Returns an Action",
17
+ inputSchema: { id: z.number().describe("Server ID") },
18
+ annotations: DESTRUCTIVE_IDEMPOTENT,
19
+ }, async ({ id }) => action(`/servers/${id}/actions/remove_from_placement_group`));
20
+ server.registerTool("change_server_alias_ips", {
21
+ description: "Set the alias IPs of a server on a network it is already attached to. REPLACES the existing alias list for that network: to add one, pass the current alias_ips (get_server private_net) plus the new IP; pass [] to remove all. Returns an Action",
22
+ inputSchema: {
23
+ id: z.number().describe("Server ID"),
24
+ network: z.number().describe("ID of a network already attached to the server"),
25
+ alias_ips: z.array(z.string()).describe("Complete new list of alias IPs, e.g. [\"10.0.1.50\"]"),
26
+ },
27
+ annotations: DESTRUCTIVE_IDEMPOTENT,
16
28
  }, async ({ id, network, alias_ips }) => action(`/servers/${id}/actions/change_alias_ips`, { network, alias_ips }));
17
29
  // --- Load balancers ---
18
- server.tool("attach_load_balancer_to_network", "Attach a load balancer to a network (one network per load balancer). Optionally request a specific private ip, or ip_range to auto-assign from a specific subnet; ip must lie within ip_range if both are given. Returns an Action", {
19
- id: z.number().describe("Load balancer ID"),
20
- network: z.number().describe("Network ID"),
21
- ip: z.string().optional().describe("Private IP to assign; auto-assigned if omitted"),
22
- ip_range: z.string().optional().describe("Subnet ip_range (CIDR) to auto-assign the IP from, e.g. 10.0.1.0/24"),
30
+ server.registerTool("attach_load_balancer_to_network", {
31
+ description: "Attach a load balancer to a network (one network per load balancer). Optionally request a specific private ip, or ip_range to auto-assign from a specific subnet; ip must lie within ip_range if both are given. Returns an Action",
32
+ inputSchema: {
33
+ id: z.number().describe("Load balancer ID"),
34
+ network: z.number().describe("Network ID"),
35
+ ip: z.string().optional().describe("Private IP to assign; auto-assigned if omitted"),
36
+ ip_range: z.string().optional().describe("Subnet ip_range (CIDR) to auto-assign the IP from, e.g. 10.0.1.0/24"),
37
+ },
38
+ annotations: ADDITIVE_IDEMPOTENT,
23
39
  }, async ({ id, network, ip, ip_range }) => action(`/load_balancers/${id}/actions/attach_to_network`, { network, ip, ip_range }));
24
- server.tool("detach_load_balancer_from_network", "Detach a load balancer from a network. Re-enable the public interface first if it was disabled, or the load balancer becomes unreachable. Returns an Action", {
25
- id: z.number().describe("Load balancer ID"),
26
- network: z.number().describe("Network ID"),
40
+ server.registerTool("detach_load_balancer_from_network", {
41
+ description: "Detach a load balancer from a network. Re-enable the public interface first if it was disabled, or the load balancer becomes unreachable. Returns an Action",
42
+ inputSchema: {
43
+ id: z.number().describe("Load balancer ID"),
44
+ network: z.number().describe("Network ID"),
45
+ },
46
+ annotations: DESTRUCTIVE_IDEMPOTENT,
27
47
  }, async ({ id, network }) => action(`/load_balancers/${id}/actions/detach_from_network`, { network }));
28
- server.tool("change_load_balancer_algorithm", "Change how a load balancer distributes new requests across targets. Returns an Action", {
29
- id: z.number().describe("Load balancer ID"),
30
- type: z.enum(["round_robin", "least_connections"]),
48
+ server.registerTool("change_load_balancer_algorithm", {
49
+ description: "Change how a load balancer distributes new requests across targets. Returns an Action",
50
+ inputSchema: {
51
+ id: z.number().describe("Load balancer ID"),
52
+ type: z.enum(["round_robin", "least_connections"]),
53
+ },
54
+ annotations: ADDITIVE_IDEMPOTENT,
31
55
  }, async ({ id, type }) => action(`/load_balancers/${id}/actions/change_algorithm`, { type }));
32
- server.tool("change_load_balancer_type", "Change a load balancer's type (max services / targets / connections; price changes accordingly — check get_pricing). Fails with invalid_load_balancer_type if the current config exceeds the new type's limits. Returns an Action", {
33
- id: z.number().describe("Load balancer ID"),
34
- load_balancer_type: z.string().describe("Type name or ID, e.g. lb11, lb21, lb31"),
56
+ server.registerTool("change_load_balancer_type", {
57
+ description: "Change a load balancer's type (max services / targets / connections; price changes accordingly — check get_pricing). Fails with invalid_load_balancer_type if the current config exceeds the new type's limits. Returns an Action",
58
+ inputSchema: {
59
+ id: z.number().describe("Load balancer ID"),
60
+ load_balancer_type: z.string().describe("Type name or ID, e.g. lb11, lb21, lb31"),
61
+ },
62
+ annotations: DESTRUCTIVE_IDEMPOTENT,
35
63
  }, async ({ id, load_balancer_type }) => action(`/load_balancers/${id}/actions/change_type`, { load_balancer_type }));
36
- server.tool("enable_load_balancer_public_interface", "Enable a load balancer's public interface so it is reachable from the internet via its public IPs. Returns an Action", { id: z.number().describe("Load balancer ID") }, async ({ id }) => action(`/load_balancers/${id}/actions/enable_public_interface`));
37
- server.tool("disable_load_balancer_public_interface", "Disable a load balancer's public interface (private-network only). Requires the load balancer to be attached to a network (load_balancer_not_attached_to_network) and all targets to use_private_ip (targets_without_use_private_ip). Returns an Action", { id: z.number().describe("Load balancer ID") }, async ({ id }) => action(`/load_balancers/${id}/actions/disable_public_interface`));
64
+ server.registerTool("enable_load_balancer_public_interface", {
65
+ description: "Enable a load balancer's public interface so it is reachable from the internet via its public IPs. Returns an Action",
66
+ inputSchema: { id: z.number().describe("Load balancer ID") },
67
+ annotations: ADDITIVE_IDEMPOTENT,
68
+ }, async ({ id }) => action(`/load_balancers/${id}/actions/enable_public_interface`));
69
+ server.registerTool("disable_load_balancer_public_interface", {
70
+ description: "Disable a load balancer's public interface (private-network only). Requires the load balancer to be attached to a network (load_balancer_not_attached_to_network) and all targets to use_private_ip (targets_without_use_private_ip). Returns an Action",
71
+ inputSchema: { id: z.number().describe("Load balancer ID") },
72
+ annotations: DESTRUCTIVE_IDEMPOTENT,
73
+ }, async ({ id }) => action(`/load_balancers/${id}/actions/disable_public_interface`));
38
74
  // --- Networks ---
39
- server.tool("add_network_route", "Add a route to a network: traffic for destination is sent to gateway. destination must be an RFC1918 range or 0.0.0.0/0 and must not overlap subnets or other routes; gateway must be an IP inside the network (not its first IP, not 172.31.1.1). Returns an Action", {
40
- id: z.number().describe("Network ID"),
41
- destination: z.string().describe("Destination CIDR, e.g. 10.100.1.0/24 or 0.0.0.0/0"),
42
- gateway: z.string().describe("Gateway IP inside the network, e.g. a server's private IP 10.0.1.2"),
75
+ server.registerTool("add_network_route", {
76
+ description: "Add a route to a network: traffic for destination is sent to gateway. destination must be an RFC1918 range or 0.0.0.0/0 and must not overlap subnets or other routes; gateway must be an IP inside the network (not its first IP, not 172.31.1.1). Returns an Action",
77
+ inputSchema: {
78
+ id: z.number().describe("Network ID"),
79
+ destination: z.string().describe("Destination CIDR, e.g. 10.100.1.0/24 or 0.0.0.0/0"),
80
+ gateway: z.string().describe("Gateway IP inside the network, e.g. a server's private IP 10.0.1.2"),
81
+ },
82
+ annotations: ADDITIVE_IDEMPOTENT,
43
83
  }, async ({ id, destination, gateway }) => action(`/networks/${id}/actions/add_route`, { destination, gateway }));
44
- server.tool("delete_network_route", "Delete a route from a network. destination and gateway must match the existing route exactly (see get_network routes). Returns an Action", {
45
- id: z.number().describe("Network ID"),
46
- destination: z.string().describe("Destination CIDR of the route"),
47
- gateway: z.string().describe("Gateway IP of the route"),
84
+ server.registerTool("delete_network_route", {
85
+ description: "Delete a route from a network. destination and gateway must match the existing route exactly (see get_network routes). Returns an Action",
86
+ inputSchema: {
87
+ id: z.number().describe("Network ID"),
88
+ destination: z.string().describe("Destination CIDR of the route"),
89
+ gateway: z.string().describe("Gateway IP of the route"),
90
+ },
91
+ annotations: DESTRUCTIVE_IDEMPOTENT,
48
92
  }, async ({ id, destination, gateway }) => action(`/networks/${id}/actions/delete_route`, { destination, gateway }));
49
- server.tool("change_network_ip_range", "Change a network's IP range. Can only be extended by shortening the netmask with the same base address (10.0.0.0/16 -> 10.0.0.0/15), never shrunk. The network must have NO attached servers or load balancers (detach them first). Returns an Action", {
50
- id: z.number().describe("Network ID"),
51
- ip_range: z.string().describe("New range in CIDR, same start IP as the current range, e.g. 10.0.0.0/15"),
93
+ server.registerTool("change_network_ip_range", {
94
+ description: "Change a network's IP range. Can only be extended by shortening the netmask with the same base address (10.0.0.0/16 -> 10.0.0.0/15), never shrunk. The network must have NO attached servers or load balancers (detach them first). Returns an Action",
95
+ inputSchema: {
96
+ id: z.number().describe("Network ID"),
97
+ ip_range: z.string().describe("New range in CIDR, same start IP as the current range, e.g. 10.0.0.0/15"),
98
+ },
99
+ annotations: ADDITIVE_IDEMPOTENT,
52
100
  }, async ({ id, ip_range }) => action(`/networks/${id}/actions/change_ip_range`, { ip_range }));
53
101
  // --- ISOs ---
54
- server.tool("list_isos", "List ISOs available to attach_iso (public and private). name is an exact match. architecture filters x86/arm; include_architecture_wildcard (requires architecture) also includes ISOs with no architecture. Check deprecation before use. All pages", {
55
- name: z.string().optional().describe("Exact ISO name"),
56
- architecture: z.enum(["x86", "arm"]).optional(),
57
- include_architecture_wildcard: z.boolean().optional()
58
- .describe("Also include ISOs with architecture null; only valid together with architecture"),
102
+ server.registerTool("list_isos", {
103
+ description: "List ISOs available to attach_iso (public and private). name is an exact match. architecture filters x86/arm; include_architecture_wildcard (requires architecture) also includes ISOs with no architecture. Check deprecation before use. All pages",
104
+ inputSchema: {
105
+ name: z.string().optional().describe("Exact ISO name"),
106
+ architecture: z.enum(["x86", "arm"]).optional(),
107
+ include_architecture_wildcard: z.boolean().optional()
108
+ .describe("Also include ISOs with architecture null; only valid together with architecture"),
109
+ },
110
+ annotations: READ_ONLY,
59
111
  }, async (filters) => withToolError(async () => {
60
112
  if (filters.include_architecture_wildcard !== undefined && !filters.architecture) {
61
113
  throw new Error("include_architecture_wildcard requires architecture");
62
114
  }
63
- const isos = await listAll((p) => hcloudRequest("GET", "/isos", { query: { ...filters, page: p.page, per_page: p.perPage } }), "isos");
115
+ const isos = await listAll((p) => hcloudRequest("GET", "/isos", { query: { ...filters, ...p } }), "isos");
64
116
  return json(isos);
65
117
  }));
66
118
  }
@@ -1,6 +1,6 @@
1
1
  import { z } from "zod";
2
2
  import { hcloudRequest } from "./hcloud-api.js";
3
- import { json, listAll, withToolError } from "./tool-helpers.js";
3
+ import { ADDITIVE, ADDITIVE_IDEMPOTENT, DESTRUCTIVE_IDEMPOTENT, READ_ONLY, json, listAll, withToolError } from "./tool-helpers.js";
4
4
  const certId = z.number().int().describe("Certificate ID");
5
5
  const certType = z.enum(["uploaded", "managed"]);
6
6
  const labels = z.record(z.string());
@@ -10,27 +10,39 @@ const MANAGED_REQUIREMENTS = "Managed (Let's Encrypt) certificates are validated
10
10
  "caa_record_does_not_allow_ca, ca_dns_validation_failed, Let's Encrypt rate limits";
11
11
  const USAGE = "Certificates are referenced by ID in Load Balancer HTTPS services: http.certificates in add_load_balancer_service / update_load_balancer_service";
12
12
  export function registerCertificateTools(server) {
13
- server.tool("list_certificates", "List TLS certificates (all pages). Optional filters: name, label_selector, type. Each includes domain_names, not_valid_after, fingerprint, managed status and used_by (load balancers using it)", {
14
- name: z.string().optional().describe("Exact certificate name"),
15
- label_selector: z.string().optional().describe("Label selector, e.g. env=prod"),
16
- type: z.array(certType).optional().describe("Filter by type(s)"),
13
+ server.registerTool("list_certificates", {
14
+ description: "List TLS certificates (all pages). Optional filters: name, label_selector, type. Each includes domain_names, not_valid_after, fingerprint, managed status and used_by (load balancers using it)",
15
+ inputSchema: {
16
+ name: z.string().optional().describe("Exact certificate name"),
17
+ label_selector: z.string().optional().describe("Label selector, e.g. env=prod"),
18
+ type: z.array(certType).optional().describe("Filter by type(s)"),
19
+ },
20
+ annotations: READ_ONLY,
17
21
  }, async (args) => withToolError(async () => {
18
- const certs = await listAll((p) => hcloudRequest("GET", "/certificates", { query: { ...args, page: p.page, per_page: p.perPage } }), "certificates");
22
+ const certs = await listAll((p) => hcloudRequest("GET", "/certificates", { query: { ...args, ...p } }), "certificates");
19
23
  return json(certs);
20
24
  }));
21
- server.tool("get_certificate", "Get a TLS certificate: PEM chain (public), domain_names, validity window, fingerprint, used_by, and for managed certs status.issuance / status.renewal / status.error", { id: certId }, async ({ id }) => withToolError(async () => json((await hcloudRequest("GET", `/certificates/${id}`)).certificate)));
22
- server.tool("create_certificate", "Create a TLS certificate. type \"uploaded\" (default): provide certificate (PEM, leaf first then chain) and private_key (PEM); " +
23
- "supported keys RSA 2048/3072/4096 or ECDSA P-256/P-384; you must renew it yourself before not_valid_after. " +
24
- "type \"managed\": provide domain_names; Hetzner requests and auto-renews a Let's Encrypt cert. " +
25
- MANAGED_REQUIREMENTS +
26
- ". Returns {certificate, action}: action tracks managed issuance (poll get_action), null for uploaded. " +
27
- USAGE, {
28
- name: z.string().describe("Unique name within the project"),
29
- type: certType.default("uploaded"),
30
- certificate: z.string().optional().describe("uploaded only: certificate + chain in PEM, each cert certifying the preceding one"),
31
- private_key: z.string().optional().describe("uploaded only: private key in PEM. Sent to the API only; never returned"),
32
- domain_names: z.array(z.string()).optional().describe('managed only: domains to include, e.g. ["example.com", "www.example.com"]'),
33
- labels: labels.optional(),
25
+ server.registerTool("get_certificate", {
26
+ description: "Get a TLS certificate: PEM chain (public), domain_names, validity window, fingerprint, used_by, and for managed certs status.issuance / status.renewal / status.error",
27
+ inputSchema: { id: certId },
28
+ annotations: READ_ONLY,
29
+ }, async ({ id }) => withToolError(async () => json((await hcloudRequest("GET", `/certificates/${id}`)).certificate)));
30
+ server.registerTool("create_certificate", {
31
+ description: "Create a TLS certificate. type \"uploaded\" (default): provide certificate (PEM, leaf first then chain) and private_key (PEM); " +
32
+ "supported keys RSA 2048/3072/4096 or ECDSA P-256/P-384; you must renew it yourself before not_valid_after. " +
33
+ "type \"managed\": provide domain_names; Hetzner requests and auto-renews a Let's Encrypt cert. " +
34
+ MANAGED_REQUIREMENTS +
35
+ ". Returns {certificate, action}: action tracks managed issuance (poll get_action), null for uploaded. " +
36
+ USAGE,
37
+ inputSchema: {
38
+ name: z.string().describe("Unique name within the project"),
39
+ type: certType.default("uploaded"),
40
+ certificate: z.string().optional().describe("uploaded only: certificate + chain in PEM, each cert certifying the preceding one"),
41
+ private_key: z.string().optional().describe("uploaded only: private key in PEM. Sent to the API only; never returned"),
42
+ domain_names: z.array(z.string()).optional().describe('managed only: domains to include, e.g. ["example.com", "www.example.com"]'),
43
+ labels: labels.optional(),
44
+ },
45
+ annotations: ADDITIVE,
34
46
  }, async (args) => withToolError(async () => {
35
47
  const { name, type, certificate, private_key, domain_names, labels } = args;
36
48
  let body;
@@ -50,16 +62,28 @@ export function registerCertificateTools(server) {
50
62
  }
51
63
  return json(await hcloudRequest("POST", "/certificates", { body }));
52
64
  }));
53
- server.tool("update_certificate", "Rename a certificate and/or replace its labels (labels overwrite the whole set). The certificate content cannot be changed; to rotate an uploaded cert, create a new one, point the load balancer service at it, then delete the old one", { id: certId, name: z.string().optional(), labels: labels.optional() }, async ({ id, name, labels }) => withToolError(async () => {
65
+ server.registerTool("update_certificate", {
66
+ description: "Rename a certificate and/or replace its labels (labels overwrite the whole set). The certificate content cannot be changed; to rotate an uploaded cert, create a new one, point the load balancer service at it, then delete the old one",
67
+ inputSchema: { id: certId, name: z.string().optional(), labels: labels.optional() },
68
+ annotations: ADDITIVE_IDEMPOTENT,
69
+ }, async ({ id, name, labels }) => withToolError(async () => {
54
70
  if (name === undefined && labels === undefined)
55
71
  throw new Error("Provide name and/or labels");
56
72
  return json((await hcloudRequest("PUT", `/certificates/${id}`, { body: { name, labels } })).certificate);
57
73
  }));
58
- server.tool("delete_certificate", "Delete a certificate. Irreversible; confirm with the user first. Check used_by (get_certificate) first: load balancer HTTPS services referencing it should be switched to another certificate", { id: certId }, async ({ id }) => withToolError(async () => {
74
+ server.registerTool("delete_certificate", {
75
+ description: "Delete a certificate. Irreversible; confirm with the user first. Check used_by (get_certificate) first: load balancer HTTPS services referencing it should be switched to another certificate",
76
+ inputSchema: { id: certId },
77
+ annotations: DESTRUCTIVE_IDEMPOTENT,
78
+ }, async ({ id }) => withToolError(async () => {
59
79
  await hcloudRequest("DELETE", `/certificates/${id}`);
60
80
  return json({ deleted: id });
61
81
  }));
62
- server.tool("retry_certificate", "Retry a failed issuance or renewal of a managed certificate (only when status.issuance or status.renewal is \"failed\"; see status.error for the cause and fix it first). " +
63
- MANAGED_REQUIREMENTS +
64
- ". Returns an Action (poll get_action)", { id: certId }, async ({ id }) => withToolError(async () => json(await hcloudRequest("POST", `/certificates/${id}/actions/retry`))));
82
+ server.registerTool("retry_certificate", {
83
+ description: "Retry a failed issuance or renewal of a managed certificate (only when status.issuance or status.renewal is \"failed\"; see status.error for the cause and fix it first). " +
84
+ MANAGED_REQUIREMENTS +
85
+ ". Returns an Action (poll get_action)",
86
+ inputSchema: { id: certId },
87
+ annotations: ADDITIVE,
88
+ }, async ({ id }) => withToolError(async () => json(await hcloudRequest("POST", `/certificates/${id}/actions/retry`))));
65
89
  }