Skip to main content
Glama

waha_edit_message

Edit text in WhatsApp messages sent by the bot to correct errors or update information in existing conversations.

Instructions

Edit a sent message in a chat. Only works for messages sent by the bot.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chatIdYesChat ID (format: number@c.us)
messageIdYesMessage ID to edit
textYesNew message text
linkPreviewNoEnable link preview (default: true)
linkPreviewHighQualityNoEnable high quality link preview (default: false)

Implementation Reference

  • src/index.ts:185-214 (registration)
    MCP tool registration and input schema definition for 'waha_edit_message' in the listTools handler
    name: "waha_edit_message",
    description: "Edit a sent message in a chat. Only works for messages sent by the bot.",
    inputSchema: {
      type: "object",
      properties: {
        chatId: {
          type: "string",
          description: "Chat ID (format: number@c.us)",
        },
        messageId: {
          type: "string",
          description: "Message ID to edit",
        },
        text: {
          type: "string",
          description: "New message text",
        },
        linkPreview: {
          type: "boolean",
          description: "Enable link preview (default: true)",
          default: true,
        },
        linkPreviewHighQuality: {
          type: "boolean",
          description: "Enable high quality link preview (default: false)",
          default: false,
        },
      },
      required: ["chatId", "messageId", "text"],
    },
  • Primary MCP tool handler for 'waha_edit_message'. Validates input, calls WAHAClient.editMessage, and formats success response.
    private async handleEditMessage(args: any) {
      const chatId = args.chatId;
      const messageId = args.messageId;
      const text = args.text;
      const linkPreview = args.linkPreview !== false;
      const linkPreviewHighQuality = args.linkPreviewHighQuality || false;
    
      if (!chatId) {
        throw new Error("chatId is required");
      }
    
      if (!messageId) {
        throw new Error("messageId is required");
      }
    
      if (!text) {
        throw new Error("text is required");
      }
    
      await this.wahaClient.editMessage({
        chatId,
        messageId,
        text,
        linkPreview,
        linkPreviewHighQuality,
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Successfully edited message ${messageId} in chat ${chatId}.\nNew text: ${text}`,
          },
        ],
      };
    }
  • Low-level WAHAClient.editMessage method that performs the actual PUT request to WAHA API to edit a message.
    async editMessage(params: {
      chatId: string;
      messageId: string;
      text: string;
      linkPreview?: boolean;
      linkPreviewHighQuality?: boolean;
    }): Promise<void> {
      const { chatId, messageId, text, linkPreview, linkPreviewHighQuality } = params;
    
      if (!chatId) {
        throw new WAHAError("chatId is required");
      }
    
      if (!messageId) {
        throw new WAHAError("messageId is required");
      }
    
      if (!text) {
        throw new WAHAError("text is required");
      }
    
      const endpoint = `/api/${this.session}/chats/${encodeURIComponent(
        chatId
      )}/messages/${encodeURIComponent(messageId)}`;
    
      const body = {
        text,
        linkPreview: linkPreview !== false,
        linkPreviewHighQuality: linkPreviewHighQuality || false,
      };
    
      await this.request<void>(endpoint, {
        method: "PUT",
        body: JSON.stringify(body),
      });
    }
  • Dispatch case in MCP CallToolRequestSchema handler that routes to the specific tool handler.
    case "waha_edit_message":
      return await this.handleEditMessage(args);
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool edits messages and has a usage constraint (bot-sent messages only), but lacks details on permissions, rate limits, error conditions, or what happens on success/failure. For a mutation tool with zero annotation coverage, this is a significant gap, though it's not misleading.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence: 'Edit a sent message in a chat. Only works for messages sent by the bot.' It's front-loaded with the core purpose and includes a critical constraint without unnecessary words. Every part earns its place, making it highly concise and well-structured.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with 5 parameters), no annotations, and no output schema, the description is minimally adequate. It covers the purpose and a key constraint, but lacks details on behavior, error handling, or return values. For a tool that modifies data, this leaves gaps in understanding how to use it effectively, though it's not entirely incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all 5 parameters (chatId, messageId, text, linkPreview, linkPreviewHighQuality) with descriptions. The description doesn't add any parameter-specific details beyond what the schema provides, such as format examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Edit a sent message in a chat.' It specifies the verb ('Edit') and resource ('a sent message'), and distinguishes it from siblings like waha_delete_message or waha_send_message. However, it doesn't explicitly differentiate from waha_react_to_message or waha_pin_message in terms of message modification types, keeping it at 4 rather than 5.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool: 'Only works for messages sent by the bot.' This is a specific usage constraint. However, it doesn't mention alternatives (e.g., waha_send_message for new messages) or when not to use it (e.g., for messages sent by others), so it falls short of a 5.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/seejux/waha-whatsapp-mcp'

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