Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

list_servers

Retrieve a list of all server instances with their details from your Hetzner Cloud account to monitor and manage your infrastructure.

Instructions

List all servers in your Hetzner Cloud account. Returns a list of all server instances with their details. Example: - Basic list: list_servers()

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_servers' MCP tool. It fetches all servers from the Hetzner Cloud API using the client and converts each to a dictionary using the server_to_dict helper, returning them in a 'servers' list or an error message.
    @mcp.tool() def list_servers() -> Dict[str, Any]: """ List all servers in your Hetzner Cloud account. Returns a list of all server instances with their details. Example: - Basic list: list_servers() """ try: servers = client.servers.get_all() return { "servers": [server_to_dict(server) for server in servers] } except Exception as e: return {"error": f"Failed to list servers: {str(e)}"}
  • Helper function that converts a Hetzner Server object to a dictionary containing key details like id, name, status, networking info, protection settings, and labels. Used by list_servers and other server-related tools.
    def server_to_dict(server: Server) -> Dict[str, Any]: """Convert a Server object to a dictionary with relevant information.""" return { "id": server.id, "name": server.name, "status": server.status, "created": server.created.isoformat() if server.created else None, "server_type": server.server_type.name if server.server_type else None, "image": server.image.name if server.image else None, "datacenter": server.datacenter.name if server.datacenter else None, "location": server.datacenter.location.name if server.datacenter and server.datacenter.location else None, "public_net": { "ipv4": server.public_net.ipv4.ip if server.public_net and server.public_net.ipv4 else None, "ipv6": server.public_net.ipv6.ip if server.public_net and server.public_net.ipv6 else None, }, "included_traffic": server.included_traffic, "outgoing_traffic": server.outgoing_traffic, "ingoing_traffic": server.ingoing_traffic, "backup_window": server.backup_window, "rescue_enabled": server.rescue_enabled, "locked": server.locked, "protection": { "delete": server.protection["delete"] if server.protection else False, "rebuild": server.protection["rebuild"] if server.protection else False, }, "labels": server.labels, "volumes": [volume.id for volume in server.volumes] if server.volumes else [], }
  • The @mcp.tool() decorator registers the list_servers function as an MCP tool in the FastMCP server instance.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dkruyt/mcp-hetzner'

If you have feedback or need assistance with the MCP directory API, please join our Discord server