Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

create_volume

Add storage volumes to Hetzner Cloud servers by specifying name, size, location, format, and attachment options.

Instructions

Create a new volume.

Creates a new volume with the specified configuration.

Examples:
- Basic volume: {"name": "data-volume", "size": 10}
- With location: {"name": "db-volume", "size": 100, "location": "fsn1"}
- Attached to server: {"name": "app-volume", "size": 50, "server": 123456, "automount": true}
- With format: {"name": "log-volume", "size": 20, "format": "ext4"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Pydantic BaseModel defining the input parameters and validation for the create_volume tool.
    class CreateVolumeParams(BaseModel):
        name: str = Field(..., description="Name of the volume")
        size: int = Field(..., description="Size of the volume in GB (min 10, max 10240)")
        location: Optional[str] = Field(None, description="Location where the volume will be created (e.g., nbg1, fsn1)")
        server: Optional[int] = Field(None, description="ID of the server to attach the volume to")
        automount: Optional[bool] = Field(False, description="Auto-mount the volume after attaching it")
        format: Optional[str] = Field(None, description="Filesystem format (e.g., xfs, ext4)")
        labels: Optional[Dict[str, str]] = Field(None, description="User-defined labels (key-value pairs)")
  • The primary handler function decorated with @mcp.tool(), implementing the create_volume tool logic: validates inputs, resolves location and server objects, calls Hetzner Cloud API to create volume, handles response and formats output including volume details, action status, and next actions.
    @mcp.tool()
    def create_volume(params: CreateVolumeParams) -> Dict[str, Any]:
        """
        Create a new volume.
        
        Creates a new volume with the specified configuration.
        
        Examples:
        - Basic volume: {"name": "data-volume", "size": 10}
        - With location: {"name": "db-volume", "size": 100, "location": "fsn1"}
        - Attached to server: {"name": "app-volume", "size": 50, "server": 123456, "automount": true}
        - With format: {"name": "log-volume", "size": 20, "format": "ext4"}
        """
        try:
            # Get location if provided
            location = None
            if params.location:
                location = client.locations.get_by_name(params.location)
                if not location:
                    return {"error": f"Location '{params.location}' not found"}
            
            # Get server if provided
            server = None
            if params.server:
                server = client.servers.get_by_id(params.server)
                if not server:
                    return {"error": f"Server with ID {params.server} not found"}
            
            # Create the volume
            response = client.volumes.create(
                name=params.name,
                size=params.size,
                location=location,
                server=server,
                automount=params.automount,
                format=params.format,
                labels=params.labels
            )
            
            # Extract volume and action information
            volume = response.volume
            action = response.action
            next_actions = response.next_actions
            
            # Format the response
            return {
                "volume": volume_to_dict(volume),
                "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,
                "next_actions": [
                    {
                        "id": next_action.id,
                        "status": next_action.status,
                        "command": next_action.command,
                        "progress": next_action.progress,
                        "error": next_action.error,
                        "started": next_action.started.isoformat() if next_action.started else None,
                        "finished": next_action.finished.isoformat() if next_action.finished else None,
                    }
                    for next_action in next_actions
                ] if next_actions else None,
            }
        except Exception as e:
            return {"error": f"Failed to create volume: {str(e)}"}
  • Helper function used by create_volume (and other volume tools) to serialize Volume domain objects into JSON-friendly dictionaries for the tool 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,
        }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but lacks critical behavioral details. It mentions 'Creates a new volume with the specified configuration' but doesn't disclose permissions required, rate limits, whether it's idempotent, or what happens on failure (e.g., if server ID is invalid). Examples show outcomes but not operational constraints.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the purpose, followed by examples that efficiently illustrate parameter combinations. Each example sentence earns its place by demonstrating different use cases. However, the first two sentences are somewhat redundant ('Create a new volume' and 'Creates a new volume...'), slightly reducing efficiency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations, 0% schema coverage, but with an output schema (implied by context signals), the description is fairly complete. It covers purpose and parameters well via examples, though it lacks behavioral context like error handling or side effects. The output schema likely handles return values, so this is adequate but not exhaustive.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate fully. It provides rich examples that clarify parameter usage beyond the schema: e.g., 'size' in GB with implied ranges, 'location' values like 'fsn1', 'server' as an ID, 'automount' for attachment, and 'format' options. This adds significant meaning to all parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Create a new volume') and specifies it's for creating with configuration. It distinguishes from siblings like 'attach_volume' or 'resize_volume' by focusing on creation. However, it doesn't explicitly contrast with 'create_server' or other creation tools, keeping it at 4 rather than 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance on when to use this tool versus alternatives like 'create_server' (which might include storage) or 'attach_volume' (for existing volumes). The examples imply usage but don't state explicit contexts or prerequisites, such as needing a server ID for attachment or location availability.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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