MCP
Meta Ads CLI with Claude Code — Complete Automation Guide 2026
The Meta Ads CLI with Claude Code transforms Facebook advertising from point-and-click workflows into terminal-driven automation. Connect via MCP, execute campaigns programmatically, and scale media buying operations with AI agents that create, optimize, and report on Meta campaigns without manual intervention.
Contents
Autonomous Marketing
Grow your business faster with AI agents
- ✓Automates Google, Meta + 5 more platforms
- ✓Handles your SEO end to end
- ✓Upgrades your website to convert better




What is the Meta Ads CLI with Claude Code?
The Meta Ads CLI with Claude Code is a command-line interface that connects Anthropic's Claude AI to Meta's Marketing API, enabling programmatic Facebook and Instagram advertising management through terminal commands. Instead of clicking through Meta Ads Manager's web interface, marketers execute campaigns, analyze performance, and optimize spend through AI-powered CLI workflows that can process hundreds of ads in seconds.
This combination leverages the Model Context Protocol (MCP) to give Claude real-time access to Meta's advertising data. When properly configured, Claude Code can create campaigns from specifications, analyze performance trends, detect creative fatigue, reallocate budgets, and generate reports — all from terminal prompts. The Meta Ads CLI with Claude Code represents a fundamental shift from manual media buying to agentic marketing operations.
Meta released its official CLI in April 2026 after seeing 67% of high-volume advertisers request programmatic access to replace repetitive GUI tasks. Agencies report 85-90% reduction in manual campaign management time when switching from Meta Ads Manager to CLI-based workflows. For marketers managing 50+ campaigns, the time savings compound dramatically — what took 8 hours of clicking now completes in under 30 minutes of terminal commands.
The Meta Ads CLI with Claude Code works alongside other automation tools. For broader AI marketing needs, see Claude Marketing Skills Complete Guide. For Google Ads automation, check Claude Skills for Google Ads. For a comparison of CLI vs web-based approaches, read How to Use Claude for Meta Ads.
1,000+ Marketers Use Ryze





Automating hundreds of agencies




