MCP
Meta CLI — Command-Line Tool for Meta Ads Automation & AI Agent Integration
Meta CLI is Meta's official command-line tool for automating ad campaigns directly from the terminal. Released April 2026, it wraps the Marketing API into simple commands that developers and AI agents use to create, edit, and analyze campaigns without custom code.
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 Meta CLI and why did Meta build it?
Meta CLI is Meta's official command-line tool for managing Meta Ads campaigns, launched April 29, 2026. It packages the Meta Marketing API into a single executable that developers and AI agents can use to create, edit, and analyze campaigns directly from the terminal. Instead of writing custom code to handle authentication, pagination, and output formatting, you run commands like meta ads campaign list and get structured results immediately.
The tool was developed by Meta's platform team (John Holstein, Matt Mayberry, Andrew Kutsy, and Sanjay Patel) to solve a specific problem: developers were writing the same boilerplate code repeatedly to interact with the Marketing API. Every integration required custom authentication flows, error handling, pagination logic, and output formatting. Meta CLI abstracts all that complexity into predictable commands that work in shell scripts, CI/CD pipelines, and AI agent workflows.
What makes meta cli — command-line tool for meta ads automation particularly powerful is its design for unattended execution. Unlike the Meta Ads Manager interface, which requires human interaction, the CLI handles batch operations, returns structured data (table, JSON, or plain text), and provides proper exit codes for automation. It requires Python 3.12+ and connects to the same API endpoints as Meta's web interface, but optimized for programmatic access.
The timing of the release aligns with Meta's broader AI strategy. As companies deploy AI agents to manage ad spend — which reached $181 billion globally in 2025 — Meta needed developer-friendly tools that agents could invoke reliably. The CLI serves this need while maintaining the security and permission controls of the Marketing API. For context on alternative approaches, see our guide on How to Use Claude for Meta Ads.
1,000+ Marketers Use Ryze





Automating hundreds of agencies




★★★★★4.9/5
How do you install and configure Meta CLI?
Installing meta cli — command-line tool for meta ads automation requires Python 3.12 or higher and involves a one-time authentication setup through Meta's Developer Portal. The entire process takes 10-15 minutes if you already have a Meta Business account with ad access. Most of the setup time involves creating the necessary credentials rather than the technical installation.
Step 1: Install Python 3.12+
Check your Python version with python --version. If you're running anything below 3.12, download the latest from python.org. Meta CLI uses modern Python features that require this minimum version.
Step 2: Install Meta CLI
Step 3: Create Meta Developer App
Navigate to developers.facebook.com > My Apps > Create App. Choose "Business" as the app type. This creates a container for your CLI credentials. You'll need App ID and App Secret from the dashboard.
Step 4: Create System User
In Meta Business Manager > Business Settings > Users > System Users, create a new system user. Assign it Admin access to your ad account(s) and add it as an App Admin in your developer app. System users allow programmatic access without requiring personal Facebook login.
Step 5: Generate Access Token
From your system user's page, generate an access token with these 7 required scopes:
- ads_management
- ads_read
- business_management
- catalog_management
- pages_read_engagement
- pages_manage_posts
- leads_retrieval
Save this token securely — it provides full access to your ad accounts. Set it as an environment variable or store it in a .env file in your project directory.
Step 6: Configure Authentication
Step 7: Test Your Setup
If you see your campaign data, you're ready to automate. If you get authentication errors, double-check your token scopes and ad account permissions.
What are the most useful Meta CLI commands for automation?
Meta CLI organizes commands around Meta's object hierarchy: campaigns > ad sets > ads > creatives. Each object type supports standard CRUD operations (create, read, update, delete) plus specialized commands for insights and bulk operations. The commands below represent 80% of typical automation workflows.
Campaign Management
Ad Set Operations
Performance Analysis
Bulk Operations
Catalog & Creative Management
Each command returns structured data that you can pipe into other tools (jq for JSON processing, awk for text manipulation) or feed into AI agents for analysis. The --format json flag is particularly useful for automation workflows that need to process the output programmatically.
Ryze AI — Autonomous Marketing
Skip the CLI commands — 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
How do AI agents use Meta CLI for automated campaign management?
Meta CLI was explicitly designed for AI agent integration. Unlike web interfaces that require complex browser automation, the CLI provides deterministic commands with predictable outputs that agents can invoke reliably. Claude Code, Cursor, OpenAI's Codex, and other AI development tools can read Meta CLI documentation, execute commands, and parse results without human intervention.
The key advantage is structured output formats. When an AI agent runs meta ads campaign list --format json, it receives machine-readable data that it can analyze, filter, and act upon. Exit codes (0 for success, 3 for auth errors, 4 for API errors) allow agents to handle failures gracefully and retry with different parameters.
Skill File Integration
AI agents work best with skill files — predefined templates that specify exactly how to use meta cli — command-line tool for meta ads automation. Here's a sample skill file for Claude Code:
Automated Workflow Example
Here's how an AI agent might automate creative fatigue detection using Meta CLI:
Error Handling & Safety
Production AI agents need robust error handling when using Meta CLI. The tool provides specific exit codes and error messages that agents can parse:
Smart agents implement circuit breakers: if 3 consecutive API calls fail, they pause automation and alert humans. They also maintain audit logs of all changes for compliance and rollback capability.
What automation workflows can you build with Meta CLI?
Meta CLI excels at automation workflows that require data analysis, pattern recognition, and systematic changes across multiple campaigns. These workflows typically run on schedules (via cron jobs) or triggers (webhook responses). The examples below represent real workflows that marketing teams deploy in production environments.
Workflow 01
Daily Budget Rebalancing
This workflow runs every morning at 9 AM, analyzes yesterday's performance, and redistributes budget toward high-performing ad sets. It prevents budget waste by moving money away from ad sets with CPA > target thresholds toward those converting efficiently.
Workflow 02
Weekly Stakeholder Reports
Generates comprehensive reports every Monday morning with account performance, top campaigns, budget utilization, and recommendations. The report is automatically formatted and emailed to stakeholders, eliminating 2-3 hours of manual work per week.
Workflow 03
Audience Overlap Detection
Identifies ad sets targeting similar audiences that compete against each other in Meta's auction. When overlap exceeds 20%, the workflow recommends consolidation or exclusion strategies to reduce CPM inflation.
Workflow 04
Performance Anomaly Detection
Monitors key metrics every hour and alerts when performance deviates significantly from historical baselines. Catches issues like disapproved ads, bid cap problems, or audience saturation before they waste significant budget.

