delete_ssh_key
Permanently remove an SSH key from Hetzner Cloud by specifying its ID to manage server access and security.
Instructions
Delete an SSH key.
Permanently deletes an SSH key identified by its ID.
Example:
- Delete SSH key: {"ssh_key_id": 12345}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- mcp_hetzner/server.py:1287-1307 (handler)The handler function decorated with @mcp.tool() that implements the delete_ssh_key tool. It retrieves the SSH key by ID using the Hetzner Cloud client and deletes it if found.@mcp.tool() def delete_ssh_key(params: SSHKeyIdParam) -> Dict[str, Any]: """ Delete an SSH key. Permanently deletes an SSH key identified by its ID. Example: - Delete SSH key: {"ssh_key_id": 12345} """ try: ssh_key = client.ssh_keys.get_by_id(params.ssh_key_id) if not ssh_key: return {"error": f"SSH key with ID {params.ssh_key_id} not found"} success = client.ssh_keys.delete(ssh_key) return {"success": success} except Exception as e: return {"error": f"Failed to delete SSH key: {str(e)}"}
- mcp_hetzner/server.py:240-241 (schema)Pydantic BaseModel defining the input schema for the delete_ssh_key tool, requiring an integer ssh_key_id.class SSHKeyIdParam(BaseModel): ssh_key_id: int = Field(..., description="The ID of the SSH key")
- mcp_hetzner/server.py:101-110 (helper)Helper function to convert SSHKey objects to dictionaries, used in related SSH key tools like list_ssh_keys and get_ssh_key.def ssh_key_to_dict(ssh_key: SSHKey) -> Dict[str, Any]: """Convert an SSHKey object to a dictionary with relevant information.""" return { "id": ssh_key.id, "name": ssh_key.name, "fingerprint": ssh_key.fingerprint, "public_key": ssh_key.public_key, "labels": ssh_key.labels, "created": ssh_key.created.isoformat() if ssh_key.created else None, }