★★★★★4.9/5
How to install and set up the Meta Ads CLI with Claude Code?
Setting up the Meta Ads CLI with Claude Code requires three components: Node.js runtime, Claude Code installation, and Meta's official CLI package. The process takes 15-20 minutes for first-time users but only 5 minutes for developers already familiar with Node.js environments.
Prerequisites
- •Node.js 18+ installed on your machine
- •Claude Pro subscription ($20/month)
- •Meta Business account with ad account access
- •Terminal/command line basic familiarity
Step 1: Install Claude Code
Claude Code is Anthropic's CLI agent for developers. Install it globally via npm:
The auth command opens your browser to link your Anthropic account. Grant file system and command execution permissions.
Step 2: Install Meta Ads CLI
Meta's official CLI package connects to the Marketing API. Install via pip or npm:
Step 3: Authenticate Meta API
Create a Meta app in Business Suite, generate system user credentials, and configure 7 required scopes:
Store your access token securely. Meta tokens expire every 60 days and require refresh.
What are the MCP connection methods for Meta Ads CLI?
The Model Context Protocol (MCP) bridges Claude Code with Meta's Marketing API through three connection methods. Each offers different tradeoffs between setup complexity, data freshness, and automation capabilities. Meta's official MCP server launched in April 2026 as the primary recommended path.
| Method | Setup Time | Technical Level | Best For |
|---|---|---|---|
| Meta Official MCP | 10 minutes | JSON config editing | Direct API access, free beta |
| Ryze Hosted MCP | 2 minutes | OAuth click only | Zero setup, managed auth |
| Custom MCP Server | 30+ minutes | Advanced development | Enterprise custom workflows |
Meta Official MCP Server
Meta's hosted MCP server provides direct Marketing API access through Claude Desktop configuration. Edit your MCP settings JSON file:
Ryze Hosted MCP
Skip the technical setup with Ryze's one-click MCP connector. Visit get-ryze.ai/mcp, authenticate with Meta Business, and receive a pre-configured MCP URL. Handles token refresh and multi-account access automatically.
Which are the 6 core CLI workflows for Meta Ads automation?
The Meta Ads CLI with Claude Code excels at six automation workflows that replace hours of manual Ads Manager work. These workflows leverage programmatic API access to execute bulk operations, analyze performance patterns, and optimize campaigns at scale. Each workflow can process hundreds of ad objects in minutes rather than hours.
Workflow 01
Bulk Campaign Creation
Create 50+ campaigns from a single specification file. Define targeting, budgets, creatives, and schedule in JSON or YAML format. Claude Code reads your spec, validates parameters against Meta's API requirements, and executes batch campaign creation with progress tracking. What takes 3+ hours in Ads Manager completes in under 10 minutes.
Workflow 02
Automated Performance Analysis
Pull performance data across all campaigns, analyze trends, and generate actionable insights without manual data exports. Claude Code queries the Marketing API for impressions, clicks, conversions, CPM, CPA, and ROAS across custom date ranges. Identifies statistical anomalies, creative fatigue patterns, and budget optimization opportunities in seconds.
Workflow 03
Dynamic Budget Reallocation
Automatically shift spend from underperforming campaigns to top performers based on real-time ROAS metrics. Set threshold rules in your CLI configuration — campaigns below 2.0x ROAS get budget reduced by 25%, campaigns above 4.0x ROAS get budget increased by 50%. Execute changes across dozens of campaigns simultaneously.
Workflow 04
Creative Asset Management
Organize, version, and deploy creative assets programmatically. Upload new images and videos to Meta's creative library, generate ad copy variants, and create ad sets with systematic creative testing. Track creative performance over time and automatically pause fatigued creatives when CTR drops below historical averages.
Workflow 05
Audience Optimization
Analyze audience overlap, refresh lookalike audiences, and identify expansion opportunities through API-driven insights. Calculate audience intersection percentages, flag competing ad sets, and recommend exclusion strategies. Refresh custom and lookalike audiences based on recent conversion data to maintain targeting relevance.
Workflow 06
Automated Reporting
Generate comprehensive performance reports with executive summaries, campaign breakdowns, and optimization recommendations. Pull data from custom date ranges, apply business logic for metric calculations, and format outputs for stakeholder consumption. Schedule daily, weekly, or monthly reports that email automatically to your team.
Ryze AI — Autonomous Marketing
Skip the terminal — let AI optimize your Meta Ads 24/7
- ✓Automates Google, Meta + 5 more platforms
- ✓Handles your SEO end to end
- ✓Upgrades your website to convert better
2,000+
Marketers
$500M+
Ad spend
23
Countries
Essential Meta Ads CLI commands for automation
The Meta Ads CLI provides 40+ commands for programmatic campaign management. Mastering 12 core commands covers 90% of daily automation needs. These commands work with both Meta's official CLI and Claude Code integration, enabling both interactive prompts and scripted automation workflows.
Campaign Management Commands
| Command | Purpose | Example Usage |
|---|---|---|
| meta ads list-campaigns | View all campaigns with status | Daily monitoring dashboards |
| meta ads create-campaign | Create new campaign from spec | Bulk campaign launches |
| meta ads update-budget | Modify daily/lifetime budgets | Dynamic budget optimization |
| meta ads pause-campaign | Stop underperforming campaigns | Automated performance rules |
Analytics and Reporting
Creative and Asset Management
Advanced Automation
Combine multiple commands in scripts for complex automation workflows. Schedule via cron jobs or trigger via webhooks from your attribution system. For advanced users managing enterprise accounts, custom automation saves 20+ hours per week.
How does Meta Ads CLI compare to GUI management?
The CLI vs GUI comparison reveals stark efficiency differences for media buyers managing complex accounts. While Meta Ads Manager excels for creative review and initial setup, the CLI dominates for bulk operations, data analysis, and systematic optimization. High-volume advertisers report 75-85% time savings switching from GUI to CLI workflows.
| Task | Meta Ads Manager (GUI) | Meta Ads CLI | Time Savings |
|---|---|---|---|
| Create 50 campaigns | 3-4 hours (clicking, duplicating) | 8-10 minutes (batch upload) | 95% |
| Weekly reporting | 2-3 hours (export, format, analyze) | 5 minutes (automated script) | 97% |
| Budget reallocation | 45-60 minutes (manual edits) | 2 minutes (bulk command) | 96% |
| Creative fatigue audit | 30-45 minutes (manual review) | 30 seconds (automated check) | 98% |
| Audience overlap analysis | Impossible (no GUI tool) | 2 minutes (API calculation) | New capability |
The GUI maintains advantages for creative asset review, visual ad preview, and initial campaign setup where visual confirmation matters. However, CLI excels at data manipulation, bulk operations, and systematic optimization — exactly the tasks that consume most media buyer time. For comparison with other automation approaches, see Top AI Tools for Meta Ads Management in 2026.
When to Use GUI vs CLI
Use Meta Ads Manager GUI
- •Creative asset preview and approval
- •Initial campaign setup and targeting
- •Ad copy writing and editing
- •Visual performance dashboards
- •Stakeholder presentations
Use Meta Ads CLI
- •Bulk campaign creation and editing
- •Automated reporting and analysis
- •Performance monitoring and alerts
- •Budget optimization workflows
- •Data export and integration

