home / mcp / facebook ads mcp server
A read-only MCP server that queries Facebook Ads data (accounts, campaigns, ad sets, ads, insights) via natural language requests.
Configuration
View docs{
"mcpServers": {
"david-mo-fb-ads-mcp-server": {
"command": "python",
"args": [
"server.py",
"--fb-token",
"YOUR_FACEBOOK_ACCESS_TOKEN"
]
}
}
}You can connect Claude or other MCP-compatible assistants to Facebook Ads data with this MCP server. It lets you read ad accounts, campaigns, ad sets, ads, and performance insights through natural language queries, enabling you to fetch metrics and details on demand without manual API calls.
Run the MCP server locally and connect it to your MCP client. You can ask natural language questions like: which ad accounts do I have access to, what are the active campaigns for a given account, show me metrics for a specific campaign, or pull insights for an ad set. Use the MCP client’s workflow to send requests to the server, which will fetch data from Facebook Ads API and return structured results.
Prerequisites: Python 3.10 or higher, a Facebook Developer account with Ads API access, and an access token with ads_read permission.
1. Clone or download the project directory. 2. Create and activate a virtual environment. 3. Install dependencies from the requirements file.
cd fb-ads-mcp-server
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtStart the server by providing your Facebook access token via the --fb-token flag.
python server.py --fb-token YOUR_FACEBOOK_ACCESS_TOKENConfigure each MCP connection to point to the local server so Claude Desktop can route queries to it.
{
"mcpServers": {
"fb-ads-mcp-server": {
"command": "python",
"args": [
"server.py",
"--fb-token",
"YOUR_FACEBOOK_ACCESS_TOKEN"
]
}
}
}If you use a virtual environment, point to the Python executable inside the venv for the MCP server process.
{
"mcpServers": {
"fb-ads-mcp-server": {
"command": "/absolute/path/to/fb-ads-mcp-server/venv/bin/python",
"args": [
"server.py",
"--fb-token",
"YOUR_FACEBOOK_ACCESS_TOKEN"
]
}
}
}On Windows, you can pass the server path as an argument to the Python command.
{
"mcpServers": {
"fb-ads-mcp-server": {
"command": "python",
"args": [
"C:\\absolute\\path\\to\\fb-ads-mcp-server\\server.py",
"--fb-token",
"YOUR_FACEBOOK_ACCESS_TOKEN"
]
}
}
}- Use a token with only ads_read permission for read-only access. Avoid hardcoding tokens in configuration files. Prefer secure storage and routine token rotation.
- Do not commit tokens to version control. Rotate tokens regularly and monitor API activity in the Meta Developer dashboard.
If you see a missing token error, ensure you started the server with the --fb-token option. If the token is invalid or expired, regenerate a new token with the required permission. For rate limits or network issues, retry with backoff and consider caching frequently accessed data.
The server uses Facebook Graph API for read-only access to ad accounts, campaigns, ad sets, ads, and insights. Ensure your token is valid for the API version in use and that your app has the necessary Ads API access.
You can retrieve accounts, campaigns, ad sets, ads, and insights. Typical actions include listing accounts, filtering campaigns by status, getting detailed campaign/ad set/ad information, and fetching performance metrics such as impressions, clicks, spend, CTR, and more.
List all ad accounts linked to your access token.
Fetch detailed information about a specific ad account.
Retrieve all campaigns for a given ad account, with optional fields and filters.
Get detailed information for a specific campaign by its ID.
Retrieve all ad sets within a campaign, with optional fields and limits.
Get detailed information for a specific ad set by its ID.
Retrieve all ads within an ad set, with optional fields and limits.
Get detailed information for a specific ad by its ID.
Get performance metrics for a campaign over a date range or presets.
Get performance metrics for an ad set.
Get performance metrics for a specific ad.
Get a lightweight summary with key metrics for quick contexts.
Fetch the next/previous page URL for paginated results.