Skip to main content
Glama
by wsapi-chat

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

NameRequiredDescriptionDefault
chatIdYesChat ID where the message is located
messageIdYesID of the message to mark as read
receiptTypeYesType of receipt to send
senderIdYesID 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

  • 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', }; }, };
  • 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`); }
  • 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; }

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/wsapi-chat/wsapi-mcp'

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