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

whatsapp_edit_message

Edit text in previously sent WhatsApp messages by providing the message ID, chat ID, and new 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
textYesNew text content for the message (max 4096 characters)
toYesChat ID where the message is located

Implementation Reference

  • Core implementation of the 'whatsapp_edit_message' tool handler. Validates input, logs activity, performs PUT request to WSAPI /messages/{id}/text endpoint to update message text, and returns success response with new message ID.
    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 validation schema for 'whatsapp_edit_message' tool input, defining messageId, to (chat ID), and new text with constraints.
    export const editMessageSchema = z.object({ messageId: messageIdSchema, to: chatIdSchema, text: z.string().min(1).max(4096), });
  • Export of messagingTools object that bundles the editMessage tool (whatsapp_edit_message) for registration in the MCP server.
    export const messagingTools = { sendTextMessage, sendImageMessage, sendVideoMessage, sendLinkMessage, sendReactionMessage, editMessage, deleteMessage, markMessageAsRead, starMessage, ...advancedMessagingTools, };
  • src/server.ts:53-79 (registration)
    Server method that registers all tools from messagingTools (including whatsapp_edit_message) into the MCP server's tools Map by iterating over tool categories.
    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`); }

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