whatsapp_mark_message_read
Mark WhatsApp messages as read to confirm message receipt and update read status for specific chats and senders.
Instructions
Mark a message as read.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chatId | Yes | Chat ID where the message is located | |
| messageId | Yes | ID of the message to mark as read | |
| receiptType | Yes | Type of receipt to send | |
| senderId | Yes | ID of the message sender |
Input Schema (JSON Schema)
{
"properties": {
"chatId": {
"description": "Chat ID where the message is located",
"type": "string"
},
"messageId": {
"description": "ID of the message to mark as read",
"type": "string"
},
"receiptType": {
"description": "Type of receipt to send",
"enum": [
"delivered",
"sender",
"read",
"played"
],
"type": "string"
},
"senderId": {
"description": "ID of the message sender",
"type": "string"
}
},
"required": [
"messageId",
"chatId",
"senderId",
"receiptType"
],
"type": "object"
}
Implementation Reference
- src/tools/messaging.ts:446-494 (handler)The complete ToolHandler for 'whatsapp_mark_message_read', defining the tool's metadata, MCP inputSchema, and the handler logic that validates input and sends a PUT request to the WSAPI to mark the message as read.export const markMessageAsRead: ToolHandler = { name: 'whatsapp_mark_message_read', description: 'Mark a message as read.', inputSchema: { type: 'object', properties: { messageId: { type: 'string', description: 'ID of the message to mark as read', }, chatId: { type: 'string', description: 'Chat ID where the message is located', }, senderId: { type: 'string', description: 'ID of the message sender', }, receiptType: { type: 'string', enum: ['delivered', 'sender', 'read', 'played'], description: 'Type of receipt to send', }, }, required: ['messageId', 'chatId', 'senderId', 'receiptType'], }, handler: async (args: any) => { const input = validateInput(markMessageAsReadSchema, args); logger.info('Marking message as read', { messageId: input.messageId, chatId: input.chatId, receiptType: input.receiptType, }); await wsapiClient.put(`/messages/${input.messageId}/read`, { chatId: input.chatId, senderId: input.senderId, receiptType: input.receiptType, }); logger.info('Message marked as read successfully', { messageId: input.messageId }); return { success: true, message: 'Message marked as read successfully', }; }, };
- src/validation/schemas.ts:159-164 (schema)Zod schema used for runtime input validation in the markMessageAsRead handler.export const markMessageAsReadSchema = z.object({ messageId: messageIdSchema, chatId: chatIdSchema, senderId: phoneNumberSchema, receiptType: z.enum(['delivered', 'sender', 'read', 'played']), });
- src/server.ts:53-79 (registration)The setupToolHandlers method registers all tools, including those from messagingTools (which contains whatsapp_mark_message_read), into the server's tools Map for MCP handling.private setupToolHandlers(): void { logger.info('Setting up tool handlers'); // Register all tool categories const toolCategories = [ messagingTools, contactTools, groupTools, chatTools, sessionTools, instanceTools, accountTools, ]; toolCategories.forEach(category => { Object.values(category).forEach(tool => { if (this.tools.has(tool.name)) { logger.warn(`Tool ${tool.name} already registered, skipping`); return; } this.tools.set(tool.name, tool); logger.debug(`Registered tool: ${tool.name}`); }); }); logger.info(`Registered ${this.tools.size} tools`); }
- src/validation/schemas.ts:305-312 (schema)Generic validateInput helper function used in the handler to validate arguments against the markMessageAsReadSchema.export function validateInput<T>(schema: z.ZodSchema<T>, data: unknown): T { const result = schema.safeParse(data); if (!result.success) { const errors = result.error.errors.map(err => `${err.path.join('.')}: ${err.message}`); throw new Error(`Validation failed: ${errors.join(', ')}`); } return result.data; }