buddypress_create_activity
Create new activity items in BuddyPress communities to post updates, comments, and user interactions for enhanced community engagement.
Instructions
Create a new activity item
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| component | No | Component (activity, groups, members, etc.) | |
| content | Yes | Activity content | |
| primary_item_id | No | Primary item ID (e.g., group ID) | |
| secondary_item_id | No | Secondary item ID | |
| type | No | Activity type (activity_update, activity_comment, etc.) | |
| user_id | No | User ID (default: current user) |
Implementation Reference
- src/index.ts:559-561 (handler)Executes the buddypress_create_activity tool by sending a POST request to the BuddyPress /activity endpoint with the provided arguments using the buddypressRequest helper.else if (name === 'buddypress_create_activity') { result = await buddypressRequest('/activity', 'POST', args); }
- src/index.ts:81-92 (schema)Defines the input schema and parameters for the buddypress_create_activity tool, including required 'content' and optional fields like user_id, component, type, etc.inputSchema: { type: 'object', properties: { content: { type: 'string', description: 'Activity content', required: true }, user_id: { type: 'number', description: 'User ID (default: current user)' }, component: { type: 'string', description: 'Component (activity, groups, members, etc.)' }, type: { type: 'string', description: 'Activity type (activity_update, activity_comment, etc.)' }, primary_item_id: { type: 'number', description: 'Primary item ID (e.g., group ID)' }, secondary_item_id: { type: 'number', description: 'Secondary item ID' }, }, required: ['content'], },
- src/index.ts:78-93 (registration)Registers the buddypress_create_activity tool in the tools array used for listing and dispatching tools in the MCP server.{ name: 'buddypress_create_activity', description: 'Create a new activity item', inputSchema: { type: 'object', properties: { content: { type: 'string', description: 'Activity content', required: true }, user_id: { type: 'number', description: 'User ID (default: current user)' }, component: { type: 'string', description: 'Component (activity, groups, members, etc.)' }, type: { type: 'string', description: 'Activity type (activity_update, activity_comment, etc.)' }, primary_item_id: { type: 'number', description: 'Primary item ID (e.g., group ID)' }, secondary_item_id: { type: 'number', description: 'Secondary item ID' }, }, required: ['content'], }, },
- src/index.ts:18-46 (helper)Helper function that makes authenticated HTTP requests to the BuddyPress REST API, used by all BuddyPress tools including buddypress_create_activity.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(); }