mlg-meta-mcp
Provides tools for managing Meta Ads campaigns, ad sets, ads, targeting research, creative inspection, insights, and account discovery via the Meta Marketing API.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mlg-meta-mcp compare campaign performance this month vs last month"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mlg-meta-mcp
Open-source MCP server for Meta Ads — 30 tools covering account discovery, campaign/ad set/ad management, targeting research, creative inspection, insights, and LLM-friendly workflows.
mlg-meta-mcp is designed for developers and operators who want more than a thin proxy over the Meta Marketing API. It adds account discovery, business-oriented outputs, productivity tools, comparison flows, and targeting/creative tooling that are easier for LLMs and agents to use in real workflows.
Why this project exists
Many Meta Ads MCP servers stop at exposing raw API calls. That is useful, but not always enough for real agent workflows.
This project aims to be more practical in day-to-day usage:
Automatic account discovery instead of hard-wiring a single account
Business-oriented insights instead of raw metric dumps
Safer productivity operations like clone and bulk status changes
LLM-friendly responses that summarize what happened and why it matters
Structured comparison logic for period-over-period analysis
Related MCP server: AdWeave Meta Ads
Contract design principle
Core MCP tools should return maximal useful signal for the broadest set of consumers.
consumers (LLMs, apps, prompts, UI layers) own filtering and interpretation
formatting and ergonomic summaries are good
destructive filtering of useful signal in the base tool contract is not
project-specific business rules should live in higher-level workflows, not in neutral core tool outputs
What it includes today
Account discovery
Discover all ad accounts accessible by the configured System User token
Resolve accounts by ID or by account name
Get full account info (name, currency, timezone, business, status)
Campaign operations
Get campaigns
Get full campaign details (bid strategy, buying type, special ad categories, issues)
Create campaigns
Update campaigns
Pause campaigns
Activate campaigns
Ad set operations
Get ad sets from an account or campaign
Get full ad set details (targeting, optimization goal, bid amount, effective status)
Create ad sets
Update ad sets
Pause ad sets
Activate ad sets
Ad operations
Get ads
Get full ad details (effective status, creative ID, issues)
Update ads (status and bid amount)
Creative inspection
Get creatives attached to an ad (object_story_spec, image hash, call to action)
Targeting research
Search interests by keyword
Get interest suggestions from a seed list
Validate interests by name or Meta ID
Browse behaviors
Browse demographic categories
Search geo locations by keyword
Budget scheduling
Create time-bounded budget increases or multipliers for a campaign
Insights and analysis
Get insights for account, campaign, ad set, or ad
Compare two explicit periods with business-aware fallback logic
Productivity tools
Clone campaigns (with ad sets)
Clone ad sets
Bulk pause campaigns
Bulk activate campaigns
Check alerts with configurable thresholds
Highlighted workflows
This MCP is especially useful for these workflows:
Discover accessible ad accounts automatically
Inspect campaign, ad set, ad, or account performance
Compare campaign performance across two periods
Duplicate winning structures quickly
Pause or activate many campaigns in one action
Generate alert-oriented summaries from Meta Ads data
Research and validate targeting audiences
Diagnose delivery issues via effective status and issues_info
How compareTwoPeriods works
compareTwoPeriods compares performance between two explicit periods for one of four levels:
accountcampaignadsetad
Each side now accepts either:
datePreset(today,yesterday,last_7d,last_30d,this_month,last_month)timeRangewith{ since, until }inYYYY-MM-DDformat
The tool also supports explicit result selection:
primary_from_insights(default) — resolve one action type from the insights and apply it to both periodsspecific_action— compare one explicit Metaaction_typelikeleadorpurchaseall_actions— sum all action types
It also supports optional metric selection:
spendresultscprimpressionsclicksctr
If metrics is omitted, the tool keeps the backward-compatible default set: spend, results, and cpr.
The response now makes the resolved result definition explicit so consumers can see what results means.
For account, adset, and ad
The comparison is direct:
current period for the same object
previous period for the same object
For campaign
Campaign comparisons use a smarter fallback chain:
Same campaign in the previous period
Most similar campaign in the same account
Account campaign average for the previous period
No reference available
The tool response explicitly tells the user which reference was used.
Similar campaign logic
The similar-campaign fallback is not based only on naming.
It requires:
same campaign
objectivesame dominant ad set
optimizationGoal
Then it ranks valid candidates using:
budget similarity
bid strategy match
billing event match
name similarity as a tie-breaker
Installation
git clone https://github.com/iammalego/mlg-meta-mcp.git
cd mlg-meta-mcp
npm install
cp .env.example .envThen edit .env with your Meta credentials.
Configuration
Required environment variables
META_SYSTEM_USER_TOKEN=your_system_user_token_here
META_API_VERSION=v22.0
LOG_LEVEL=infoRequired Meta permissions
Your token should have permissions appropriate for the operations you want to run. In most setups, that includes:
ads_managementads_readbusiness_management
Local development
npm run devProduction build
npm run build
npm startMCP client setup
Claude Desktop
Add this to claude_desktop_config.json:
{
"mcpServers": {
"mlg-meta-mcp": {
"command": "node",
"args": ["/absolute/path/to/mlg-meta-mcp/dist/index.js"],
"env": {
"META_SYSTEM_USER_TOKEN": "your_token_here",
"META_API_VERSION": "v22.0",
"LOG_LEVEL": "info"
}
}
}
}Generic stdio usage
Any MCP client that supports stdio transport can run this server by starting the compiled dist/index.js entrypoint.
Available tools
30 tools total.
Account tools
discoverAdAccountsgetAccountInfo
Campaign tools
getCampaignsgetCampaignDetailsupdateCampaignpauseCampaignactivateCampaigncloneCampaignbulkPauseCampaignsbulkActivateCampaigns
Ad set tools
getAdSetsgetAdSetDetailsupdateAdSetpauseAdSetactivateAdSetcloneAdSet
Ad tools
getAdsgetAdDetailsupdateAd
Creative tools
getAdCreatives
Targeting tools
searchInterestsgetInterestSuggestionsvalidateInterestssearchBehaviorssearchDemographicssearchGeoLocations
Budget tools
createBudgetSchedule
Insights tools
getInsightscompareTwoPeriodscheckAlerts
Example prompts
These are the kinds of prompts this MCP is designed to support well:
"List all ad accounts accessible with this token."
"Show active campaigns for the account named Plannit."
"Get full details for campaign 123 including issues and delivery status."
"Compare this campaign between last_7d and last_30d."
"If the campaign did not exist in the previous period, explain which fallback reference was used."
"Clone this campaign and reduce its budget by 20%."
"Pause these campaigns as a dry run first."
"Check alerts for yesterday using a CPR threshold of 5000."
"Search interests related to 'sustainable fashion' and suggest related ones."
"Validate these interest IDs before using them in a new ad set."
"Schedule a budget increase of 20% for campaign 123 this weekend."
Architecture
The codebase is intentionally split into layers:
src/tools/index.ts→ MCP tool definitions and Zod-first schemassrc/tools/handlers.ts→ MCP-facing handlers and MCP response envelopes (text summaries plus structured content when useful)src/services/*→ business logicsrc/api/*→ Meta API clients (GraphClient,InsightsClient,BusinessClient,TargetingClient,CreativeClient)src/types/*→ shared types
This separation helps keep the MCP surface, business logic, and Meta API integration independent.
For example, getInsights keeps a readable text summary, but non-account levels also preserve itemized structured metrics so clients can do their own ranking, filtering, and interpretation.
compareTwoPeriods follows the same idea: text output only includes the requested (or defaulted) metrics, while structuredContent.metrics exposes both the requested metric list and the returned per-metric values/change objects.
Quality and project status
Current technical foundations:
TypeScript strict mode
Zod-first tool schemas
Structured logging with Pino
Categorized error handling
Vitest test setup
MCP SDK integration over stdio
Project status:
actively evolving
suitable for local/self-hosted usage
focused on practical Meta Ads workflows for MCP clients and agents
Roadmap
Planned features:
Delivery diagnosis — explain why a campaign, ad set, or ad is not delivering (billing issues, policy violations, parent paused, bid too low, etc.) using
issues_infoandeffective_statusLearning phase status — expose whether an ad set is in learning, how many conversions remain to exit, and whether it is
LEARNING_LIMITEDand whyAd fatigue detection — detect when an ad needs creative rotation by combining frequency trends with CTR decay
Attribution comparison — side-by-side view of 1d/7d click and view attribution windows for the same object
Placement breakdown — performance by placement (Feed, Stories, Reels, Audience Network, Messenger)
Possible future directions:
remote MCP support
broader automation and monitoring flows
Testing
npm test
npm run test:coverage
npm run type-check
npm run lintDocumentation
Contributing
Contributions, issues, and feedback are welcome.
If you want to contribute, start with:
reading the architecture docs
checking existing issues
opening a focused PR or improvement proposal
License
MIT © iammalego
Acknowledgments
The open-source MCP ecosystem
Available Tools
31 toolsactivateAdSetB
Activate a paused ad set
Inputs: adSetId (required).
activateCampaignC
Activate a paused campaign
Inputs: campaignId (required).
bulkActivateCampaignsA
Activate multiple campaigns in a single operation. Supports dry-run mode to preview changes.
Inputs: campaignIds (required), dryRun.
bulkPauseCampaignsB
Pause multiple campaigns in a single operation. Supports dry-run mode to preview changes.
Inputs: campaignIds (required), dryRun.
checkAlertsB
Check campaigns for performance alerts based on configurable thresholds. Identifies high CPR, low CTR, and other performance issues.
Inputs: accountId (required), minCtr, datePreset, cprThreshold, +1 more.
cloneAdSetA
Clone an existing ad set to the same or different campaign. Copies targeting, budget, and all configuration.
Inputs: sourceAdSetId (required), targetCampaignId (required), newName.
cloneCampaignB
Clone an existing campaign with a new name. Optionally clone all ad sets within the campaign. Useful for duplicating successful campaign structures.
Inputs: newName (required), sourceCampaignId (required), copyAdSets, budgetAdjustment.
compareTwoPeriodsA
Compare performance metrics between two explicit periods for an account, campaign, adset, or ad. Each side accepts either a preset or a custom timeRange. Result selection can follow the primary action inferred from insights, a specific Meta action_type, or all actions. Optional metrics let callers compare spend, results, cpr, impressions, clicks, and/or ctr; omitting metrics keeps the backward-compatible spend/results/cpr default. For campaigns, the response also explains whether the baseline came from the same campaign, a similar campaign, or the account campaign average.
Inputs: level (required), objectId (required), currentPeriod (required), previousPeriod (required), +3 more.
createBudgetScheduleC
Create a budget schedule for a campaign with a specific time window.
Inputs: timeEnd (required), timeStart (required), campaignId (required), budgetValue (required), +1 more.
discoverAdAccountsA
Discover all ad accounts accessible via the System User Token. Returns account IDs, names, and business information. Results are cached for 5 minutes to improve performance.
Inputs: no named parameters.
getAccountInfoB
Get detailed information about an ad account including currency, timezone, status, and linked business.
Inputs: accountId (required).
getAdCreativesA
Get all creatives associated with an ad.
Inputs: adId (required).
getAdDetailsA
Get full ad details including effective status, creative ID, and issues.
Inputs: adId (required).
getAdsB
Get ads from an ad set or campaign. Supports filtering by status.
Inputs: status, adSetId, campaignId.
getAdSetDetailsA
Get extended ad set details including bid amount, effective status, and issues.
Inputs: adSetId (required).
getAdSetsB
Get ad sets from a campaign or account. Supports filtering by status.
Inputs: status, accountId, campaignId.
getBillingInfoA
Get billing and financial information for an ad account including pending balance (bill amount due), total spend, spend cap, payment method details, and tax info. All monetary values are in the smallest currency unit (e.g. cents for USD).
Inputs: accountId (required).
getCampaignDetailsA
Get extended campaign details including bid strategy, buying type, special ad categories, and issues.
Inputs: campaignId (required).
getCampaignsB
Get campaigns from an ad account. Supports filtering by status (ACTIVE, PAUSED, ALL). Account can be specified by ID (act_XXX) or by name.
Inputs: accountId (required), status.
getInsightsA
Get performance metrics for accounts, campaigns, adsets, or ads. Supports date presets (yesterday, last_7d, etc) or custom date ranges. Account level returns an aggregated summary; campaign/adset/ad levels also return structured per-item metrics with normalized ids/names plus spend, results, and CPR so consumers can filter and interpret the full signal.
Inputs: level (required), objectId (required), timeRange, datePreset.
getInterestSuggestionsB
Get interest suggestions based on a list of seed interests.
Inputs: interestList (required), limit.
pauseAdSetB
Pause an active ad set
Inputs: adSetId (required).
pauseCampaignC
Pause an active campaign
Inputs: campaignId (required).
searchBehaviorsC
Search for Facebook behavior targeting categories.
Inputs: limit.
searchDemographicsA
Search for Facebook demographic targeting categories by class.
Inputs: demographicClass (required), limit.
searchGeoLocationsB
Search for geographic locations for targeting (countries, cities, regions, etc.).
Inputs: query (required), limit, locationTypes.
searchInterestsC
Search for Facebook interest targeting options by keyword.
Inputs: query (required), limit.
updateAdB
Update an existing ad status or bid amount.
Inputs: adId (required), status, bidAmount.
updateAdSetB
Update an existing ad set. Only provided fields will be updated.
Inputs: adSetId (required), name, status, targeting, +2 more.
updateCampaignB
Update an existing campaign. Only provided fields will be updated.
Inputs: campaignId (required), name, status, dailyBudget, +1 more.
validateInterestsB
Validate a list of interests by name or Facebook ID. At least one of interestList or interestFbidList must be provided.
Inputs: interestList, interestFbidList.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 31 tools
Most tools are clearly separated by resource and action, but some pairs like getCampaigns/getCampaignDetails and getAds/getAdDetails could confuse an agent because the names do not clearly signal list versus detail. The interest-related tools also overlap somewhat, though their descriptions distinguish keyword search from suggestions and validation.
Tool names consistently use camelCase and generally follow a verb-noun pattern. Minor deviations exist, such as discoverAdAccounts versus getAccountInfo, and compareTwoPeriods not following the same noun-object shape, but overall the naming is predictable.
With 31 tools, the surface exceeds the 25+ threshold and feels heavy for an MCP server. While Meta Ads has a broad domain, many tools could be consolidated, such as single and bulk campaign state changes or list-versus-detail retrieval pairs.
The server covers reading, updating, pausing, activating, cloning, insights, targeting, billing, and alerts, which is substantial. However, direct creation of campaigns, ad sets, and ads is missing except through cloning, and there are no delete operations, leaving notable lifecycle gaps.
Maintenance
Related MCP Connectors
Meta Ads MCP server: run Facebook and Instagram campaigns, ad sets, ads and reports from AI.
Meta Ads and Google Ads MCP server: 250+ tools for Claude, ChatGPT, Cursor and Codex.
Meta Ads MCP server with 47 tools for campaigns, creatives, audiences, and insights.
Meta Ads MCP server: 10 tools for Facebook and Instagram reports, ads, Ad Library. Ads start paused.
Related MCP Servers
AlicenseNot gradedqualityFmaintenanceMCP server for managing Google Ads, Meta Ads, LinkedIn Ads, and TikTok Ads via AI. 210+ tools including account audits, wasted spend detection, and PMax insights.2MIT- AlicenseNot gradedqualityDmaintenanceMeta Ads MCP server with 47 tools for campaigns, creatives, audiences, and insights — plus AI-powered campaign diagnosis and buyer personas.MIT
- FlicenseNot gradedqualityDmaintenanceA comprehensive MCP server for managing and analyzing Meta Ads (Facebook/Instagram) with over 80 natural-language tools for AI agents like Claude Desktop.-
- AlicenseAqualityDmaintenanceMCP server to manage Meta Ads (Facebook/Instagram) campaigns, ad sets, insights, and audiences from Claude Code using natural language.98 npmMIT