Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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)}"}
  • 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,
        }
  • The @mcp.tool() decorator registers the list_ssh_keys function as an MCP tool.
    def list_ssh_keys() -> Dict[str, Any]:

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