list_networks
List all networks available in your Civo cloud account to view their details and status.
Instructions
List available networks on Civo
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/networks.ts:3-10 (schema)Tool definition (schema) for list_networks — declares the tool name, description, and empty inputSchema (no parameters required).
export const LIST_NETWORKS_TOOL: Tool = { name: 'list_networks', description: 'List available networks on Civo', inputSchema: { type: 'object', properties: {}, }, }; - src/index.ts:62-91 (registration)Server capabilities registration — LIST_NETWORKS_TOOL is registered in the server's tool capabilities map at line 82.
// Server implementation const server = new Server( { name: 'example-servers/civo', version: '0.1.0', }, { capabilities: { tools: { [CREATE_INSTANCE_TOOL.name]: CREATE_INSTANCE_TOOL, [LIST_INSTANCES_TOOL.name]: LIST_INSTANCES_TOOL, [REBOOT_INSTANCE_TOOL.name]: REBOOT_INSTANCE_TOOL, [SHUTDOWN_INSTANCE_TOOL.name]: SHUTDOWN_INSTANCE_TOOL, [START_INSTANCE_TOOL.name]: START_INSTANCE_TOOL, [RESIZE_INSTANCE_TOOL.name]: RESIZE_INSTANCE_TOOL, [DELETE_INSTANCE_TOOL.name]: DELETE_INSTANCE_TOOL, [LIST_DISK_IMAGES_TOOL.name]: LIST_DISK_IMAGES_TOOL, [GET_DISK_IMAGE_TOOL.name]: GET_DISK_IMAGE_TOOL, [LIST_SIZES_TOOL.name]: LIST_SIZES_TOOL, [LIST_REGIONS_TOOL.name]: LIST_REGIONS_TOOL, [LIST_NETWORKS_TOOL.name]: LIST_NETWORKS_TOOL, [CREATE_NETWORK_TOOL.name]: CREATE_NETWORK_TOOL, [RENAME_NETWORK_TOOL.name]: RENAME_NETWORK_TOOL, [DELETE_NETWORK_TOOL.name]: DELETE_NETWORK_TOOL, [LIST_KUBERNETES_CLUSTERS_TOOL.name]: LIST_KUBERNETES_CLUSTERS_TOOL, [CREATE_KUBERNETES_CLUSTER_TOOL.name]: CREATE_KUBERNETES_CLUSTER_TOOL, [DELETE_KUBERNETES_CLUSTER_TOOL.name]: DELETE_KUBERNETES_CLUSTER_TOOL, [LIST_KUBERNETES_VERSIONS_TOOL.name]: LIST_KUBERNETES_VERSIONS_TOOL, }, }, - src/index.ts:96-118 (registration)ListToolsRequestSchema handler — LIST_NETWORKS_TOOL is included in the list of tools returned to clients (line 109).
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ CREATE_INSTANCE_TOOL, LIST_INSTANCES_TOOL, REBOOT_INSTANCE_TOOL, SHUTDOWN_INSTANCE_TOOL, START_INSTANCE_TOOL, RESIZE_INSTANCE_TOOL, DELETE_INSTANCE_TOOL, LIST_DISK_IMAGES_TOOL, GET_DISK_IMAGE_TOOL, LIST_SIZES_TOOL, LIST_REGIONS_TOOL, LIST_NETWORKS_TOOL, CREATE_NETWORK_TOOL, RENAME_NETWORK_TOOL, DELETE_NETWORK_TOOL, LIST_KUBERNETES_CLUSTERS_TOOL, CREATE_KUBERNETES_CLUSTER_TOOL, DELETE_KUBERNETES_CLUSTER_TOOL, LIST_KUBERNETES_VERSIONS_TOOL, ], })); - src/index.ts:362-377 (handler)CallToolRequestSchema handler for 'list_networks' — calls the listNetworks API function and formats the response with network names, IDs, and labels.
case 'list_networks': { const networks = await listNetworks(); const networkList = networks .map((n: any) => `${n.name} (${n.id}) - ${n.label}`) .join('\n'); return { content: [ { type: 'text', text: `Available Networks:\n${networkList}`, }, ], isError: false, }; } - src/api/networks.ts:1-25 (helper)Helper function listNetworks() that makes the actual HTTP GET request to CIVO_API_URL/networks and returns parsed Network[] data.
import { CIVO_API_KEY, CIVO_API_URL } from './civo.js'; export interface Network { id: string; name: string; default: boolean; cider: string; label: string; } export async function listNetworks(): Promise<Network[]> { const url = `${CIVO_API_URL}/networks`; const response = await fetch(url, { headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${CIVO_API_KEY}`, }, }); if (!response.ok) { throw new Error(`Failed to list networks: ${response.statusText}`); } return await response.json(); }