clone_proxmox_vm
Clone Proxmox virtual machines or containers to create new instances for testing, deployment, or backup purposes.
Instructions
Clone a VM or container to create a new one
Input Schema
TableJSON 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 that processes tool arguments and calls the clone_proxmox_vm implementation, returning formatted MCP content.
async def handle_clone_proxmox_vm(arguments: dict[str, Any]) -> dict[str, Any]: """Handle clone_proxmox_vm tool.""" 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"), ) return {"content": [{"type": "text", "text": json.dumps(result, indent=2)}]} - src/homelab_mcp/proxmox_api.py:539-590 (handler)Core implementation function that performs the actual VM cloning operation via Proxmox REST API, supporting both full and linked clones for VMs (qemu) and containers (lxc).
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", ) -> 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 Returns: Clone operation result """ client = get_proxmox_client(host=host) 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: {str(e)}", } - JSON Schema definition for the clone_proxmox_vm tool, defining input parameters (node, vmid, new_vmid, name, full, vm_type, host) and their types, constraints, and default values.
"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:29-131 (registration)Tool registration mapping clone_proxmox_vm to handle_clone_proxmox_vm function, imported from proxmox_handlers and registered in the TOOL_HANDLERS dictionary.
from .proxmox_handlers import ( handle_clone_proxmox_vm, handle_create_proxmox_lxc, handle_create_proxmox_vm, handle_delete_proxmox_vm, handle_get_proxmox_node_status, handle_get_proxmox_script_info, handle_get_proxmox_vm_status, handle_list_proxmox_resources, handle_manage_proxmox_vm, handle_search_proxmox_scripts, ) from .service_handlers import ( handle_check_ansible_service, handle_check_service_requirements, handle_destroy_terraform_service, handle_get_service_info, handle_get_service_status, handle_install_service, handle_list_available_services, handle_plan_terraform_service, handle_refresh_terraform_service, handle_run_ansible_playbook, ) from .ssh_handlers import ( handle_setup_mcp_admin, handle_ssh_discover, handle_ssh_execute_command, handle_start_interactive_shell, handle_update_mcp_admin_groups, handle_verify_mcp_admin, ) from .vm_handlers import ( handle_control_vm, handle_deploy_vm, handle_get_vm_logs, handle_get_vm_status, handle_list_vms, handle_remove_vm, ) # Type alias for handler functions ToolHandler = Callable[[dict[str, Any]], Awaitable[dict[str, Any]]] # Tool handler registry mapping tool names to their handler functions TOOL_HANDLERS: dict[str, ToolHandler] = { # SSH tools "ssh_discover": handle_ssh_discover, "setup_mcp_admin": handle_setup_mcp_admin, "verify_mcp_admin": handle_verify_mcp_admin, "ssh_execute_command": handle_ssh_execute_command, "start_interactive_shell": handle_start_interactive_shell, "update_mcp_admin_groups": handle_update_mcp_admin_groups, # Network tools "discover_and_map": handle_discover_and_map, "bulk_discover_and_map": handle_bulk_discover_and_map, "get_network_sitemap": handle_get_network_sitemap, "analyze_network_topology": handle_analyze_network_topology, "suggest_deployments": handle_suggest_deployments, "get_device_changes": handle_get_device_changes, # Infrastructure tools "deploy_infrastructure": handle_deploy_infrastructure, "update_device_config": handle_update_device_config, "decommission_device": handle_decommission_device, "scale_services": handle_scale_services, "validate_infrastructure_changes": handle_validate_infrastructure_changes, "create_infrastructure_backup": handle_create_infrastructure_backup, "rollback_infrastructure_changes": handle_rollback_infrastructure_changes, # VM tools "deploy_vm": handle_deploy_vm, "control_vm": handle_control_vm, "get_vm_status": handle_get_vm_status, "list_vms": handle_list_vms, "get_vm_logs": handle_get_vm_logs, "remove_vm": handle_remove_vm, # Service tools "list_available_services": handle_list_available_services, "get_service_info": handle_get_service_info, "check_service_requirements": handle_check_service_requirements, "install_service": handle_install_service, "get_service_status": handle_get_service_status, "plan_terraform_service": handle_plan_terraform_service, "destroy_terraform_service": handle_destroy_terraform_service, "refresh_terraform_service": handle_refresh_terraform_service, "check_ansible_service": handle_check_ansible_service, "run_ansible_playbook": handle_run_ansible_playbook, # Credential tools "register_server": handle_register_server, "list_registered_servers": handle_list_registered_servers, "update_server_credentials": handle_update_server_credentials, "remove_server": handle_remove_server, # Proxmox tools "search_proxmox_scripts": handle_search_proxmox_scripts, "get_proxmox_script_info": handle_get_proxmox_script_info, "list_proxmox_resources": handle_list_proxmox_resources, "get_proxmox_node_status": handle_get_proxmox_node_status, "get_proxmox_vm_status": handle_get_proxmox_vm_status, "manage_proxmox_vm": handle_manage_proxmox_vm, "create_proxmox_lxc": handle_create_proxmox_lxc, "create_proxmox_vm": handle_create_proxmox_vm, "clone_proxmox_vm": handle_clone_proxmox_vm, "delete_proxmox_vm": handle_delete_proxmox_vm, }