PagePilot MCP
README.md
# π PagePilot MCP
**π Language / NgΓ΄n ngα»―:** **English** Β· [TiαΊΏng Viα»t](./README.vi.md)
> **An MCP server that lets AI agents manage a Facebook Fanpage through the official Graph API β safe, no scraping, and never touching private messages.**
[](https://www.python.org/)
[](./LICENSE)
[](https://modelcontextprotocol.io/)
[](https://developers.facebook.com/docs/graph-api/)
---
## π Table of Contents
- [Introduction](#-introduction)
- [Key Features](#-key-features)
- [Why Is It Safe?](#-why-is-it-safe)
- [Requirements](#-requirements)
- [Getting a Facebook Token](#-getting-a-facebook-token)
- [Installation & Running](#-installation--running)
- [MCP Client Configuration](#-mcp-client-configuration)
- [The 29 Tools](#-the-29-tools)
- [Project Structure](#-project-structure)
- [Environment Variables](#-environment-variables)
- [Disclaimer](#-disclaimer)
- [License](#-license)
- [Author](#-author)
---
## π Introduction
**PagePilot MCP** is an **MCP (Model Context Protocol) server** written in Python that lets AI agents such as **Claude Desktop**, **Cursor**, or any **MCP client** directly **manage a Facebook Fanpage** through the official **Facebook Graph API**.
Instead of opening a browser and doing everything by hand, you simply give your AI agent instructions in natural language β and PagePilot takes care of the rest: publishing posts, scheduling, moderating comments, and analyzing performance.
> π‘ Every action goes through a **legitimate Page Access Token** that you yourself grant. No cookies, no scraping, no hacks.
---
## β¨ Key Features
- π **Versatile posting** β text, photos, links; create / edit / delete posts and **schedule posts** for future publishing.
- π¬ **Smart comment moderation** β reply, hide / unhide, delete, **bulk operations**, and automatic **negative comment filtering**.
- π **In-depth analytics** β fan count, post insights, reactions, and like / share / comment counts.
- π **Token management** β check Page status, debug tokens, and swap to a **long-lived token (~60 days)** with a single command.
- π‘οΈ **Robust Graph client** β automatically handles network / Graph API errors, with a configurable timeout.
- π§© **29 MCP tools**, neatly organized into 4 clear groups.
---
## π Why Is It Safe?
PagePilot is built on a **"safety first"** principle:
1. **It uses only the official Facebook Graph API.** No cookies, no HTML scraping, no browser automation. That means it **does not violate Facebook's security mechanisms** and carries **no risk of getting banned** for abnormal behavior.
2. **It uses only a legitimate Page Access Token** β a token that you (the Page admin) grant through Facebook's standard OAuth flow.
3. **π« It DELIBERATELY excludes all messaging / Messenger / DM functionality.** PagePilot does **NOT** read, send, or touch anyone's private messages. This tool does exactly one thing: **manage a Page's public content** β publishing posts, moderating comments, and analytics. User privacy is fully respected.
> In short: PagePilot is a **Page administration assistant**, not a tool for spamming messages or tracking users.
---
## π Requirements
- **Python 3.10+** (**Python 3.12** recommended)
- A **Facebook Fanpage** for which you are an admin
- A **Facebook App** of type *Business* (to obtain a token and grant permissions)
- Any MCP client (Claude Desktop, Cursor, etc.)
---
## π Getting a Facebook Token
Follow these steps to obtain a **Page Access Token** and **Page ID**:
1. Go to [developers.facebook.com](https://developers.facebook.com/) β **Create App** β choose the **Business** type.
2. Open the **Graph API Explorer** (Tools β Graph API Explorer).
3. In the dropdown, select your **Page** (instead of *User*).
4. Grant the following permissions (scopes):
- `pages_manage_posts` β create / edit / delete posts
- `pages_read_engagement` β read engagement (likes, comments, shares)
- `pages_manage_engagement` β moderate comments (hide, delete, reply)
- `pages_read_user_content` β read user-generated content on the Page
- `read_insights` β read analytics (insights)
5. Click **Generate Access Token** β copy the **Page Access Token**.
6. Get your **Page ID**: go to the Page β *About* β *Page transparency*, or use the `page_status` tool itself once configured.
> β³ **Recommended:** The default token from the Explorer only lasts a few hours. Swap it for a **long-lived token (~60 days)** using the `exchange_long_lived_token` tool (requires `FB_APP_ID` and `FB_APP_SECRET`).
---
## βοΈ Installation & Running
```bash
# 1. Clone the project
git clone https://github.com/Thangterter-Pipo/pagepilot-mcp.git
cd pagepilot-mcp
# 2. Create a virtual environment (pick one)
python -m venv .venv # the standard way
# or
uv venv # if you use uv (faster)
# Activate the venv
source .venv/bin/activate # Linux / macOS
.venv\Scripts\activate # Windows
# 3. Install dependencies
pip install -r requirements.txt
# 4. Create a .env file from the template and fill in your token
cp .env.example .env
# Open .env and fill in FB_PAGE_ACCESS_TOKEN, FB_PAGE_ID...
# 5. Run the MCP server
python -m pagepilot.server
```
---
## π§© MCP Client Configuration
Example configuration for **Claude Desktop** (the `claude_desktop_config.json` file):
```json
{
"mcpServers": {
"pagepilot": {
"command": "python",
"args": ["-m", "pagepilot.server"],
"cwd": "/path/to/pagepilot-mcp",
"env": {
"FB_PAGE_ACCESS_TOKEN": "EAAB...your-token",
"FB_PAGE_ID": "1234567890",
"FB_APP_ID": "optional",
"FB_APP_SECRET": "optional",
"FB_GRAPH_VERSION": "v22.0",
"FB_REQUEST_TIMEOUT": "30"
}
}
}
}
```
> π‘ If you use a virtualenv, point `command` to the Python inside the venv (e.g. `/path/to/pagepilot-mcp/.venv/bin/python` or `...\.venv\Scripts\python.exe`) to make sure dependencies are loaded correctly.
After saving the config, **restart your MCP client** β you'll see PagePilot's 29 tools ready for your AI agent to call.
---
## π οΈ The 29 Tools
PagePilot provides **29 MCP tools**, organized into **4 groups**:
### 1οΈβ£ Status & Token
- `page_status` β Check the connection status and current Page information.
- `debug_token` β Inspect token details: expiry, scopes, app ID (requires `FB_APP_ID` / `FB_APP_SECRET`).
- `exchange_long_lived_token` β Swap a short-lived token for a long-lived one (~60 days).
### 2οΈβ£ Posting
- `create_post` β Publish a text post to the Page.
- `create_photo_post` β Publish a post with a photo.
- `create_link_post` β Publish a post with a link (includes a preview).
- `update_post` β Update the content of an existing post.
- `delete_post` β Delete a post.
- `schedule_post` β Schedule a post for a future time.
- `get_scheduled_posts` β List posts that are pending scheduled publishing.
### 3οΈβ£ Reading Posts & Comments / Moderation
- `list_posts` β List the posts on the Page.
- `get_post` β Get the details of a single post.
- `get_post_permalink` β Get the public link (permalink) of a post.
- `list_comments` β List the comments on a post.
- `get_comment_replies` β Get the replies to a comment.
- `reply_to_comment` β Reply to a comment.
- `delete_comment` β Delete a comment.
- `hide_comment` β Hide a comment.
- `unhide_comment` β Unhide a comment.
- `bulk_delete_comments` β Delete multiple comments at once.
- `bulk_hide_comments` β Hide multiple comments at once.
- `filter_negative_comments` β Filter / detect negative comments.
### 4οΈβ£ Analytics
- `get_page_info` β Get an overview of the Page.
- `get_fan_count` β The number of fans (followers) of the Page.
- `get_post_insights` β Detailed insights for a single post.
- `get_post_reactions` β Reaction statistics for a post.
- `get_comment_count` β Count the comments on a post.
- `get_like_count` β Count the likes on a post.
- `get_share_count` β Count the shares of a post.
---
## π Project Structure
```
pagepilot-mcp/
βββ pagepilot/
β βββ __init__.py
β βββ config.py # Read & validate environment variables (.env)
β βββ graph_client.py # Robust Graph API client: auto-handles network/Graph errors,
β β # supports debug_token + long-lived token exchange
β βββ manager.py # Business logic for all the tools
β βββ server.py # FastMCP entry point (run: python -m pagepilot.server)
βββ requirements.txt
βββ .env.example
βββ LICENSE
βββ README.md
```
---
## π§ Environment Variables
Set these in your `.env` file (copy from `.env.example`):
- `FB_PAGE_ACCESS_TOKEN` β **(required)** Page Access Token.
- `FB_PAGE_ID` β **(required)** The Fanpage's ID.
- `FB_APP_ID` β *(optional)* App ID β only needed for `debug_token` or long-lived token exchange.
- `FB_APP_SECRET` β *(optional)* App Secret β only needed for `debug_token` or long-lived token exchange.
- `FB_GRAPH_VERSION` β *(optional)* Graph API version, defaults to **`v22.0`**.
- `FB_REQUEST_TIMEOUT` β *(optional)* Per-request timeout (seconds), defaults to **`30`**.
Example `.env`:
```env
FB_PAGE_ACCESS_TOKEN=EAAB...your-token-here
FB_PAGE_ID=1234567890
FB_APP_ID=
FB_APP_SECRET=
FB_GRAPH_VERSION=v22.0
FB_REQUEST_TIMEOUT=30
```
---
## β οΈ Disclaimer
- PagePilot is **intended only for managing Fanpages that you own or have administrative rights to**.
- You are responsible for **complying with [Facebook / Meta's Terms of Service (ToS)](https://developers.facebook.com/terms/)** and Platform Policies when using this tool.
- This tool does **not** support and does **not** encourage spam, engagement manipulation, or any policy-violating behavior.
- The author is not responsible for misuse. Please use it responsibly. π
---
## π License
This project is released under the **[MIT License](./LICENSE)**. You are free to use, modify, and distribute it.
---
## π€ Author
**Thangterter-Pipo**
π GitHub: [github.com/Thangterter-Pipo](https://github.com/Thangterter-Pipo)
> If PagePilot is useful to you, please β star the repo to show your support! All issues and pull requests are welcome. π
This server cannot be deployed
Maintenance
ActivityStale
ResponsivenessNo issues