Skip to main content
Glama

whmcs_get_currencies

Retrieve configured currencies from a WHMCS installation to manage billing and payment settings.

Instructions

Get configured currencies

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • src/index.ts:1029-1041 (registration)
    MCP tool registration for whmcs_get_currencies, including schema (empty input) and thin wrapper handler calling whmcsClient.getCurrencies()
        'whmcs_get_currencies',
        {
            title: 'Get Currencies',
            description: 'Get configured currencies',
            inputSchema: {},
        },
        async () => {
            const result = await whmcsClient.getCurrencies();
            return {
                content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
            };
        }
    );
  • Core handler implementation in WhmcsApiClient that performs the actual WHMCS API call to 'GetCurrencies' action
    async getCurrencies() {
        return this.call<WhmcsApiResponse & {
            totalresults: number;
            currencies: { currency: Array<{
                id: number;
                code: string;
                prefix: string;
                suffix: string;
                format: number;
                rate: string;
                default: number;
            }> };
        }>('GetCurrencies');
    }
  • Generic API call helper method used by all WHMCS API methods, including getCurrencies, handling authentication, request formatting, and error 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scarecr0w12/whmcs-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server