create_vm
Create a new virtual machine by providing a name, cluster UUID, and optional vCPU, memory, and disk specifications.
Instructions
Create a new virtual machine. Requires name, cluster UUID, and basic specs.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Name for the new VM | |
| cluster_uuid | Yes | UUID of the cluster to create the VM on | |
| num_vcpus | No | Number of vCPUs (default: 2) | |
| memory_mb | No | Memory in MB (default: 4096) | |
| disk_size_gb | No | Boot disk size in GB (default: 40) |
Implementation Reference
- src/nutanix_mcp/tools/vm.py:201-235 (handler)The async handler function that creates a VM. Extracts arguments (name, cluster_uuid, num_vcpus, memory_mb, disk_size_gb), builds the request body, and calls v4_post to the Nutanix vmm API at 'ahv/config/vms'. Returns a taskExtId for tracking the async VM creation.
async def handle_create_vm( client: NutanixClient, arguments: dict[str, Any] ) -> dict[str, Any]: """Create a VM using v4 vmm API.""" name = arguments["name"] cluster_uuid = arguments["cluster_uuid"] num_vcpus = arguments.get("num_vcpus", 2) memory_mb = arguments.get("memory_mb", 4096) disk_size_gb = arguments.get("disk_size_gb", 40) body = { "name": name, "cluster": {"extId": cluster_uuid}, "numSockets": 1, "numCoresPerSocket": num_vcpus, "memorySizeBytes": memory_mb * 1024 * 1024, "disks": [ { "diskSizeBytes": disk_size_gb * 1024 * 1024 * 1024, "storageConfig": { "storageContainerReference": None, }, } ], } result = await client.v4_post( namespace="vmm", path="ahv/config/vms", body=body, ) return { "status": "vm_creation_initiated", "taskExtId": result.get("data", {}).get("extId"), } - src/nutanix_mcp/tools/vm.py:85-119 (schema)The input schema definition for the 'create_vm' tool. Defines parameters: name (required), cluster_uuid (required), num_vcpus (default 2), memory_mb (default 4096), disk_size_gb (default 40).
{ "name": "create_vm", "description": ( "Create a new virtual machine. Requires name, cluster UUID, and basic specs." ), "inputSchema": { "type": "object", "properties": { "name": { "type": "string", "description": "Name for the new VM", }, "cluster_uuid": { "type": "string", "description": "UUID of the cluster to create the VM on", }, "num_vcpus": { "type": "integer", "description": "Number of vCPUs (default: 2)", "default": 2, }, "memory_mb": { "type": "integer", "description": "Memory in MB (default: 4096)", "default": 4096, }, "disk_size_gb": { "type": "integer", "description": "Boot disk size in GB (default: 40)", "default": 40, }, }, "required": ["name", "cluster_uuid"], }, }, - src/nutanix_mcp/tools/vm.py:240-246 (registration)The handler dispatch table mapping the string 'create_vm' to the handle_create_vm function in the VM_HANDLERS dictionary.
VM_HANDLERS: dict[str, Any] = { "list_vms": handle_list_vms, "get_vm": handle_get_vm, "power_on_vm": handle_power_on_vm, "power_off_vm": handle_power_off_vm, "create_vm": handle_create_vm, } - src/nutanix_mcp/server.py:34-41 (registration)The ALL_HANDLERS dictionary in server.py that merges VM_HANDLERS (among others) into a single dispatch table used by the call_tool handler.
# Merge all handler dispatch tables ALL_HANDLERS: dict[str, Any] = { **VM_HANDLERS, **CLUSTER_HANDLERS, **PE_HANDLERS, **REPORT_HANDLERS, **NETWORKING_HANDLERS, } - src/nutanix_mcp/server.py:52-62 (registration)The list_tools handler in server.py that registers all tool definitions (including create_vm's schema) via the MCP list_tools() decorator.
@server.list_tools() async def list_tools() -> list[Tool]: """Return the list of available tools.""" return [ Tool( name=tool["name"], description=tool["description"], inputSchema=tool["inputSchema"], ) for tool in all_tools ]