list_domains
Retrieve domain details in an Apache CloudStack environment by specifying domain level or name using the MCP-enabled server tool for efficient cloud resource management.
Instructions
List domains
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| level | No | Domain level | |
| name | No | Domain name |
Implementation Reference
- src/handlers/admin-handlers.ts:123-150 (handler)The handler function that implements the core logic for the 'list_domains' tool. It queries the CloudStack client for domains, processes the response, formats it into a readable list, and returns it in the MCP content format.async handleListDomains(args: any) { const result = await this.cloudStackClient.listDomains(args); const domains = result.listdomainsresponse?.domain || []; const domainList = domains.map((domain: any) => ({ id: domain.id, name: domain.name, path: domain.path, level: domain.level, parentdomainid: domain.parentdomainid, parentdomainname: domain.parentdomainname, haschild: domain.haschild, state: domain.state })); return { content: [ { type: 'text', text: `Found ${domainList.length} domains:\n\n${domainList .map((domain: any) => `• ${domain.name} (${domain.id})\n Path: ${domain.path}\n Level: ${domain.level}\n Parent: ${domain.parentdomainname || 'None'}\n Has Children: ${domain.haschild}\n State: ${domain.state}\n` ) .join('\n')}` } ] }; }
- The tool definition including name, description, and input schema for 'list_domains', which specifies optional parameters for filtering domains by level or name.name: 'list_domains', description: 'List domains', inputSchema: { type: 'object', properties: { level: { type: 'number', description: 'Domain level', }, name: { type: 'string', description: 'Domain name', }, }, additionalProperties: false, }, },
- src/server.ts:186-187 (registration)The dispatch case in the CallToolRequest handler that registers and routes calls to the 'list_domains' tool to its specific handler method.case 'list_domains': return await this.adminHandlers.handleListDomains(args);
- src/cloudstack-client.ts:247-249 (helper)Supporting method in the CloudStack client that makes the underlying API request to 'listDomains' endpoint.async listDomains(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listDomains', params); }