Skip to main content
Glama
hetzner-mcp-server

hetzner-mcp-server

by nityeshaga

Hetzner MCP Server

npm version

An MCP server that lets Claude Code manage your Hetzner Cloud servers.

npm install -g hetzner-mcp-server

What is MCP?

MCP (Model Context Protocol) is a way for AI assistants like Claude to interact with external services and APIs. Think of it like giving Claude "hands" to do things on your behalf.

How it works:

  1. You install an MCP server (like this one) on your computer

  2. You configure Claude Code to use it

  3. Claude can now use "tools" that the MCP server provides

  4. When you ask Claude to "create a server", it uses these tools to actually do it

Your understanding is correct: MCP exposes certain API capabilities as tool calls for the AI agent. The AI can then decide when to use these tools to help you accomplish tasks.


Related MCP server: MCP SSH Server

What is Hetzner Cloud?

Hetzner is a cloud hosting provider (like AWS, DigitalOcean, or Linode) where you can rent virtual servers. You pay by the hour for the servers you use.

What is a "Project" in Hetzner?

A Project is like a folder or container that groups related resources together. When you sign up for Hetzner Cloud:

  1. You create Projects to organize your work (e.g., "My Blog", "Client Website", "Test Environment")

  2. Inside each project, you create Servers (the actual virtual machines)

  3. Each project also contains related resources: SSH keys, firewall rules, networks, etc.

Example: You might have:

  • Project "Personal Blog" → 1 server running your blog

  • Project "Client Work" → 3 servers for different client websites

  • Project "Testing" → Temporary servers you spin up and delete

Each project is completely separate - servers in one project can't see servers in another.


What Can This MCP Do?

It CAN:

  • Create servers (this costs money!)

  • Delete servers (permanent, irreversible)

  • Power on/off servers (like pressing the power button)

  • Reboot servers

  • List all your servers and see their details (IP address, status, specs)

  • Manage SSH keys (the keys used to log into your servers)

  • Show available options (server sizes, OS images, datacenter locations)

It CANNOT:

  • Create new Projects (you do that manually in the Hetzner web console)

  • Manage billing or payment methods

  • Access other projects (it only sees the project whose token you provide)

  • Manage advanced features like load balancers, volumes, or firewalls (not implemented yet)

Important: This Can Spend Your Money!

When you create a server through this MCP, Hetzner will charge you real money. Servers are billed hourly. For example:

  • A small cx22 server costs €0.006/hour (€4/month)

  • A larger cx52 server costs €0.119/hour (€86/month)

Always check pricing with hetzner_list_server_types before creating servers, and delete servers you're not using to avoid charges.


Hetzner MCP + Kamal = Your Own PaaS

