This guide explains how to use Meta Ads MCP with your own Meta Developer App. Note that this is an alternative method - we recommend using Pipeboard authentication for a simpler setup.
Before using direct Meta authentication, you'll need to set up a Meta Developer App:
- Go to Meta for Developers and create a new app
- Choose the "Business" app type
- In your app settings, add the "Marketing API" product
- Configure your app's OAuth redirect URI to include
http://localhost:8888/callback - Note your App ID (Client ID) for use with the MCP
When using your own Meta app, you'll need to provide the App ID:
# Using uvx
uvx meta-ads-mcp --app-id YOUR_META_ADS_APP_ID
# Using pip installation
python -m meta_ads_mcp --app-id YOUR_META_ADS_APP_IDAdd this to your claude_desktop_config.json or ~/.cursor/mcp.json:
"mcpServers": {
"meta-ads": {
"command": "uvx",
"args": ["meta-ads-mcp", "--app-id", "YOUR_META_ADS_APP_ID"]
}
}When using direct Meta OAuth, the MCP uses Meta's OAuth 2.0 authentication flow:
- Starts a local callback server on your machine
- Opens a browser window to authenticate with Meta
- Asks you to authorize the app
- Redirects back to the local server to extract and store the token securely
You can use these environment variables instead of command-line arguments:
# Your Meta App ID
export META_APP_ID=your_app_id
uvx meta-ads-mcp
# Or provide a direct access token (bypasses local cache)
export META_ACCESS_TOKEN=your_access_token
uvx meta-ads-mcpRun the test script to verify authentication:
# Basic test
python test_meta_ads_auth.py --app-id YOUR_APP_ID
# Force new login
python test_meta_ads_auth.py --app-id YOUR_APP_ID --force-loginWhen using direct Meta authentication:
- Test authentication by calling the
mcp_meta_ads_get_login_linktool - Verify account access by calling
mcp_meta_ads_get_ad_accounts - Check specific account details with
mcp_meta_ads_get_account_info
-
App ID Issues
- If you encounter errors like
(#200) Provide valid app ID, verify your App ID is correct - Make sure you've completed the app setup steps above
- Check that your app has the Marketing API product added
- If you encounter errors like
-
OAuth Flow
- Run with
--force-loginto get a fresh token:uvx meta-ads-mcp --login --app-id YOUR_APP_ID --force-login - Make sure the terminal has permissions to open a browser window
- Check that the callback server can run on port 8888
- Run with
-
Direct Token Usage
- If you have a valid access token, you can bypass the OAuth flow:
export META_ACCESS_TOKEN=your_access_token- This will ignore the local token cache
If you receive errors from the Meta API:
- Verify your app has the Marketing API product added
- Ensure the user has appropriate permissions on the ad accounts
- Check if there are rate limits or other restrictions on your app