Skip to main content
Glama

waha_clear_chat_messages

Clear all messages from a WhatsApp chat. This destructive operation permanently removes chat history and cannot be undone.

Instructions

Clear all messages from a chat. WARNING: This is a destructive operation that cannot be undone.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
chatIdYesChat ID (format: number@c.us)

Implementation Reference

  • The primary handler function for the 'waha_clear_chat_messages' tool. It validates input, calls the WAHAClient.clearChatMessages method, and returns a confirmation message warning about the destructive nature of the operation.
    private async handleClearChatMessages(args: any) {
      const chatId = args.chatId;
    
      if (!chatId) {
        throw new Error("chatId is required");
      }
    
      await this.wahaClient.clearChatMessages(chatId);
    
      return {
        content: [
          {
            type: "text",
            text: `WARNING: All messages have been cleared from chat ${chatId}.\nThis operation cannot be undone.`,
          },
        ],
      };
    }
  • Input schema definition for the tool, specifying the required 'chatId' parameter and description.
      name: "waha_clear_chat_messages",
      description: "Clear all messages from a chat. WARNING: This is a destructive operation that cannot be undone.",
      inputSchema: {
        type: "object",
        properties: {
          chatId: {
            type: "string",
            description: "Chat ID (format: number@c.us)",
          },
        },
        required: ["chatId"],
      },
    },
  • src/index.ts:1067-1073 (registration)
    Registration and dispatch logic in the CallToolRequestSchema handler's switch statement that routes calls to the specific handler function.
    case "waha_clear_chat_messages":
      return await this.handleClearChatMessages(args);
    case "waha_delete_chat":
      return await this.handleDeleteChat(args);
    case "waha_archive_chat":
      return await this.handleArchiveChat(args);
    case "waha_unarchive_chat":
  • Underlying WAHAClient helper method that performs the actual HTTP DELETE request to the WAHA API endpoint to clear messages from the specified chat.
    async clearChatMessages(chatId: string): Promise<void> {
      if (!chatId) {
        throw new WAHAError("chatId is required");
      }
    
      const endpoint = `/api/${this.session}/chats/${encodeURIComponent(
        chatId
      )}/messages`;
    
      await this.request<void>(endpoint, {
        method: "DELETE",
      });
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively warns that the operation is 'destructive' and 'cannot be undone,' which is crucial for a mutation tool. However, it lacks details on permissions needed, rate limits, or what 'clear' entails (e.g., whether it affects media files or just text).

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 extremely concise—two sentences that directly state the purpose and a critical warning. It is front-loaded with the core action, and every word earns its place without redundancy or fluff, making it efficient for quick comprehension.

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 destructive nature and lack of annotations or output schema, the description is partially complete. It covers the high-risk aspect but misses details like response format, error conditions, or side effects. For a mutation tool with no structured safety hints, more behavioral context would improve completeness.

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%, with the single parameter 'chatId' fully documented in the schema. The description adds no additional parameter semantics beyond what the schema provides, such as format examples or validation rules. Baseline 3 is appropriate since the schema handles parameter documentation adequately.

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

Purpose5/5

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

The description explicitly states the action ('Clear all messages') and the target resource ('from a chat'), which is specific and unambiguous. It clearly distinguishes this from sibling tools like waha_delete_message (single message deletion) or waha_delete_chat (entire chat deletion), establishing a unique scope.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., chat must exist), compare to similar tools like waha_delete_chat, or specify contexts where clearing messages is appropriate versus other actions. The warning implies caution but doesn't offer usage criteria.

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