Delete Message
delete_messageDelete a WhatsApp message for all chat participants using the pinned instance. Specify the message ID, chat JID, and whether it was sent by you.
Instructions
Delete a message for everyone via the pinned WhatsApp instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Message ID to delete | |
| remoteJid | Yes | JID of the chat containing the message | |
| fromMe | Yes | Whether the message was sent by this instance | |
| participant | No | Participant JID (required for group messages) |
Implementation Reference
- src/tools/delete-message.ts:13-37 (handler)Handler function registerDeleteMessage that registers the 'delete_message' tool. It defines input schema, builds a payload with id, remoteJid, fromMe, and optional participant, then calls the Evolution API endpoint /chat/deleteMessageForEveryone/{instanceName} via DELETE request.
export function registerDeleteMessage(server: McpServer, client: EvolutionClient): void { server.registerTool( "delete_message", { title: "Delete Message", description: "Delete a message for everyone via the pinned WhatsApp instance.", inputSchema: schema, }, async (args) => { try { const payload: Record<string, unknown> = { id: args.id, remoteJid: args.remoteJid, fromMe: args.fromMe, }; if (args.participant) payload["participant"] = args.participant; const data = await client.delete(`/chat/deleteMessageForEveryone/${client.instanceName}`, payload); return { content: [{ type: "text" as const, text: JSON.stringify(data, null, 2) }] }; } catch (e) { if (e instanceof McpError) return { isError: true, content: [{ type: "text" as const, text: e.message }] }; throw e; } } ); } - src/tools/delete-message.ts:6-11 (schema)Input schema using zod: id (string), remoteJid (string), fromMe (boolean), and optional participant (string for group messages).
const schema = { id: z.string().min(1).describe("Message ID to delete"), remoteJid: z.string().min(1).describe("JID of the chat containing the message"), fromMe: z.boolean().describe("Whether the message was sent by this instance"), participant: z.string().optional().describe("Participant JID (required for group messages)"), }; - src/tools/index.ts:29-29 (registration)Import statement for registerDeleteMessage from ./delete-message.js
import { registerDeleteMessage } from "./delete-message.js"; - src/tools/index.ts:102-102 (registration)Registration call to registerDeleteMessage(server, client) in the main tools registration function.
registerDeleteMessage(server, client);