Skip to main content
Glama

buddypress_create_friendship

Send a friendship request between users by specifying initiator and friend user IDs to establish new connections in BuddyPress communities.

Instructions

Create a friendship request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
friend_idYesFriend user ID
initiator_idYesInitiator user ID

Implementation Reference

  • Handler logic that executes the tool by making a POST request to the BuddyPress /friends endpoint with the provided arguments.
    else if (name === 'buddypress_create_friendship') { result = await buddypressRequest('/friends', 'POST', args); }
  • Tool schema definition, including name, description, and input schema requiring initiator_id and friend_id.
    { name: 'buddypress_create_friendship', description: 'Create a friendship request', inputSchema: { type: 'object', properties: { initiator_id: { type: 'number', description: 'Initiator user ID', required: true }, friend_id: { type: 'number', description: 'Friend user ID', required: true }, }, required: ['initiator_id', 'friend_id'], }, },
  • src/index.ts:528-530 (registration)
    Registration of all tools via the ListToolsRequestSchema handler that returns the tools array containing this tool.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools }; });
  • Helper function used by all tools to make authenticated HTTP 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