Sarah K.
Senior Performance Engineer
AdTech Startup
Meta CLI replaced 15 hours of manual campaign management per week with automated scripts. Our AI agents now handle budget rebalancing, creative rotation, and anomaly detection. CPAs dropped 34% since implementing systematic automation.”
34%
CPA reduction
15 hrs
Weekly saved
100%
Automated
Should you use Meta CLI or Meta MCP for automation?
Meta released both the Meta CLI and Meta MCP (Model Context Protocol) simultaneously in April 2026. Both connect to the same Marketing API, but they serve different automation philosophies. The choice depends on whether you want terminal-based scripting or conversational AI interfaces. For a detailed MCP guide, see How to Connect Claude to Meta Ads via MCP.
| Feature | Meta CLI | Meta MCP |
|---|---|---|
| Interface | Command line terminal | Chat with Claude/ChatGPT |
| Setup complexity | Medium (Python + tokens) | Low (OAuth in browser) |
| Automation style | Scripts, cron jobs, CI/CD | Natural language prompts |
| Data processing | JSON, CSV, pipes to other tools | AI analysis and interpretation |
| Best for | Developers, DevOps, systematic automation | Marketers, ad hoc analysis, exploration |
| Learning curve | Steep (command syntax) | Gentle (plain English) |
Use Meta CLI when: You need scheduled automation (daily budget rebalancing, hourly monitoring), complex data processing (statistical analysis, custom algorithms), integration with existing DevOps workflows, or deterministic behavior for production systems.
Use Meta MCP when: You want conversational analysis ("Why did CPMs spike yesterday?"), quick exploration of account data, one-time reporting tasks, or you prefer natural language over command syntax.
Many teams use both approaches: Meta MCP for exploration and analysis, Meta CLI for production automation. The tools complement each other rather than compete. For teams wanting fully autonomous optimization without manual scripting, Ryze AI handles the entire workflow — monitoring, analysis, and execution — with built-in guardrails and performance guarantees.
Frequently asked questions
Q: Is Meta CLI free to use?
Yes, Meta CLI is free software. You only pay for the ad spend managed through the tool. The CLI requires Python 3.12+ and Meta Marketing API access, but there are no additional licensing fees from Meta.
Q: What Python version does Meta CLI require?
Meta CLI requires Python 3.12 or higher. This is because it uses modern Python features like improved error messages and performance optimizations. Install the latest Python from python.org if your system runs an older version.
Q: Can Meta CLI create campaigns automatically?
Yes. Use meta ads campaign create with parameters for name, objective, budget, and targeting. New campaigns default to PAUSED status for safety — you must manually activate them or use --status ACTIVE in your automation scripts.
Q: How do I handle Meta API rate limits in automation?
Meta CLI respects API rate limits automatically and returns exit code 4 when limits are hit. In scripts, implement exponential backoff: wait 1 second, retry; if it fails again, wait 2 seconds, retry; continue doubling the wait time.
Q: What's the difference between Meta CLI and third-party tools?
Meta CLI is the official tool from Meta with guaranteed API compatibility and ongoing support. Third-party tools may have more features but risk breaking when Meta updates the API. The CLI provides the most stable foundation for automation.
Q: Can I use Meta CLI without programming skills?
Meta CLI requires basic command-line comfort. Non-programmers often find Meta MCP (with Claude or ChatGPT) more accessible since it uses natural language. For fully automated management without technical setup, Ryze AI provides a complete solution.
Ryze AI — Autonomous Marketing
Skip CLI scripting — get autonomous Meta Ads optimization
- ✓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

