facebook-page-mcp-server

RadouaneElarfaoui/facebook-page-mcp-server

3.1

If you are the rightful owner of facebook-page-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

This project is a Model Context Protocol (MCP) server built with Express.js, designed to interact with a Facebook Page using the Graph API.

Tools
2
Resources
0
Prompts
0

Facebook Page MCP Server

Deploy with Vercel

This project is a Model Context Protocol (MCP) server that acts as a secure proxy to the Facebook Graph API, allowing AI models and assistants to interact with a specific Facebook Page.

Table of Contents

Overview

This server, built with Node.js, Express, and TypeScript, provides a set of tools that can be called by any MCP-compatible client. It handles authentication with the Facebook Graph API and exposes a simple, secure interface for common Page interactions.

Features

  • Secure: Protects your MCP endpoint with Bearer Token authentication.
  • Pre-defined Tools: Offers a set of ready-to-use tools for Facebook Page management.
  • Flexible: Includes a generic graph-api-request tool for custom API calls.
  • Easy Deployment: Can be deployed to Vercel with a single click.
  • Extensible: Easily add new tools and features.

Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • A Facebook Page and a corresponding Page Access Token.
  • Vercel CLI (optional, for CLI deployment).

Installation and Configuration

  1. Clone the repository:

    git clone https://github.com/RadouaneElarfaoui/facebook-page-mcp-server.git
    cd facebook-page-mcp-server
    
  2. Install dependencies:

    npm install
    
  3. Set up environment variables: Copy the example file:

    cp .env.example .env
    

    Edit the .env file with your credentials:

    • FB_PAGE_ACCESS_TOKEN: Your Facebook Page Access Token.
    • MCP_ACCESS_TOKEN: A secret password to protect your server.

Usage

Running the Server

  • Development Mode (with hot-reloading):
    npm run dev
    
  • Production Mode:
    npm run build
    npm start
    

The server will run on port 3000 by default.

Making Requests

Send a POST request to the /mcp endpoint with your MCP_ACCESS_TOKEN as a Bearer Token.

Example curl request:

curl -X POST http://localhost:3000/mcp \
     -H "Authorization: Bearer YOUR_SECRET_MCP_ACCESS_TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
           "tool": "get-page-info",
           "parameters": {}
         }'

Connecting to AI Assistants

You can connect this server to any MCP-compatible AI assistant.

VS Code (Copilot)

  1. Start the server locally.

  2. In your VS Code settings (mcp.json), define the MCP server:

    "mcpServers": {
        "facebook-page": {
            "url": "http://localhost:3000/mcp",
            "headers": {
                "Authorization": "Bearer YOUR_SECRET_MCP_ACCESS_TOKEN"
            }
        }
    }
    

    Note: For a deployed server, replace the local URL with your production URL.

Anthropic Claude Desktop

  1. Start the server locally.

  2. Locate your Claude Desktop configuration file:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  3. Edit the file to add the server endpoint:

    {
      "mcpHttpEndpoints": [
        {
          "url": "http://localhost:3000/mcp",
          "headers": {
            "Authorization": "Bearer YOUR_SECRET_MCP_ACCESS_TOKEN"
          }
        }
      ]
    }
    

    Remember to replace YOUR_SECRET_MCP_ACCESS_TOKEN with the token from your .env file.

Deployment

Vercel

Method 1: Vercel Website (Recommended)

  1. Click the "Deploy with Vercel" button at the top of this README.
  2. Follow the on-screen instructions, creating a new Git repository.
  3. In the Vercel project settings, add your FB_PAGE_ACCESS_TOKEN and MCP_ACCESS_TOKEN as environment variables.

Method 2: Vercel CLI

  1. Install the Vercel CLI (npm i -g vercel) and log in (vercel login).
  2. Link the project (vercel link).
  3. Add secrets:
    vercel secret add fb-page-access-token YOUR_FB_PAGE_ACCESS_TOKEN
    vercel secret add mcp-access-token YOUR_MCP_ACCESS_TOKEN
    
  4. Deploy to production:
    vercel --prod
    

Available Tools

  • get-page-info: Get basic Page details.
  • get-page-feed: Get recent posts from the Page's feed.
  • create-post: Create a new post.
  • update-post: Update an existing post.
  • delete-post: Delete a post.
  • graph-api-request: Make a generic request to the Graph API.

Contributing

Contributions are welcome! Please open an issue to discuss your ideas or submit a pull request.

  1. Fork the repository.
  2. Create your feature branch (git checkout -b feature/YourFeature).
  3. Commit your changes (git commit -m 'Add YourFeature').
  4. Push to the branch (git push origin feature/YourFeature).
  5. Open a Pull Request.