Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

resize_volume

Increase the size of a Hetzner Cloud volume to expand storage capacity. Specify volume ID and new size in GB.

Instructions

Resize a volume. Increases the size of a volume (size can only be increased, not decreased). Example: - Resize volume: {"volume_id": 12345, "size": 100}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Implementation Reference

  • The resize_volume MCP tool handler. Retrieves the volume by ID, validates that the new size is larger than current, calls the Hetzner Cloud API client.volumes.resize(), and returns success with action details or error.
    @mcp.tool() def resize_volume(params: ResizeVolumeParams) -> Dict[str, Any]: """ Resize a volume. Increases the size of a volume (size can only be increased, not decreased). Example: - Resize volume: {"volume_id": 12345, "size": 100} """ try: volume = client.volumes.get_by_id(params.volume_id) if not volume: return {"error": f"Volume with ID {params.volume_id} not found"} if params.size <= volume.size: return {"error": f"New size ({params.size} GB) must be greater than current size ({volume.size} GB)"} action = client.volumes.resize(volume, params.size) # Format the response return { "success": True, "action": { "id": action.id, "status": action.status, "command": action.command, "progress": action.progress, "error": action.error, "started": action.started.isoformat() if action.started else None, "finished": action.finished.isoformat() if action.finished else None, } if action else None, } except Exception as e: return {"error": f"Failed to resize volume: {str(e)}"}
  • Pydantic schema/model for resize_volume tool parameters: volume_id (required int) and size (required int, new size in GB). Used for input validation.
    class ResizeVolumeParams(BaseModel): volume_id: int = Field(..., description="The ID of the volume") size: int = Field(..., description="New size of the volume in GB (must be greater than current size)")
  • The @mcp.tool() decorator registers the resize_volume function as an MCP tool.
    @mcp.tool()
  • Helper function to convert Hetzner Volume object to dictionary format, used in volume listing and details tools (potentially relevant for resize_volume responses).
    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