Skip to main content
Glama
wsapi-chat

WSAPI WhatsApp MCP Server

by wsapi-chat

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
NameRequiredDescriptionDefault
nameYesGroup name (max 255 characters)
participantsYesList of participant phone numbers

Implementation Reference

  • 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' };
      },
    };
  • 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`);
    }

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/wsapi-chat/wsapi-mcp'

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