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

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, }

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