Hetzner API工具集

一个为Hetzner Cloud、Robot和DNS API提供的生产级MCP服务器,包含约170个工具,支持多种安全模式和操作防护。

  • by fidesit
  • TypeScript
  • 本地部署
  • 更新于
在 GitHub 查看 fidesit/hetzner-mcp

使用说明

hetzner-mcp

生产级MCP(模型上下文协议)服务器 所有三个Hetzner API:云、机器人(专用服务器)和DNS。

特性

  • ~170个MCP工具 涵盖每一项有意义的Hetzner API操作
  • Hetzner 云 API --服务器、卷、网络、防火墙、浮动/主IP、负载均衡器、证书、SSH密钥、放置组、映像、ISO、存储箱、数据中心、位置、定价、操作
  • Hetzner机器人API --专用服务器、重置、局域网唤醒、启动配置(rescue/linux/vnc)、SSH密钥、IP、子网、防火墙、vSwitch、RDNS、流量、故障转移
  • Hetzner DNS API --区域、记录、批量操作、区域文件导入/导出
  • 安全模式 — read_only (默认)隐藏所有变异工具; read_write 启用完全访问
  • 工具组筛选 — HETZNER_TOOLS 有选择地启用 cloud, dns和/或 robot 工具组
  • 破坏性操作防护装置 --删除/重建工具需要明确 confirm: true
  • 自动分页 --列表端点自动返回所有结果
  • 限速意识 -接近API限值时发出警告
  • 行动投票 --返回操作的变体被轮询到完成
  • 零依赖 超越 @modelcontextprotocol/sdk 和 zod

安装

npm install
npm run build

配置

为要使用的API设置环境变量:

# Cloud + DNS API (uses same token)
export HETZNER_CLOUD_TOKEN=your-cloud-api-token

# Robot API (dedicated servers)
export HETZNER_ROBOT_USER=your-robot-username
export HETZNER_ROBOT_PASSWORD=your-robot-password

# Safety mode (default: read_only)
export HETZNER_MODE=read_only   # or read_write

# Tool groups to enable (default: all configured)
export HETZNER_TOOLS=cloud,dns,robot

必须至少配置一个API。工具仅针对已配置的API进行注册。

工具组筛选

使用 HETZNER_TOOLS 以选择性地仅启用特定的工具组。该值是一个逗号分隔的列表: cloud, dns, robot.

  • 如果 未设置,所有具有有效凭据的组都会自动启用(cloud 和 dns 当 HETZNER_CLOUD_TOKEN 设置, robot 设置机器人凭据时)。
  • 如果 集,即使其他组的凭据可用,也只注册列出的组。

示例:

# Only DNS and Robot tools (skip Cloud)
export HETZNER_TOOLS=dns,robot

# Only Cloud tools (skip DNS and Robot)
export HETZNER_TOOLS=cloud

无效的组名导致服务器退出并出错。

克劳德桌面版

添加到您的 claude_desktop_config.json:

{
  "mcpServers": {
    "hetzner": {
      "command": "node",
      "args": ["/path/to/hetzner-mcp/dist/index.js"],
      "env": {
        "HETZNER_CLOUD_TOKEN": "your-token-here",
        "HETZNER_MODE": "read_only"
      }
    }
  }
}

对于Robot API访问,添加 HETZNER_ROBOT_USER 和 HETZNER_ROBOT_PASSWORD 到 env 块。

安全模式

read_only (默认)

只有读取操作可用。没有注册创建、更新或删除资源的工具。这是探索和监控的安全默认设置。

read_write

所有工具都可用,包括突变。破坏性行动(delete_*, rebuild_server, cancel_robot_server)要求明确 confirm: true 参数。如果 confirm 如果未设置,这些工具将返回警告消息而不是执行。

工具命名约定

API 前缀 示例
云 (无) list_servers, create_volume
DNS dns_ list_dns_zones, create_dns_record
机器人 robot_ list_robot_servers, reset_robot_server

云API工具(约100个工具)

服务器

list_servers, get_server, create_server, update_server, delete_server, get_server_metrics

服务器操作

power_on_server, power_off_server, reboot_server, reset_server, shutdown_server, rebuild_server, change_server_type, enable_server_rescue, disable_server_rescue, create_server_image, enable_server_backup, disable_server_backup, attach_iso_to_server, detach_iso_from_server, change_server_dns_ptr, change_server_protection, request_server_console, attach_server_to_network, detach_server_from_network, change_server_alias_ips, add_server_to_placement_group, remove_server_from_placement_group, list_server_actions, get_server_action

卷

list_volumes, get_volume, create_volume, update_volume, delete_volume, attach_volume, detach_volume, resize_volume, change_volume_protection, list_volume_actions

网络

list_networks, get_network, create_network, update_network, delete_network, add_subnet_to_network, delete_subnet_from_network, add_route_to_network, delete_route_from_network, change_network_ip_range, change_network_protection, list_network_actions

防火墙

list_firewalls, get_firewall, create_firewall, update_firewall, delete_firewall, set_firewall_rules, apply_firewall_to_resources, remove_firewall_from_resources, list_firewall_actions

浮动IP

list_floating_ips, get_floating_ip, create_floating_ip, update_floating_ip, delete_floating_ip, assign_floating_ip, unassign_floating_ip, change_floating_ip_dns_ptr, change_floating_ip_protection, list_floating_ip_actions

主要IP

