Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

list_volumes

Retrieve and view all storage volumes in your Hetzner Cloud account with their details.

Instructions

List all volumes in your Hetzner Cloud account.

Returns a list of all volume instances with their details.

Example:
- Basic list: list_volumes()

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'list_volumes' tool. It is registered via the @mcp.tool() decorator and implements the core logic: retrieves all volumes using the Hetzner client and formats them into a dictionary using the volume_to_dict helper.
    def list_volumes() -> Dict[str, Any]:
        """
        List all volumes in your Hetzner Cloud account.
        
        Returns a list of all volume instances with their details.
        
        Example:
        - Basic list: list_volumes()
        """
        try:
            volumes = client.volumes.get_all()
            return {
                "volumes": [volume_to_dict(volume) for volume in volumes]
            }
        except Exception as e:
            return {"error": f"Failed to list volumes: {str(e)}"}
  • Helper function that converts a Hetzner Volume domain object to a serializable dictionary, used by the list_volumes handler to format the response.
    def volume_to_dict(volume: Volume) -> Dict[str, Any]:
        """Convert a Volume object to a dictionary with relevant information."""
        return {
            "id": volume.id,
            "name": volume.name,
            "size": volume.size,
            "location": volume.location.name if volume.location else None,
            "server": volume.server.id if volume.server else None,
            "linux_device": volume.linux_device,
            "protection": {
                "delete": volume.protection["delete"] if volume.protection else False,
            },
            "labels": volume.labels,
            "format": volume.format,
            "created": volume.created.isoformat() if volume.created else None,
            "status": volume.status,
        }

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