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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_hetzner/server.py:257-274 (handler)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)}"}
- mcp_hetzner/server.py:52-79 (helper)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 [], }
- mcp_hetzner/server.py:257-257 (registration)The @mcp.tool() decorator registers the list_servers function as an MCP tool in the FastMCP server instance.@mcp.tool()