Skip to main content
Glama

buddypress_create_message

Create and send private messages between users on a BuddyPress community site. Specify recipients, subject, and content to facilitate user communication.

Instructions

Create a new message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sender_idNoSender user ID (default: current user)
recipientsYesArray of recipient user IDs
subjectYesMessage subject
messageYesMessage content

Implementation Reference

  • Executes the buddypress_create_message tool by sending a POST request to the BuddyPress /messages endpoint with the provided arguments using the shared buddypressRequest helper.
    else if (name === 'buddypress_create_message') {
      result = await buddypressRequest('/messages', 'POST', args);
    }
  • Input schema defining the parameters for the buddypress_create_message tool, including required recipients, subject, and message.
    inputSchema: {
      type: 'object',
      properties: {
        sender_id: { type: 'number', description: 'Sender user ID (default: current user)' },
        recipients: { type: 'array', items: { type: 'number' }, description: 'Array of recipient user IDs', required: true },
        subject: { type: 'string', description: 'Message subject', required: true },
        message: { type: 'string', description: 'Message content', required: true },
      },
      required: ['recipients', 'subject', 'message'],
    },
  • src/index.ts:428-441 (registration)
    Tool object registration in the tools array, used by listTools handler, including name, description, and schema.
    {
      name: 'buddypress_create_message',
      description: 'Create a new message',
      inputSchema: {
        type: 'object',
        properties: {
          sender_id: { type: 'number', description: 'Sender user ID (default: current user)' },
          recipients: { type: 'array', items: { type: 'number' }, description: 'Array of recipient user IDs', required: true },
          subject: { type: 'string', description: 'Message subject', required: true },
          message: { type: 'string', description: 'Message content', required: true },
        },
        required: ['recipients', 'subject', 'message'],
      },
    },
  • Shared helper function that makes authenticated HTTP requests to the BuddyPress REST API, used by all tool handlers including buddypress_create_message.
    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