Skip to main content
Glama

waha_get_all_contacts

Retrieve and organize all WhatsApp contacts with pagination, sorting options, and result limits for efficient contact management.

Instructions

List all contacts with pagination.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sortByNoSort field (default: id)
sortOrderNoSort order (default: asc)
limitNoLimit results (default: 100, max: 100)
offsetNoOffset for pagination

Implementation Reference

  • Core handler function for the 'waha_get_all_contacts' MCP tool. Processes input arguments, invokes WAHAClient.getAllContacts(), and returns a formatted text content block with the JSON-stringified list of contacts.
    private async handleGetAllContacts(args: any) {
      const contacts = await this.wahaClient.getAllContacts({
        sortBy: args.sortBy,
        sortOrder: args.sortOrder,
        limit: args.limit,
        offset: args.offset,
      });
    
      return {
        content: [
          {
            type: "text",
            text: `Found ${contacts.length} contact(s):\n${JSON.stringify(contacts, null, 2)}`,
          },
        ],
      };
    }
  • Input schema definition for the tool, specifying optional parameters for sorting (by id or name), sort order (asc/desc), limit (max 100), and offset for pagination.
            description: "Sort order (default: asc)",
          },
          limit: {
            type: "number",
            description: "Limit results (default: 100, max: 100)",
          },
          offset: {
            type: "number",
            description: "Offset for pagination",
          },
        },
      },
    },
    {
      name: "waha_check_contact_exists",
      description: "Check if phone number is registered on WhatsApp.",
      inputSchema: {
        type: "object",
        properties: {
          phone: {
            type: "string",
            description: "Phone number to check (e.g., '1234567890')",
          },
        },
        required: ["phone"],
      },
  • src/index.ts:1137-1138 (registration)
    Tool registration in the MCP CallToolRequestSchema handler's switch statement, mapping the tool name to its handler method.
    case "waha_check_contact_exists":
      return await this.handleCheckContactExists(args);
  • WAHAClient helper method that constructs and sends the GET request to the WAHA API endpoint /api/contacts/all with session, sorting, and pagination query parameters.
    async getAllContacts(params?: {
      sortBy?: "id" | "name";
      sortOrder?: "asc" | "desc";
      limit?: number;
      offset?: number;
    }): Promise<any[]> {
      const queryParams: Record<string, any> = {
        session: this.session
      };
    
      if (params?.sortBy) queryParams.sortBy = params.sortBy;
      if (params?.sortOrder) queryParams.sortOrder = params.sortOrder;
      if (params?.limit) queryParams.limit = Math.min(params.limit, 100);
      if (params?.offset) queryParams.offset = params.offset;
    
      const queryString = this.buildQueryString(queryParams);
      const endpoint = `/api/contacts/all${queryString}`;
    
      return this.request<any[]>(endpoint, {
        method: "GET",
      });
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only mentions 'pagination' without details on rate limits, permissions, or response format. It doesn't disclose whether this is a read-only operation, what happens on errors, or if it requires authentication, which is inadequate for a tool with potential data access.

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 that front-loads the core purpose ('List all contacts') and includes a key behavioral trait ('with pagination'). There's no wasted verbiage or redundancy.

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

Completeness2/5

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

For a tool with 4 parameters, no annotations, and no output schema, the description is insufficient. It lacks details on return values, error handling, authentication needs, or how pagination works in practice, leaving significant gaps for the agent.

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 fully documents all parameters. The description adds no additional meaning beyond implying pagination through 'limit' and 'offset', which is already clear from the schema. This meets the baseline for high schema coverage.

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 action ('List all contacts') and resource ('contacts'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'waha_get_contact' (singular) or 'waha_get_chats', which suggests it could be more specific about 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 like 'waha_get_contact' or 'waha_check_contact_exists'. There's no mention of prerequisites, context, or exclusions, leaving the agent without usage direction.

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