list_networks
Discover available networks in the CloudStack MCP Server by filtering based on zone, type, or default status. Manage and query network configurations efficiently.
Instructions
List networks
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| isdefault | No | Filter by default networks | |
| type | No | Network type (Isolated, Shared, L2) | |
| zoneid | No | Zone ID to filter networks |
Implementation Reference
- src/handlers/network-handlers.ts:6-37 (handler)The main handler function that executes the list_networks tool logic: calls CloudStack API, processes networks, formats output as MCP content.
async handleListNetworks(args: any) { const result = await this.cloudStackClient.listNetworks(args); const networks = result.listnetworksresponse?.network || []; const networkList = networks.map((network: any) => ({ id: network.id, name: network.name, displaytext: network.displaytext, type: network.type, state: network.state, zonename: network.zonename, cidr: network.cidr, gateway: network.gateway, netmask: network.netmask, vlan: network.vlan, broadcasturi: network.broadcasturi, traffictype: network.traffictype })); return { content: [ { type: 'text', text: `Found ${networkList.length} networks:\n\n${networkList .map((net: any) => `• ${net.name} (${net.id})\n Display Text: ${net.displaytext}\n Type: ${net.type}\n State: ${net.state}\n Zone: ${net.zonename}\n CIDR: ${net.cidr}\n Gateway: ${net.gateway}\n Netmask: ${net.netmask}\n VLAN: ${net.vlan || 'N/A'}\n` ) .join('\n')}` } ] }; } - Tool schema definition including name, description, and input schema for list_networks.
{ name: 'list_networks', description: 'List networks', inputSchema: { type: 'object', properties: { zoneid: { type: 'string', description: 'Zone ID to filter networks', }, type: { type: 'string', description: 'Network type (Isolated, Shared, L2)', }, isdefault: { type: 'boolean', description: 'Filter by default networks', }, }, additionalProperties: false, }, }, - src/server.ts:150-151 (registration)Registration and dispatch of the list_networks tool in the MCP server request handler switch statement.
case 'list_networks': return await this.networkHandlers.handleListNetworks(args); - src/cloudstack-client.ts:133-135 (helper)CloudStack client helper method that makes the API request for listing networks.
async listNetworks(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listNetworks', params); }