Claude Code Just Took Over My Ad Account – And Yours Is Next + Video

Listen to this Post

Featured Image

Introduction:

The line between conversational AI and programmatic ad execution has officially vanished. On April 29, 2026, Meta launched Ads AI Connectors – an open beta that includes both a command-line interface (CLI) and a Model Context Protocol (MCP) server, enabling advertisers to create, manage, and analyze campaigns directly through AI tools using natural language commands. What Caleb Kruse demonstrated – sending a single prompt from his phone to restructure his entire campaign through the Meta API – is no longer a futuristic vision but a production-ready reality that every media buyer, growth marketer, and ad operations team needs to understand.

Learning Objectives:

  • Understand how Meta’s Ads CLI and MCP server enable AI-driven campaign management through natural language
  • Master the setup and configuration of Claude Code for Meta Ads automation
  • Implement safe automation workflows with human-in-the-loop controls to avoid account bans
  • Execute campaign restructuring, performance analysis, and budget optimization via the command line and AI agents
  • Apply security best practices for token management and API access

You Should Know:

  1. The Meta Ads CLI – Your Terminal Is Now an Ad Manager

Meta’s Ads CLI, published on April 29, 2026, wraps the entire Meta Marketing API into a single installable program. This is not another API wrapper – it’s a standalone executable that can be invoked from a shell, a CI/CD pipeline, or, significantly, an AI agent. The tool was built specifically for “developers and AI agents working with the Meta Marketing API,” reflecting a fundamental shift in how Meta positions access to its advertising infrastructure.

Why This Matters: Previously, developers using the Marketing API consistently flagged the same friction points: writing authentication logic from scratch, handling pagination across large result sets, formatting output for downstream tools, and managing errors consistently. The Ads CLI absorbs all that boilerplate. Authentication, pagination, output formatting, and exit codes are all handled inside the tool itself.

Installation and Setup:

 Install via pip (requires Python 3.12 or higher)
pip install meta-ads-cli

Or install from source
git clone https://github.com/attainmentlabs/meta-ads-cli.git
cd meta-ads-cli
cp .env.example .env
 Edit .env with your credentials

Authentication Flow:

  1. Go to Meta Business Suite > Business Settings

2. Navigate to Users > System Users

3. Create or select a System User

  1. Generate a token with `ads_management` and `ads_read` permissions
 Authenticate with your token
meta-ads auth login --token YOUR_ACCESS_TOKEN

List available ad accounts
meta-ads accounts list

Set default account
meta-ads accounts switch act_123456789

Core Commands for Campaign Management:

 List all campaigns
meta-ads campaigns list

List active campaigns in table format
meta-ads campaigns list --status ACTIVE --output table

Get campaign details
meta-ads campaigns get 120210123456789

Create a new campaign
meta-ads campaigns create --1ame "Q1 Brand Awareness" --objective OUTCOME_AWARENESS

Update campaign budget
meta-ads campaigns update 120210123456789 --daily_budget 5000

Pause or activate a campaign
meta-ads campaigns pause 120210123456789
meta-ads campaigns activate 120210123456789

Get performance metrics for the last 7 days
meta-ads insights get --campaign_id CAMPAIGN_ID --date-preset last_7d --fields conversions,impressions,spend,roas

Critical Safety Feature: All resources created through the CLI are set to PAUSED status by default. Nothing goes live automatically. An operator must explicitly call `meta-ads campaign update CAMPAIGN_ID –status ACTIVE` to begin delivery. This built-in safeguard is essential for any automation workflow.

  1. The MCP Server – How Claude Code Actually Talks to Meta

The Model Context Protocol (MCP) server is the bridge that enables AI assistants like Claude Code to interact with Facebook and Instagram advertising data through the Meta Marketing API. This is what makes Caleb’s “one prompt from my phone” workflow possible.

