Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

get_server

Retrieve detailed information about a specific Hetzner Cloud server using its unique ID to manage resources and monitor configurations.

Instructions

Get details about a specific server.

Returns detailed information about a server identified by its ID.

Example:
- Get server details: {"server_id": 12345}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The main handler function for the 'get_server' MCP tool. It takes a ServerIdParam, fetches the server using the Hetzner Cloud API client, converts it to a dict using server_to_dict, and returns the server details or an error.
    def get_server(params: ServerIdParam) -> Dict[str, Any]:
        """
        Get details about a specific server.
        
        Returns detailed information about a server identified by its ID.
        
        Example:
        - Get server details: {"server_id": 12345}
        """
        try:
            server = client.servers.get_by_id(params.server_id)
            if not server:
                return {"error": f"Server with ID {params.server_id} not found"}
            
            return {"server": server_to_dict(server)}
        except Exception as e:
            return {"error": f"Failed to get server: {str(e)}"}
  • Pydantic BaseModel defining the input schema for the get_server tool, requiring a 'server_id' integer.
    class ServerIdParam(BaseModel):
        server_id: int = Field(..., description="The ID of the server")
  • Helper function that converts a Hetzner Cloud Server object to a structured dictionary used in the get_server tool response.
    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 [],
        }

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