get_ssh_key
Retrieve details for a specific SSH key by its ID to manage access to Hetzner Cloud resources.
Instructions
Get details about a specific SSH key.
Returns detailed information about an SSH key identified by its ID.
Example:
- Get SSH key details: {"ssh_key_id": 12345}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- mcp_hetzner/server.py:1220-1237 (handler)The handler function for the 'get_ssh_key' tool. It retrieves an SSH key by ID from the Hetzner Cloud API using the client, converts it to a dictionary using ssh_key_to_dict, and returns it or an error.@mcp.tool() def get_ssh_key(params: SSHKeyIdParam) -> Dict[str, Any]: """ Get details about a specific SSH key. Returns detailed information about an SSH key identified by its ID. Example: - Get SSH key details: {"ssh_key_id": 12345} """ 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"} return {"ssh_key": ssh_key_to_dict(ssh_key)} except Exception as e: return {"error": f"Failed to get SSH key: {str(e)}"}
- mcp_hetzner/server.py:240-241 (schema)Pydantic model defining the input schema for the get_ssh_key tool, requiring the SSH key ID.class SSHKeyIdParam(BaseModel): ssh_key_id: int = Field(..., description="The ID of the SSH key")
- mcp_hetzner/server.py:101-110 (helper)Helper function that converts a Hetzner Cloud SSHKey object to a serializable dictionary format, used in get_ssh_key and list_ssh_keys tools.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:1220-1220 (registration)The @mcp.tool() decorator registers the get_ssh_key function as an MCP tool with the name 'get_ssh_key'.@mcp.tool()