list_subnets
Retrieve subnets/VLANs configured in Prism Central including names, VLAN IDs, CIDRs, IP pools, and associated clusters. Supports filtering by name or VLAN ID and limiting results.
Instructions
List subnets/VLANs configured in Prism Central. Returns subnet names, VLAN IDs, CIDRs, IP pools, and associated clusters.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | OData filter expression. Examples: "name eq 'production-vlan'", "vlanId eq 100" | |
| limit | No | Maximum number of subnets to return. Omit to retrieve all (auto-paginates). |
Implementation Reference
- Handler for list_subnets - calls v4 networking API config/subnets endpoint with optional filter/limit, auto-paginates, returns formatted subnet list
async def handle_list_subnets( client: NutanixClient, arguments: dict[str, Any] ) -> dict[str, Any]: """List subnets using v4 networking API.""" filter_expr = arguments.get("filter") limit = arguments.get("limit") result = await client.v4_list_all( namespace="networking", path="config/subnets", filter=filter_expr, max_results=limit, ) subnets = result.get("data", []) metadata = result.get("metadata", {}) return { "count": len(subnets), "truncated": metadata.get("truncated", False), "subnets": [ { "name": s.get("name"), "extId": s.get("extId"), "subnetType": s.get("subnetType"), "vlanId": s.get("networkId"), "cidr": _extract_cidr(s), "cluster": s.get("clusterReference"), } for s in subnets ], } - Schema definition for list_subnets tool - defines optional 'filter' (string) and 'limit' (integer) input parameters
{ "name": "list_subnets", "description": ( "List subnets/VLANs configured in Prism Central. Returns subnet names, " "VLAN IDs, CIDRs, IP pools, and associated clusters." ), "inputSchema": { "type": "object", "properties": { "filter": { "type": "string", "description": ( "OData filter expression. Examples: " "\"name eq 'production-vlan'\", \"vlanId eq 100\"" ), }, "limit": { "type": "integer", "description": "Maximum number of subnets to return. Omit to retrieve all (auto-paginates).", }, }, }, }, - Helper function used by handle_list_subnets to extract CIDR notation from subnet IP configuration
def _extract_cidr(subnet: dict) -> str | None: """Extract CIDR from subnet IP config.""" ip_config = subnet.get("ipConfig") if not ip_config: return None # ipConfig can be a list of configs or a single dict if isinstance(ip_config, list): ip_config = ip_config[0] if ip_config else None if not ip_config or not isinstance(ip_config, dict): return None ipv4 = ip_config.get("ipv4", {}) if not ipv4: return None ip_subnet = ipv4.get("ipSubnet", {}) if not ip_subnet: return None ip = ip_subnet.get("ip", {}).get("value") prefix = ip_subnet.get("prefixLength") if ip and prefix: return f"{ip}/{prefix}" return None - src/nutanix_mcp/tools/networking.py:292-299 (registration)Handler dispatch mapping - maps 'list_subnets' string to handle_list_subnets function
NETWORKING_HANDLERS: dict[str, Any] = { "list_subnets": handle_list_subnets, "get_subnet": handle_get_subnet, "list_images": handle_list_images, "get_image": handle_get_image, "list_categories": handle_list_categories, "get_category": handle_get_category, } - src/nutanix_mcp/server.py:34-41 (registration)Merges NETWORKING_HANDLERS into ALL_HANDLERS for tool dispatch in the MCP server's call_tool handler
# Merge all handler dispatch tables ALL_HANDLERS: dict[str, Any] = { **VM_HANDLERS, **CLUSTER_HANDLERS, **PE_HANDLERS, **REPORT_HANDLERS, **NETWORKING_HANDLERS, }