whmcs_get_stats
Retrieve WHMCS system statistics such as income totals and order counts to monitor business performance and track key metrics.
Instructions
Get WHMCS system statistics including income and order counts
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/whmcs-client.ts:1143-1172 (handler)The core handler method in WhmcsApiClient that performs the WHMCS API 'GetStats' call to retrieve system statistics including 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/index.ts:983-996 (registration)Registers the 'whmcs_get_stats' MCP tool, providing title, description, empty input schema (no parameters), and thin handler that invokes whmcsClient.getStats() and formats response as JSON text.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/index.ts:988-996 (schema)Defines the input schema for the tool as empty object (no input parameters required).inputSchema: {}, }, async () => { const result = await whmcsClient.getStats(); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/whmcs-client.ts:29-63 (helper)General helper method used by all API methods including getStats to make authenticated POST requests to WHMCS API endpoint.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; }