Facebook Pages Manager MCP server

Integrates with Facebook Pages to enable direct management of posts, comments, and engagement metrics through the Graph API for streamlined social media management.
Back to servers
Setup instructions
Provider
Hagai Hen
Release date
May 09, 2025
Stats
33 stars

This project is a MCP server for automating and managing interactions on a Facebook Page using the Facebook Graph API. It provides tools to create posts, moderate comments, fetch post insights, and filter negative feedback that can be used with Claude or other LLM-based agents.

Installation

Prerequisites

To use this Facebook MCP server, you'll need:

  • Python installed on your system
  • Facebook Page credentials (access token and page ID)

Step 1: Clone the Repository

git clone https://github.com/your-org/facebook-mcp-server.git
cd facebook-mcp-server

Step 2: Install Dependencies

Install dependencies using uv, a fast Python package manager:

# Install uv if you don't have it already
curl -Ls https://astral.sh/uv/install.sh | bash

# Install project dependencies
uv pip install -r requirements.txt

Step 3: Configure Environment Variables

Create a .env file in the root directory with your Facebook credentials:

FACEBOOK_ACCESS_TOKEN=your_facebook_page_access_token
FACEBOOK_PAGE_ID=your_page_id

You can obtain these credentials from the Facebook Developer platform at Facebook Graph API Explorer.

Integration with Claude Desktop

Configuration

To integrate the Facebook MCP server with Claude Desktop:

  1. Open Claude Desktop
  2. Navigate to Settings → Developer → Edit Config
  3. Add the following entry to the configuration file:
"FacebookMCP": {
  "command": "uv",
  "args": [
    "run",
    "--with",
    "mcp[cli]",
    "--with",
    "requests",
    "mcp",
    "run",
    "/path/to/facebook-mcp-server/server.py"
  ]
}

Be sure to replace /path/to/facebook-mcp-server/ with the actual path where you cloned the repository.

Available Tools

The Facebook MCP server provides the following tools:

Content Creation

  • post_to_facebook - Create a new Facebook post with a message
  • post_image_to_facebook - Post an image with a caption
  • update_post - Update an existing post's message
  • schedule_post - Schedule a post for future publication
  • delete_post - Delete a specific post by ID

Comment Management

  • reply_to_comment - Reply to a specific comment on a post
  • delete_comment / delete_comment_from_post - Delete a specific comment by ID
  • hide_comment - Hide a comment from public view
  • unhide_comment - Unhide a previously hidden comment
  • filter_negative_comments - Filter out comments with negative sentiment keywords
  • bulk_delete_comments - Delete multiple comments by ID
  • bulk_hide_comments - Hide multiple comments by ID

Analytics and Insights

  • get_page_posts - Retrieve recent posts from the Page
  • get_post_comments - Fetch comments on a given post
  • get_number_of_comments - Count comments on a post
  • get_number_of_likes - Count likes on a post
  • get_post_impressions - Get total impressions on a post
  • get_post_impressions_unique - Get number of unique users who saw the post
  • get_post_impressions_paid - Get number of paid impressions
  • get_post_impressions_organic - Get number of organic impressions
  • get_post_engaged_users - Get number of users who engaged with the post
  • get_post_clicks - Get number of clicks on the post
  • get_post_reactions_like_total - Get total number of 'Like' reactions
  • get_post_reactions_breakdown - Get all reaction counts in one call
  • get_post_top_commenters - Get the top commenters on a post
  • get_page_fan_count - Retrieve the total number of Page fans
  • get_post_share_count - Get the number of shares on a post

User Interaction

  • send_dm_to_user - Send a direct message to a user

Usage Examples

Creating a Post

To create a new post on your Facebook Page:

response = post_to_facebook("Check out our latest product announcement!")
post_id = response["id"]
print(f"Created post with ID: {post_id}")

Moderating Comments

To fetch and hide negative comments:

# Get comments from a post
comments = get_post_comments(post_id)

# Filter negative comments
negative_comments = filter_negative_comments(comments)

# Hide negative comments
for comment in negative_comments:
    hide_comment(comment["id"])

Analyzing Post Performance

To get insights about a post's performance:

# Get post engagement metrics
impressions = get_post_impressions(post_id)
engaged_users = get_post_engaged_users(post_id)
likes = get_number_of_likes(post_id)
comments = get_number_of_comments(post_id)
shares = get_post_share_count(post_id)

print(f"Post performance: {impressions} impressions, {engaged_users} engaged users")
print(f"Engagement: {likes} likes, {comments} comments, {shares} shares")

Scheduling Content

To schedule a post for future publication:

# Schedule a post for tomorrow at 10 AM
import datetime
tomorrow = datetime.datetime.now() + datetime.timedelta(days=1)
scheduled_time = tomorrow.replace(hour=10, minute=0, second=0).isoformat()

response = schedule_post("Our weekend special starts tomorrow!", scheduled_time)
scheduled_post_id = response["id"]

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "facebook-mcp-server" '{"command":"uv","args":["run","--with","mcp[cli]","--with","requests","mcp","run","/path/to/facebook-mcp-server/server.py"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "facebook-mcp-server": {
            "command": "uv",
            "args": [
                "run",
                "--with",
                "mcp[cli]",
                "--with",
                "requests",
                "mcp",
                "run",
                "/path/to/facebook-mcp-server/server.py"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "facebook-mcp-server": {
            "command": "uv",
            "args": [
                "run",
                "--with",
                "mcp[cli]",
                "--with",
                "requests",
                "mcp",
                "run",
                "/path/to/facebook-mcp-server/server.py"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later