Skip to main content
Glama

waha_get_chats

Retrieve recent WhatsApp chats with ID, name, message preview, and unread count. Filter by chat IDs or paginate results to manage conversations efficiently.

Instructions

Get overview of recent WhatsApp chats. Returns chat ID, name, last message preview, and unread count. Default limit is 10 chats.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of chats to retrieve (default: 10, max: 100)
offsetNoOffset for pagination
chatIdsNoOptional filter for specific chat IDs (format: number@c.us)

Implementation Reference

  • The primary handler function for the 'waha_get_chats' MCP tool. It extracts parameters from the input arguments, calls the WAHAClient.getChatsOverview method to fetch chat data from the WAHA API, formats the response using formatChatsOverview, and returns a structured text content response.
    private async handleGetChats(args: any) {
      const limit = args.limit || 10;
      const offset = args.offset;
      const chatIds = args.chatIds;
    
      const chats = await this.wahaClient.getChatsOverview({
        limit,
        offset,
        ids: chatIds,
      });
    
      const formattedResponse = formatChatsOverview(chats);
    
      return {
        content: [
          {
            type: "text",
            text: formattedResponse,
          },
        ],
      };
    }
  • The input schema and metadata definition for the 'waha_get_chats' tool, provided in the ListTools MCP response. Defines parameters like limit, offset, and chatIds with descriptions and defaults.
      name: "waha_get_chats",
      description: "Get overview of recent WhatsApp chats. Returns chat ID, name, last message preview, and unread count. Default limit is 10 chats.",
      inputSchema: {
        type: "object",
        properties: {
          limit: {
            type: "number",
            description: "Number of chats to retrieve (default: 10, max: 100)",
            default: 10,
          },
          offset: {
            type: "number",
            description: "Offset for pagination",
          },
          chatIds: {
            type: "array",
            items: { type: "string" },
            description: "Optional filter for specific chat IDs (format: number@c.us)",
          },
        },
      },
    },
  • src/index.ts:1051-1053 (registration)
    Tool dispatch registration in the CallToolRequestSchema handler switch statement. Routes calls to 'waha_get_chats' to the handleGetChats method.
    case "waha_get_chats":
      return await this.handleGetChats(args);
    case "waha_get_messages":
  • Helper function that formats the array of ChatOverview objects into a human-readable string for LLM consumption, used by the tool handler.
    export function formatChatsOverview(chats: ChatOverview[]): string {
      if (chats.length === 0) {
        return "No chats found.";
      }
    
      const sections = chats.map((chat, index) => {
        return `\n[Chat ${index + 1}]\n${formatChatOverview(chat)}`;
      });
    
      return `Found ${chats.length} chat${chats.length > 1 ? 's' : ''}:\n${sections.join('\n')}`;
    }
  • Underlying WAHA API client method that performs the HTTP GET request to /api/{session}/chats/overview with query parameters and returns the raw ChatOverview array, called by the tool handler.
    async getChatsOverview(
      params: GetChatsOverviewParams = {}
    ): Promise<ChatOverview[]> {
      const { limit = 10, offset, ids } = params;
    
      const queryParams: Record<string, any> = {
        limit: Math.min(limit, 100), // Max 100
        offset,
      };
    
      if (ids && ids.length > 0) {
        queryParams.ids = ids;
      }
    
      const queryString = this.buildQueryString(queryParams);
      const endpoint = `/api/${this.session}/chats/overview${queryString}`;
    
      return this.request<ChatOverview[]>(endpoint, {
        method: "GET",
      });
    }
Behavior3/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 mentions the default limit and return fields, which adds useful context, but doesn't cover aspects like rate limits, authentication needs, error conditions, or whether the operation is read-only (implied by 'Get' but not explicit). It adequately describes core behavior but lacks comprehensive operational details.

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 front-loaded with the core purpose, followed by return details and default limit, all in two efficient sentences. Every element earns its place with no redundancy, making it highly concise and well-structured for quick comprehension.

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

Completeness4/5

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

Given the tool's moderate complexity (3 parameters, no output schema, no annotations), the description is reasonably complete. It covers purpose, output fields, and a key behavioral detail (default limit), but lacks information on error handling, pagination beyond offset, or how 'recent' is defined. For a read operation with good schema coverage, this is sufficient but not exhaustive.

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

Parameters4/5

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

Schema description coverage is 100%, so the schema fully documents all three parameters. The description adds value by mentioning the default limit (10 chats), which complements the schema's default value, but doesn't provide additional semantic context beyond what's already in the schema. Since parameters are well-covered, a baseline score above 3 is justified due to the added default clarification.

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 clearly states the specific action ('Get overview of recent WhatsApp chats') and resource ('WhatsApp chats'), distinguishing it from sibling tools like waha_get_contact or waha_get_messages. It specifies the scope ('recent') and output format ('chat ID, name, last message preview, and unread count'), making the purpose unambiguous.

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

Usage Guidelines3/5

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

The description implies usage for retrieving chat overviews but provides no explicit guidance on when to use this tool versus alternatives like waha_get_groups or waha_get_all_contacts. It mentions a default limit but doesn't clarify prerequisites or exclusions, leaving usage context partially inferred.

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