Module Create
whmcs_module_createProvisions a service account in WHMCS by supplying the service ID.
Instructions
Create/provision a service account
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountid | Yes | Service ID |
Implementation Reference
- src/index.ts:911-926 (registration)Registration of the 'whmcs_module_create' tool with the MCP server. Defines input schema (accountid required) and delegates to whmcsClient.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) }], }; } ); - src/whmcs-client.ts:1111-1113 (handler)The actual API handler method that calls the WHMCS 'ModuleCreate' API endpoint via the generic call() method to create/provision a service account.
async moduleCreate(params: { accountid: number }) { return this.call<WhmcsApiResponse>('ModuleCreate', params); } - src/index.ts:916-919 (schema)Input schema for whmcs_module_create: requires a single 'accountid' (number) field representing the Service ID.
inputSchema: { accountid: z.number().describe('Service ID'), }, }, - src/whmcs-client.ts:29-63 (helper)Core generic helper method that all API calls (including ModuleCreate) use. Handles authentication, parameter flattening, HTTP POST request, 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; }