DEV Community

Cover image for How to Connect Claude to Hetzner Cloud
Marco Starker
Marco Starker

Posted on Originally published at marco-starker.de

How to Connect Claude to Hetzner Cloud

In short

Claude talks to other services through MCP servers. For Hetzner I use my own, hetzner-mcp. It runs as a Docker container, queries the Hetzner Cloud API with an API token and is read-only by default. Claude can then tell you what runs in your project and what it costs per month.

In five steps:

  1. create an API token with read permission in the Hetzner Console
  2. start hetzner-mcp with Docker
  3. make it reachable via HTTPS and lock it down
  4. add it to Claude as a custom connector
  5. test it

After that you can ask Claude things like: "What do my Hetzner servers cost per month?"

What Claude can do with it

hetzner-mcp brings the tools of @lazyants/hetzner-mcp-server to Claude over HTTP: servers, networks, firewalls, IPs, volumes, Storage Boxes, DNS zones and prices. That is 185 tools in total, 59 of them read-only. By default only the read-only ones are active.

Note: The Hetzner Cloud API has no invoices. Claude calculates the costs from your inventory and the price list (hetzner_get_pricing).

What you need

  • a server with Docker that is reachable from the internet
  • a domain or subdomain with a TLS certificate, e.g. behind a reverse proxy such as Nginx Proxy Manager
  • access to your project in the Hetzner Console

1. Create an API token

  1. Open the project in the Hetzner Console.
  2. Security → API tokens → Generate API token.
  3. Choose the permission Read. That is enough for the default mode.
  4. Copy the token. Hetzner shows it only once.

A token is always valid for exactly one project. If you have several projects, start one container per project, each with its own port and connector.

2. Start hetzner-mcp

Create a compose.yaml and put the token into a .env next to it (HETZNER_API_TOKEN=...):

services:
  hetzner-mcp:
    image:     ghcr.io/dasred/hetzner-mcp:1
    restart:   unless-stopped
    read_only: true
    cap_drop:
      - ALL
    security_opt:
      - no-new-privileges:true
    environment:
      HETZNER_API_TOKEN: ${HETZNER_API_TOKEN}
      MCP_READ_ONLY:     'true'
    ports:
      - '127.0.0.1:3000:3000'
Enter fullscreen mode Exit fullscreen mode
docker compose up -d
curl http://localhost:3000/healthz
Enter fullscreen mode Exit fullscreen mode

The answer is {"status":"ok"}. The server stores nothing, so read_only: true and cap_drop: ALL work without volumes.

3. Make it reachable via HTTPS and lock it down

Custom connectors in Claude connect from Anthropic's servers, not from your machine. Add a host to your reverse proxy, e.g. hetzner.mcp.example.com, that points to port 3000 of the container, with a TLS certificate. The MCP endpoint is then https://hetzner.mcp.example.com/mcp.

Anyone who reaches this endpoint can call every active tool with your token. Claude's connectors cannot send custom headers, so a bearer token does not help for the Claude apps. Protect the host at the reverse proxy with an IP allowlist: only Anthropic's outbound IP addresses and your own network. In Nginx Proxy Manager this is an access list.

4. Add it to Claude

  1. In Claude, open Settings → Connectors → Add custom connector.
  2. Name: e.g. Hetzner.
  3. URL: https://hetzner.mcp.example.com/mcp
  4. Save.

In Claude Code there is a command, which can also send a bearer token if MCP_AUTH_TOKEN is set on the server:

claude mcp add --transport http hetzner https://hetzner.mcp.example.com/mcp \
  --header "Authorization: Bearer your-mcp-auth-token"
Enter fullscreen mode Exit fullscreen mode

5. Test it

Ask Claude, for example:

  • "Which servers are running in my Hetzner project?"
  • "What do my Hetzner servers cost per month?"
  • "Show me the rules of the firewall of web-1."

Claude calls hetzner_list_servers, hetzner_get_pricing or hetzner_list_firewalls for this.

Should Claude change things as well?

With MCP_READ_ONLY=false and a token with Read & Write, Claude can create, restart and delete servers, change firewalls and DNS records and much more. New resources cost money, deleted servers are gone. Only turn this on if you really need it, and narrow it down, e.g. with MCP_TOOLS_DENY=hetzner_delete_*,hetzner_rebuild_server. With MCP_SPLITS you also load only the tool groups you need. All filters are listed under Configuration.

If it doesn't work

Symptom Cause
The connector does not connect The server is not publicly reachable, or the reverse proxy blocks Anthropic's IPs.
405 Method not allowed Normal for a GET in the browser. The server only accepts POST on /mcp.
Hetzner error unauthorized The token is wrong, deleted or belongs to another project.
Tools are missing MCP_READ_ONLY, MCP_SPLITS or the allow and deny lists filter them out.
New tools don't show up Disconnect the connector in Claude once and connect it again to reload the tool list.

Everything else is in the hetzner-mcp docs, the background in my article about four MCP servers in nine days.

Top comments (0)