Skip to main content
Glama
phantosmax

CloudStack MCP Server

by phantosmax

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
NameRequiredDescriptionDefault
hypervisorNoHypervisor type
zoneidNoZone ID to filter clusters

Implementation Reference

  • 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);
  • 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); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/phantosmax/cloudstack-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server