Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

update_ssh_key

Modify the name or labels of an existing SSH key in Hetzner Cloud to maintain organized access management.

Instructions

Update an SSH key.

Updates the name or labels of an existing SSH key.

Example:
- Update name: {"ssh_key_id": 12345, "name": "new-key-name"}
- Update labels: {"ssh_key_id": 12345, "name": "existing-name", "labels": {"environment": "staging"}}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function implementing the 'update_ssh_key' MCP tool. It retrieves the SSH key by ID, updates its name and/or labels using the Hetzner Cloud client, and returns the updated key details or an error.
    @mcp.tool()
    def update_ssh_key(params: UpdateSSHKeyParams) -> Dict[str, Any]:
        """
        Update an SSH key.
        
        Updates the name or labels of an existing SSH key.
        
        Example:
        - Update name: {"ssh_key_id": 12345, "name": "new-key-name"}
        - Update labels: {"ssh_key_id": 12345, "name": "existing-name", "labels": {"environment": "staging"}}
        """
        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"}
            
            updated_ssh_key = client.ssh_keys.update(
                ssh_key=ssh_key,
                name=params.name,
                labels=params.labels
            )
            
            return {"ssh_key": ssh_key_to_dict(updated_ssh_key)}
        except Exception as e:
            return {"error": f"Failed to update SSH key: {str(e)}"}
  • Pydantic model defining the input parameters (schema) for the update_ssh_key tool.
    class UpdateSSHKeyParams(BaseModel):
        ssh_key_id: int = Field(..., description="The ID of the SSH key")
        name: str = Field(..., description="New name for the SSH key")
        labels: Optional[Dict[str, str]] = Field(None, description="User-defined labels (key-value pairs)")
  • Helper function to serialize SSHKey domain objects to dictionaries, used in the response of the update_ssh_key tool.
    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?

No annotations are provided, so the description carries the full burden. It states this is an update operation, implying mutation, but doesn't disclose behavioral traits such as required permissions, whether changes are reversible, rate limits, or error conditions. The examples show input formats but don't describe the response or side effects. This leaves significant gaps for a mutation tool.

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 and front-loaded: it starts with the core purpose, adds a clarifying sentence, and includes relevant examples. There's minimal waste, though the examples could be slightly more concise. Overall, it's efficient and well-structured for quick understanding.

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 the tool's complexity (a mutation with 3 parameters), no annotations, and an output schema present (which reduces the need to describe return values), the description is moderately complete. It covers the basic purpose and parameters through examples but lacks behavioral details and usage guidelines. It's adequate for a simple update tool but could be more comprehensive.

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

Parameters3/5

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

The schema description coverage is 0%, so the schema provides no parameter descriptions. The description compensates by listing updatable fields (name or labels) and providing examples that illustrate usage with 'ssh_key_id', 'name', and 'labels'. However, it doesn't fully explain all parameters (e.g., the purpose of 'ssh_key_id' is only implied, and 'labels' structure is shown but not detailed). This adds some value but doesn't fully cover the semantics.

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

Purpose4/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: 'Update an SSH key' and elaborates with 'Updates the name or labels of an existing SSH key.' This specifies the verb (update), resource (SSH key), and scope (name or labels). However, it doesn't explicitly differentiate from sibling tools like 'create_ssh_key' or 'delete_ssh_key' beyond the update action, though the context is reasonably clear.

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 guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing SSH key ID), exclusions (e.g., what cannot be updated), or comparisons to sibling tools like 'create_ssh_key' or 'delete_ssh_key'. Usage is implied through the examples but not explicitly stated.

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