whmcs_get_product_groups
Retrieve all product groups from WHMCS to organize and manage hosting services, billing plans, or digital products within your system.
Instructions
Get all product groups from WHMCS
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:239-252 (registration)Registers the 'whmcs_get_product_groups' tool with the MCP server. Defines empty input schema and a thin handler wrapper that calls whmcsClient.getProductGroups() and returns JSON response.server.registerTool( 'whmcs_get_product_groups', { title: 'Get Product Groups', description: 'Get all product groups from WHMCS', inputSchema: {}, }, async () => { const result = await whmcsClient.getProductGroups(); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/whmcs-client.ts:390-402 (handler)Core handler implementation in WhmcsApiClient class. Makes authenticated API call to WHMCS 'GetProductGroups' action, handling response typing for product groups data.async getProductGroups() { return this.call<WhmcsApiResponse & { totalresults: number; productgroups: { productgroup: Array<{ id: number; name: string; headline: string; tagline: string; orderfrmtpl: string; }> }; }>('GetProductGroups'); }
- src/index.ts:240-244 (schema)Input schema definition for the tool (empty object, no parameters required). Defined inline in registration.'whmcs_get_product_groups', { title: 'Get Product Groups', description: 'Get all product groups from WHMCS', inputSchema: {},
- src/whmcs-client.ts:68-93 (helper)Helper method flattenParams used by all API calls including getProductGroups to properly encode nested parameters for WHMCS API.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; }