pe_list_vms
List virtual machines on a Prism Element cluster, retrieving names, UUIDs, power states, and resource allocation for specified hosts.
Instructions
List VMs on a specific Prism Element cluster. Returns VM names, UUIDs, power states, and resource allocation.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pe_host | Yes | Prism Element CVM IP address or hostname | |
| count | No | Maximum number of VMs to return |
Implementation Reference
- The main handler function for pe_list_vms. Calls client.pe_list(pe_host, 'vms', count=count) to fetch VMs from Prism Element v2 API, then extracts name, uuid, powerState, numVcpus, memoryMb, hostUuid, and ipAddresses for each VM.
async def handle_pe_list_vms( client: NutanixClient, arguments: dict[str, Any] ) -> dict[str, Any]: """List VMs from Prism Element v2 API.""" pe_host = arguments["pe_host"] count = arguments.get("count") result = await client.pe_list(pe_host, "vms", count=count) entities = result.get("entities", []) return { "count": len(entities), "vms": [ { "name": vm.get("name"), "uuid": vm.get("uuid"), "powerState": vm.get("power_state"), "numVcpus": vm.get("num_vcpus"), "memoryMb": vm.get("memory_mb"), "hostUuid": vm.get("host_uuid"), "ipAddresses": vm.get("ip_addresses", []), } for vm in entities ], } - The input schema (JSON Schema) for pe_list_vms. Defines required 'pe_host' (string) and optional 'count' (integer) parameters.
{ "name": "pe_list_vms", "description": ( "List VMs on a specific Prism Element cluster. " "Returns VM names, UUIDs, power states, and resource allocation." ), "inputSchema": { "type": "object", "properties": { "pe_host": { "type": "string", "description": "Prism Element CVM IP address or hostname", }, "count": { "type": "integer", "description": "Maximum number of VMs to return", }, }, "required": ["pe_host"], }, - src/nutanix_mcp/tools/prism_element.py:418-430 (registration)The handler dispatch dictionary (PE_HANDLERS) that maps 'pe_list_vms' to the handle_pe_list_vms function. This is merged into ALL_HANDLERS in server.py.
# ─── Handler Dispatch ───────────────────────────────────────────────────────── PE_HANDLERS: dict[str, Any] = { "pe_get_cluster_info": handle_pe_get_cluster_info, "pe_list_vms": handle_pe_list_vms, "pe_list_hosts": handle_pe_list_hosts, "pe_list_containers": handle_pe_list_containers, "pe_list_storage_pools": handle_pe_list_storage_pools, "pe_list_disks": handle_pe_list_disks, "pe_list_alerts": handle_pe_list_alerts, "pe_list_protection_domains": handle_pe_list_protection_domains, "pe_list_snapshots": handle_pe_list_snapshots, } - src/nutanix_mcp/client.py:436-457 (helper)The pe_list helper method in NutanixClient that handles the actual API call to Prism Element's v2 API. Called by handle_pe_list_vms with resource='vms'.
async def pe_list( self, pe_host: str, resource: str, count: Optional[int] = None, filter_criteria: Optional[str] = None, ) -> dict[str, Any]: """List resources from a Prism Element node using v2 API. Args: pe_host: Prism Element CVM IP or hostname resource: Resource type (e.g., 'vms', 'hosts', 'disks', 'containers') count: Max results to return filter_criteria: Filter string for the query """ params: dict[str, str] = {} if count is not None: params["count"] = str(count) if filter_criteria: params["filter_criteria"] = filter_criteria return await self.pe_get(pe_host, resource, params=params) - src/nutanix_mcp/server.py:52-62 (registration)The MCP server registration via @server.list_tools() which returns the tool definitions (including pe_list_vms) to the MCP protocol.
@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 ]