buddypress_list_groups
Retrieve BuddyPress groups using filters like status, user membership, or search terms to manage community groups through the BuddyPress MCP Server.
Instructions
List BuddyPress groups with optional filters
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| page | No | Page number (default: 1) | |
| per_page | No | Items per page (default: 20) | |
| search | No | Search term | |
| status | No | Group status (public, private, hidden) | |
| user_id | No | Filter groups by user membership | |
| group_type | No | Group type |
Implementation Reference
- src/index.ts:598-607 (handler)Handler logic for executing the buddypress_list_groups tool. Constructs URLSearchParams from input arguments and calls the shared buddypressRequest helper to GET /groups endpoint.else if (name === 'buddypress_list_groups') { const params = new URLSearchParams(); if (args.page) params.append('page', String(args.page)); if (args.per_page) params.append('per_page', String(args.per_page)); if (args.search) params.append('search', String(args.search)); if (args.status) params.append('status', String(args.status)); if (args.user_id) params.append('user_id', String(args.user_id)); if (args.group_type) params.append('group_type', String(args.group_type)); result = await buddypressRequest(`/groups?${params}`); }
- src/index.ts:187-197 (schema)Input schema defining the parameters for the buddypress_list_groups tool, including pagination, search, status, user filter, and group type.inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number (default: 1)' }, per_page: { type: 'number', description: 'Items per page (default: 20)' }, search: { type: 'string', description: 'Search term' }, status: { type: 'string', description: 'Group status (public, private, hidden)' }, user_id: { type: 'number', description: 'Filter groups by user membership' }, group_type: { type: 'string', description: 'Group type' }, }, },
- src/index.ts:184-198 (registration)Registration of the buddypress_list_groups tool in the global tools array, which is returned by the ListToolsRequestSchema handler.{ name: 'buddypress_list_groups', description: 'List BuddyPress groups with optional filters', inputSchema: { type: 'object', properties: { page: { type: 'number', description: 'Page number (default: 1)' }, per_page: { type: 'number', description: 'Items per page (default: 20)' }, search: { type: 'string', description: 'Search term' }, status: { type: 'string', description: 'Group status (public, private, hidden)' }, user_id: { type: 'number', description: 'Filter groups by user membership' }, group_type: { type: 'string', description: 'Group type' }, }, }, },
- src/index.ts:18-46 (helper)Shared helper utility function for making authenticated requests to BuddyPress REST API, used by all tool handlers including buddypress_list_groups.async function buddypressRequest( endpoint: string, method: string = 'GET', body?: any ): Promise<any> { const url = `${BUDDYPRESS_URL}/wp-json/buddypress/v2${endpoint}`; const auth = Buffer.from(`${BUDDYPRESS_USERNAME}:${BUDDYPRESS_PASSWORD}`).toString('base64'); const options: any = { method, headers: { 'Authorization': `Basic ${auth}`, 'Content-Type': 'application/json', }, }; if (body && method !== 'GET') { options.body = JSON.stringify(body); } const response = await fetch(url, options); if (!response.ok) { const errorText = await response.text(); throw new Error(`BuddyPress API Error (${response.status}): ${errorText}`); } return await response.json(); }