### Start MCP Server in Stdio Mode (JavaScript) Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Demonstrates how to start the MCP server in standard input/output mode for command-line integration. Includes an example Claude Desktop configuration and JSON-RPC requests/responses for listing tools and their schemas. Authentication is handled via environment variables. ```javascript // Start the server in stdio mode (default) node mcpServer.js // Claude Desktop configuration (~/.config/Claude/claude_desktop_config.json) { "mcpServers": { "messenger": { "command": "/usr/bin/node", "args": ["/path/to/mcpServer.js"], "env": { "MESSENGER_PLATFORM_API_API_KEY": "your_facebook_access_token" } } } } // The server listens on stdin/stdout for JSON-RPC messages // Example request to list tools: { "jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {} } // Response includes all available tools { "jsonrpc": "2.0", "id": 1, "result": { "tools": [ { "name": "send_text_message", "description": "Send a text message to a recipient", "inputSchema": { "type": "object", "properties": {...} } } ] } } ``` -------------------------------- ### Minimal Dockerfile for fb-messenger-mcp Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md This Dockerfile sets up a minimal Node.js environment to build and run the fb-messenger-mcp project. It installs dependencies, copies project files, and sets the entrypoint to start the MCP server. ```dockerfile FROM node:22.12-alpine AS builder WORKDIR /app COPY package.json package-lock.json ./ RUN npm install COPY . . ENTRYPOINT ["node", "mcpServer.js"] ``` -------------------------------- ### Real-time MCP Communication via SSE Mode (JavaScript) Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Illustrates how to start the MCP server with Server-Sent Events (SSE) transport and establish an SSE connection from the client. It demonstrates how to receive session IDs, send tool call requests over the SSE connection, and handle potential errors. The example uses fetch for sending tool calls. ```javascript // Start server with SSE transport node mcpServer.js --sse // SSE stream at http://127.0.0.1:3001/sse // Messages at http://127.0.0.1:3001/messages // Client-side SSE connection const eventSource = new EventSource('http://127.0.0.1:3001/sse'); let sessionId; eventSource.onmessage = (event) => { const data = JSON.parse(event.data); if (data.sessionId) { sessionId = data.sessionId; console.log('Connected with session:', sessionId); // Send a tool call request fetch(`http://127.0.0.1:3001/messages?sessionId=${sessionId}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'send_text_message', arguments: { pageScopedId: '1234567890', messageText: 'Hello via SSE!' } } }) }); } }; eventSource.onerror = (error) => { console.error('SSE error:', error); eventSource.close(); }; ``` -------------------------------- ### Example Tool Structure Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Illustrates the typical structure of a tool file within the 'tools/' directory. Each tool exports an 'apiTool' object containing the function to make the API call and its OpenAI function calling schema definition. It also shows the usage of environment variables for authentication and a placeholder for the pageId. ```javascript // Example: tools/messenger-platform-api/messenger-platform-api/text-message.js // Uses process.env.MESSENGER_PLATFORM_API_API_KEY for authentication const pageId = ''; // Must be populated by users async function functionName(params) { // API call using fetch to https://graph.facebook.com/v20.0/{pageId}/messages } export const apiTool = { function: functionName, definition: { name: "tool_name", description: "Tool description.", parameters: { ... } // OpenAI function calling schema } }; ``` -------------------------------- ### Run Server with Streamable HTTP Support Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md This command launches the MCP server with Streamable HTTP support enabled. This mode activates the `/mcp` endpoint, allowing for streamable responses. It assumes Node.js is installed and accessible in the PATH. ```sh node mcpServer.js --streamable-http ``` -------------------------------- ### Install Dependencies Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Installs all the necessary Node.js packages for the project. This is a standard npm command. ```sh npm install ``` -------------------------------- ### Run MCP Server (Default Stdio) Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Starts the MCP server using the default standard input/output mode, suitable for CLI integration with Claude Desktop. This command executes the main server script. ```sh node mcpServer.js ``` -------------------------------- ### Environment Variable Example for API Key Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md Demonstrates how environment variables are used within generated tool files to access API keys. These variables are typically set in a .env file. ```javascript // environment variables are used inside of each tool file const apiKey = process.env.ACME_API_KEY; ``` -------------------------------- ### Testing MCP Server with Postman Command Line Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md Provides commands to verify the Node.js version and get the absolute path to the mcpServer.js file, required for configuring Postman MCP requests. ```sh which node ``` ```sh node --version ``` ```sh realpath mcpServer.js ``` -------------------------------- ### Run MCP Server (SSE) Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Starts the MCP server using Server-Sent Events (SSE) transport mode. The SSE stream is available at http://127.0.0.1:3001/sse and messages at http://127.0.0.1:3001/messages. ```sh node mcpServer.js --sse # SSE stream at http://127.0.0.1:3001/sse # Messages at http://127.0.0.1:3001/messages ``` -------------------------------- ### Run MCP Server (Streamable HTTP) Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Starts the MCP server with the streamable HTTP transport mode. The server will be accessible at http://127.0.0.1:3001/mcp. This mode is useful for HTTP-based integrations. ```sh node mcpServer.js --streamable-http # Server runs at http://127.0.0.1:3001/mcp ``` -------------------------------- ### Open Postman Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Opens Postman if it is installed on the system. This command is a convenience shortcut for development and testing. ```sh npm run postman ``` -------------------------------- ### Run Server with Server-Sent Events (SSE) Support Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md This command enables Server-Sent Events (SSE) for the MCP server. When used, the server exposes `/sse` and `/messages` endpoints for real-time event streaming. This requires Node.js to be installed. ```sh node mcpServer.js --sse ``` -------------------------------- ### Call MCP Tool via Streamable HTTP Mode (JavaScript) Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Shows how to start the MCP server in Streamable HTTP mode and make an HTTP POST request to call a tool, specifically sending a text message. It illustrates the request payload structure and the expected response format. Custom ports can be configured using the PORT environment variable. ```javascript // Start server with HTTP transport node mcpServer.js --streamable-http // Server runs at http://127.0.0.1:3001/mcp // Example HTTP request to call a tool fetch('http://127.0.0.1:3001/mcp', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'send_text_message', arguments: { pageScopedId: '1234567890', messageText: 'Hello from MCP!' } } }) }) .then(res => res.json()) .then(data => { console.log(data.result.content[0].text); // Output: {"recipient_id":"1234567890","message_id":"mid.1234567890"} }) .catch(err => console.error('Error:', err)); // Custom port via environment variable // PORT=8080 node mcpServer.js --streamable-http ``` -------------------------------- ### List Available Tools via CLI Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md This command lists all generated tools, including their descriptions and parameters. It's useful for understanding the capabilities of the MCP server and its available integrations. The output provides details about each tool, such as its name, description, and required parameters. ```sh node index.js tools ``` -------------------------------- ### Discover Messenger Platform Tools via CLI Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Lists all available tools within the Messenger Platform API, including their descriptions and parameters. This command-line interface (CLI) tool is useful for understanding the capabilities and arguments required for each tool. ```bash # List all tools via CLI node index.js tools # Output format: # Available Tools: # # Workspace: messenger-platform-api # Collection: messenger-platform-api # send_text_message # Description: Send a text message to a recipient using the Messenger Platform API. # Parameters: # - pageScopedId: The Page-scoped ID (PSID) of the recipient. # - messageText: The text of the message to be sent. # # send_generic_template_message # Description: Send a generic template message via the Messenger Platform API. # Parameters: # - pageScopedId: The page-scoped ID of the recipient. # - version: The API version to use. # ... ``` -------------------------------- ### Docker Deployment for MCP Server Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Provides instructions for building and running the Messenger Platform MCP server in a Docker container for production environments. This includes a Dockerfile for image creation and commands for running the container in different modes (stdio, HTTP, SSE), with environment variable support. ```dockerfile # Dockerfile FROM node:22.12-alpine AS builder WORKDIR /app COPY package.json package-lock.json ./ RUN npm install COPY . . ENTRYPOINT ["node", "mcpServer.js"] ``` ```bash # Build the Docker image docker build -t fb-messenger-mcp . # Run with stdio mode (for Claude Desktop) docker run -i --rm --env-file=.env fb-messenger-mcp # Run with HTTP mode docker run -i --rm --env-file=.env -p 3001:3001 fb-messenger-mcp --streamable-http # Run with SSE mode docker run -i --rm --env-file=.env -p 3001:3001 fb-messenger-mcp --sse # Claude Desktop configuration for Docker ``` -------------------------------- ### Configure Messenger MCP Server with Docker Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Defines the Docker command and arguments for running the fb-messenger-mcp service, including mounting environment files for configuration. ```json { "mcpServers": { "messenger-docker": { "command": "docker", "args": [ "run", "-i", "--rm", "--env-file=/absolute/path/to/.env", "fb-messenger-mcp" ] } } } ``` -------------------------------- ### Configure MCP Server in Claude Desktop Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md Illustrates the JSON configuration for adding an MCP server to Claude Desktop. This includes specifying the command to execute the Node.js MCP server and its arguments. ```json { "mcpServers": { "": { "command": "", "args": [""] } } } ``` -------------------------------- ### Manage Messenger API Keys with Environment Variables Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Demonstrates how to set and use the MESSENGER_PLATFORM_API_API_KEY environment variable for authenticating with the Facebook Messenger Platform API. Includes instructions for generating tokens and running the server with environment variables. ```bash # .env file MESSENGER_PLATFORM_API_API_KEY=your_facebook_page_access_token_here # Alternative: set environment variable directly export MESSENGER_PLATFORM_API_API_KEY="EAAexample..." # Run server with env var MESSENGER_PLATFORM_API_API_KEY="EAAexample..." node mcpServer.js # Multiple environments # .env.development MESSENGER_PLATFORM_API_API_KEY=dev_token_here PORT=3001 # .env.production MESSENGER_PLATFORM_API_API_KEY=prod_token_here PORT=80 # Load specific env file NODE_ENV=production node -r dotenv/config mcpServer.js dotenv_config_path=.env.production ``` -------------------------------- ### Discover Tools from Directory - JavaScript Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Automatically loads and registers all tools from the `tools/` directory. It handles deduplication of tool names, automatically numbering duplicates. The tools are defined with an `apiTool` object containing a `function` implementation and a `definition` for AI integration. Tool paths are specified in `paths.js`. ```javascript // lib/tools.js - discoverTools function import { discoverTools } from './lib/tools.js'; // Discover all available tools const tools = await discoverTools(); // Tools are loaded from paths.js // tools/paths.js export const toolPaths = [ 'messenger-platform-api/messenger-platform-api/text-message.js', 'messenger-platform-api/messenger-platform-api/ban-a-user.js', // ... more tools ]; // Each tool exports an apiTool object // Example tool structure: { function: async (args) => { /* implementation */ }, definition: { type: 'function', function: { name: 'send_text_message', description: 'Send a text message', parameters: { type: 'object', properties: { pageScopedId: {...}, messageText: {...} }, required: ['pageScopedId', 'messageText'] } } }, path: 'messenger-platform-api/messenger-platform-api/text-message.js' } // If duplicate names exist, they're automatically numbered // send_text_message, send_text_message_2, send_text_message_3, etc. ``` -------------------------------- ### Configure Claude Desktop for Docker Server Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md This JSON configuration snippet is for Claude Desktop, allowing it to connect to a Dockerized MCP server. It specifies the command to run the Docker container and passes environment variables from a .env file. Replace '' with the actual name of your Docker image. ```json { "mcpServers": { "": { "command": "docker", "args": ["run", "-i", "--rm", "--env-file=.env", ""] } } } ``` -------------------------------- ### List Available Tools Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Lists all the available Messenger Platform API tools that have been discovered by the MCP server. This command helps in understanding the capabilities exposed by the server. ```sh npm run list-tools # OR node index.js tools ``` -------------------------------- ### Dockerfile for Messenger MCP Server Build Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt A multi-stage Dockerfile to build a production-ready image for the Messenger MCP server. It first builds dependencies using a 'builder' stage and then copies artifacts to a lean Alpine-based runtime image. ```dockerfile FROM node:22.12-alpine AS builder WORKDIR /app COPY package*.json ./ RUN npm ci --only=production FROM node:22.12-alpine WORKDIR /app COPY --from=builder /app/node_modules ./node_modules COPY . . ENTRYPOINT ["node", "mcpServer.js"] ``` -------------------------------- ### Build Docker Image for Production Deployment Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/README.md This command builds a Docker image for the project, intended for production environments. It tags the image with a specified server name. Ensure you are in the project's root directory containing the Dockerfile. ```sh docker build -t . ``` -------------------------------- ### Discover Messenger Platform Tools Programmatically Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Enables programmatic access to discover and filter available Messenger Platform API tools. The `discoverTools` function returns a list of tools, allowing iteration for details like name, description, and parameters. Tools can be filtered by name patterns or grouped by functionality. ```javascript // Programmatic access to tool listing import { discoverTools } from './lib/tools.js'; const tools = await discoverTools(); // Iterate through tools tools.forEach(tool => { const { name, description, parameters } = tool.definition.function; console.log(`Tool: ${name}`); console.log(`Description: ${description}`); console.log('Parameters:', Object.keys(parameters.properties)); console.log('Required:', parameters.required); }); // Filter tools by name pattern const messageTools = tools.filter(t => t.definition.function.name.includes('message') ); // Group by functionality const grouped = tools.reduce((acc, tool) => { const name = tool.definition.function.name; if (name.includes('ban') || name.includes('block')) { acc.moderation = acc.moderation || []; acc.moderation.push(tool); } else if (name.includes('message') || name.includes('template')) { acc.messaging = acc.messaging || []; acc.messaging.push(tool); } return acc; }, {}); ``` -------------------------------- ### Run Docker Container Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Runs the fb-messenger-mcp application as a Docker container. It uses an environment file (.env) for configuration, which must contain the MESSENGER_PLATFORM_API_API_KEY. ```sh docker run -i --rm --env-file=.env fb-messenger-mcp ``` -------------------------------- ### Build Docker Image Source: https://github.com/ramborau/fb-messenger-mcp/blob/main/CLAUDE.md Builds a Docker image for the fb-messenger-mcp project. This command is used to containerize the application for consistent deployment. ```sh docker build -t fb-messenger-mcp . ``` -------------------------------- ### Access and Use Messenger API Key in JavaScript Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Provides a JavaScript code snippet showing how to access the Messenger API key from environment variables using process.env, validate its presence, and include it in request headers for authenticated API calls. ```javascript // Accessing environment variables in tools // Each tool reads the API key from process.env const token = process.env.MESSENGER_PLATFORM_API_API_KEY; // Validate token before making requests if (!token) { throw new Error('MESSENGER_PLATFORM_API_API_KEY not set in environment'); } // Use token in Authorization header const headers = { 'Content-Type': 'application/json', 'Authorization': `Bearer ${token}` }; // Make authenticated request const response = await fetch(url, { method: 'POST', headers, body: JSON.stringify(data) }); // Token scopes required for different operations: // - pages_messaging: Send and receive messages // - pages_manage_metadata: Manage page settings // - pages_read_engagement: Read page engagement data // - pages_manage_posts: Manage page posts // Update pageId in each tool file (required) // tools/messenger-platform-api/messenger-platform-api/text-message.js:11 const pageId = 'your_facebook_page_id_here'; // Replace empty string ``` -------------------------------- ### Send Generic Template - JavaScript Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Sends a rich, structured message with images, buttons, and actions using the `send_generic_template` tool. The tool sends a predefined template by default, but can be customized by modifying the `messageData` object within the tool file. Requires API key and page ID configuration. ```javascript // tools/messenger-platform-api/messenger-platform-api/generic-template.js import { apiTool } from './tools/messenger-platform-api/messenger-platform-api/generic-template.js'; // Send a generic template with custom elements const result = await apiTool.function({ pageScopedId: '1234567890', version: 'v20.0' }); // The tool sends a predefined template with: // - Title: "Welcome!" // - Image with default web action // - Two buttons: "View Website" and "Start Chatting" console.log(result); // Success response: // { // "recipient_id": "1234567890", // "message_id": "mid.1458668856218:ed81099e15d3f4f233" // } // Customize the template by modifying the tool file: const messageData = { recipient: { id: pageScopedId }, message: { attachment: { type: "template", payload: { template_type: "generic", elements: [ { title: "Product Name", image_url: "https://example.com/product.jpg", subtitle: "Product description here", default_action: { type: "web_url", url: "https://example.com/product", webview_height_ratio: "tall" }, buttons: [ { type: "web_url", url: "https://example.com/product", title: "View Details" }, { type: "postback", title: "Add to Cart", payload: "ADD_TO_CART_PAYLOAD" } ] } ] } } } }; ``` -------------------------------- ### Send Facebook Messenger Quick Reply Message Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Sends a message to a Facebook Messenger user with quick reply buttons to facilitate interaction. It allows customization of reply options including text, payload, and optional image URLs. This function is designed to enhance user engagement by providing predefined responses. ```javascript // tools/messenger-platform-api/messenger-platform-api/text-quick-reply.js import { apiTool } from './tools/messenger-platform-api/messenger-platform-api/text-quick-reply.js'; // Send quick reply with predefined options const result = await apiTool.function({ pageScopedId: '1234567890', version: 'v20.0' }); // Default template shows color picker: "Pick a color: Red, Green" console.log(result); // { // "recipient_id": "1234567890", // "message_id": "mid.1458668856218:ed81099e15d3f4f233" // } // To customize, edit the tool file with your own quick replies: const body = { recipient: { id: pageScopedId }, messaging_type: "RESPONSE", message: { text: "What would you like to do?", quick_replies: [ { content_type: "text", title: "View Order", payload: "VIEW_ORDER", image_url: "https://example.com/icons/order.png" }, { content_type: "text", title: "Contact Support", payload: "CONTACT_SUPPORT", image_url: "https://example.com/icons/support.png" }, { content_type: "text", title: "Track Shipment", payload: "TRACK_SHIPMENT", image_url: "https://example.com/icons/tracking.png" } ] } }; // Email quick reply // content_type: "user_email" - requests user's email // Phone quick reply // content_type: "user_phone_number" - requests user's phone number ``` -------------------------------- ### Upload Facebook Messenger Photo Attachment Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Uploads a photo to Facebook Messenger, optionally making it reusable. Reusable attachments are stored by Facebook and can be sent multiple times using their `attachment_id`, saving bandwidth and upload time. This function requires a valid URL and specifies if the attachment should be reusable. ```javascript // tools/messenger-platform-api/messenger-platform-api/attachment-upload-photo.js import { apiTool } from './tools/messenger-platform-api/messenger-platform-api/attachment-upload-photo.js'; // Upload a photo by URL const result = await apiTool.function({ pageId: '123456789', version: 'v20.0', url: 'https://example.com/image.jpg', isReusable: true }); console.log(result); // Success response returns attachment_id for reuse: // { // "attachment_id": "1458668856218" // } // Use the attachment_id in future messages to avoid re-uploading: const messageWithAttachment = { recipient: { id: recipientPsid }, message: { attachment: { type: "image", payload: { attachment_id: "1458668856218" } } } }; // For non-reusable attachments: const oneTimeUpload = await apiTool.function({ pageId: '123456789', version: 'v20.0', url: 'https://example.com/temp-image.jpg', isReusable: false }); // Error handling: // - Invalid URL: Returns error with details // - Invalid page ID: Returns authorization error // - File size too large: Returns error with size limits ``` -------------------------------- ### Send Facebook Messenger Receipt Template Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Sends a detailed receipt message to a Facebook Messenger user, including order summary, items, payment information, and shipping address. This is useful for e-commerce applications to provide order confirmations. The function requires extensive details about the order and recipient. ```javascript // tools/messenger-platform-api/messenger-platform-api/receipt-template.js import { apiTool } from './tools/messenger-platform-api/messenger-platform-api/receipt-template.js'; // Send receipt with full order details const result = await apiTool.function({ pageId: '1234567890', version: 'v20.0', recipientName: 'John Doe', orderNumber: 'ORDER-12345', currency: 'USD', paymentMethod: 'Visa 1234', orderUrl: 'https://example.com/order/12345', timestamp: '1458668856', address: { street_1: '1 Hacker Way', street_2: '', city: 'Menlo Park', postal_code: '94025', state: 'CA', country: 'US' }, elements: [ { title: 'Classic T-Shirt', subtitle: 'Size: Large, Color: Blue', quantity: 2, price: 25.00, currency: 'USD', image_url: 'https://example.com/tshirt.jpg' }, { title: 'Jeans', subtitle: 'Size: 32, Color: Black', quantity: 1, price: 50.00, currency: 'USD', image_url: 'https://example.com/jeans.jpg' } ] }); console.log(result); // Receipt includes: // - Order summary (subtotal, shipping, tax, total) // - Adjustments (discounts, coupons) // - Items with images and details // - Shipping address // Response: // { // "recipient_id": "1234567890", // "message_id": "mid.1458668856218:ed81099e15d3f4f233" // } ``` -------------------------------- ### Send Text Message - JavaScript Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Sends a simple text message to a Facebook Messenger recipient using the `send_text_message` tool. It can be called directly as a JavaScript function or invoked via an AI assistant by sending a JSON object with the tool name and arguments. Requires environment variables for API key and page ID. ```javascript // tools/messenger-platform-api/messenger-platform-api/text-message.js import { apiTool } from './tools/messenger-platform-api/messenger-platform-api/text-message.js'; // Direct function call const result = await apiTool.function({ pageScopedId: '1234567890', messageText: 'Hello! This is a test message.' }); console.log(result); // Success response: // { // "recipient_id": "1234567890", // "message_id": "mid.1458668856218:ed81099e15d3f4f233" // } // Error response: // { // "error": "An error occurred while sending the message: ..." // } // Via MCP protocol (through Claude Desktop or other client) // The AI assistant can call: send_text_message with parameters // Claude would execute: { "name": "send_text_message", "arguments": { "pageScopedId": "1234567890", "messageText": "Hello from Claude!" } } // Environment setup required in .env // MESSENGER_PLATFORM_API_API_KEY=your_facebook_page_access_token // Also set pageId in tool file at line 11: const pageId = 'your_page_id'; ``` -------------------------------- ### Block User with Messenger Platform API Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Prevents a user from all interactions, including messaging and commenting, with your Facebook page. This is a more restrictive action than banning and can be reversed using the unblock_user tool. It requires the page-scoped ID, page ID, and API version. ```javascript // tools/messenger-platform-api/messenger-platform-api/block-a-user.js // Similar to ban-a-user.js but uses "block_user" action // Block prevents: // - Messaging the page // - Commenting on page posts // - Interacting with page content const result = await apiTool.function({ pageScopedId: '1234567890', pageId: '987654321', version: 'v20.0' }); // Use unblock_user tool to reverse: import { apiTool as unblockTool } from './tools/messenger-platform-api/messenger-platform-api/unblock-a-user.js'; const unblockResult = await unblockTool.function({ pageScopedId: '1234567890', pageId: '987654321', version: 'v20.0' }); ``` -------------------------------- ### Move Conversation to Spam with Messenger Platform API Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Marks a conversation as spam, moving it to the spam folder within the page inbox. This helps filter unwanted messages without blocking the user. The operation requires a conversation ID, page ID, and API version. It is reversible by reviewing and unmarking the conversation. ```javascript // tools/messenger-platform-api/messenger-platform-api/move-conversation-to-spam.js // Move a conversation to spam folder const result = await apiTool.function({ conversationId: 'conversation_id_here', pageId: '987654321', version: 'v20.0' }); console.log(result); // { // "success": true // } // Spam conversations: // - Moved to spam folder in page inbox // - Can be reviewed and unmarked later // - Helps filter unwanted messages // - Doesn't block the user (use block_user for that) ``` -------------------------------- ### Ban User with Messenger Platform API Source: https://context7.com/ramborau/fb-messenger-mcp/llms.txt Allows banning a user by their page-scoped ID to prevent interaction with the Facebook page. This action is reversible using the unban_user tool and does not permanently block the user. The tool requires the page-scoped ID, page ID, and API version. ```javascript // tools/messenger-platform-api/messenger-platform-api/ban-a-user.js import { apiTool } from './tools/messenger-platform-api/messenger-platform-api/ban-a-user.js'; // Ban a user by their page-scoped ID const result = await apiTool.function({ pageScopedId: '1234567890', pageId: '987654321', version: 'v20.0' }); console.log(result); // Success response: // { // "success": true // } // Via MCP in Claude Desktop // User: "Ban the user with ID 1234567890" // Claude calls: ban_user tool { "name": "ban_user", "arguments": { "pageScopedId": "1234567890", "pageId": "987654321", "version": "v20.0" } } // To unban the user later: // Use the unban_user tool with the same pageScopedId // Banned users: // - Cannot send messages to the page // - Don't receive messages from the page // - Can be unbanned at any time // - Action is reversible via unban_user tool ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.