list_ssh_keys
Retrieve all SSH keys stored in your Hetzner Cloud account to manage server access and authentication.
Instructions
List all SSH keys in your Hetzner Cloud account.
Returns a list of all SSH key instances with their details.
Example:
- Basic list: list_ssh_keys()
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_hetzner/server.py:1203-1219 (handler)The handler function decorated with @mcp.tool() that implements the list_ssh_keys tool. It fetches all SSH keys from the Hetzner client and formats them using the ssh_key_to_dict helper.def list_ssh_keys() -> Dict[str, Any]: """ List all SSH keys in your Hetzner Cloud account. Returns a list of all SSH key instances with their details. Example: - Basic list: list_ssh_keys() """ try: ssh_keys = client.ssh_keys.get_all() return { "ssh_keys": [ssh_key_to_dict(ssh_key) for ssh_key in ssh_keys] } except Exception as e: return {"error": f"Failed to list SSH keys: {str(e)}"}
- mcp_hetzner/server.py:100-110 (helper)Helper function used by list_ssh_keys to convert Hetzner SSHKey objects into serializable dictionaries for the tool response.# Helper function to convert SSHKey object to dict 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, }
- mcp_hetzner/server.py:1203-1203 (registration)The @mcp.tool() decorator registers the list_ssh_keys function as an MCP tool.def list_ssh_keys() -> Dict[str, Any]: