Skip to main content
Glama

whmcs_module_create

Provision a service account in WHMCS by specifying the service ID to automate account setup and management.

Instructions

Create/provision a service account

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
accountidYesService ID

Implementation Reference

  • src/index.ts:892-907 (registration)
    Tool registration for 'whmcs_module_create', including schema definition (accountid: service ID) and thin handler wrapper that calls WhmcsApiClient.moduleCreate
    server.registerTool(
        'whmcs_module_create',
        {
            title: 'Module Create',
            description: 'Create/provision a service account',
            inputSchema: {
                accountid: z.number().describe('Service ID'),
            },
        },
        async (params) => {
            const result = await whmcsClient.moduleCreate(params);
            return {
                content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
            };
        }
    );
  • Core handler implementation in WhmcsApiClient: calls WHMCS API with action='ModuleCreate' passing the accountid (service ID) via the generic API call method.
    async moduleCreate(params: { accountid: number }) {
        return this.call<WhmcsApiResponse>('ModuleCreate', params);
    }
  • Input schema validation using Zod: requires accountid as number (Service ID). Defined in tool registration.
        accountid: z.number().describe('Service ID'),
    },
  • Generic API call method used by all tools, including moduleCreate. Handles authentication, param flattening, HTTP POST to /includes/api.php, error handling, and response parsing.
    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