@cesteral/meta-mcp
v5.0.0
Published
Meta Ads MCP Server - Campaign entity management and reporting via the configured Meta Graph API (default: v27.0)
Maintainers
Readme
@cesteral/meta-mcp
Meta Ads MCP Server - Campaign management via the configured Meta Graph API (default: v27.0).
Purpose
Management server for Meta Ads. Provides full CRUD operations, performance insights, targeting discovery, bulk operations, and specialized features like entity duplication and delivery estimates. Designed for AI agents to manage Meta Ads campaigns programmatically through the Model Context Protocol with per-session Bearer token authentication.
Choose Your Path
- Self-host this connector when you want direct control of credentials, infrastructure, and Meta Ads API access.
- Use Cesteral Intelligence when the workflow needs approvals before spend commits, credential brokering, auditability, and cross-platform execution.
Self-host quickstart | Compare OSS vs Cesteral Intelligence | Book a workflow demo
Features
- Per-session Bearer token auth via
MetaBearerAuthStrategy(validates tokens againstGET /me) - Streamable HTTP + stdio transports via Hono + the MCP SDK's web-standard transport
- OpenTelemetry instrumentation for traces and metrics
- Rate limiting via shared
RateLimiterclass (20/min default per process, override withMETA_RATE_LIMIT_PER_MINUTE; writes cost 3x). Buckets are per Graph user (the token's/meid): one for calls on a named ad account per account, one for everything else, so one tenant's traffic never queues another's - Structured logging via Pino
- MCP Resources for entity schemas, examples, insights reference, and targeting reference
- MCP Prompts for campaign setup, insights reporting, troubleshooting, and schema exploration
MCP Tools
Core CRUD
1. meta_list_entities
List Meta Ads entities with optional filtering and cursor-based pagination.
Parameters:
entityType(string, required): Type of entity to listadAccountId(string, required): Ad Account ID (with or withoutact_prefix)fields(string[], optional): Field names to returnfiltering(array, optional): Filter objects in Meta filtering formatlimit(number, optional): Results per page (1-100, default 25)after(string, optional): Cursor for next page
2. meta_get_entity
Get a single Meta Ads entity by ID.
Parameters:
entityType(string, required): Type of entity to retrieveentityId(string, required): The entity IDfields(string[], optional): Field names to return
3. meta_create_entity
Create a new Meta Ads entity.
Parameters:
entityType(string, required): Type of entity to createadAccountId(string, required): Ad Account IDdata(object, required): Entity fields as key-value pairs
4. meta_update_entity
Update an existing Meta Ads entity (POST with PATCH semantics).
Parameters:
entityType(string, optional): Type of entity to update (informational only, not used in API call)entityId(string, required): The entity ID to updatedata(object, required): Fields to update as key-value pairs
5. meta_delete_entity
Delete a Meta Ads entity.
Parameters:
entityType(string, required): Type of entity to deleteentityId(string, required): The entity ID to delete
Account
6. meta_list_ad_accounts
List ad accounts accessible to the authenticated user.
Parameters:
fields(string[], optional): Field names to return (defaults to id, name, account_status, currency, timezone_name, amount_spent, balance)limit(number, optional): Number of accounts to return (1-100)after(string, optional): Pagination cursor from previous response
Insights
All Meta reporting tools (
meta_get_insights,meta_get_insights_breakdowns, and themeta_download_reporttool used in async report flows) return data using the shared bounded report-view contract:mode("summary"default — headers + counts + 10-row preview, or"rows"for a paginated rows page),columns(project to selected columns),offset(zero-based pagination), andmaxRows(page size; default 10 for summary, 50 for rows; hard cap 200).limitandafterremain available for cursoring across upstream Meta pages.
7. meta_get_insights
Get performance insights for a Meta Ads entity (account, campaign, ad set, or ad).
Parameters:
entityId(string, required): Entity ID to get insights forfields(string[], optional): Metrics/fields to returndatePreset(string, optional): Date preset (today,yesterday,last_7d,last_30d, etc.)timeRange(object, optional): Object withsinceanduntil(YYYY-MM-DD)timeIncrement(string, optional): Granularity (1for daily,7for weekly,monthly,all_days)level(string, optional): Aggregation level (account,campaign,adset,ad)limit(number, optional): Upstream Meta page size (1-500). UsemaxRowsto control the bounded view's returned-row count.after(string, optional): Cursor for next upstream pagemode,columns,offset,maxRows(optional): Bounded report-view params (see note above)
8. meta_get_insights_breakdowns
Get performance insights broken down by dimension (age, gender, country, device, etc.).
Parameters:
entityId(string, required): Entity ID to get insights forbreakdowns(string[], required): Breakdown dimensions (e.g.,['age', 'gender'])fields(string[], optional): Metrics to returndatePreset(string, optional): Date presettimeRange(object, optional): Object withsinceanduntiltimeIncrement(string, optional): Time granularitylevel(string, optional): Aggregation levelactionAttributionWindows(string[], optional): Attribution windows (e.g.,['1d_click', '7d_click'])limit(number, optional): Upstream Meta page size (1-500). UsemaxRowsfor bounded-view row count.after(string, optional): Cursor for next upstream pagemode,columns,offset,maxRows(optional): Bounded report-view params (see note above)
9. meta_get_available_metrics
List the Insights metrics, breakdowns and action breakdowns available (static catalog), grouped by category. Use it to discover valid fields before calling the insights tools.
Parameters:
level(string, optional):account,campaign,adset, orad
Async Reporting
10. meta_submit_report
Submit an async insights report (POST /{id}/insights with async=1) and return a reportRunId immediately.
Parameters:
entityId(string, required): Account (act_XXX), campaign, ad set, or ad IDfields,datePreset,timeRange,timeIncrement,level,breakdowns(optional): As formeta_get_insights(datePresetandtimeRangeare mutually exclusive)dry_run(boolean, optional): Validate without submitting
11. meta_check_report_status
Poll an async report. Meta's async_status is mapped to canonical states — "Job Completed" → complete, "Job Failed" → failed; the raw string is returned as rawStatus.
Parameters:
reportRunId(string, required): Report run ID frommeta_submit_report
12. meta_download_report
Download rows from a completed async report (bounded report-view contract).
Parameters:
reportRunId(string, required): Report run IDcursor(string, optional):nextCursorfrom a previous callincludeComputedMetrics(boolean, optional): Appendcpa,roas,cpm,ctr,cpccolumns, computed fromspend,impressions,clicks,actionsandaction_valuesmode,columns,maxRows(optional): Bounded report-view params
Bulk Operations
13. meta_bulk_update_status
Batch update status for multiple Meta Ads entities.
Parameters:
entityType(string, optional): Type of entities to update (informational only, not used in API call)entityIds(string[], required): Entity IDs to update (max 50)status(string, required):ACTIVE,PAUSED, orARCHIVED
14. meta_bulk_create_entities
Batch create multiple entities of the same type.
Parameters:
entityType(string, required): Type of entities to createadAccountId(string, required): Ad Account IDitems(array, required): Array of entity data objects (max 50)
15. meta_bulk_update_entities
Batch update multiple entities with individual data payloads.
Parameters:
entityType(string, optional): Type of entities being updated (informational only, not used in API call)items(array, required): Array of update items (max 50), each withentityIdanddata
Targeting
16. meta_search_targeting
Search for targeting options (interests, behaviors, demographics) by keyword.
Parameters:
type(string, required): Search type (adinterest,adinterestsuggestion,adgeolocation,adlocale, etc.)query(string, required): Search keywordtargetingClass(string, optional): Meta'sclassparameter, used withadTargetingCategorylimit(number, optional): Max results (1-100, default 25)after(string, optional):pagination.nextCursorfrom a previous response
17. meta_get_targeting_options
Browse available targeting categories for an ad account.
Parameters:
adAccountId(string, required): Ad Account IDtype(string, optional): Filter by targeting type (e.g.,interests,behaviors)
Specialized
18. meta_duplicate_entity
Duplicate a campaign, ad set, or ad via POST /{id}/copies.
Parameters:
entityType(string, required): Type of entity to duplicate (campaign,adSet,ad)entityId(string, required): ID of the entity to duplicaterenameOptions(object, optional): Object withprefixand/orsuffixfor namingstatusOption(string, optional): Status for copy (ACTIVE,PAUSED,INHERITED_FROM_SOURCE)
19. meta_get_delivery_estimate
Get estimated audience size and delivery estimates for a targeting spec.
Parameters:
adAccountId(string, required): Ad Account IDtargetingSpec(object, required): Targeting specification (must includegeo_locationsorcustom_audiences)optimizationGoal(string, optional): Optimization goal (e.g.,LINK_CLICKS,REACH,OFFSITE_CONVERSIONS)
20. meta_get_ad_preview
Get preview HTML for an ad in a specific format.
Parameters:
adId(string, required): Ad ID to previewadFormat(string, required): Ad format (e.g.,DESKTOP_FEED_STANDARD,MOBILE_FEED_STANDARD,INSTAGRAM_STANDARD)
21. meta_adjust_bids
Batch adjust ad set bid amounts with percentage or absolute changes.
Parameters:
adAccountId(string, required): Ad Account IDadjustments(array, required): Array of bid adjustments (max 50), each withadSetId,adjustmentType(percentage/absolute), andvalue
22. meta_validate_entity
Client-side validation of entity payloads without making API calls.
Parameters:
entityType(string, required): Type of entity to validatemode(string, required): Validation mode (createorupdate)data(object, required): Entity data to validateadAccountId(string, optional): Required for create modeentityId(string, optional): Required for update mode
23. meta_upload_image
Download an image from a URL and upload it to the ad account's image library (/act_{id}/adimages). Returns the image hash for creative payloads.
Parameters:
adAccountId(string, required): Ad Account IDmediaUrl(string, required): Publicly accessible image URLname(string, optional): Name in the media librarydry_run(boolean, optional): Validate without uploading
24. meta_upload_video
Download a video from a URL, upload it to /act_{id}/advideos, and poll until processing completes.
Parameters:
adAccountId(string, required): Ad Account IDmediaUrl(string, required): Publicly accessible video URLtitle,description(string, optional): Video metadatadry_run(boolean, optional): Validate without uploading
25. meta_attach_creative
Attach media uploaded by meta_upload_image / meta_upload_video to an ad set: one POST /act_{id}/ads that creates a PAUSED ad with the creative written inline (object_story_spec with link_data for an image, video_data for a video). Effect-class governed write (meta.attach_creative.v1).
Parameters:
adAccountId,adSetId,name,pageId(string, required)imageHashorvideoId(string, exactly one): the upload's handlethumbnailImageHashorthumbnailUrl(video only, exactly one)link(string, required): destination URLmessage,headline,description,callToActionType(string, optional)dry_run(boolean, optional): Validate without creating
26. meta_manage_budget_schedule
Create or list budget schedules (high-demand periods) on a campaign via /{campaignId}/budget_schedules.
Parameters:
operation(string, required):createorlistcampaignId(string, required): Campaign IDdata(object, required for create):budget_value(integer),budget_value_type(ABSOLUTEorMULTIPLIER),time_startandtime_end(Unix timestamps in seconds)dry_run(boolean, optional): Validate without creating
27. meta_get_pacing_status
Client-side pacing calculator (no Meta API call): actual vs expected spend for a flight.
Parameters:
adAccountId,campaignId(string, required)spendToDate,budgetTotal(number, required): In account currencyflightStartDate,flightEndDate(string, required):YYYY-MM-DDcurrency(string, optional): DefaultUSD
Discovery
28. meta_search_tools
Rank this server's tools against a natural-language query.
Parameters:
query(string, required): What you want to dolimit(number, optional): Max results (default 10)
Supported Entity Types
| Entity Type | API Object | Notes |
| ---------------- | --------------- | ------------------------------------------- |
| campaign | Campaign | Top-level entity under ad account |
| adSet | Ad Set | Targeting, budget, schedule, bidding |
| ad | Ad | Links ad creative to ad set |
| adCreative | Ad Creative | Creative content (images, videos, copy) |
| customAudience | Custom Audience | Lookalike, website, customer list audiences |
Entity Hierarchy: Ad Account > Campaign > Ad Set > Ad (+ Ad Creatives, Custom Audiences)
Current Status
Phase: Production-Ready
All listed tools are fully implemented using the configured Meta Graph API with Bearer token authentication, insights reporting, and targeting discovery.
Development
# Install dependencies
pnpm install
# Run in development mode
pnpm run dev:http
# Build
pnpm run build
# Start production server
pnpm run start
# Type check
pnpm run typecheckEnvironment Variables
META_MCP_PORT: Server port (default: 3005)META_MCP_HOST: Server host (default: 127.0.0.1)MCP_AUTH_MODE: Authentication mode -meta-bearer(default),jwt, ornoneMCP_AUTH_SECRET_KEY: Required whenMCP_AUTH_MODE=jwtMETA_API_BASE_URL: Graph API base URL (default:https://graph.facebook.com/v27.0)META_API_VERSION: Graph API version (e.g.v27.0); used to build the base URL ongraph.facebook.comwhenMETA_API_BASE_URLis not set. An explicitMETA_API_BASE_URLwins.META_RATE_LIMIT_PER_MINUTE: Rate limit ceiling per process (default: 20)META_ACCESS_TOKEN: Access token for stdio modeMETA_VIDEO_UPLOAD_MAX_BUFFERED_BYTES: Max buffered video upload size in bytes (default:268435456)
Architecture
Key Components
MetaGraphApiClient- HTTP client for the configured Graph API version with form-encoded POST for writesMetaService- CRUD, bulk ops, duplication, delivery estimates, ad previewsMetaInsightsService- Insights queries with breakdowns, attribution windows, and time seriesMetaTargetingService- Targeting search and category browsingMetaBearerAuthStrategy- Bearer token auth viaGET /mevalidationMetaAuthAdapter- Token management for per-session API callsSessionServiceStore- Per-session service instances keyed by session ID
Key Gotchas
- Budget values are in cents (e.g.,
1000= $10.00) special_ad_categoriesis required on campaign creation even if empty ([])meta_update_entityreturns{success: true}— fetch the entity after to confirm changestargetingon ad sets replaces entirely on update (no merge semantics)ARCHIVEDstatus is permanent and cannot be reversed- Insights data may lag up to 48 hours for recent activity
- Video uploads use a buffered proxy path and are intentionally capped below Meta's largest native upload limits
Transport
Streamable HTTP via Hono + the MCP SDK's web-standard transport. Health check at /health.
Contributing
See root CLAUDE.md for development guidelines, build system details, and monorepo conventions. See the root README for full architecture context.
Get Started
Self-host: Follow the deployment guide to run this server on your own infrastructure.
Cesteral Intelligence: Request access -- governed execution with credential brokering, approvals, audit, and multi-tenant access.
Book a workflow demo: See it in action with your own ad accounts.
Compare options: OSS connectors vs Cesteral Intelligence
License
Apache License 2.0 — see LICENSE for details. This package is part of Cesteral's open-source connector layer; managed hosting and higher-level governance features live outside this repository.