Meta’s official MCP server supports full CRUD operations, performance insights, targeting discovery, bulk operations, and specialized features like entity duplication and delivery estimates. Unlike earlier unofficial implementations that risked account bans, Meta’s official AI Connectors launched on April 29, 2026, provide a secure, approved path for AI-driven ad management.

Setting Up Claude Code with Meta Ads MCP:

Option 1 – Claude Desktop Configuration:

{
"mcpServers": {
"meta-ads": {
"command": "npx",
"args": ["-y", "media-buyer-plugin", "--meta"],
"env": {
"META_ADS_ACCESS_TOKEN": "YOUR_TOKEN_HERE"
}
}
}
}

Save this to your Claude Desktop config (Settings → Developer → Edit Config) and restart.

Option 2 – Claude Code CLI Setup:

 Install the plugin globally
npm install -g media-buyer-plugin

Add Meta Ads MCP server to Claude Code
claude mcp add -s user meta-ads -- media-buyer-meta

Available Tools (45 Meta Ads Tools):

| Category | Tools |

|-|-|

| Write (13) | Create campaign, ad set, creative, ad; upload image/video; update campaign/adset/ad; duplicate adset; validate token |
| Read (19) | List campaigns/adsets/ads; search by name; get ad preview; get campaign insights |
| Analysis | Breakdown Effect analysis; Learning Phase diagnostics; Auction Overlap detection; Creative Fatigue identification |

Natural Language Commands That Now Work:

"list my ad accounts"
"create a campaign targeting women 25-44 in the US with a $50 daily budget"
"pause ad 123456789"
"show me last 7 days performance for all campaigns"
"duplicate adset 987654321"
"analyze my campaigns from the last 7 days"
"why is my CPA increasing on this campaign?"
"diagnose why this ad set is in Learning Limited"

The system connects directly to live campaign data, enabling real execution rather than generic recommendations. Unlike implementations from Google and Amazon, which initially focused on read-only access, Meta’s connectors support full write capabilities from launch.

3. Building the “One Prompt” Campaign Restructuring Workflow

What Caleb executed – taking the top 5 spending ads from 3 new ad sets and moving them into new ad sets within an evergreen CBO campaign – represents a template for AI-driven campaign restructuring. Here’s how to build this workflow step by step.

Step 1: Identify Top-Performing Ads

 Get insights for specific ad sets
meta-ads insights get --level ad --date-preset last_7d \
--fields id,name,spend,conversions,ctr \
--filtering '[{"field":"adset_id","operator":"IN","value":["ADSET_ID_1","ADSET_ID_2","ADSET_ID_3"]}]' \
--sort '{"spend":"DESC"}' --limit 5

Step 2: Extract Ad IDs and Creative Assets

 Get ad details including creative IDs
meta-ads ads get AD_ID --fields id,name,creative_id,status

Step 3: Create New Ad Sets

 Create the guest speaker ad set
meta-ads adsets create \
--campaign_id CAMPAIGN_ID \
--1ame "Guest Speaker Ad Set" \
--daily_budget 5000 \
--targeting '{"geo_locations":{"countries":["US"]},"age_min":25,"age_max":44}'

Create the top Instagram content ad set
meta-ads adsets create \
--campaign_id CAMPAIGN_ID \
--1ame "Top Instagram Content Ad Set" \
--daily_budget 5000 \
--targeting '{"geo_locations":{"countries":["US"]},"age_min":25,"age_max":44}'

Step 4: Move Ads to New Ad Sets

 Update each ad to the new ad set
meta-ads ads update AD_ID --adset_id NEW_ADSET_ID

Or use the MCP server through Claude Code
 Simply prompt: "Move ad [bash] to ad set [bash]"

Step 5: Activate the New Structure

 Activate the new ad sets
meta-ads adsets activate NEW_ADSET_ID_1
meta-ads adsets activate NEW_ADSET_ID_2

Pause the old ad sets (optional)
meta-ads adsets pause OLD_ADSET_ID_1
meta-ads adsets pause OLD_ADSET_ID_2

