Skip to main content
Glama
phantosmax

CloudStack MCP Server

by phantosmax

list_hosts

Retrieve and filter hosts in Apache CloudStack based on zone, type, state, or hypervisor. Manage cloud infrastructure efficiently with this MCP tool.

Instructions

List hosts

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hypervisorNoHypervisor type
stateNoHost state
typeNoHost type (Routing, Storage, etc.)
zoneidNoZone ID to filter hosts

Implementation Reference

  • The main handler function for the 'list_hosts' tool. It queries the CloudStack API via the client, extracts host data, maps it to a simplified structure, and formats a detailed text response listing all hosts with their key attributes.
    async handleListHosts(args: any) { const result = await this.cloudStackClient.listHosts(args); const hosts = result.listhostsresponse?.host || []; const hostList = hosts.map((host: any) => ({ id: host.id, name: host.name, type: host.type, state: host.state, ipaddress: host.ipaddress, zonename: host.zonename, clustername: host.clustername, hypervisor: host.hypervisor, cpunumber: host.cpunumber, cpuspeed: host.cpuspeed, memorytotal: host.memorytotal, memoryused: host.memoryused })); return { content: [ { type: 'text', text: `Found ${hostList.length} hosts:\n\n${hostList .map((host: any) => `• ${host.name} (${host.id})\n Type: ${host.type}\n State: ${host.state}\n IP: ${host.ipaddress}\n Zone: ${host.zonename}\n Cluster: ${host.clustername}\n Hypervisor: ${host.hypervisor}\n CPUs: ${host.cpunumber} @ ${host.cpuspeed}MHz\n Memory: ${host.memoryused}/${host.memorytotal}MB\n` ) .join('\n')}` } ] }; }
  • Tool schema definition for 'list_hosts', including name, description, and input schema specifying optional parameters like zoneid, type, state, hypervisor.
    { name: 'list_hosts', description: 'List hosts', inputSchema: { type: 'object', properties: { zoneid: { type: 'string', description: 'Zone ID to filter hosts', }, type: { type: 'string', description: 'Host type (Routing, Storage, etc.)', }, state: { type: 'string', description: 'Host state', }, hypervisor: { type: 'string', description: 'Hypervisor type', }, }, additionalProperties: false, }, },
  • src/server.ts:188-189 (registration)
    Registers the 'list_hosts' tool in the MCP server's CallToolRequest handler by mapping the tool name to the adminHandlers.handleListHosts method.
    case 'list_hosts': return await this.adminHandlers.handleListHosts(args);
  • Helper method in CloudStackClient that wraps the generic API request for the 'listHosts' CloudStack API endpoint.
    async listHosts(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listHosts', 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