Get TLD Pricing
whmcs_get_tld_pricingRetrieve domain TLD pricing for a specified currency ID. Use this tool to obtain cost data for all top-level domains in your WHMCS system.
Instructions
Get domain TLD pricing information
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| currencyid | No | Currency ID |
Implementation Reference
- src/index.ts:750-765 (registration)Tool registration for 'whmcs_get_tld_pricing' in the MCP server. Defines the tool name, title, description, input schema (with optional currencyid), and handler that delegates to whmcsClient.getTLDPricing().
server.registerTool( 'whmcs_get_tld_pricing', { title: 'Get TLD Pricing', description: 'Get domain TLD pricing information', inputSchema: { currencyid: z.number().optional().describe('Currency ID'), }, }, async (params) => { const result = await whmcsClient.getTLDPricing(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } ); - src/index.ts:755-757 (schema)Input schema for the tool: accepts an optional currencyid parameter of type number.
inputSchema: { currencyid: z.number().optional().describe('Currency ID'), }, - src/whmcs-client.ts:912-936 (handler)The getTLDPricing() method on WhmcsApiClient. This is the actual handler making the WHMCS API call to 'GetTLDPricing' action. It accepts optional currencyid and returns typed response including currency info and pricing per TLD (register, transfer, renew, addons, grace_period, redemption).
async getTLDPricing(params: { currencyid?: number; } = {}) { return this.call<WhmcsApiResponse & { currency: { id: number; code: string; prefix: string; suffix: string; }; pricing: Record<string, { categories: string[]; addons: { dns: boolean; email: boolean; idprotect: boolean; }; register: Record<string, string>; transfer: Record<string, string>; renew: Record<string, string>; grace_period: Record<string, unknown>; redemption: Record<string, unknown>; }>; }>('GetTLDPricing', params); } - src/whmcs-client.ts:29-62 (helper)The generic API call helper that getTLDPricing uses. Constructs the WHMCS API URL, sends POST with form-urlencoded auth credentials and action parameters, handles errors, and returns parsed JSON response.
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;