Sarah K.
Paid Media Manager
E-commerce Agency
Moving to CLI automation cut our campaign management time from 15 hours to under 2 hours per week. We can now manage 200+ campaigns as easily as we used to manage 20.”
87%
Time reduction
200+
Campaigns managed
10x
Scale increase
How to troubleshoot common Meta Ads CLI issues?
CLI automation introduces new failure modes not present in GUI workflows. Authentication expires, rate limits trigger, API responses change format, and command syntax updates with new Meta releases. Understanding these issues and their solutions prevents downtime in automated workflows.
Authentication and Access Issues
Error: "Invalid access token" or "Token expired"
Meta access tokens expire every 60 days. Long-lived tokens last longer but still require refresh.
meta auth refresh
# Or re-authenticate completely
meta auth login --force
Set up automatic token refresh in production environments to prevent authentication failures.
Error: "Insufficient permissions for ad account"
System users need proper role assignments in Meta Business Manager.
- Assign "Admin" role for full API access
- Grant "Ads Manager" for campaign management only
- Enable "Reports" permission for insights API
Check Business Settings > System Users > Assigned Assets to verify permissions.
API Rate Limiting
Meta enforces rate limits to prevent API abuse. Enterprise accounts get higher limits, but all accounts can hit throttling during bulk operations. Implement exponential backoff and batch request strategies.
Data Format and Validation Errors
Meta's API validation rules change frequently. Campaign specs that worked last month may fail due to new targeting restrictions, creative requirements, or policy updates. Enable verbose error logging to diagnose issues quickly.
Frequently asked questions
Q: Is the Meta Ads CLI with Claude Code free?
Meta's CLI is free during open beta. Claude Code requires Claude Pro ($20/month). MCP connections vary — Meta's official server is free, Ryze offers a free trial, custom servers require development time.
Q: Can I automate campaign changes with Claude Code?
Yes. Claude Code can create campaigns, adjust budgets, pause underperformers, and upload creatives through Meta's Marketing API. All changes require explicit confirmation unless you configure auto-execution rules.
Q: How does this compare to Meta's Advantage+ automation?
Advantage+ optimizes individual campaigns using Meta's algorithms. CLI automation manages your entire account structure — creating campaigns, reallocating budgets, and analyzing performance across all campaigns simultaneously.
Q: What technical skills do I need for CLI automation?
Basic terminal comfort and JSON file editing. Advanced automation requires scripting knowledge (Bash, Python). Most marketers start with simple commands and gradually build complexity as they gain confidence.
Q: Can I use this with other advertising platforms?
Yes. Similar CLI tools exist for Google Ads, TikTok Ads, and LinkedIn. Claude Code can connect to multiple platforms via MCP servers, enabling cross-platform automation and unified reporting.
Q: What are the risks of automated campaign management?
Potential for large-scale errors if automation rules are misconfigured. Always test with small budgets first, implement spending caps, and maintain human oversight for major changes. Start with read-only analysis before enabling write access.
Ryze AI — Autonomous Marketing
Skip the CLI setup — get Meta Ads automation in 2 minutes
- ✓Automates Google, Meta + 5 more platforms
- ✓Handles your SEO end to end
- ✓Upgrades your website to convert better
2,000+
Marketers
$500M+
Ad spend
23
Countries

