Skip to content
Back to search

mcp-hetzner

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.

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/dkruyt--mcp-hetzner/badge.svg)](/listings/dkruyt--mcp-hetzner)

HTML

<a href="/listings/dkruyt--mcp-hetzner"><img src="/api/listings/dkruyt--mcp-hetzner/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

Install instructions from the README

As written by the repo's author. findsafeskills has not verified these steps.

Method 1: Direct Installation

1. Clone this repository:

git clone https://github.com/dkruyt/mcp-hetzner.git
cd mcp-hetzner

2. Install dependencies:

pip install -e .

3. Create a `.env` file and add your Hetzner Cloud API token:

HCLOUD_TOKEN=your_hetzner_cloud_api_token_here

Method 2: Install as a Package

# Install directly from the repository
pip install git+https://github.com/dkruyt/mcp-hetzner.git

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

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 297 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Hetzner Cloud MCP Server
  2. 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.
  3. ![MCP Hetzner Demo](media/mcp-hetzner.gif)
  4. ## Features
  5. - List, create, and manage Hetzner Cloud servers
  6. - Create, attach, detach, and resize volumes
  7. - Manage firewall rules and apply them to servers
  8. - Create and manage SSH keys for secure server access
  9. - View available images, server types, and locations
  10. - Power on/off and reboot servers
  11. - Simple, structured API for language model interaction
  12. - Claude Code integration for managing Hetzner resources directly from Claude
  13. ## Requirements
  14. - Python 3.11+
  15. - Hetzner Cloud API token
  16. ## Installation
  17. ### Method 1: Direct Installation
  18. 1. Clone this repository:
  19. ```bash
  20. git clone https://github.com/dkruyt/mcp-hetzner.git
  21. cd mcp-hetzner
  22. ```
  23. 2. Install dependencies:
  24. ```bash
  25. pip install -e .
  26. ```
  27. 3. Create a `.env` file and add your Hetzner Cloud API token:
  28. ```
  29. HCLOUD_TOKEN=your_hetzner_cloud_api_token_here
  30. ```
  31. ### Method 2: Install as a Package
  32. ```bash
  33. # Install directly from the repository
  34. pip install git+https://github.com/dkruyt/mcp-hetzner.git
  35. ```
  36. After installing as a package, create a `.env` file in your working directory with your Hetzner Cloud API token.
  37. ## Usage
  38. ### Starting the Server
  39. Option 1: Run the installed package:
  40. ```bash
  41. # Using default stdio transport
  42. mcp-hetzner
  43. # Using SSE transport
  44. mcp-hetzner --transport sse
  45. # Setting a custom port
  46. mcp-hetzner --transport sse --port 8000
  47. ```
  48. Option 2: Run as a module:
  49. ```bash
  50. python -m mcp_hetzner
  51. # or
  52. python -m mcp_hetzner.server
  53. ```
  54. The server supports two transport modes:
  55. - `stdio` (default): Standard I/O transport, typically used with Claude Code
  56. - `sse`: Server-Sent Events transport, suitable for HTTP clients
  57. By default, the server runs on `localhost:8080`. You can customize the host and port by:
  58. 1. Setting the `MCP_HOST` and `MCP_PORT` environment variables in your `.env` file
  59. 2. Using the `--port` command line argument (overrides the environment variable)
  60. ### Using with Claude Code
  61. To use with Claude Code, run the server with SSE transport:
  62. ```bash
  63. # Start the server with SSE transport
  64. mcp-hetzner --transport sse --port 8080
  65. # In another terminal, connect Claude Code to the server
  66. claude-code --mcp-server localhost:8080
  67. ```
  68. ### Testing the API
  69. A test client is included to verify the server functionality:
  70. ```bash
  71. python -m mcp_hetzner.client
  72. ```
  73. ## Example Workflows
  74. ### Basic Server Management
  75. ```
  76. # List all your servers
  77. list_servers
  78. # Create a new server
  79. create_server {
  80. "name": "web-server",
  81. "server_type": "cx11",
  82. "image": "ubuntu-22.04"
  83. }
  84. # Power operations
  85. power_off {"server_id": 12345}
  86. power_on {"server_id": 12345}
  87. reboot {"server_id": 12345}
  88. # Delete a server when no longer needed
  89. delete_server {"server_id": 12345}
  90. ```
  91. ### Volume Management
  92. ```
  93. # List all volumes
  94. list_volumes
  95. # Create a new volume
  96. create_volume {
  97. "name": "data-volume",
  98. "size": 10,
  99. "location": "nbg1",
  100. "format": "ext4"
  101. }
  102. # Attach volume to a server
  103. attach_volume {
  104. "volume_id": 12345,
  105. "server_id": 67890,
  106. "automount": true
  107. }
  108. # Detach volume from server
  109. detach_volume {
  110. "volume_id": 12345
  111. }
  112. # Resize a volume (can only increase size)
  113. resize_volume {
  114. "volume_id": 12345,
  115. "size": 50
  116. }
  117. # Delete a volume when no longer needed
  118. delete_volume {
  119. "volume_id": 12345
  120. }
  121. ```
  122. ### Firewall Management
  123. ```
  124. # List all firewalls
  125. list_firewalls
  126. # Create a firewall for web servers
  127. create_firewall {
  128. "name": "web-firewall",
  129. "rules": [
  130. {
  131. "direction": "in",
  132. "protocol": "tcp",
  133. "port": "80",
  134. "source_ips": ["0.0.0.0/0", "::/0"]
  135. },
  136. {
  137. "direction": "in",
  138. "protocol": "tcp",
  139. "port": "443",
  140. "source_ips": ["0.0.0.0/0", "::/0"]
  141. }
  142. ]
  143. }
  144. # Apply firewall to a server
  145. apply_firewall_to_resources {
  146. "firewall_id": 12345,
  147. "resources": [
  148. {
  149. "type": "server",
  150. "server_id": 67890
  151. }
  152. ]
  153. }
  154. ```
  155. ### SSH Key Management
  156. ```
  157. # List all SSH keys
  158. list_ssh_keys
  159. # Create a new SSH key
  160. create_ssh_key {
  161. "name": "my-laptop",
  162. "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAA... user@laptop"
  163. }
  164. # Use the SSH key when creating a server
  165. create_server {
  166. "name": "secure-server",
  167. "server_type": "cx11",
  168. "image": "ubuntu-22.04",
  169. "ssh_keys": [12345]
  170. }
  171. # Update an SSH key's name
  172. update_ssh_key {
  173. "ssh_key_id": 12345,
  174. "name": "work-laptop"
  175. }
  176. # Delete an SSH key
  177. delete_ssh_key {
  178. "ssh_key_id": 12345
  179. }
  180. ```
  181. ### Infrastructure Planning
  182. ```
  183. # Explore available resources
  184. list_server_types
  185. list_images
  186. list_locations
  187. # Get specific server information
  188. get_server {"server_id": 12345}
  189. ```
  190. ## Available Functions
  191. The MCP server provides the following functions:
  192. ### Server Management
  193. - `list_servers`: List all servers in your Hetzner Cloud account
  194. - `get_server`: Get details about a specific server
  195. - `create_server`: Create a new server
  196. - `delete_server`: Delete a server
  197. - `power_on`: Power on a server
  198. - `power_off`: Power off a server
  199. - `reboot`: Reboot a server
  200. ### Volume Management
  201. - `list_volumes`: List all volumes in your Hetzner Cloud account
  202. - `get_volume`: Get details about a specific volume
  203. - `create_volume`: Create a new volume
  204. - `delete_volume`: Delete a volume
  205. - `attach_volume`: Attach a volume to a server
  206. - `detach_volume`: Detach a volume from a server
  207. - `resize_volume`: Increase the size of a volume
  208. ### Firewall Management
  209. - `list_firewalls`: List all firewalls in your Hetzner Cloud account
  210. - `get_firewall`: Get details about a specific firewall
  211. - `create_firewall`: Create a new firewall
  212. - `update_firewall`: Update firewall name or labels
  213. - `delete_firewall`: Delete a firewall
  214. - `set_firewall_rules`: Set or update firewall rules
  215. - `apply_firewall_to_resources`: Apply a firewall to servers or server groups
  216. - `remove_firewall_from_resources`: Remove a firewall from servers or server groups
  217. ### SSH Key Management
  218. - `list_ssh_keys`: List all SSH keys in your Hetzner Cloud account
  219. - `get_ssh_key`: Get details about a specific SSH key
  220. - `create_ssh_key`: Create a new SSH key
  221. - `update_ssh_key`: Update SSH key name or labels
  222. - `delete_ssh_key`: Delete an SSH key
  223. ### Information
  224. - `list_images`: List available OS images
  225. - `list_server_types`: List available server types
  226. - `list_locations`: List available datacenter locations
  227. ## License
  228. MIT

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.