hetzner cloud.com
hetzner cloud.com logo

Hetzner Cloud

Integrates with Hetzner Cloud API to enable management of cloud infrastructure resources including servers, volumes, fir...

Created byApr 23, 2025

Hetzner Cloud MCP Server

A Model Context Protocol (MCP) server for interacting with the Hetzner Cloud API. This server allows language models to manage Hetzner Cloud resources through structured functions.
![MCP Hetzner Demo](media/mcp-hetzner.gif)

Features

  • List, create, and manage Hetzner Cloud servers
  • Create, attach, detach, and resize volumes
  • Manage firewall rules and apply them to servers
  • Create and manage SSH keys for secure server access
  • View available images, server types, and locations
  • Power on/off and reboot servers
  • Simple, structured API for language model interaction
  • Claude Code integration for managing Hetzner resources directly from Claude

Requirements

  • Python 3.11+
  • Hetzner Cloud API token

Installation

Method 1: Direct Installation

  1. Clone this repository:
  1. Install dependencies:
  1. Create a `.env` file and add your Hetzner Cloud API token:

Method 2: Install as a Package

After installing as a package, create a `.env` file in your working directory with your Hetzner Cloud API token.

Usage

Starting the Server

Option 1: Run the installed package:
Option 2: Run as a module:
The server supports two transport modes:
  • `stdio` (default): Standard I/O transport, typically used with Claude Code
  • `sse`: Server-Sent Events transport, suitable for HTTP clients
By default, the server runs on `localhost:8080`. You can customize the host and port by:
  1. Setting the `MCP_HOST` and `MCP_PORT` environment variables in your `.env` file
  1. Using the `--port` command line argument (overrides the environment variable)

Using with Claude Code

To use with Claude Code, run the server with SSE transport:

Testing the API

A test client is included to verify the server functionality:

Example Workflows

Basic Server Management

Volume Management

Firewall Management

SSH Key Management

Infrastructure Planning

Available Functions

The MCP server provides the following functions:

Server Management

  • `list_servers`: List all servers in your Hetzner Cloud account
  • `get_server`: Get details about a specific server
  • `create_server`: Create a new server
  • `delete_server`: Delete a server
  • `power_on`: Power on a server
  • `power_off`: Power off a server
  • `reboot`: Reboot a server

Volume Management

  • `list_volumes`: List all volumes in your Hetzner Cloud account
  • `get_volume`: Get details about a specific volume
  • `create_volume`: Create a new volume
  • `delete_volume`: Delete a volume
  • `attach_volume`: Attach a volume to a server
  • `detach_volume`: Detach a volume from a server
  • `resize_volume`: Increase the size of a volume

Firewall Management

  • `list_firewalls`: List all firewalls in your Hetzner Cloud account
  • `get_firewall`: Get details about a specific firewall
  • `create_firewall`: Create a new firewall
  • `update_firewall`: Update firewall name or labels
  • `delete_firewall`: Delete a firewall
  • `set_firewall_rules`: Set or update firewall rules
  • `apply_firewall_to_resources`: Apply a firewall to servers or server groups
  • `remove_firewall_from_resources`: Remove a firewall from servers or server groups

SSH Key Management

  • `list_ssh_keys`: List all SSH keys in your Hetzner Cloud account
  • `get_ssh_key`: Get details about a specific SSH key
  • `create_ssh_key`: Create a new SSH key
  • `update_ssh_key`: Update SSH key name or labels
  • `delete_ssh_key`: Delete an SSH key

Information

  • `list_images`: List available OS images
  • `list_server_types`: List available server types
  • `list_locations`: List available datacenter locations

License

MIT