Skip to main content
Glama
wsapi-chat
by wsapi-chat

whatsapp_edit_message

Modify text in previously sent WhatsApp messages by providing the message ID, chat ID, and updated content to correct errors or update information.

Instructions

Edit a previously sent text message.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageIdYesID of the message to edit
toYesChat ID where the message is located
textYesNew text content for the message (max 4096 characters)

Implementation Reference

  • Full ToolHandler implementation for 'whatsapp_edit_message', including MCP inputSchema (JSON Schema), handler logic that validates with Zod schema, logs, calls wsapiClient.put to edit message, and returns success response.
    export const editMessage: ToolHandler = { name: 'whatsapp_edit_message', description: 'Edit a previously sent text message.', inputSchema: { type: 'object', properties: { messageId: { type: 'string', description: 'ID of the message to edit', }, to: { type: 'string', description: 'Chat ID where the message is located', }, text: { type: 'string', description: 'New text content for the message (max 4096 characters)', }, }, required: ['messageId', 'to', 'text'], }, handler: async (args: any) => { const input = validateInput(editMessageSchema, args); logger.info('Editing message', { messageId: input.messageId, to: input.to, textLength: input.text.length, }); const result = await wsapiClient.put(`/messages/${input.messageId}/text`, { to: input.to, text: input.text, }); logger.info('Message edited successfully', { messageId: result.id }); return { success: true, messageId: result.id, message: 'Message edited successfully', }; }, };
  • Zod schema for input validation used in the whatsapp_edit_message handler.
    export const editMessageSchema = z.object({ messageId: messageIdSchema, to: chatIdSchema, text: z.string().min(1).max(4096), });
  • src/server.ts:56-79 (registration)
    Registers all tools including 'whatsapp_edit_message' (via messagingTools) into the MCP server's tools Map for handling list_tools and call_tool requests.
    // 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`); }
  • Groups messaging tools including editMessage (whatsapp_edit_message) for export and subsequent registration in server.ts.
    export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };

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