whmcs_get_admin_users
Retrieve a list of WHMCS administrator accounts to manage user permissions and access control within your hosting platform.
Instructions
Get list of admin users
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:998-1011 (registration)Registration of the MCP tool 'whmcs_get_admin_users'. Defines title, description, empty input schema, and handler that delegates to whmcsClient.getAdminUsers() and formats response as JSON text.server.registerTool( 'whmcs_get_admin_users', { title: 'Get Admin Users', description: 'Get list of admin users', inputSchema: {}, }, async () => { const result = await whmcsClient.getAdminUsers(); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/whmcs-client.ts:1174-1201 (handler)Core handler implementation in WhmcsApiClient.getAdminUsers(). Makes authenticated API call to WHMCS 'GetAdminUsers' action, returning typed response with admin user details.* Get admin users */ async getAdminUsers() { return this.call<WhmcsApiResponse & { admin_users: Array<{ id: number; uuid: string; roleId: number; username: string; twoFactorAuthModule: string; firstname: string; lastname: string; email: string; signature: string; notes: string; template: string; language: string; isDisabled: boolean; loginAttempts: number; supportDepartmentIds: string; receivesTicketNotifications: string; homeWidgets: string; hiddenMenus: string; fullName: string; gravatarHash: string; }>; }>('GetAdminUsers'); }
- src/index.ts:1003-1003 (schema)Input schema for the tool: empty object, indicating no input parameters required.inputSchema: {},
- src/whmcs-client.ts:29-93 (helper)Generic 'call' helper method used by getAdminUsers() to perform the actual HTTP POST to WHMCS API with authentication and parameter handling.async call<T extends WhmcsApiResponse>(action: string, params: Record<string, unknown> = {}): Promise<T> { const url = `${this.config.apiUrl.replace(/\/$/, '')}/includes/api.php`; const postData: Record<string, string> = { identifier: this.config.apiIdentifier, secret: this.config.apiSecret, action: action, responsetype: 'json', ...this.flattenParams(params) }; if (this.config.accessKey) { postData.accesskey = this.config.accessKey; } const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(postData).toString(), }); if (!response.ok) { throw new Error(`WHMCS API request failed: ${response.status} ${response.statusText}`); } const data = await response.json() as T; if (data.result === 'error') { throw new Error(`WHMCS API error: ${data.message || 'Unknown error'}`); } return data; } /** * Flatten nested params for URL encoding */ private flattenParams(params: Record<string, unknown>, prefix = ''): Record<string, string> { const result: Record<string, string> = {}; for (const [key, value] of Object.entries(params)) { const newKey = prefix ? `${prefix}[${key}]` : key; if (value === null || value === undefined) { continue; } else if (typeof value === 'object' && !Array.isArray(value)) { Object.assign(result, this.flattenParams(value as Record<string, unknown>, newKey)); } else if (Array.isArray(value)) { value.forEach((item, index) => { if (typeof item === 'object') { Object.assign(result, this.flattenParams(item as Record<string, unknown>, `${newKey}[${index}]`)); } else { result[`${newKey}[${index}]`] = String(item); } }); } else { result[newKey] = String(value); } } return result; }