create_instance
Create a new WhatsApp Business instance for sending messages, managing contacts, and handling events through webhooks with QR code authentication.
Instructions
Create a new WhatsApp instance
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| instanceName | Yes | Name for the instance | |
| qrcode | No | Generate QR code for connection | |
| webhookUrl | No | Webhook URL for events |
Implementation Reference
- src/index.ts:43-55 (registration)Registration of the 'create_instance' tool in the MCP tools array, including description and input schema definition.{ name: 'create_instance', description: 'Create a new WhatsApp instance', inputSchema: { type: 'object', properties: { instanceName: { type: 'string', description: 'Name for the instance' }, qrcode: { type: 'boolean', description: 'Generate QR code for connection' }, webhookUrl: { type: 'string', description: 'Webhook URL for events' } }, required: ['instanceName'] } },
- src/index.ts:46-54 (schema)Input schema validation for the create_instance tool parameters.inputSchema: { type: 'object', properties: { instanceName: { type: 'string', description: 'Name for the instance' }, qrcode: { type: 'boolean', description: 'Generate QR code for connection' }, webhookUrl: { type: 'string', description: 'Webhook URL for events' } }, required: ['instanceName'] }
- src/index.ts:572-582 (handler)Main MCP handler function for 'create_instance' tool. Delegates to EvolutionAPI service and formats response as MCP content.private async handleCreateInstance(args: any) { const result = await evolutionAPI.createInstance(args); return { content: [ { type: 'text', text: JSON.stringify(result, null, 2) } ] }; }
- src/services/evolution-api.ts:26-37 (helper)Supporting utility in EvolutionAPI service that performs the actual HTTP POST request to the backend /instance/create endpoint to create the WhatsApp instance.async createInstance(data: { instanceName: string; qrcode?: boolean; integration?: string; webhookUrl?: string; webhookByEvents?: boolean; webhookBase64?: boolean; webhookHeaders?: Record<string, string>; }): Promise<Instance> { const response = await this.client.post('/instance/create', data); return response.data; }