Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

delete_server

Permanently remove a Hetzner Cloud server using its unique ID to decommission resources and stop billing.

Instructions

Delete a server.

Permanently deletes a server identified by its ID.

Example:
- Delete server: {"server_id": 12345}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The handler function for the 'delete_server' MCP tool. It retrieves the server by ID using the Hetzner Cloud client and initiates its deletion, returning the action details.
    @mcp.tool()
    def delete_server(params: ServerIdParam) -> Dict[str, Any]:
        """
        Delete a server.
        
        Permanently deletes a server identified by its ID.
        
        Example:
        - Delete server: {"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"}
                
            action = client.servers.delete(server)
            
            # Don't wait for the action to complete - the method doesn't exist
            return {
                "success": True,
                "action": {
                    "id": action.id,
                    "status": action.status,
                    "command": action.command,
                    "progress": action.progress,
                    "error": action.error,
                    "started": action.started.isoformat() if action.started else None,
                    "finished": action.finished.isoformat() if action.finished else None,
                } if action else None,
            }
        except Exception as e:
            return {"error": f"Failed to delete server: {str(e)}"}
  • Pydantic BaseModel defining the input schema for the delete_server tool (and other server-related tools), requiring a server_id integer.
    class ServerIdParam(BaseModel):
        server_id: int = Field(..., description="The ID of the server")
  • The @mcp.tool() decorator registers the delete_server function as an MCP tool.
    @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