The Claude Code Approach: With the MCP server configured, the entire workflow becomes a single natural language prompt:

"Take the top 5 spending ads from the 3 new ad sets I launched last week and move them into a new guest speaker ad set and a new top Instagram content ad set inside my evergreen CBO campaign."

The AI handles: pulling all stats, finding the ads, creating the new ad sets, moving the ads, and reorganizing the entire campaign structure – all through the Meta API without ever touching Ads Manager.

4. Security, Compliance, and the Ban Risk Reality

The most critical question facing any advertiser considering this approach: Will connecting Claude Code to my Meta Ads account get me banned?

The Official Answer: Connecting Claude (or ChatGPT, Cursor, or any AI client) to your Meta Ads account is now safe IF you use Meta’s official AI Connectors that launched April 29, 2026. The risk of account bans comes from using unofficial MCP servers and scraper-style tools that operators were getting banned for through 2025 and early 2026.

What Gets Accounts Banned:

  • Using automated tools that interact with Ads Manager outside of Meta’s official Marketing API
  • Unauthorized third-party scripts that may leak information or be used to steal budgets
  • Aggressive API behavior that triggers Meta’s fraud detection systems
  • Full automation with no human oversight

The Safe Approach – Semi-Automation:

 Always start with PAUSED status (default behavior)
meta-ads campaigns create --1ame "Test Campaign" --objective CONVERSIONS
 The campaign is created in PAUSED state

Review before activating
meta-ads campaigns get CAMPAIGN_ID

Only activate after human review
meta-ads campaigns activate CAMPAIGN_ID

Best Practices for Token Management:

  1. Use System Users, not personal accounts – System Users have specific, limited permissions and can be audited
  2. Implement token rotation – Long-lived tokens expire after ~60 days

3. Use the refresh script – `bash scripts/refresh_token.sh`

  1. Never hardcode tokens – Use environment variables or secure secret management
 Set up environment variables
export META_ADS_ACCESS_TOKEN="your_token_here"
export META_ADS_ACCOUNT_ID="act_123456789"

Use in commands
meta-ads campaigns list --account-id $META_ADS_ACCOUNT_ID

The Human-in-the-Loop Principle: Full automation for ad spend is not worth the account risk. Semi-automation – AI drafts, human approves – gets you 80% of the efficiency with 0% of the ban risk.

5. Performance Monitoring and Optimization via CLI

Beyond campaign management, the Ads CLI exposes the Insights endpoint of the Marketing API, allowing operators to query spend, impressions, CTR, and ROAS directly from the terminal.

Real-Time Performance Queries:

 Get campaign-level insights for last 7 days
meta-ads insights get --level campaign --date-preset last_7d \
--fields spend,impressions,clicks,ctr,cpc,conversions,roas

Get ad-level breakdown by age and gender
meta-ads insights get --level ad --date-preset last_7d \
--breakdowns age,gender \
--fields spend,conversions

Export to JSON for analysis
meta-ads insights get --level campaign --date-preset last_30d \
--fields all --output-file campaign_performance.json

Get performance with specific date range
meta-ads insights get --level adset --date-range 2026-01-01:2026-01-31 \
--fields spend,conversions,ctr

Automated Optimization Script Example:

!/bin/bash
 Daily optimization script

Get underperforming campaigns (ROAS < 2.0)
meta-ads insights get --level campaign --date-preset last_7d \
--fields id,name,spend,conversions,roas \
--filtering '[{"field":"roas","operator":"LT","value":2.0}]' \
--output json > underperforming.json

Pause campaigns with spend > $500 and ROAS < 1.5
jq '.data[] | select(.spend > 50000 and .roas < 1.5) | .id' underperforming.json | \
while read campaign_id; do
meta-ads campaigns pause $campaign_id
echo "Paused campaign $campaign_id due to low ROAS"
done

6. API Versioning and the Road Ahead