list_primary_ips, get_primary_ip, create_primary_ip, update_primary_ip, delete_primary_ip, assign_primary_ip, unassign_primary_ip, change_primary_ip_dns_ptr, change_primary_ip_protection

负载均衡器

list_load_balancers, get_load_balancer, create_load_balancer, update_load_balancer, delete_load_balancer, get_load_balancer_metrics, add_load_balancer_target, remove_load_balancer_target, add_load_balancer_service, update_load_balancer_service, delete_load_balancer_service, change_load_balancer_algorithm, change_load_balancer_type, change_load_balancer_protection, change_load_balancer_dns_ptr, attach_load_balancer_to_network, detach_load_balancer_from_network, enable_load_balancer_public_interface, disable_load_balancer_public_interface, list_load_balancer_actions

证书

list_certificates, get_certificate, create_certificate, update_certificate, delete_certificate, retry_certificate_issuance, list_certificate_actions

SSH密钥

list_ssh_keys, get_ssh_key, create_ssh_key, update_ssh_key, delete_ssh_key

安置小组

list_placement_groups, get_placement_group, create_placement_group, update_placement_group, delete_placement_group

参考数据

list_server_types, get_server_type, list_images, get_image, update_image, delete_image, change_image_protection, list_image_actions, list_isos, get_iso, list_load_balancer_types, get_load_balancer_type, list_datacenters, get_datacenter, list_locations, get_location, get_pricing, list_actions, get_action

储物箱

list_storage_boxes, get_storage_box, update_storage_box

DNS API工具(约15个工具)

list_dns_zones, get_dns_zone, create_dns_zone, update_dns_zone, delete_dns_zone, validate_dns_zone_file, import_dns_zone, export_dns_zone, list_dns_records, get_dns_record, create_dns_record, update_dns_record, delete_dns_record, bulk_create_dns_records, bulk_update_dns_records

机器人API工具(~55个工具)

服务器

list_robot_servers, get_robot_server, rename_robot_server, get_robot_server_cancellation, cancel_robot_server, withdraw_robot_server_cancellation

局域网重置和唤醒

list_robot_reset_options, get_robot_reset_options, reset_robot_server, get_robot_wol, send_robot_wol

启动配置

get_robot_boot_config, get_robot_rescue, enable_robot_rescue, disable_robot_rescue, get_robot_linux, enable_robot_linux, disable_robot_linux, get_robot_vnc, enable_robot_vnc, disable_robot_vnc

SSH密钥

list_robot_ssh_keys, get_robot_ssh_key, create_robot_ssh_key, update_robot_ssh_key, delete_robot_ssh_key

IP和子网

list_robot_ips, get_robot_ip, update_robot_ip, get_robot_ip_mac, create_robot_ip_mac, delete_robot_ip_mac, list_robot_subnets, get_robot_subnet, update_robot_subnet, get_robot_subnet_mac, create_robot_subnet_mac, delete_robot_subnet_mac

防火墙

get_robot_firewall, set_robot_firewall, delete_robot_firewall, list_robot_firewall_templates, get_robot_firewall_template, create_robot_firewall_template, update_robot_firewall_template, delete_robot_firewall_template

虚拟交换机

list_robot_vswitches, get_robot_vswitch, create_robot_vswitch, update_robot_vswitch, delete_robot_vswitch, add_robot_vswitch_server, remove_robot_vswitch_server

RDNS

list_robot_rdns, get_robot_rdns, create_robot_rdns, update_robot_rdns, delete_robot_rdns

流量和故障转移

get_robot_traffic, list_robot_failover_ips, get_robot_failover_ip, route_robot_failover_ip

发展

npm run dev      # Run with tsx (hot reload)
npm run build    # Build with tsup
npm run lint     # Type check with tsc
npm test         # Run tests with vitest

建筑

src/
├── index.ts              # Entry point, stdio transport
├── server.ts             # MCP server setup, tool registrar
├── config.ts             # Environment variable loading
├── clients/
│   ├── common.ts         # Shared types, errors, helpers
│   ├── cloud.ts          # Cloud API client (Bearer auth, pagination, action polling)
│   └── robot.ts          # Robot API client (Basic auth, form-encoded, request queue)
├── types/
│   ├── cloud.ts          # Cloud API response types
│   ├── robot.ts          # Robot API response types
│   └── dns.ts            # DNS API response types
└── tools/                # 34 tool registration files
    ├── servers.ts         ├── robot-servers.ts
    ├── server-actions.ts  ├── robot-reset.ts
    ├── server-types.ts    ├── robot-wol.ts
    ├── images.ts          ├── robot-boot.ts
    ├── isos.ts            ├── robot-keys.ts
    ├── volumes.ts         ├── robot-ips.ts
    ├── networks.ts        ├── robot-subnets.ts
    ├── firewalls.ts       ├── robot-firewalls.ts
    ├── floating-ips.ts    ├── robot-vswitch.ts
    ├── primary-ips.ts     ├── robot-rdns.ts
    ├── load-balancers.ts  ├── robot-traffic.ts
    ├── load-balancer-types.ts ├── robot-failover.ts
    ├── certificates.ts    ├── dns-zones.ts
    ├── ssh-keys.ts        ├── dns-records.ts
    ├── placement-groups.ts
    ├── datacenters.ts
    ├── locations.ts
    ├── pricing.ts
    ├── actions.ts
    └── storage-boxes.ts

许可证

麻省理工学院