list_clusters
Retrieve a list of clusters in the CloudStack MCP Server, filtered by zone ID or hypervisor type, to manage and monitor cloud resources efficiently.
Instructions
List clusters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hypervisor | No | Hypervisor type | |
| zoneid | No | Zone ID to filter clusters |
Implementation Reference
- src/handlers/admin-handlers.ts:185-211 (handler)The main handler function for the 'list_clusters' tool. It invokes the CloudStack client to list clusters, processes the response by mapping cluster details, and formats it as a structured text content block for the MCP protocol response.async handleListClusters(args: any) { const result = await this.cloudStackClient.listClusters(args); const clusters = result.listclustersresponse?.cluster || []; const clusterList = clusters.map((cluster: any) => ({ id: cluster.id, name: cluster.name, zonename: cluster.zonename, hypervisortype: cluster.hypervisortype, clustertype: cluster.clustertype, allocationstate: cluster.allocationstate, managedstate: cluster.managedstate })); return { content: [ { type: 'text', text: `Found ${clusterList.length} clusters:\n\n${clusterList .map((cluster: any) => `• ${cluster.name} (${cluster.id})\n Zone: ${cluster.zonename}\n Hypervisor: ${cluster.hypervisortype}\n Type: ${cluster.clustertype}\n Allocation State: ${cluster.allocationstate}\n Managed State: ${cluster.managedstate}\n` ) .join('\n')}` } ] }; }
- The tool definition object for 'list_clusters', including the name, description, and inputSchema for validation of parameters like zoneid and hypervisor.{ name: 'list_clusters', description: 'List clusters', inputSchema: { type: 'object', properties: { zoneid: { type: 'string', description: 'Zone ID to filter clusters', }, hypervisor: { type: 'string', description: 'Hypervisor type', }, }, additionalProperties: false, }, },
- src/server.ts:190-191 (registration)Registration and dispatch logic in the MCP server's CallToolRequestSchema handler. The switch statement routes calls to the 'list_clusters' tool to the corresponding AdminHandlers method.case 'list_clusters': return await this.adminHandlers.handleListClusters(args);
- src/cloudstack-client.ts:260-262 (helper)Supporting method in the CloudStackClient class that wraps the low-level 'listClusters' API request, handling authentication and HTTP communication with the CloudStack server.async listClusters(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listClusters', params); }