This guide covers how to test the Meta Ads MCP server at every level: unit tests, integration workflows, live API tests, and manual verification via MCP Inspector.
Run the full test suite:
uv run pytestWith coverage:
uv run pytest --cov=meta_ads_mcp --cov-report=term-missingRun a specific test file:
uv run pytest tests/test_tools_campaigns.py -vtests/test_integration_workflows.py contains mocked multi-step workflow tests that verify tool interactions without hitting the real API:
uv run pytest tests/test_integration_workflows.py -vThese cover:
- Campaign creation workflow (create -> get -> update -> insights)
- Full funnel setup (campaign -> ad set -> creative -> ad)
- Diagnosis workflow (list -> diagnostics chain)
- Audience workflow (create custom -> create lookalike -> list)
tests/test_live.py runs against the real Meta Ads API. These require valid credentials in .env and are automatically skipped in CI.
uv run pytest tests/test_live.py -v -sPrerequisites:
- Valid
.envfile withMETA_ACCESS_TOKEN,META_APP_ID,META_APP_SECRET META_DEFAULT_AD_ACCOUNT_IDset for account-specific tests- Network access to the Meta Graph API
The MCP Inspector provides a web UI for testing tools interactively.
npx @modelcontextprotocol/inspector uv run python -m meta_ads_mcpThis opens a browser at http://localhost:5173 where you can:
- See all 35 registered tools in the left panel
- Click any tool to view its schema and parameters
- Execute tools with test parameters and see formatted markdown output
After starting the Inspector, verify all tools appear:
Accounts (2): get_ad_accounts, get_account_info
Campaigns (5): list_campaigns, get_campaign, create_campaign, update_campaign, get_campaign_diagnostics
Ad Sets (5): list_ad_sets, get_ad_set, create_ad_set, update_ad_set, get_ad_set_diagnostics
Ads (5): list_ads, get_ad, create_ad, update_ad_status, get_ad_diagnostics
Insights (5): get_insights, get_account_insights, get_campaign_insights, compare_performance, get_breakdown_report
Creatives (4): list_creatives, get_creative, create_ad_creative, update_ad_creative
Audiences (4): list_audiences, get_audience, create_custom_audience, create_lookalike_audience
- Read flow:
get_ad_accounts-> pick an account ->list_campaigns->get_campaign->get_campaign_insights - Write flow (dry run):
create_campaignwithdry_run=true-> verify PAUSED status in output - Error handling:
get_campaignwith an invalid ID -> verify error code and suggestion appear - Date presets:
get_insightswithdate_preset=this_quarter-> verify date range is correct
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"meta-ads": {
"command": "uv",
"args": ["--directory", "/path/to/MetaAdsMCP", "run", "python", "-m", "meta_ads_mcp"],
"env": {
"META_ACCESS_TOKEN": "your_token_here",
"META_APP_ID": "your_app_id",
"META_APP_SECRET": "your_app_secret",
"META_DEFAULT_AD_ACCOUNT_ID": "act_your_account_id"
}
}
}
}Add to your project's .mcp.json:
{
"mcpServers": {
"meta-ads": {
"command": "uv",
"args": ["run", "python", "-m", "meta_ads_mcp"],
"cwd": "/path/to/MetaAdsMCP"
}
}
}Credentials are loaded from the .env file in the MetaAdsMCP directory.
Run all quality checks before submitting changes:
uv run ruff check . # Lint
uv run black --check . # Format check
uv run mypy src/ # Type check
uv run pytest # Tests