list_users
Retrieve a list of users in CloudStack MCP Server by filtering based on account, domain ID, or user state for efficient user management.
Instructions
List users
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "list_users"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account | No | Account name to filter users | |
| domainid | No | Domain ID to filter users | |
| state | No | User state |
Implementation Reference
- src/handlers/admin-handlers.ts:92-121 (handler)The handler function that implements the core logic for the 'list_users' tool: fetches users from CloudStack API, maps and formats the data into a readable MCP response.
async handleListUsers(args: any) { const result = await this.cloudStackClient.listUsers(args); const users = result.listusersresponse?.user || []; const userList = users.map((user: any) => ({ id: user.id, username: user.username, firstname: user.firstname, lastname: user.lastname, email: user.email, state: user.state, account: user.account, accounttype: user.accounttype, domain: user.domain, created: user.created })); return { content: [ { type: 'text', text: `Found ${userList.length} users:\n\n${userList .map((user: any) => `• ${user.username} (${user.id})\n Name: ${user.firstname} ${user.lastname}\n Email: ${user.email}\n State: ${user.state}\n Account: ${user.account}\n Domain: ${user.domain}\n Created: ${user.created}\n` ) .join('\n')}` } ] }; } - The tool schema definition for 'list_users', including name, description, and input schema for MCP tool registration.
{ name: 'list_users', description: 'List users', inputSchema: { type: 'object', properties: { account: { type: 'string', description: 'Account name to filter users', }, domainid: { type: 'string', description: 'Domain ID to filter users', }, state: { type: 'string', description: 'User state', }, }, additionalProperties: false, }, }, - src/server.ts:184-185 (registration)The switch case in the MCP server that registers and routes 'list_users' tool calls to the appropriate handler.
case 'list_users': return await this.adminHandlers.handleListUsers(args); - src/cloudstack-client.ts:243-245 (helper)Helper method in CloudStack client that makes the actual API request to CloudStack's listUsers endpoint.
async listUsers(params: CloudStackParams = {}): Promise<CloudStackResponse> { return this.request('listUsers', params); }