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
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- mcp_hetzner/server.py:276-292 (handler)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)}"}
- mcp_hetzner/server.py:169-170 (schema)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")
- mcp_hetzner/server.py:52-79 (helper)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 [], }