Marketing API v25.0, which arrived in Q1 2026, brought breaking changes that require developers to use the unified Advantage+ campaign structure. From V25.0, Advantage+ Shopping and Advantage+ App campaigns can no longer be created or updated using the Marketing API. This extends to all MAPI versions after May 19, 2026.

Migration Checklist:

  • Review all existing Advantage+ Shopping and App campaigns
  • Migrate to the new unified Advantage+ structure before the deadline
  • Update automation scripts to use the new campaign objectives and structures
  • Test all CLI and MCP workflows against v25.0 endpoints

What This Means for Automation: Meta is consolidating its advertising API toward a streamlined Advantage+ setup. Advertisers who build automation on top of the CLI and MCP today will benefit from Meta’s ongoing unification efforts, as the official connectors will track API changes automatically.

What Undercode Say:

  • The barrier to entry has collapsed. You no longer need a developer to build API integrations or a media buyer to click through Ads Manager. Natural language + CLI + MCP = full campaign control from anywhere, on any device. The person who can articulate their strategy clearly to an AI now has an unfair advantage over the person who can only execute through dashboards.

  • The real risk is not the tool – it’s the operator. Meta’s official AI Connectors are safe when used correctly. The accounts getting banned are those using unofficial scrapers, ignoring the human-in-the-loop principle, or pushing fully automated spend without oversight. Semi-automation (AI drafts, human approves) delivers 80% of the efficiency with 0% of the ban risk. The discipline to review before launch separates the professionals from the banned.

  • This changes the economics of ad operations. A single media buyer with Claude Code can now manage campaign structures that previously required a team of analysts, developers, and account managers. The 2-hour creative update becomes a 30-second prompt. The campaign restructure that required 20 clicks across 5 screens becomes a single sentence. This is not incremental efficiency – it’s an order-of-magnitude shift in what a single operator can achieve.

Prediction:

  • +1 The Meta Ads CLI and MCP will become the default interface for enterprise ad operations within 18 months. Agencies that adopt these tools early will achieve 3-5x operational efficiency gains over competitors still using Ads Manager as their primary interface.

  • +1 We’ll see the emergence of “AI-1ative media buyers” – professionals who have never touched Ads Manager but can manage million-dollar budgets through natural language prompts. The skill premium will shift from dashboard proficiency to strategic articulation and AI orchestration.

  • -1 The democratization of ad automation will lead to a wave of inexperienced operators launching campaigns without understanding Meta’s auction dynamics, Learning Phase mechanics, or creative fatigue. Expect a temporary increase in wasted spend and account suspensions as the industry adjusts.

  • -1 Meta’s fraud detection systems will need to evolve rapidly to distinguish between legitimate AI-driven automation and malicious activity. The current “human-in-the-loop” requirement may become stricter, potentially requiring explicit approval workflows for any AI-generated campaign changes.

  • +1 The CLI + MCP stack will become the foundation for a new category of ad tech tools – AI agents that not only execute but also optimize, test, and learn across campaigns. The “media buyer” role will transform from execution to strategy, with AI handling the tactical heavy lifting.

▶️ Related Video (82% Match):

https://www.youtube.com/watch?v=5_QP6_EmReQ

🎯Let’s Practice For Free:

🎓 Live Courses & Certifications:

Join Undercode Academy for Verified Certifications

🚀 Request a Custom Project:

Secure, high-velocity infrastructure and disruptive technological engineering. Contact our engineering team for high-tier development and proprietary systems:
[email protected]
💎 Smart Architecture | 🛡️ Secure by Design | ⭐ Trusted by Thousands

IT/Security Reporter URL:

Reported By: Calebkrusemedia Media – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅

🔐JOIN OUR CYBER WORLD [ CVE News • HackMonitor • UndercodeNews ]

💬 Whatsapp | 💬 Telegram

📢 Follow UndercodeTesting & Stay Tuned:

𝕏 formerly Twitter 🐦 | @ Threads | 🔗 Linkedin | 🦋BlueSky