Skip to main content
Glama

buddypress_create_activity

Create new activity items in BuddyPress for user updates, group posts, or comments using the REST API.

Instructions

Create a new activity item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesActivity content
user_idNoUser ID (default: current user)
componentNoComponent (activity, groups, members, etc.)
typeNoActivity type (activity_update, activity_comment, etc.)
primary_item_idNoPrimary item ID (e.g., group ID)
secondary_item_idNoSecondary item ID

Implementation Reference

  • Handler logic for the buddypress_create_activity tool. Executes a POST request to the BuddyPress /activity endpoint using the provided arguments.
    else if (name === 'buddypress_create_activity') {
      result = await buddypressRequest('/activity', 'POST', args);
    }
  • Input schema definition for the buddypress_create_activity tool, specifying parameters like content (required), 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)
    Registration of the buddypress_create_activity tool in the tools array, including name, description, and input schema.
    {
      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'],
      },
    },
  • Helper function used by all BuddyPress tools, including buddypress_create_activity, to make authenticated API requests to the BuddyPress REST API.
    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();
    }

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/vapvarun/buddypress-mcp'

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