RadouaneElarfaoui/facebook-page-mcp-server
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.
Facebook Page MCP Server
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
- Features
- Getting Started
- Usage
- Connecting to AI Assistants
- Deployment
- Available Tools
- Contributing
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-requesttool 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
-
Clone the repository:
git clone https://github.com/RadouaneElarfaoui/facebook-page-mcp-server.git cd facebook-page-mcp-server -
Install dependencies:
npm install -
Set up environment variables: Copy the example file:
cp .env.example .envEdit the
.envfile 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)
-
Start the server locally.
-
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
-
Start the server locally.
-
Locate your Claude Desktop configuration file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
- macOS:
-
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_TOKENwith the token from your.envfile.
Deployment
Vercel
Method 1: Vercel Website (Recommended)
- Click the "Deploy with Vercel" button at the top of this README.
- Follow the on-screen instructions, creating a new Git repository.
- In the Vercel project settings, add your
FB_PAGE_ACCESS_TOKENandMCP_ACCESS_TOKENas environment variables.
Method 2: Vercel CLI
- Install the Vercel CLI (
npm i -g vercel) and log in (vercel login). - Link the project (
vercel link). - Add secrets:
vercel secret add fb-page-access-token YOUR_FB_PAGE_ACCESS_TOKEN vercel secret add mcp-access-token YOUR_MCP_ACCESS_TOKEN - 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.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/YourFeature). - Commit your changes (
git commit -m 'Add YourFeature'). - Push to the branch (
git push origin feature/YourFeature). - Open a Pull Request.