buddypress_list_activities
Retrieve and filter BuddyPress activity stream items, including user posts, group updates, and comments, using parameters like user ID, group ID, search terms, and scope options.
Instructions
List activity stream items 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 | |
| user_id | No | Filter by user ID | |
| group_id | No | Filter by group ID | |
| scope | No | Activity scope (all, friends, groups, favorites, mentions) | |
| display_comments | No | Include comments |
Implementation Reference
- src/index.ts:545-554 (handler)Executes the buddypress_list_activities tool by constructing URL query parameters from input arguments and making an authenticated GET request to the BuddyPress /activity endpoint.if (name === 'buddypress_list_activities') { 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.user_id) params.append('user_id', String(args.user_id)); if (args.group_id) params.append('group_id', String(args.group_id)); if (args.scope) params.append('scope', String(args.scope)); if (args.display_comments !== undefined) params.append('display_comments', String(args.display_comments)); result = await buddypressRequest(`/activity?${params}`);
- src/index.ts:54-65 (schema)Defines the input schema for the buddypress_list_activities tool, specifying optional parameters for pagination, search, and filtering activities.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' }, user_id: { type: 'number', description: 'Filter by user ID' }, group_id: { type: 'number', description: 'Filter by group ID' }, scope: { type: 'string', description: 'Activity scope (all, friends, groups, favorites, mentions)' }, display_comments: { type: 'boolean', description: 'Include comments' }, }, },
- src/index.ts:51-66 (registration)Registers the buddypress_list_activities tool in the tools array used by the MCP server for tool listing and execution dispatching.{ name: 'buddypress_list_activities', description: 'List activity stream items 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' }, user_id: { type: 'number', description: 'Filter by user ID' }, group_id: { type: 'number', description: 'Filter by group ID' }, scope: { type: 'string', description: 'Activity scope (all, friends, groups, favorites, mentions)' }, display_comments: { type: 'boolean', description: 'Include comments' }, }, }, },
- src/index.ts:18-46 (helper)Shared helper function for making authenticated HTTP requests to the BuddyPress REST API, used by all BuddyPress tools including buddypress_list_activities.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(); }