Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

get_volume

Retrieve detailed information about a specific Hetzner Cloud volume using its unique ID to manage storage resources.

Instructions

Get details about a specific volume.

Returns detailed information about a volume identified by its ID.

Example:
- Get volume details: {"volume_id": 12345}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The main handler function for the 'get_volume' tool. It takes a volume_id parameter, fetches the volume using the Hetzner Cloud API client, converts it to a dictionary using the volume_to_dict helper, and returns the details or an error.
    @mcp.tool()
    def get_volume(params: VolumeIdParam) -> Dict[str, Any]:
        """
        Get details about a specific volume.
        
        Returns detailed information about a volume identified by its ID.
        
        Example:
        - Get volume details: {"volume_id": 12345}
        """
        try:
            volume = client.volumes.get_by_id(params.volume_id)
            if not volume:
                return {"error": f"Volume with ID {params.volume_id} not found"}
            
            return {"volume": volume_to_dict(volume)}
        except Exception as e:
            return {"error": f"Failed to get volume: {str(e)}"}
  • Pydantic BaseModel defining the input schema for the get_volume tool, which requires a single 'volume_id' integer field.
    # Volume ID Parameter Model
    class VolumeIdParam(BaseModel):
        volume_id: int = Field(..., description="The ID of the volume")
  • Supporting utility function that serializes a hcloud.volumes.domain.Volume object into a JSON-serializable dictionary format, used directly in the get_volume handler.
    # Helper function to convert Volume object to dict
    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