Skip to main content
Glama

waha_get_groups

Retrieve WhatsApp group lists with customizable filtering, sorting, and pagination options for efficient chat management.

Instructions

List all groups with filtering and pagination options.

Input Schema

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

Implementation Reference

  • The handler function that implements the core logic of the 'waha_get_groups' tool. It parses arguments, calls the WAHAClient.getGroups method, and returns a formatted text response with the list of groups as JSON.
    private async handleGetGroups(args: any) { const groups = await this.wahaClient.getGroups({ sortBy: args.sortBy, sortOrder: args.sortOrder, limit: args.limit, offset: args.offset, exclude: args.exclude, }); return { content: [ { type: "text", text: `Found ${groups.length} group(s):\n${JSON.stringify(groups, null, 2)}`, }, ], }; }
  • src/index.ts:516-546 (registration)
    Tool registration in the ListToolsRequestSchema handler, including name, description, and input schema definition for validation.
    name: "waha_get_groups", description: "List all groups with filtering and pagination options.", inputSchema: { type: "object", properties: { sortBy: { type: "string", enum: ["id", "name"], description: "Sort field (default: id)", }, sortOrder: { type: "string", enum: ["asc", "desc"], description: "Sort order (default: asc)", }, limit: { type: "number", description: "Limit results (default: 100, max: 100)", }, offset: { type: "number", description: "Offset for pagination", }, exclude: { type: "array", items: { type: "string" }, description: "Exclude fields like 'participants'", }, }, }, },
  • Supporting method in WAHAClient that performs the actual HTTP GET request to the WAHA API endpoint /api/{session}/groups with query parameters for sorting, pagination, and filtering.
    async getGroups(params?: { sortBy?: "id" | "name"; sortOrder?: "asc" | "desc"; limit?: number; offset?: number; exclude?: string[]; }): Promise<any[]> { const queryParams: Record<string, any> = {}; 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; if (params?.exclude) queryParams.exclude = params.exclude; const queryString = this.buildQueryString(queryParams); const endpoint = `/api/${this.session}/groups${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