Skip to main content
Glama
dkruyt

Hetzner Cloud MCP Server

by dkruyt

attach_volume

Attach a Hetzner Cloud volume to a server and optionally mount it for expanded storage capacity.

Instructions

Attach a volume to a server.

Attaches a volume to a server and optionally mounts it.

Example:
- Attach volume: {"volume_id": 12345, "server_id": 67890}
- Attach and mount: {"volume_id": 12345, "server_id": 67890, "automount": true}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The handler function implementing the attach_volume tool logic. It retrieves the volume and server, attaches the volume using the Hetzner client, and returns the action status.
    @mcp.tool()
    def attach_volume(params: AttachVolumeParams) -> Dict[str, Any]:
        """
        Attach a volume to a server.
        
        Attaches a volume to a server and optionally mounts it.
        
        Example:
        - Attach volume: {"volume_id": 12345, "server_id": 67890}
        - Attach and mount: {"volume_id": 12345, "server_id": 67890, "automount": true}
        """
        try:
            volume = client.volumes.get_by_id(params.volume_id)
            if not volume:
                return {"error": f"Volume with ID {params.volume_id} not found"}
            
            server = client.servers.get_by_id(params.server_id)
            if not server:
                return {"error": f"Server with ID {params.server_id} not found"}
            
            action = client.volumes.attach(volume, server, params.automount)
            
            # 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 attach volume: {str(e)}"}
  • Pydantic BaseModel defining the input parameters for the attach_volume tool.
    class AttachVolumeParams(BaseModel):
        volume_id: int = Field(..., description="The ID of the volume")
        server_id: int = Field(..., description="The ID of the server to attach the volume to")
        automount: Optional[bool] = Field(False, description="Auto-mount the volume after attaching it")
  • The @mcp.tool() decorator registers the attach_volume function as an MCP tool.
    @mcp.tool()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool 'attaches a volume to a server and optionally mounts it,' which implies a mutation operation, but doesn't address critical behavioral aspects like permissions required, whether the operation is reversible, potential side effects, or error conditions (e.g., if volume is already attached).

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?

The description is appropriately sized and front-loaded with the core purpose in the first sentence. The examples are helpful and directly relevant, though the structure could be slightly improved by separating the optional mounting behavior into its own sentence for clarity.

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

Completeness3/5

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

Given that there's an output schema (which handles return values) but no annotations and 0% schema description coverage, the description is moderately complete. It covers the basic operation and parameters via examples, but lacks behavioral details (e.g., permissions, reversibility) and usage guidelines, which are important for a mutation tool like this.

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

Parameters3/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. It provides examples that illustrate the three parameters (volume_id, server_id, automount) and their usage, adding meaningful context beyond the bare schema. However, it doesn't explain parameter constraints (e.g., valid ID ranges) or the effect of automount beyond 'mounts it,' leaving some gaps.

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 tool's purpose with a specific verb ('Attach') and resource ('a volume to a server'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from the sibling tool 'detach_volume', which would be helpful for complete clarity.

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?

The description provides no guidance on when to use this tool versus alternatives like 'detach_volume' or 'create_volume', nor does it mention prerequisites (e.g., volume/server must exist) or constraints (e.g., volume must be detached). The examples show usage but don't provide contextual guidance.

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