detach_volume
Detach a volume from a Hetzner Cloud server to disconnect storage resources and manage server configurations.
Instructions
Detach a volume from a server.
Detaches a volume from the server it's currently attached to.
Example:
- Detach volume: {"volume_id": 12345}
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| params | Yes |
Implementation Reference
- mcp_hetzner/server.py:1128-1162 (handler)The handler function for detach_volume tool. Retrieves the volume by ID, checks if attached, calls client.volumes.detach(), and returns action status.@mcp.tool() def detach_volume(params: VolumeIdParam) -> Dict[str, Any]: """ Detach a volume from a server. Detaches a volume from the server it's currently attached to. Example: - Detach volume: {"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"} if not volume.server: return {"error": f"Volume with ID {params.volume_id} is not attached to any server"} action = client.volumes.detach(volume) # 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 detach volume: {str(e)}"}
- mcp_hetzner/server.py:215-216 (schema)Pydantic input schema for detach_volume (and other volume tools), requiring the volume_id integer.class VolumeIdParam(BaseModel): volume_id: int = Field(..., description="The ID of the volume")