Get System Stats
whmcs_get_statsRetrieve WHMCS system statistics including total income and order counts to monitor business performance.
Instructions
Get WHMCS system statistics including income and order counts
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1002-1015 (registration)Registration of the 'whmcs_get_stats' tool with MCP server. No input parameters, calls whmcsClient.getStats() and returns JSON response.
server.registerTool( 'whmcs_get_stats', { title: 'Get System Stats', description: 'Get WHMCS system statistics including income and order counts', inputSchema: {}, }, async () => { const result = await whmcsClient.getStats(); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } ); - src/whmcs-client.ts:1156-1184 (handler)The getStats() method on WhmcsApiClient that executes the actual WHMCS API 'GetStats' call and returns typed system statistics (income, orders, tickets, etc.).
async getStats() { return this.call<WhmcsApiResponse & { income_today: string; income_thismonth: string; income_thisyear: string; income_alltime: string; orders_pending: number; orders_today_cancelled: number; orders_today_pending: number; orders_today_fraud: number; orders_today_active: number; orders_today_total: number; orders_yesterday_cancelled: number; orders_yesterday_pending: number; orders_yesterday_fraud: number; orders_yesterday_active: number; orders_yesterday_total: number; orders_thismonth_total: number; orders_thisyear_total: number; tickets_allactive: number; tickets_awaitingreply: number; tickets_flaggedtickets: number; cancellations_pending: number; todoitems_due: number; networkissues_open: number; billableitems_uninvoiced: number; quotes_valid: number; }>('GetStats'); } - src/whmcs-client.ts:29-63 (helper)Generic API call helper that constructs the request to WHMCS's includes/api.php with authentication credentials and action parameter. Used by getStats() internally.
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; }