waha_demote_group_admin
Remove admin privileges from participants in a WhatsApp group. Requires admin access to manage group permissions and maintain appropriate access levels.
Instructions
Remove admin privileges from participant(s). 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 demote (format: [{'id': 'number@c.us'}, ...]) |
Implementation Reference
- src/index.ts:2231-2258 (handler)MCP tool handler: parses input args (groupId and JSON participants), calls wahaClient.demoteGroupAdmin, returns formatted success response with result.private async handleDemoteGroupAdmin(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.demoteGroupAdmin({ groupId, participants, }); return { content: [ { type: "text", text: `Successfully demoted ${participants.length} admin(s) in group ${groupId}.\n${JSON.stringify(result, null, 2)}`, }, ], }; }
- src/index.ts:753-769 (schema)Tool schema: defines input parameters groupId (string) and participants (JSON string array of {id: string}), both required.name: "waha_demote_group_admin", description: "Remove admin privileges from participant(s). 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 demote (format: [{'id': 'number@c.us'}, ...])", }, }, required: ["groupId", "participants"], }, },
- src/index.ts:1117-1118 (registration)Tool registration in CallToolRequestSchema dispatcher switch statement.case "waha_demote_group_admin": return await this.handleDemoteGroupAdmin(args);
- src/client/waha-client.ts:1065-1087 (helper)WAHAClient helper method: performs HTTP POST to WAHA API endpoint /groups/{groupId}/admin/demote with participants array.async demoteGroupAdmin(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)}/admin/demote`; const body = { participants }; return this.request<any>(endpoint, { method: "POST", body: JSON.stringify(body), }); }