clone_proxmox_vm
Clone a Proxmox VM or container to create a new instance. Specify source and new VM IDs for the clone.
Instructions
Clone a VM or container to create a new one
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| node | Yes | Node name | |
| vmid | Yes | Source VM/Container ID | |
| new_vmid | Yes | New VM/Container ID | |
| name | No | New VM name (optional) | |
| full | No | Full clone (true) or linked clone (false) | |
| vm_type | No | Type: 'qemu' for VM or 'lxc' for container | qemu |
| host | No | Proxmox host (optional) |
Implementation Reference
- Handler function for clone_proxmox_vm tool. Validates hostname, calls the API function clone_proxmox_vm, and returns formatted response.
async def handle_clone_proxmox_vm(arguments: dict[str, Any]) -> dict[str, Any]: """Handle clone_proxmox_vm tool.""" from ..server import get_resource_manager if host := arguments.get("host"): validate_hostname(host) result = await clone_proxmox_vm( node=arguments["node"], vmid=arguments["vmid"], new_vmid=arguments["new_vmid"], host=arguments.get("host"), name=arguments.get("name"), full=arguments.get("full", True), vm_type=arguments.get("vm_type", "qemu"), session=get_resource_manager().proxmox_session, ) return {"content": [{"type": "text", "text": json.dumps(result, indent=2)}]} - Core API function that performs the actual Proxmox clone operation via REST API POST request to /nodes/{node}/{vm_type}/{vmid}/clone.
async def clone_proxmox_vm( node: str, vmid: int, new_vmid: int, host: str | None = None, name: str | None = None, full: bool = True, vm_type: str = "qemu", session: aiohttp.ClientSession | None = None, ) -> dict[str, Any]: """ Clone a VM or container. Args: node: Node name vmid: Source VM/Container ID new_vmid: New VM/Container ID host: Proxmox host (optional) name: New VM name full: Full clone (True) or linked clone (False) vm_type: 'qemu' for VM or 'lxc' for container session: Optional shared aiohttp.ClientSession (from ResourceManager) Returns: Clone operation result """ client = await get_proxmox_client(host=host, session=session) try: config: dict[str, Any] = { "newid": new_vmid, "full": 1 if full else 0, } if name: config["name"] = name result = await client.post(f"/nodes/{node}/{vm_type}/{vmid}/clone", config) return { "status": "success", "node": node, "source_vmid": vmid, "new_vmid": new_vmid, "message": f"VM {vmid} cloned to {new_vmid} successfully", "data": result, } except (aiohttp.ClientError, ValueError) as e: logger.error("Error cloning VM: %s", str(e)) return { "status": "error", "message": f"Failed to clone VM: {sanitize_error(e)}", } - Input schema for clone_proxmox_vm tool defining parameters: node, vmid, new_vmid, name, full, vm_type, host.
"clone_proxmox_vm": { "description": "Clone a VM or container to create a new one", "inputSchema": { "type": "object", "properties": { "node": { "type": "string", "description": "Node name", }, "vmid": { "type": "integer", "description": "Source VM/Container ID", }, "new_vmid": { "type": "integer", "description": "New VM/Container ID", }, "name": { "type": "string", "description": "New VM name (optional)", }, "full": { "type": "boolean", "description": "Full clone (true) or linked clone (false)", "default": True, }, "vm_type": { "type": "string", "description": "Type: 'qemu' for VM or 'lxc' for container", "enum": ["qemu", "lxc"], "default": "qemu", }, "host": { "type": "string", "description": "Proxmox host (optional)", }, }, "required": ["node", "vmid", "new_vmid"], }, }, - src/homelab_mcp/tool_handlers/__init__.py:147-147 (registration)Registration of clone_proxmox_vm handler in the TOOL_HANDLERS dictionary.
"clone_proxmox_vm": handle_clone_proxmox_vm, - src/homelab_mcp/tool_annotations.py:153-157 (registration)Tool annotations for clone_proxmox_vm marking it as not read-only, destructive, or idempotent.
"clone_proxmox_vm": ToolAnnotations( readOnlyHint=False, destructiveHint=False, idempotentHint=False, ),