waha_add_group_participants
Add participants to WhatsApp groups using admin privileges. Specify group ID and participant list in JSON format to manage group membership.
Instructions
Add member(s) to a group. Requires admin privileges.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groupId | Yes | Group ID (format: number@g.us) | |
| participants | Yes | JSON array of participants to add (format: [{'id': 'number@c.us'}, ...]) |
Implementation Reference
- src/index.ts:2135-2162 (handler)The main MCP tool handler function that processes the tool call, validates input, parses the participants JSON string from input, calls the underlying WAHAClient method, and returns a formatted response with the result.private async handleAddGroupParticipants(args: any) { const groupId = args.groupId; const participantsStr = args.participants; if (!groupId) { throw new Error("groupId is required"); } if (!participantsStr) { throw new Error("participants is required"); } const participants = JSON.parse(participantsStr); const result = await this.wahaClient.addGroupParticipants({ groupId, participants, }); return { content: [ { type: "text", text: `Successfully added ${participants.length} participant(s) to group ${groupId}.\n${JSON.stringify(result, null, 2)}`, }, ], }; }
- src/index.ts:698-715 (registration)Tool registration in the list of available tools returned by ListToolsRequestSchema. Includes name, description, and input schema definition.{ name: "waha_add_group_participants", description: "Add member(s) to a group. Requires admin privileges.", inputSchema: { type: "object", properties: { groupId: { type: "string", description: "Group ID (format: number@g.us)", }, participants: { type: "string", description: "JSON array of participants to add (format: [{'id': 'number@c.us'}, ...])", }, }, required: ["groupId", "participants"], }, },
- src/index.ts:701-714 (schema)Input schema definition for the tool, specifying required groupId and participants as JSON string.inputSchema: { type: "object", properties: { groupId: { type: "string", description: "Group ID (format: number@g.us)", }, participants: { type: "string", description: "JSON array of participants to add (format: [{'id': 'number@c.us'}, ...])", }, }, required: ["groupId", "participants"], },
- src/client/waha-client.ts:981-1003 (helper)Underlying WAHA API client method that makes the HTTP POST request to the WAHA server endpoint /api/{session}/groups/{groupId}/participants/add to add participants to the group.async addGroupParticipants(params: { groupId: string; participants: Array<{ id: string }>; }): Promise<any> { const { groupId, participants } = params; if (!groupId) { throw new WAHAError("groupId is required"); } if (!participants || participants.length === 0) { throw new WAHAError("participants array is required"); } const endpoint = `/api/${this.session}/groups/${encodeURIComponent(groupId)}/participants/add`; const body = { participants }; return this.request<any>(endpoint, { method: "POST", body: JSON.stringify(body), }); }