list_accounts
Retrieve and filter accounts within a domain on the CloudStack MCP Server by account type or state to manage user roles and access effectively.
Instructions
List accounts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accounttype | No | Account type (0=User, 1=Admin, 2=DomainAdmin) | |
| domainid | No | Domain ID to filter accounts | |
| state | No | Account state |
Implementation Reference
- src/handlers/admin-handlers.ts:64-90 (handler)MCP tool handler function that executes list_accounts: calls CloudStack API via client, processes accounts, formats as text response.async handleListAccounts(args: any) { const result = await this.cloudStackClient.listAccounts(args); const accounts = result.listaccountsresponse?.account || []; const accountList = accounts.map((account: any) => ({ id: account.id, name: account.name, accounttype: account.accounttype, domain: account.domain, state: account.state, receivedbytes: account.receivedbytes, sentbytes: account.sentbytes })); return { content: [ { type: 'text', text: `Found ${accountList.length} accounts:\n\n${accountList .map((account: any) => `• ${account.name} (${account.id})\n Type: ${account.accounttype}\n Domain: ${account.domain}\n State: ${account.state}\n Received: ${account.receivedbytes} bytes\n Sent: ${account.sentbytes} bytes\n` ) .join('\n')}` } ] }; }
- Tool definition and input schema for list_accounts tool.{ name: 'list_accounts', description: 'List accounts', inputSchema: { type: 'object', properties: { domainid: { type: 'string', description: 'Domain ID to filter accounts', }, state: { type: 'string', description: 'Account state', }, accounttype: { type: 'number', description: 'Account type (0=User, 1=Admin, 2=DomainAdmin)', }, }, additionalProperties: false, }, },
- src/server.ts:182-183 (registration)Tool dispatch/registration in the MCP server request handler switch statement.case 'list_accounts': return await this.adminHandlers.handleListAccounts(args);
- src/cloudstack-client.ts:239-240 (helper)CloudStack client helper method that makes the underlying listAccounts API request.async listAccounts(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listAccounts', params);