Skip to main content

facebook-mcp

CI PyPI Python License: MIT

An open-source Model Context Protocol server that lets AI assistants manage your Facebook Pages: publish and schedule posts, moderate comments, and read analytics. It's built on FastMCP and works with Claude Desktop, Claude Code, ChatGPT, Gemini CLI, Cursor, VS Code and any other MCP client.

"Schedule tomorrow's 9am post on Acme Coffee announcing the new menu, then hide any spam comments on yesterday's post."

Features

  • Multi-page: give it one user token and it finds every Page you manage. Each Page uses its own Page token automatically.
  • 16 tools covering posts, scheduling, photos, Reels, comments, moderation and insights.
  • Safe by default: tools are labelled read-only or destructive (MCP annotations), a --read-only mode hides write tools, requests are signed with appsecret_proof, and tokens never appear in URLs or logs.
  • Runs anywhere: stdio for desktop clients, streamable HTTP (with optional bearer auth) for remote clients, or the Docker image.
  • Production-quality code: typed (mypy --strict), layered architecture, and over 95% test coverage against a mocked Graph API.

Quick start

1. Get a token. Create a Meta app and generate an access token with the Page permissions listed in docs/setup-meta-app.md. This takes about 5 minutes.

2. Add the server to your MCP client. You'll need uv. For example, in Claude Desktop's claude_desktop_config.json:

{
  "mcpServers": {
    "facebook": {
      "command": "uvx",
      "args": ["facebook-mcp"],
      "env": {
        "FB_USER_ACCESS_TOKEN": "your-long-lived-user-token",
        "FB_APP_SECRET": "your-app-secret"
      }
    }
  }
}

Config for every other client (Claude Code, ChatGPT, Gemini CLI, Cursor, VS Code, Docker) is in docs/clients.md.

3. Ask your assistant something like "Which Facebook Pages can you manage?"

Tools

Every tool except list_pages accepts an optional page (a Page id or exact name). Leave it out and the server uses the default Page. For post ids, it uses the Page that owns the post.

Tool Type Description
list_pages read Pages this server can manage
get_page_info read Name, category, about, link, fans and followers
list_posts read Published posts with reaction, comment and share counts (paginated)
list_scheduled_posts read Scheduled, not-yet-published posts
get_post read One post with engagement counts
create_post write Publish or schedule a text/link post
create_photo_post write Publish a photo from a public URL
create_reel write Upload a local video and publish or schedule it as a Reel
update_post write Edit a post's text
delete_post destructive Delete a post
list_comments read Comments on a post, or replies to a comment (paginated)
add_comment write Comment as the Page, or reply to a comment
set_comment_hidden write Hide or unhide a comment
delete_comment destructive Delete a comment
get_page_insights read Page analytics over a period or date range
get_post_insights read Analytics for one post

Configuration

Settings come from environment variables, or from a .env file in the working directory (see .env.example).

Variable Default Description
FB_USER_ACCESS_TOKEN Multi-page mode. A long-lived user token; every Page you manage is discovered.
FB_PAGE_ID + FB_PAGE_ACCESS_TOKEN Single-page mode. Use instead of the user token.
FB_DEFAULT_PAGE Page id or name to use when a tool call doesn't name one
FB_APP_SECRET Your app secret. Turns on appsecret_proof signing (recommended).
FB_GRAPH_API_VERSION v26.0 Graph API version
FB_TIMEOUT 30 Graph request timeout, in seconds
FB_UPLOAD_TIMEOUT 900 Timeout for sending and confirming video/file uploads, in seconds
MCP_TRANSPORT stdio stdio or http
MCP_HOST / MCP_PORT / MCP_PATH 127.0.0.1 / 8000 / /mcp HTTP transport only
MCP_AUTH_TOKEN HTTP only: require Authorization: Bearer <token>
MCP_READ_ONLY false Hide every write tool
MCP_LOG_LEVEL INFO Log level (logs go to stderr)

CLI flags override environment variables:

facebook-mcp --transport http --port 8000 --read-only
facebook-mcp exchange-token --app-id 123 --token SHORT_LIVED_TOKEN   # reads FB_APP_SECRET

Security

  • Use --read-only until you trust your setup.
  • Always set MCP_AUTH_TOKEN when serving over HTTP, and never expose an unauthenticated server to the internet.
  • Turn on Require App Secret in your Meta app's advanced settings, so a leaked token can't be used without your app secret.
  • Never commit tokens. .env is git-ignored.

To report a vulnerability, see SECURITY.md.

Documentation

Contributing

Contributions are welcome. See CONTRIBUTING.md for the dev setup and guidelines. In short: uv sync, then uv run pytest.

License

MIT © Salinda Hulangamuwa

This is an independent project. It is not affiliated with, endorsed by, or sponsored by Meta Platforms, Inc. Facebook is a trademark of Meta Platforms, Inc.

Metadata

Release files for facebook-mcp 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for facebook-mcp 0.3.1
File Size Uploaded Provenance Actions
facebook_mcp-0.3.1.tar.gz 29.3 kB Without provenance Details for facebook_mcp-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for facebook-mcp 0.3.1
File Interpreter ABI Platform Actions
facebook_mcp-0.3.1-py3-none-any.whl Python 3 none any Details for facebook_mcp-0.3.1-py3-none-any.whl

Total release size: 63.8 kB

Release files / facebook_mcp-0.3.1.tar.gz

Download URL facebook_mcp-0.3.1.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
69c857e68a495eeb9d50bf5402811add002cb9436b98923e7ff621c2c80689cc
BLAKE2b-256 checksum
How to use checksums
4634cb19e83b4f0801255b216442d03c1509435781c1a5ac8ca0fd86d0ebe787
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / facebook_mcp-0.3.1-py3-none-any.whl

Download URL facebook_mcp-0.3.1-py3-none-any.whl
Size 34.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6975f083718627695531a589c3e36a11efb67bdc5b7e155b6e28f540114360a
BLAKE2b-256 checksum
How to use checksums
3de73087db112f0de2fbc5fdd9b40825647b82b1dd14f1ac788a06ad59140e8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for facebook-mcp 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page