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", }); }

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-mcp'

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