Read from the Hetzner API
hetzner_queryRun read-only JavaScript against Hetzner Cloud and Robot APIs to chain GET requests and filter responses in code, returning only the fields you need.
Instructions
Run JavaScript that reads from the Hetzner API. Only GET requests are possible, so nothing can be changed. Chain several calls and filter the data in the code instead of returning whole responses.
Globals available in the code:
hetzner.request({ method = 'GET', path, query?, body?, api? }) -> parsed JSON body (null if empty)
hetzner.get(path, query?) / hetzner.post(path, body?) / hetzner.put(path, body?) / hetzner.delete(path)
hetzner.paginate(path, query?, { maxPages = 50 }?) -> all items of a list endpoint across pages
hetzner.waitForAction(actionOrResponse, { timeoutMs = 90000 }?) -> finished action, throws if it failed
sleep(ms), console.log(...)
robot.get(path, query?) / robot.post(path, body?) / robot.put(path, body?) / robot.delete(path) / robot.request({...})
Paths are relative to the API root, e.g. "/servers/123" (no host, no /v1). Storage Box paths are routed
to api.hetzner.com automatically. Array query values become repeated keys. Failed calls throw an Error
with .status, .code and .details. No fetch, require or other network access exists.
Every request is checked against the API reference before it is sent (operation exists, known query and
body fields, required fields, types, enum values); a mismatch throws with code "validation_failed" and
nothing is sent. Only if the reference itself is wrong: hetzner.request({ ..., validate: false }).
hetzner is the Cloud API of the selected project. robot is the Robot webservice for dedicated servers
(NOT available: no Robot webservice user is configured); it is account-wide and ignores project. Robot paths
are singular ("/server", "/firewall/{server-number}"), have no pagination and no actions, and are rate
limited per endpoint (see "Request limit" in describe()). Pass Robot bodies as plain objects; they are
sent form-encoded, nested values become rules[input][0][action]=accept.
Examples: async () => (await hetzner.paginate('/servers')).map(s => ({ id: s.id, name: s.name, status: s.status, type: s.server_type.name, ip: s.public_net.ipv4?.ip, location: s.datacenter?.location?.name })) async () => (await hetzner.get('/servers', { label_selector: 'env=prod', status: ['running'] })).servers.length async () => (await robot.get('/server')).map(({ server: s }) => ({ number: s.server_number, name: s.server_name, ip: s.server_ip, product: s.product, dc: s.dc })) async () => (await robot.get('/firewall/321')).firewall async () => { const [servers, volumes] = await Promise.all([hetzner.paginate('/servers'), hetzner.paginate('/volumes')]); return volumes.filter(v => !v.server).map(v => ({ id: v.id, name: v.name, size: v.size })); }
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>"
},
"name": "hetzner_query"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | JavaScript: an async arrow function whose return value is the result. Return only the fields you need. | |
| project | No | Hetzner Cloud project to use. Only needed when several projects are available. |