Combine this MCP with Kamal (DHH's deployment tool) and the kamal-deploy skill to get a complete deployment platform inside Claude Code.

The mental model:

  • Hetzner MCP = Provisions the servers (the computers)

  • Kamal = Deploys your app to those servers (the software)

  • Together = Your own Vercel/Render/Hatchbox alternative

Feature Comparison

Feature

Hetzner MCP + Kamal

Hatchbox

Vercel

Render

Create/manage servers

✅ Via MCP

✅ Web UI

❌ Serverless

✅ Managed

Deploy apps

✅ Kamal

✅ Git push

✅ Git push

✅ Git push

Zero-downtime deploys

✅

✅

✅

✅

SSL certificates

✅ Let's Encrypt

✅ Auto

✅ Auto

✅ Auto

Databases

✅ Kamal accessories

✅ Managed

❌ External

✅ Managed

Redis

✅ Kamal accessories

✅ Managed

❌ External

✅ Managed

Background jobs

✅ Kamal workers

✅ Sidekiq

⚠️ Cron only

✅ Workers

Rollback

✅ kamal rollback

✅ One-click

✅ One-click

✅ One-click

Custom domains

✅

✅

✅

✅

SSH access to server

✅ Full root

✅ Limited

❌ None

❌ None

Docker support

✅ Native

❌ No

✅ Yes

✅ Yes

Non-Ruby apps

✅ Any Docker app

❌ Ruby only

✅ Any

✅ Any

Multiple apps per server

✅ Manual

✅ Clusters

N/A

N/A

Web UI dashboard

❌ CLI only

✅

✅

✅

Automatic backups

❌ DIY

✅

N/A

✅

Managed security updates

❌ DIY

✅

✅

✅

Monitoring/alerts

❌ DIY

✅

✅

✅

Cost Comparison (typical Rails app)

Platform

Monthly Cost

What You Get

Hetzner + Kamal

~€4-8/mo

Full server, unlimited apps

Hatchbox

$10-29/mo + server

Managed Rails deployment

Vercel

$20+/mo

Serverless, limited compute

Render

$7-25/mo per service

Managed containers

When to Use What

Choose Hetzner MCP + Kamal if you:

  • Want full control over your infrastructure

  • Are comfortable with CLI (Claude helps!)

  • Want the cheapest option for production apps

  • Need to run any Docker-based app (not just Rails)

  • Want to learn how deployment actually works

Choose Hatchbox if you:

  • Only deploy Rails apps

  • Want a polished web UI

  • Need team access management

  • Prefer fully managed backups/updates

  • Don't want to think about servers

Choose Vercel if you:

  • Build Next.js/frontend apps

  • Want zero server management

  • Need edge functions/CDN

  • Don't need persistent servers

Choose Render if you:

  • Want managed containers without complexity

  • Need managed databases included

  • Want simple scaling

  • Prefer web UI over CLI

Quick Start with Kamal

  1. Install the kamal-deploy skill from claude-code-essentials

  2. Ask Claude: "Create a cx22 server with Ubuntu for my-app" (uses this MCP)

  3. Ask Claude: "Help me set up Kamal to deploy my Rails app to this server"

  4. Run kamal setup and you're live!


How Authentication Works

The API Token

To use Hetzner's API, you need an API Token. This is like a password that:

  1. Proves you are who you say you are

  2. Grants access to a specific project

  3. Has permission levels (read-only or read+write)

One token = One project. If you have 3 projects and want Claude to manage all of them, you'd need 3 different tokens (and 3 MCP configurations).

Token Permissions

When you create a token, you choose its permissions:

  • Read: Can view servers, list resources, but can't change anything

  • Read & Write: Can view AND create/delete/modify resources

For this MCP to be useful, you need Read & Write permissions.

Security Considerations

Your API token is powerful - anyone with it can create/delete servers in your project. Keep it safe:

  1. Never share your token or commit it to git

  2. Store it in environment variables, not in code

  3. Use a dedicated project for testing so mistakes don't affect production

  4. Delete unused tokens in the Hetzner console

  5. Review what Claude is doing before confirming destructive actions


Getting an API Token

  1. Go to Hetzner Cloud Console

  2. Click on the project you want to manage (or create a new one)

  3. In the left sidebar, click Security

  4. Click API Tokens

  5. Click Generate API Token

  6. Enter a name (e.g., "Claude Code MCP")

  7. Select Read & Write permissions

  8. Click Generate API Token

  9. Copy the token immediately - it won't be shown again!


Installation

Prerequisites

  • Node.js 18 or higher

  • npm

  • A Hetzner Cloud account with an API token

npm install -g hetzner-mcp-server

Then configure Claude Code to use it (see below).

Option 2: Clone and Build

# Clone the repository
git clone https://github.com/nityeshaga/hetzner-mcp-server.git
cd hetzner-mcp-server

# Install dependencies
npm install

# Build the TypeScript code
npm run build

Configuring Claude Code

Add the MCP server config to ~/.claude.json (your user-level Claude Code config file).

Important: The config goes in ~/.claude.json, NOT ~/.claude/settings.json or ~/.claude/.mcp.json. Run /mcp in Claude Code to verify the correct config location for your setup.

If installed via npm (Option 1):

Open ~/.claude.json and add hetzner to the mcpServers object:

{
  "mcpServers": {
    "hetzner": {
      "type": "stdio",
      "command": "npx",
      "args": ["hetzner-mcp-server"],
      "env": {
        "HETZNER_API_TOKEN": "your-api-token-here"
      }
    }
  }
}

If you already have other MCP servers configured (like figma), just add hetzner alongside them:

{
  "mcpServers": {
    "figma": { ... },
    "hetzner": {
      "type": "stdio",
      "command": "npx",
      "args": ["hetzner-mcp-server"],
      "env": {
        "HETZNER_API_TOKEN": "your-api-token-here"
      }
    }
  }
}

If cloned from GitHub (Option 2):

{
  "mcpServers": {
    "hetzner": {
      "type": "stdio",
      "command": "node",
      "args": ["/path/to/hetzner-mcp-server/dist/index.js"],
      "env": {
        "HETZNER_API_TOKEN": "your-api-token-here"
      }
    }
  }
}

Replace /path/to/hetzner-mcp-server with the actual path where you cloned the repo.

Replace your-api-token-here with your actual Hetzner API token.

Then restart Claude Code for the changes to take effect.


Using the MCP

Once configured, you can talk to Claude naturally:

Viewing Resources

  • "List all my servers"

  • "Show me server 12345"

  • "What SSH keys do I have?"

  • "What server types are available and how much do they cost?"

  • "What locations can I deploy to?"

  • "What OS images are available?"

Creating Servers

  • "Create a new server called my-app with Ubuntu 24.04"

  • "Spin up a cx22 server in Falkenstein running Debian"

  • "Create a server named test-server with my SSH key attached"

Managing Servers

  • "Power off server 12345"

  • "Reboot my-app server"

  • "Delete the test-server" (be careful - this is permanent!)

Managing SSH Keys

  • "Add my SSH public key" (then paste the key)

  • "List my SSH keys"

  • "Delete SSH key 789"


Available Tools (14 total)

Server Tools (7)

Tool

What it does

hetzner_list_servers

Shows all servers in the project

hetzner_get_server

Shows details of one server (IP, status, specs)

hetzner_create_server

Creates a new server (costs money!)

hetzner_delete_server

Permanently deletes a server

hetzner_power_on_server

Turns on a powered-off server

hetzner_power_off_server

Hard power off (like pulling the plug)

hetzner_reboot_server

Hard reboot (like pressing reset button)

SSH Key Tools (4)

Tool

What it does

hetzner_list_ssh_keys

Shows all SSH keys in the project

hetzner_get_ssh_key

Shows details of one SSH key

hetzner_create_ssh_key

Adds a new SSH public key

hetzner_delete_ssh_key

Removes an SSH key

Reference Tools (3)

Tool

What it does

hetzner_list_server_types

Shows available sizes and prices

hetzner_list_images

Shows available operating systems

hetzner_list_locations

Shows available datacenters


Example Workflow

Here's how you might use this MCP to deploy a new project:

1. Check what's available

You: "What server types are available?"
Claude: [Lists server types with CPU, RAM, disk, and pricing]

You: "What locations can I use?"
Claude: [Lists Falkenstein, Nuremberg, Helsinki, etc.]

2. Add your SSH key (if not already added)

You: "Add my SSH key called 'my-laptop'"
Claude: "What's the public key content?"
You: [Paste your ~/.ssh/id_rsa.pub content]
Claude: "SSH key 'my-laptop' created with ID 12345"

3. Create a server

You: "Create a cx22 server with Ubuntu 24.04 in Falkenstein, name it my-app, and use my SSH key"
Claude: "Server 'my-app' created!
  - ID: 67890
  - IP: 123.45.67.89
  - Status: initializing
  SSH key authentication is configured."

4. Connect to your server

ssh root@123.45.67.89

5. When done, delete the server (to stop charges)

You: "Delete server my-app"
Claude: "Are you sure? This is permanent."
You: "Yes, delete it"
Claude: "Server 67890 is being deleted."

Troubleshooting

"HETZNER_API_TOKEN environment variable is required"

You haven't configured the token in your Claude Code settings. Make sure:

  1. The token is in ~/.claude/settings.json

  2. You've restarted Claude Code

"Error: Authentication failed"

Your API token is invalid. Generate a new one in the Hetzner console.

"Error: Permission denied"

Your token doesn't have write permissions. Generate a new token with "Read & Write".

"Error: Resource not found"

The server/SSH key ID doesn't exist. Use the list commands to see what's available.


Development

# Install dependencies
npm install

# Build (compile TypeScript to JavaScript)
npm run build

# Development mode (auto-rebuild on changes)
npm run dev

License

MIT

Available Tools

14 tools
hetzner_create_serverCreate ServerA

Create a new server.

Required parameters:

  • name: Server name (letters, digits, hyphens)

  • server_type: Instance size (e.g., "cx22", "cpx11"). Use hetzner_list_server_types to see options.

  • image: OS image (e.g., "ubuntu-24.04"). Use hetzner_list_images to see options.

Optional parameters:

  • location: Datacenter (e.g., "fsn1", "nbg1"). Use hetzner_list_locations to see options.

  • ssh_keys: List of SSH key names or IDs for server access

  • labels: Key-value labels for organization

Returns the new server details including IP address and root password (if no SSH keys specified).

Inputs: name (required), image (required), server_type (required), labels, +4 more.

hetzner_create_ssh_keyCreate SSH KeyA

Add a new SSH public key to the project.

The SSH key can then be used when creating servers to enable SSH access.

Args:

  • name: A name for the SSH key (e.g., "my-laptop")

  • public_key: The SSH public key content (starts with "ssh-rsa", "ssh-ed25519", etc.)

  • labels: Optional key-value labels for organization

Inputs: name (required), public_key (required), labels, response_format.

hetzner_delete_serverDelete ServerA
DestructiveIdempotent

Delete a server permanently.

⚠️ This action is irreversible. All data on the server will be lost.

Inputs: id (required).

hetzner_delete_ssh_keyDelete SSH KeyA
DestructiveIdempotent

Delete an SSH key from the project.

This does NOT affect existing servers that were created with this key. They will continue to work with the key.

Inputs: id (required).

hetzner_get_serverGet ServerA
Read-onlyIdempotent

Get detailed information about a specific server.

Inputs: id (required), response_format.

hetzner_get_ssh_keyGet SSH KeyA
Read-onlyIdempotent

Get details of a specific SSH key by ID.

Inputs: id (required), response_format.

hetzner_list_imagesList ImagesA
Read-onlyIdempotent

List available OS images for creating servers.

Returns system images (operating systems) like Ubuntu, Debian, CentOS, etc. Each image includes:

  • Name (e.g., "ubuntu-24.04")

  • OS flavor and version

  • Architecture (x86 or arm)

Use this to find the right image when creating a new server.

Inputs: type, response_format.

hetzner_list_locationsList LocationsA
Read-onlyIdempotent

List available datacenter locations.

Returns all Hetzner datacenter locations where you can create servers:

  • Location code (e.g., "fsn1", "nbg1", "hel1")

  • City and country

  • Network zone

Use this to choose where to deploy your server.

Inputs: response_format.

hetzner_list_serversList ServersA
Read-onlyIdempotent

List all servers in the project.

Returns all servers with their:

  • Name and ID

  • Status (running, off, etc.)

  • IP addresses

  • Server type (CPU, RAM, disk)

  • Location

  • Image/OS

Inputs: label_selector, response_format.

hetzner_list_server_typesList Server TypesA
Read-onlyIdempotent

List all available server types (instance sizes) with their specs and pricing.

Returns information about available server configurations including:

  • Name (e.g., "cx22", "cpx11")

  • CPU cores and type

  • Memory (GB)

  • Disk size (GB)

  • Hourly and monthly pricing

Use this to find the right server type when creating a new server.

Inputs: response_format.

hetzner_list_ssh_keysList SSH KeysA
Read-onlyIdempotent

List all SSH keys in the project.

Returns all SSH public keys that have been added to this project. SSH keys are used to authenticate when connecting to servers.

Inputs: response_format.

hetzner_power_off_serverPower Off ServerA
DestructiveIdempotent

Power off a server (hard shutdown).

This is like pulling the power cord. For a graceful shutdown, SSH into the server and run 'shutdown'.

Inputs: id (required).

hetzner_power_on_serverPower On ServerA
Idempotent

Power on a server that is currently off.

Inputs: id (required).

hetzner_reboot_serverReboot ServerA
DestructiveIdempotent

Reboot a server (hard reset).

This is like pressing the reset button. For a graceful reboot, SSH into the server and run 'reboot'.

Inputs: id (required).

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 14 tools

    Disambiguation5/5

    Every tool targets a distinct resource and action: reference data (server types, images, locations), SSH key lifecycle (list, get, create, delete), and server lifecycle (list, get, create, delete, power, reboot). There is no overlap or ambiguity between tools.

    Naming Consistency5/5

    All tool names follow a consistent pattern of 'hetzner_' prefix plus verb_noun (e.g., list_server_types, create_server, power_on_server). Verbs are uniform and snake_case is used throughout, making the set highly predictable.

    Tool Count5/5

    14 tools is well-scoped for managing Hetzner cloud servers. The set covers reference data, SSH key management, and server lifecycle management without unnecessary additional tools or obvious bloat.

    Completeness4/5

    The tool set provides solid CRUD and lifecycle coverage for servers and SSH keys, including create, read, list, delete, and power operations. Minor gaps exist—no update operation for server names/labels or SSH key labels—but these are not critical and can be worked around.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      F
      maintenance
      Enables users to manage Hetzner Cloud resources including servers, load balancers, and volumes through natural language commands. It facilitates infrastructure operations such as resource creation, security configuration, and real-time pricing queries within AI-powered environments.
      1
      -
    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Enables Claude Code to control remote servers via SSH for automated deployment, testing, and operations, including command execution and file transfer.
      4
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables natural language SSH server management via Claude Code, allowing users to read logs, check services, run commands, and transfer files across multiple servers.
      6
      MIT