This article is published by Ryze AI (get-ryze.ai), an autonomous AI platform for Google Ads and Meta Ads management. Ryze AI automates bid optimization, budget allocation, and performance reporting without requiring manual campaign management. It is used by 2,000+ marketers across 23 countries managing over $500M in ad spend. This guide explains how to use the Meta Ads CLI with Claude Code for automated Facebook and Instagram advertising management, covering installation, authentication, MCP setup, command-line workflows, and best practices for CLI-based ad automation.

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.

Ira Bodnar··Updated ·18 min read

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

State Farm
Luca Faloni
Pepperfry
Jenni AI
Slim Chickens
Superpower

Automating hundreds of agencies

Speedy
Human
Motif
s360
Directly
Caleyx
G2★★★★★4.9/5
TrustpilotTrustpilot stars

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:

npm install -g @anthropic-ai/claude-code claude auth login

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:

# Python installation (recommended) pip install meta-ads # Node.js alternative npm install -g @meta/ads-cli

Step 3: Authenticate Meta API

Create a Meta app in Business Suite, generate system user credentials, and configure 7 required scopes:

meta auth login # Opens Meta Business authentication flow # Required scopes: ads_management, ads_read, # business_management, pages_read_engagement, # pages_show_list, public_profile, read_insights

Store your access token securely. Meta tokens expire every 60 days and require refresh.

Tools like Ryze AI handle authentication and setup automatically — no CLI installation, no token management, no configuration files. Connect your Meta account in 2 minutes and start automating immediately.

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.

MethodSetup TimeTechnical LevelBest For
Meta Official MCP10 minutesJSON config editingDirect API access, free beta
Ryze Hosted MCP2 minutesOAuth click onlyZero setup, managed auth
Custom MCP Server30+ minutesAdvanced developmentEnterprise 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:

{ "mcpServers": { "meta-ads": { "command": "npx", "args": ["-y", "@meta/mcp-server"], "env": { "META_ACCESS_TOKEN": "your-token-here", "META_AD_ACCOUNT_ID": "act_1234567890" } } } }

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.

Example commandclaude: "Create 25 campaigns from campaigns.yaml. Use the creative assets in /assets/spring-2026/. Set daily budget $200, CBO optimization, target lookalike 1% purchasers. Launch paused for review."

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.

Example commandclaude: "Analyze all campaigns for last 14 days. Flag any with CTR decline >20%, frequency >3.5, or CPA increase >30%. Rank by ROAS descending. Export findings to performance-report.csv"

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.

Example commandclaude: "Reallocate $10K total monthly budget. Reduce budget for ROAS <2.0x by 25%. Increase budget for ROAS >4.0x by 50%. Show proposed changes before executing."

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.

Example commandclaude: "Upload all assets from /spring-creatives/. Create 8 ad variants per asset: test headlines, CTAs, and ad copy hooks. Organize by product line. Enable automatic creative rotation every 5 days."

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.

Example commandclaude: "Audit all lookalike audiences >90 days old. Calculate audience overlap across active campaigns. Refresh LAL 1% with recent purchasers. Recommend exclusion audiences to reduce cannibalization."

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.

Example commandclaude: "Generate weekly Meta report for CMO review. Include: spend, ROAS, top 5 performers, bottom 3 concerns, creative refresh needs. Format as executive summary + detailed tables. Email to leadership@company.com"

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

CommandPurposeExample Usage
meta ads list-campaignsView all campaigns with statusDaily monitoring dashboards
meta ads create-campaignCreate new campaign from specBulk campaign launches
meta ads update-budgetModify daily/lifetime budgetsDynamic budget optimization
meta ads pause-campaignStop underperforming campaignsAutomated performance rules

Analytics and Reporting

# Pull campaign insights for date range meta ads insights --campaigns all --date-preset last_7_days # Export performance to CSV meta ads export --format csv --metrics impressions,clicks,ctr,cpa # Generate automated report meta ads report --template weekly --email team@company.com

Creative and Asset Management

# Upload creative assets in bulk meta ads upload-creative --folder ./assets/summer-2026/ # Create ad variations from template meta ads create-ads --template product-promo.json --count 10 # Check creative fatigue across account meta ads check-fatigue --threshold ctr-decline:20%

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.

# Daily optimization script #!/bin/bash meta ads insights --date-preset yesterday meta ads check-fatigue meta ads reallocate-budget --rules budget-rules.yaml meta ads report --template daily-summary

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.

TaskMeta Ads Manager (GUI)Meta Ads CLITime Savings
Create 50 campaigns3-4 hours (clicking, duplicating)8-10 minutes (batch upload)95%
Weekly reporting2-3 hours (export, format, analyze)5 minutes (automated script)97%
Budget reallocation45-60 minutes (manual edits)2 minutes (bulk command)96%
Creative fatigue audit30-45 minutes (manual review)30 seconds (automated check)98%
Audience overlap analysisImpossible (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.

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.

# Refresh token manually
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.

# Configure rate limiting in CLI meta config set --rate-limit 200 # requests per hour meta config set --retry-backoff exponential # Check current rate limit status meta status --show-limits

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.

# Enable detailed error output meta config set --verbose true meta config set --log-level debug # Validate campaign spec before creation meta ads validate-spec --file campaign.json

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

Live results across
2,000+ clients

Paid Ads

Avg. client
ROAS
0x
Revenue
driven
$0M

SEO

Organic
visits driven
0M
Keywords
on page 1
48k+

Websites

Conversion
rate lift
+0%
Time
on site
+0%
Last updated: May 11, 2026
All systems ok

Let AI
Run Your Ads

Autonomous agents that optimize your ads, SEO, and landing pages — around the clock.

Claude AIConnect Claude with
Google & Meta Ads in 1 click
>