list_hosts
List hypervisor hosts across clusters with names, IPs, capacity, and health. Filter by cluster or OData expression to narrow results.
Instructions
List hypervisor hosts across clusters. Returns host names, IPs, resource capacity, and health. Optionally filter by cluster.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cluster_uuid | No | Filter hosts to a specific cluster UUID | |
| filter | No | OData filter expression | |
| limit | No | Maximum number of hosts to return. Omit to retrieve all (auto-paginates). |
Implementation Reference
- Schema/definition of the list_hosts tool, including name, description, and inputSchema with optional cluster_uuid, filter, and limit parameters.
{ "name": "list_hosts", "description": ( "List hypervisor hosts across clusters. Returns host names, IPs, " "resource capacity, and health. Optionally filter by cluster." ), "inputSchema": { "type": "object", "properties": { "cluster_uuid": { "type": "string", "description": "Filter hosts to a specific cluster UUID", }, "filter": { "type": "string", "description": "OData filter expression", }, "limit": { "type": "integer", "description": "Maximum number of hosts to return. Omit to retrieve all (auto-paginates).", }, }, }, }, - src/nutanix_mcp/tools/cluster.py:151-197 (handler)Handler function handle_list_hosts: executes the list_hosts tool logic, calls v4 clustermgmt API to list hosts (optionally filtered by cluster_uuid), extracts hypervisor host info (name, extId, IP, CPU, memory, cluster), and returns paginated results.
async def handle_list_hosts( client: NutanixClient, arguments: dict[str, Any] ) -> dict[str, Any]: """List hosts using v4 clustermgmt API.""" cluster_uuid = arguments.get("cluster_uuid") filter_expr = arguments.get("filter") limit = arguments.get("limit") # If cluster_uuid provided, filter to that cluster's hosts if cluster_uuid: path = f"config/clusters/{cluster_uuid}/hosts" else: path = "config/hosts" result = await client.v4_list_all( namespace="clustermgmt", path=path, filter=filter_expr, max_results=limit, ) hosts = result.get("data", []) metadata = result.get("metadata", {}) def _extract_host(h: dict) -> dict: hypervisor = h.get("hypervisor") or {} ext_addr = hypervisor.get("externalAddress") or {} ipv4 = ext_addr.get("ipv4") or {} cluster_ref = h.get("cluster") or {} return { "name": h.get("hostName"), "extId": h.get("extId"), "hypervisorType": hypervisor.get("type"), "ipAddress": ipv4.get("value"), "cpuModel": h.get("cpuModel"), "numCpuSockets": h.get("numberOfCpuSockets"), "numCpuCores": h.get("numberOfCpuCores"), "memorySizeBytes": h.get("memorySizeBytes"), "cluster": cluster_ref.get("uuid") or cluster_ref.get("extId"), "clusterName": cluster_ref.get("name"), } return { "count": len(hosts), "truncated": metadata.get("truncated", False), "hosts": [_extract_host(h) for h in hosts], } - src/nutanix_mcp/tools/cluster.py:253-259 (registration)CLUSTER_HANDLERS dispatch dictionary mapping 'list_hosts' to handle_list_hosts function.
CLUSTER_HANDLERS: dict[str, Any] = { "list_clusters": handle_list_clusters, "get_cluster": handle_get_cluster, "list_hosts": handle_list_hosts, "get_host": handle_get_host, "list_storage_containers": handle_list_storage_containers, } - src/nutanix_mcp/config.py:36-40 (helper)Config reference: allowed_pe_hosts setting mentions that PE tools accept hosts discovered via list_hosts.
allowed_pe_hosts: list[str] = Field( default_factory=list, description=( "Allowlist of Prism Element hosts (IPs or hostnames). " "If empty, PE tools will only accept hosts discovered via list_hosts. "