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
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- mcp_hetzner/server.py:961-977 (handler)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)}"}
- mcp_hetzner/server.py:82-98 (helper)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, }