Skip to main content
Glama

WaPulse WhatsApp MCP Server

by Quegenx
leaveGroup.ts•2.18 kB
import { z } from 'zod'; import { Tool } from '@modelcontextprotocol/sdk/types.js'; import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js'; import { makeApiRequest } from '../../utils/helpers.js'; export const leaveGroupTool: Tool = { name: 'leave_whatsapp_group', description: 'Leave a WhatsApp group', annotations: { title: 'Leave WhatsApp Group', readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: true }, inputSchema: { type: 'object', properties: { id: { type: 'string', description: 'The ID of the group to leave' }, customToken: { type: 'string', description: 'Override default token for this request' }, customInstanceID: { type: 'string', description: 'Override default instance ID for this request' } }, required: ['id'], additionalProperties: false } }; export async function handleLeaveGroup(args: any, context?: any) { const schema = z.object({ id: z.string().min(1, 'Group ID cannot be empty'), customToken: z.string().optional(), customInstanceID: z.string().optional() }); const { id, customToken, customInstanceID } = schema.parse(args); const { log } = context || {}; try { if (log) { log.info("Leaving WhatsApp group", { groupId: id }); } const response = await makeApiRequest('/api/leaveGroup', { id }, customToken, customInstanceID); if (log) { log.info("Left group successfully", { groupId: id }); } return { content: [{ type: 'text', text: `āœ… Successfully left WhatsApp group!\n\nšŸ‘„ Group ID: ${id}\n🚪 Status: Left group\n\nāš ļø Note: You will no longer receive messages from this group and cannot send messages to it unless you are re-added.\n\nšŸ“‹ Response: ${JSON.stringify(response, null, 2)}` }] }; } catch (error: any) { if (log) { log.error("Failed to leave group", { error: error.message, groupId: id }); } throw new McpError(ErrorCode.InternalError, `Failed to leave WhatsApp group ${id}: ${error.message}`); } }

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/Quegenx/wapulse-mcp'

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