πŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more β†’
Socket
Book a DemoInstallSign in
Socket

just-facebook-mcp

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

just-facebook-mcp

MCP server for automating and managing interactions on a Facebook Page using the Facebook Graph API

0.1.0
PyPI
Maintainers
1

Just_Facebook MCP Server

This project is a Model Context Protocol (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 β€” ready to plug into Claude or any other LLM-based agent.

Originally developed from @HagaiHen/facebook-mcp-server, this version is intended for packaging and distribution via PyPI.

πŸ€– What Is This?

This MCP provides a suite of AI-callable tools that connect directly to a Facebook Page, abstracting common API operations as LLM-friendly functions.

βœ… Benefits

  • Empowers social media managers to automate moderation and analytics.
  • Seamlessly integrates with any Agent client.
  • Enables fine-grained control over Facebook content from natural language.

πŸ“¦ Features

ToolDescription
post_to_facebookCreate a new Facebook post with a message.
reply_to_commentReply to a specific comment on a post.
get_page_postsRetrieve recent posts from the Page.
get_post_commentsFetch comments on a given post.
delete_postDelete a specific post by ID.
delete_commentDelete a specific comment by ID.
delete_comment_from_postAlias for deleting a comment from a specific post.
filter_negative_commentsFilter out comments with negative sentiment keywords.
get_number_of_commentsCount the number of comments on a post.
get_number_of_likesCount the number of likes on a post.
get_post_impressionsGet total impressions on a post.
get_post_impressions_uniqueGet number of unique users who saw the post.
get_post_impressions_paidGet number of paid impressions on the post.
get_post_impressions_organicGet number of organic impressions on the post.
get_post_engaged_usersGet number of users who engaged with the post.
get_post_clicksGet number of clicks on the post.
get_post_reactions_like_totalGet total number of 'Like' reactions.
get_post_top_commentersGet the top commenters on a post.
post_image_to_facebookPost an image with a caption to the Facebook page.
send_dm_to_userSend a direct message to a user.
update_postUpdates an existing post's message.
schedule_postSchedule a post for future publication.
get_page_fan_countRetrieve the total number of Page fans.
get_post_share_countGet the number of shares on a post.

πŸš€ Setup & Installation

1. Prerequisites

This project requires Python 3.10+ and uv (a fast Python package manager).

To install uv, run:

curl -LsSf https://astral.sh/uv/install.sh | sh

2. Clone the Repository

3. πŸ› οΈ Install Dependencies

Use the uv tool with pyproject.toml:

# Install all dependencies and create a virtual environment
uv sync

# For development (includes testing and linting tools)
uv sync --dev

4. Set Up Environment

Create a .env file in the root directory and add your Facebook Page credentials:

FACEBOOK_ACCESS_TOKEN=your_facebook_page_access_token
FACEBOOK_PAGE_ID=your_page_id

Getting Your Facebook Credentials

  • Log into Facebook for Developers

  • Choose Developer as your use case.

  • Create a new app.

  • In the app dashboard, go to Customize Use Case and select all options.

  • Navigate to Tools β†’ Graph API Explorer.

  • First create a User Access Token β€” make sure to:

    *Select all required permissions

    *Associate it with your app

  • Then generate a Page Access Token (this will inherit the permissions).

  • Save the Page Access Token and use it in the .env file.

To find your Page ID:

Go to your Facebook Page β†’ About β†’ Scroll down to view the ID

⏰ Important: Facebook API Token Limitations

Facebook access tokens have limited lifespans and will expire, causing API calls to fail. Understanding these limitations is crucial for maintaining your MCP server.

Token Types & Lifespans:

Token TypeLifespanUse Case
Short-lived User Token1-2 hoursTesting only
Long-lived User Token60 daysDevelopment
Short-lived Page Token1-2 hoursTesting only
Long-lived Page Token60 daysRecommended for MCP
System User TokenNo expiration*Production apps

When Tokens Expire:

  • ❌ All MCP tools will return OAuthException errors
  • ❌ Error message: "Session has expired"
  • ❌ Error codes: 190 (expired token) or 463 (session expired)

Automatic Token Refresh:

We provide a script to easily generate long-lived tokens (60 days):

uv run python scripts/refresh_facebook_token.py

This script will:

  • βœ… Guide you through token generation
  • βœ… Exchange short-lived for long-lived tokens
  • βœ… Update your .env file automatically
  • βœ… Validate the new token

Best Practices:

  • πŸ”„ Refresh tokens every 50 days to avoid expiration
  • πŸ“… Set calendar reminders for token renewal
  • πŸ€– Use long-lived Page tokens for development
  • 🏒 Consider System User tokens for production

Troubleshooting Token Issues:

# Check if your token is expired
uv run python -c "
from just_facebook_mcp.manager import Manager
manager = Manager()
try:
    result = manager.get_page_fan_count()
    print('βœ… Token is working')
except Exception as e:
    print(f'❌ Token error: {e}')
"

5. πŸƒβ€β™‚οΈ Running the Server

# Option 1: Using the script entry point (recommended)
uv run just_facebook_mcp

# Option 2: Run the Python module directly
uv run python -m just_facebook_mcp.server

# Option 3: Activate virtual environment first
source .venv/bin/activate
python -m just_facebook_mcp.server

🧩 Using with Claude Desktop

To integrate with Claude Desktop:

  • Open Claude Desktop

  • Go to Settings β†’ Developer β†’ Edit Config

Add the following to your MCP configuration:

Option 1: Using the package entry point (recommended)

{
  "mcpServers": {
    "just_facebook_mcp": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/just_facebook_mcp-server",
        "just_facebook_mcp"
      ]
    }
  }
}

Option 2: Using Python module

{
  "mcpServers": {
    "just_facebook_mcp": {
      "command": "uv",
      "args": [
        "run",
        "--directory",
        "/absolute/path/to/just_facebook_mcp-server",
        "python",
        "-m",
        "just_facebook_mcp.server"
      ]
    }
  }
}

Option 3: If installed via pip

{
  "mcpServers": {
    "just_facebook_mcp": {
      "command": "just_facebook_mcp"
    }
  }
}

Replace /absolute/path/to/just_facebook_mcp-server with your actual project path.

πŸ”§ Development

Running Tests

uv run pytest

Code Formatting

uv run black .

Type Checking

uv run mypy .

Install Development Dependencies

uv sync --dev

βœ… You're Ready to Go!

Your Facebook MCP server is now configured and ready to power Claude Desktop! You can:

✨ Create posts through natural language

πŸ“Š Get analytics and insights

πŸ’¬ Moderate comments automatically

🎯 Schedule content

πŸ“ˆ Track engagement metrics

🀝 Contributing

Contributions, issues, and feature requests are welcome!

πŸ“„ License This project is licensed under the MIT License. See the LICENSE file for details.

Keywords

api

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts