Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

create_ssh_key

Generate SSH keys for Hetzner Cloud server authentication. Add a name and public key to create secure access credentials.

Instructions

Create a new SSH key.

Creates a new SSH key with the specified name and public key data.

Examples:
- Basic SSH key: {"name": "my-ssh-key", "public_key": "ssh-rsa AAAAB3NzaC1..."}
- With labels: {"name": "user-key", "public_key": "ssh-rsa AAAAB3NzaC1...", "labels": {"environment": "production"}}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function decorated with @mcp.tool() that implements the create_ssh_key tool. It uses the Hetzner client to create an SSH key with the given name, public_key, and optional labels, then serializes and returns it or an error.
    @mcp.tool()
    def create_ssh_key(params: CreateSSHKeyParams) -> Dict[str, Any]:
        """
        Create a new SSH key.
        
        Creates a new SSH key with the specified name and public key data.
        
        Examples:
        - Basic SSH key: {"name": "my-ssh-key", "public_key": "ssh-rsa AAAAB3NzaC1..."}
        - With labels: {"name": "user-key", "public_key": "ssh-rsa AAAAB3NzaC1...", "labels": {"environment": "production"}}
        """
        try:
            ssh_key = client.ssh_keys.create(
                name=params.name,
                public_key=params.public_key,
                labels=params.labels
            )
            
            return {"ssh_key": ssh_key_to_dict(ssh_key)}
        except Exception as e:
            return {"error": f"Failed to create SSH key: {str(e)}"}
  • Pydantic model defining the input parameters for the create_ssh_key tool.
    class CreateSSHKeyParams(BaseModel):
        name: str = Field(..., description="Name of the SSH key")
        public_key: str = Field(..., description="The public key in OpenSSH format")
        labels: Optional[Dict[str, str]] = Field(None, description="User-defined labels (key-value pairs)")
  • Helper function used by create_ssh_key (and other SSH tools) to convert Hetzner SSHKey object to a serializable dictionary.
    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,
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden for behavioral disclosure. It states this is a creation operation but doesn't mention whether it requires specific permissions, what happens on duplicate names, rate limits, or what the response contains. The examples show input format but don't explain behavioral outcomes.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with three sentences and two examples. It's front-loaded with the core purpose, followed by elaboration and practical examples. No wasted words, though the repetition in the first two sentences could be slightly tightened.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given this is a mutation tool with no annotations but with an output schema (which handles return values), the description covers the basic creation purpose and parameters well. However, it lacks important contextual details like permission requirements, error conditions, or how this tool relates to sibling SSH key operations, leaving some gaps for an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 0%, so the description must compensate. It provides meaningful context for all parameters through examples: 'name' for identification, 'public_key' with format specification ('OpenSSH format'), and optional 'labels' for key-value pairs. This adds substantial value beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verb ('Create') and resource ('SSH key'), and distinguishes it from siblings like 'get_ssh_key', 'list_ssh_keys', 'update_ssh_key', and 'delete_ssh_key' by specifying it's for creating new keys rather than reading, updating, or deleting existing ones.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no explicit guidance on when to use this tool versus alternatives like 'update_ssh_key' for modifying existing keys, or prerequisites such as authentication requirements. It only states what the tool does without contextual usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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