Mark as Read
mark_as_readMark one or more WhatsApp messages as read by specifying the chat JID, sender status, and message IDs.
Instructions
Mark one or more messages as read via the pinned WhatsApp instance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| readMessages | Yes | Array of message keys to mark as read |
Implementation Reference
- src/tools/mark-as-read.ts:16-36 (handler)The main handler function `registerMarkAsRead` that registers the 'mark_as_read' tool with the MCP server. It defines the tool logic: accepting an array of message keys (remoteJid, fromMe, id) and POSTing to `/chat/markMessageAsRead/{instanceName}`.
export function registerMarkAsRead(server: McpServer, client: EvolutionClient): void { server.registerTool( "mark_as_read", { title: "Mark as Read", description: "Mark one or more messages as read via the pinned WhatsApp instance.", inputSchema: schema, }, async (args) => { try { const data = await client.post(`/chat/markMessageAsRead/${client.instanceName}`, { readMessages: args.readMessages, }); 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/mark-as-read.ts:6-14 (schema)Input schema for the 'mark_as_read' tool using Zod. Defines `MessageKeySchema` (remoteJid, fromMe, id) and the `readMessages` array parameter.
const MessageKeySchema = z.object({ remoteJid: z.string().min(1).describe("JID of the chat"), fromMe: z.boolean().describe("Whether the message was sent by this instance"), id: z.string().min(1).describe("Message ID"), }); const schema = { readMessages: z.array(MessageKeySchema).min(1).describe("Array of message keys to mark as read"), }; - src/tools/index.ts:27-27 (registration)Import of `registerMarkAsRead` from the mark-as-read module.
import { registerMarkAsRead } from "./mark-as-read.js"; - src/tools/index.ts:100-100 (registration)Registration call `registerMarkAsRead(server, client)` inside `registerAllTools`, which wires up the tool to the MCP server.
registerMarkAsRead(server, client);