whatsapp_create_group
Create a new WhatsApp group by specifying a name and adding participants' phone numbers to facilitate group communication.
Instructions
Create a new WhatsApp group.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Group name (max 255 characters) | |
| participants | Yes | List of participant phone numbers |
Implementation Reference
- src/tools/groups.ts:19-36 (handler)The complete ToolHandler definition for 'whatsapp_create_group', including MCP inputSchema, description, and the execution logic that validates input using createGroupSchema and calls the WSAPI /groups endpoint to create the group.export const createGroup: ToolHandler = { name: 'whatsapp_create_group', description: 'Create a new WhatsApp group.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Group name (max 255 characters)' }, participants: { type: 'array', items: { type: 'string' }, description: 'List of participant phone numbers' }, }, required: ['name', 'participants'], }, handler: async (args: any) => { const input = validateInput(createGroupSchema, args); logger.info('Creating group', { name: input.name, participantCount: input.participants.length }); const result = await wsapiClient.post('/groups', input); return { success: true, groupId: result.id, message: 'Group created successfully' }; }, };
- src/validation/schemas.ts:195-198 (schema)Zod validation schema for whatsapp_create_group input, enforcing name length and non-empty array of phone numbers (referencing phoneNumberSchema).export const createGroupSchema = z.object({ name: z.string().min(1).max(255), participants: z.array(phoneNumberSchema).min(1), });
- src/server.ts:56-79 (registration)Registration logic in MCP server setup that includes groupTools (containing whatsapp_create_group) in toolCategories and registers each tool into the server's tools Map for MCP protocol handling.// Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }