How to Connect Claude Code to Meta Ads Using MCP

The Complete Guide Meta Agentic Ad Optimization

Last Updated on

Build Your 1st AI Agent

At least 10X Lower Cost

Fastest way to automate Growth

Build Your 1st AI Agent

At least 10X Lower Cost

Fastest way to automate Growth

TL;DR

  • MCP (Model Context Protocol) is an open standard developed by Anthropic that lets Claude connect directly to advertising platforms and access live performance metrics in natural language—no manual exports required.

  • Three setup methods: (1) Direct MCP server connection (free, full control), (2) Third-party platforms like Composio or Adzviser (managed, no-code), (3) Google Sheets workaround (free, not real-time).

  • Prerequisites: Claude Code app, Node.js, advertising account with API access, and basic terminal familiarity.

  • Key use cases: Budget pacing alerts, creative fatigue detection, audience optimization, attribution analysis, and placement intelligence.

  • Setup takes ~30 minutes for the direct method: install Claude Code and Node.js, create a developer app and generate an access token, configure Claude's MCP server settings, and test with natural language requests.

  • Security: Access tokens are stored locally, connections are encrypted, and Claude only accesses information when you ask—no background syncing.

  • Advanced features: Automate token refresh, configure custom metrics, manage multiple accounts, and build reusable workflows.

  • Cost: Direct MCP server connection is completely free; third-party platforms start at $0.99-$9/month.

The advertising landscape is shifting beneath our feet. AI assistants like Claude are no longer just writing tools—they're becoming operational partners capable of analyzing live performance metrics, spotting patterns, and surfacing insights that would take hours to uncover manually. But there's a problem: most AI tools still require endless copy-pasting, manual exports, and context-switching between platforms.

Enter the Model Context Protocol (MCP)—Anthropic's open standard that lets Claude connect directly to your advertising account and access live performance metrics in natural language. No more downloading CSVs, no more stale screenshots, no more fragmented workflows.

In this tutorial, you'll learn exactly how to set up a direct integration between Claude Code and your advertising platform using MCP, explore multiple implementation methods (from completely free to managed platforms), and discover practical ai workflows for marketing that transform how you manage paid social. Whether you're a growth professional managing six-figure budgets or a founder running your first promotional efforts, this integration reclaims cognitive bandwidth and lets you focus on strategy instead of spreadsheet gymnastics.

What is MCP (Model Context Protocol)?

The Model Context Protocol is an open standard developed by Anthropic that functions like a universal adapter for AI systems. Think of it as USB-C for artificial intelligence—a single, standardized interface that allows Claude (and potentially other AI assistants) to securely connect to external sources, APIs, and tools in real time.

Before MCP, connecting AI to live information required custom API integrations, complex authentication flows, and constant maintenance as platforms changed their endpoints. Each connection was a bespoke engineering project. The MCP server architecture changes that by providing a consistent framework that handles authentication, retrieval, and security automatically.

When you connect Claude to your advertising platform via an MCP server, you're essentially giving Claude a secure, read-only window into your performance metrics. You can ask questions like "Which initiatives have a frequency above 4?" or "Show me my cost per acquisition trend over the last 14 days," and Claude retrieves live information directly from the API—no manual exports required.

Why MCP Matters for Marketers

Traditional analytics workflows are fragmented: you log into your dashboard, export a CSV file, open Google Sheets or Excel, create pivot tables, build charts, and then start analyzing. Each step introduces friction, delays, and opportunities for error.

The Model Context Protocol collapses this entire workflow into a single conversational interface. Instead of wrestling with dashboards, you simply ask Claude questions in plain English. The AI handles the retrieval, processing, and presentation—delivering insights in seconds rather than hours.

This isn't just about convenience. It's about reclaiming cognitive bandwidth. When you're not spending mental energy on wrangling spreadsheets, you can focus on what actually moves the needle: creative strategy, audience experimentation, and growth hypotheses. With the rise of ai marketing automation platform solutions, this shift is transforming how professionals operate.

MCP vs Traditional API Integrations

Traditional API integrations require developers to write custom code for authentication (OAuth flows, API keys, token refresh logic), build parsing logic to transform API responses into usable formats, and maintain the integration as platforms update their endpoints.

The MCP server protocol abstracts all of this complexity. It handles authentication automatically, standardizes access patterns across different platforms, and provides a consistent interface regardless of the underlying API structure.

For growth teams, this means you can connect Claude to multiple platforms—Google Ads, Shopify, HubSpot, and dozens of other services—using the same basic setup process. No engineering team required. This is a perfect fit for teams seeking the best ai tool for growth marketing without needing technical resources.

Understanding the Claude + Meta Ads Connection

Connecting Claude Code to your advertising platform via MCP unlocks a new category of workflows—ones where AI acts as an analytical co-pilot rather than just a content generator.

Once connected, Claude can access your account in real time, including performance metrics (impressions, clicks, conversions, spend, ROAS), audience insights (demographics, placement breakdowns, device performance), creative analytics (frequency, engagement rates, creative fatigue indicators), and budget pacing (daily spend vs. budget allocation).

Use Cases: Budget Monitoring, Creative Fatigue Analysis, Audience Optimization

Budget Pacing Alerts: Ask Claude "Are any initiatives pacing above budget this week?" and get instant visibility into spend anomalies before they drain your monthly allocation.

Creative Fatigue Detection: Ask "Which creative assets have a frequency above 5 with declining CTR?" to identify creative burnout before performance tanks. Claude can surface these patterns faster than you can manually cross-reference metrics in your dashboard.

Audience Optimization: Compare performance across lookalike audiences, interest-based segments, and custom audiences by asking "Which audience segment has the lowest CPA?" Claude retrieves the metrics, calculates the results, and presents ranked insights—no pivot tables required.

Attribution Analysis: Track the full funnel from awareness to conversion by examining metrics across different objectives, helping you understand which top-of-funnel initiatives actually drive bottom-funnel results.

Placement Intelligence: Identify your best-performing placements (Facebook Feed, Instagram Stories, Audience Network) by asking Claude to compare cost-per-result across placement types. These insights are integral to building more effective ai workflows.

Prerequisites Overview

Before you begin the setup, ensure you have:

  • Claude Code App: The MCP integration only works with the downloadable Claude Code application (available for macOS and Windows). The browser version of Claude.ai does not support MCP connections. Download from claude.ai/download.

  • Node.js (LTS version): Required to run MCP servers. Download from nodejs.org. After installation, verify by running `node --version` in your terminal—you should see something like `v20.11.0`.

  • Meta Ads Account: You'll need admin access to the account you want to connect. This includes access to Business Manager and the ability to create developer apps.

  • Meta Developer App & API Access: You'll create a free developer app to generate API credentials. No coding knowledge required—we'll walk through every step of the configuration.

  • Basic Terminal/Command Line Familiarity: You'll run a few simple commands to install packages and configure settings. If you've ever installed software via Homebrew or npm, you're already qualified.

Method 1: Direct MCP Connection (Recommended)

This method establishes a direct, secure connection between Claude Code and the Marketing API using an open-source MCP server. It's completely free, gives you full control over your information, and doesn't require third-party platforms. For many, this is the ideal starting point for ai agents for agencies looking to streamline workflows.

Step 1: Install Claude Code & Node.js

Install Claude Code:

  • macOS/Linux/WSL: Open your terminal and run:

curl -fsSL https://claude.ai/install.sh | bash
  • Windows PowerShell:

  • Windows CMD:



After installation, navigate to your project directory in the terminal and launch Claude Code:

cd

Claude Code will open in your terminal. Follow the prompts to sign in with your Anthropic account (you can create a free account at claude.ai if you don't have one). Complete the authentication flow, and you're ready to proceed with the next step.

Install Node.js:

Download the LTS (Long Term Support) version from nodejs.org. The installer will guide you through the setup. After installation, verify it works by running these commands in your terminal:

node --version  # Should output something like: v20.11.0
npm --version   # Should output something like: 10.2.4

Step 2: Get Meta Ads API Credentials

To connect Claude to your advertising platform, you need to create a developer app and generate an access token. This sounds technical, but it's a straightforward point-and-click process.

Create a Meta Developer App:

  1. Go to developers.facebook.com and log in with your Facebook account

  2. Click "My Apps" in the top navigation

  3. Click "Create App"

  4. Select "Business" as the app type

  5. Fill in the app details:

  6. Click "Create App"

Generate an Access Token:

  1. In your App Dashboard, go to Tools → Graph API Explorer

  2. In the "User or Page" dropdown, select your advertising account

  3. Click "Generate Access Token"

  4. When prompted, grant the following permissions:

  5. Click "Generate Token"

  6. Important: This generates a short-lived token (valid for ~1 hour). To get a long-lived access token (valid for 60 days), use the Token Debugger:

Find Your Ad Account ID:

  1. Go to the Ads Manager dashboard (business.facebook.com/adsmanager)

  2. Look at the URL—it contains your account ID in this format: `act_XXXXXXXXXX`

  3. Copy the entire string including the `act_` prefix

Step 3: Install & Configure MCP Server

Now we'll install an MCP server that connects Claude to your advertising platform. We'll use a community-maintained server package or create a simple configuration file.

Create a Configuration File:

Locate your Claude Code config file:

  • macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`

  • Windows: `C:\Users\YourName\AppData\Roaming\Claude\claude_desktop_config.json`

If the file doesn't exist in that directory, create it. Open the file in any text editor (VS Code, Notepad, TextEdit) and add this configuration in JSON format:

{
  "mcpServers": {
    "meta-ads": {
      "command": "npx",
      "args": 
        "-y",
        "@modelcontextprotocol/server-meta-ads"
      ,
      "env": {
        "META_ACCESS_TOKEN": "YOUR_LONG_LIVED_ACCESS_TOKEN_HERE",
        "META_AD_ACCOUNT_ID": "act_XXXXXXXXXX"
      }
    }
  }
}

Replace `YOUR_LONG_LIVED_ACCESS_TOKEN_HERE` with the token you generated in the previous step, and replace `act_XXXXXXXXXX` with your actual Ad Account ID.

Save the configuration file and completely quit Claude Code (Cmd+Q on macOS, Alt+F4 on Windows).

Step 4: Test the Connection

Reopen Claude Code. You should see a small tools icon or indicator showing that MCP servers are active and ready to connect.

Try these test queries to verify the setup:

  • "Show me my initiatives from the last 7 days"

  • "What's my total spend across all initiatives this month?"

  • "Which ad sets have the highest cost per click?"

Claude will retrieve live information from your account and present it conversationally. If you see performance metrics, congratulations—your MCP server connection is working!

Troubleshooting Common Issues

Authentication Errors: If Claude reports an authentication failure, verify that:

  • Your access token is still valid (tokens expire after 60 days)

  • You've granted the correct permissions (ads_read, ads_management, business_management)

  • Your Ad Account ID includes the act_ prefix

To fix an expired token issue, return to the Graph API Explorer and generate a new long-lived access token using the same process.

API Rate Limits: The Marketing API has rate limits (typically 200 calls per hour for standard access). If you hit the limit, Claude will return an error. The solution is to wait an hour or reduce frequency.

Connection Timeouts: If Claude reports a timeout error, check your internet connection and verify that the API is operational (check status.facebook.com for platform status).

"MCP Server Not Found" Error: This usually means the MCP server package isn't installed properly. Run this command in your terminal:

npm install -g

Then restart Claude Code to fix the problem.

Method 2: Using Third-Party MCP Platforms

If you prefer a managed solution that handles authentication, token refresh, and server maintenance automatically, several platforms offer MCP integrations for advertising platforms. Many of these platforms act as a no-code ai workflow builder for professionals and agencies.

Option A: Composio Tool Router

Pros:

  • Managed authentication with automatic token refresh

  • Supports 850+ SaaS integrations beyond advertising platforms

  • Remote workbench for handling large API responses outside LLM context

  • Just-in-time tool loading (only loads tools Claude needs)

Cons:

  • Requires a Composio account (free tier available)

  • Potential costs for high-volume usage

  • Less control over information flow compared to direct connection

Setup Steps:

  1. Sign up at platform.composio.dev

  2. Create a new API key in your Composio dashboard

  3. Install the Composio Python package using this command:

  1. Create an `.env` file with your credentials in your project folder:



  1. Generate an MCP URL using this Python script:

from composio import Composio
import os
from dotenv import load_dotenv

load_dotenv()
composio_client = Composio(api_key=os.getenv("COMPOSIO_API_KEY"))
session = composio_client.create(
    user_id=os.getenv("USER_ID"),
    toolkits="metaads"
)
print(f"MCP URL: {session.mcp.url}")
  1. Add the MCP URL to your Claude Code config using this terminal command:

claude mcp add --transport http metaads-composio "YOUR_MCP_URL" --headers "X-API-Key:YOUR_COMPOSIO_API_KEY"
  1. Restart Claude Code and authenticate when prompted

Option B: Adzviser MCP Server

Pros:

  • No-code setup—connect via dashboard

  • Unlimited MCP queries on paid plans

  • Supports multiple advertising platforms (Meta, Google, TikTok)

  • Secure, encrypted connections

Cons:

  • Requires paid subscription (starts at $0.99 for 14-day trial)

  • Less flexibility than open-source solutions

Setup Steps:

  1. Sign up at adzviser.com

  2. Create a new workspace and select your advertising platform as the source

  3. Grant Adzviser access to your account via OAuth authentication

  4. Select Claude as your destination

  5. Copy the provided MCP URL from Adzviser's dashboard

  6. Add it to Claude Code's config file in JSON format:

{
  "mcpServers": {
    "adzviser": {
      "command": "npx",
      "args": "-y", "@adzviser/mcp-server",
      "env": {
        "ADZVISER_API_KEY": "your_adzviser_api_key"
      }
    }
  }
}
  1. Restart Claude and start querying your performance metrics

Option C: Google Sheets Workaround (Free)

Pros:

  • Completely free

  • No API management required

  • Works with any source that can export to Sheets

Cons:

  • Not real-time (information syncs on a schedule)

  • Requires setting up sync scripts

  • More complex initial configuration

Brief Overview:

This method involves syncing advertising metrics to Google Sheets using the Marketing API and a Python script, then connecting Claude to the Sheet via Google Sheets MCP server. Information updates on a schedule (e.g., daily at 7 AM) rather than in real-time.

For a detailed tutorial of this method, including the complete Python sync script and Google Sheets MCP configuration, see our companion guide: "How to Connect Claude to Google Sheets for Marketing Data Analysis."

Advanced Configuration & Optimization

Once your basic MCP server connection is working, you can enhance it with advanced configurations that make Claude even more powerful.

Automating Data Refresh

Access tokens expire after 60 days. To avoid manual token renewal, set up an automated refresh script using Python or Bash:

import requests
import os
from datetime import datetime, timedelta

def refresh_meta_token(current_token, app_id, app_secret):
    url = f"https://graph.facebook.com/v18.0/oauth/access_token"
    params = {
        "grant_type": "fb_exchange_token",
        "client_id": app_id,
        "client_secret": app_secret,
        "fb_exchange_token": current_token
    }
    response = requests.get(url, params=params)
    new_token = response.json().get("access_token")
    
    # Update your .env or config file
    with open(".env", "r") as f:
        config = f.read()
    
    config = config.replace(current_token, new_token)
    
    with open(".env", "w") as f:
        f.write(config)
    
    print(f"Token refreshed on {datetime.now()}")
    return new_token

# Schedule this script to run every 50 days via cron or Task Scheduler

Setting Up Custom Metrics

You can configure the MCP server to calculate custom metrics that aren't natively available in the API:

{
  "mcpServers": {
    "meta-ads": {
      "command": "npx",
      "args": "-y", "@modelcontextprotocol/server-meta-ads",
      "env": {
        "META_ACCESS_TOKEN": "your_token",
        "META_AD_ACCOUNT_ID": "act_XXXXXXXXXX",
        "CUSTOM_METRICS": "engagement_rate=(likes+comments+shares)/impressions,cost_per_engagement=spend/(likes+comments+shares)"
      }
    }
  }
}

Now when you ask Claude for "engagement rate" or "cost per engagement," it will calculate these on the fly. This is just one way to leverage ai powered marketing tools for deeper insights.

Multi-Account Management

If you manage multiple accounts, configure separate MCP servers for each in your config file:

{
  "mcpServers": {
    "meta-ads-client-a": {
      "command": "npx",
      "args": "-y", "@modelcontextprotocol/server-meta-ads",
      "env": {
        "META_ACCESS_TOKEN": "token_for_client_a",
        "META_AD_ACCOUNT_ID": "act_111111111"
      }
    },
    "meta-ads-client-b": {
      "command": "npx",
      "args": "-y", "@modelcontextprotocol/server-meta-ads",
      "env": {
        "META_ACCESS_TOKEN": "token_for_client_b",
        "META_AD_ACCOUNT_ID": "act_222222222"
      }
    }
  }
}

Then specify which account you're querying: "Show me Client A's performance this week." This is an example of agent orchestration for marketing, making it easy to switch contexts between clients or brands.

Security Best Practices

Never commit access tokens to version control: Use environment variables or secure secret management tools like 1Password, AWS Secrets Manager, or HashiCorp Vault.

Use read-only permissions when possible: If you only need to analyze metrics (not create or modify initiatives), limit your API token to `ads_read` permission only.

Rotate tokens regularly: Even though tokens are valid for 60 days, consider rotating them monthly as a security precaution.

Monitor API usage: Set up alerts for unusual API call patterns that might indicate a compromised token.

Restrict token scope: When creating your developer app, only grant permissions to the specific accounts you need—don't use account-wide access if you only need one account.

Practical Applications & Workflows

Now that your MCP server connection is configured, let's explore real-world workflows that transform how you manage your advertising initiatives.

Daily Ad Performance Reporting

Traditional workflow: Log into the dashboard, select date range, export CSV file, open in Excel, create pivot tables, calculate metrics, format report, email to stakeholders.

MCP workflow: Ask Claude, "Generate a daily performance summary for all active initiatives, including spend, ROAS, and top 3 performers."

Claude retrieves the metrics, calculates the results, and presents a formatted summary in seconds. You can even ask follow-up questions: "Which initiative had the biggest day-over-day spend increase?" or "Show me yesterday's performance compared to last week."

By leveraging ai productivity tools for growth, these workflows free up valuable time for higher-impact tasks.

Creative Fatigue Detection

Creative fatigue happens when your audience sees the same creative asset too many times, causing engagement to drop and costs to rise. The key indicator is frequency (average times each person saw your creative) combined with declining performance.

Example: "Show me all creative assets with frequency above 4 and CTR below 1% in the last 7 days."

Claude surfaces the fatigued creatives instantly. You can then ask: "For these assets, what was the CTR when frequency was below 3?" to understand the performance drop-off point.

This workflow helps you proactively refresh creatives before they tank your account performance.

Budget Pacing Alerts

Budget pacing issues—spending too fast or too slow—can waste money or leave opportunity on the table.

Example: "Calculate the daily budget pacing for all initiatives. Flag any that are spending more than 110% or less than 90% of their daily target."

Claude does the math and highlights initiatives that need attention. You can drill deeper: "For initiatives overspending, which ad sets are driving the excess spend?" This helps you reallocate budget before month-end surprises.

Competitor Analysis

While the MCP server doesn't directly access competitor information, you can use Claude to analyze your own performance against industry benchmarks.

Example: "Compare my average CTR and CPC across all initiatives to these industry benchmarks: CTR 1.5%, CPC $1.20. Which initiatives are underperforming?"

Claude cross-references your metrics with the benchmarks and surfaces underperformers, helping you prioritize optimization efforts.

Frequently Asked Questions

How much does this cost?

The direct MCP server connection (Method 1) is completely free—you only need Claude Code (free or paid subscription) and an advertising account. Third-party platforms like Composio and Adzviser have free tiers and paid plans starting around $0.99-$9/month.

Is my data secure?

Yes. MCP server connections are encrypted, and your access tokens are stored locally on your machine (not in Claude's cloud). Claude only accesses information when you explicitly ask a question—there's no background syncing or storage on Anthropic's servers.

Can I connect multiple Meta Ads accounts?

Yes. You can configure multiple MCP servers in your Claude Code config file, each pointing to a different account. See the "Multi-Account Management" section above for configuration details.

What are the API rate limits?

The Marketing API has rate limits that vary by access level:

  • Standard access: ~200 calls per hour per user

  • Advanced access: Higher limits (requires review)

Each Claude request typically triggers 1-3 API calls depending on complexity. For most use cases, you won't hit rate limits, but if you do, wait an hour or reduce frequency.

Does this work with Instagram Ads?

Yes! Instagram initiatives are managed through the same platform and use the same Marketing API. When you connect Claude to your account, you automatically get access to Instagram performance metrics as well.

Can Claude modify my campaigns, or is it read-only?

By default, the MCP server connection is read-only (using the `ads_read` permission). If you want Claude to be able to pause initiatives, adjust budgets, or create new assets, you can grant `ads_management` permission—but be cautious. Always review Claude's suggestions before implementing changes.

What if my access token expires?

Access tokens are valid for 60 days. When yours expires, Claude will return an authentication error. Simply generate a new long-lived token using the Graph API Explorer (see Step 2 above) and update your config file with the new credentials.

Do I need a paid Claude subscription?

No. The free version of Claude Code supports MCP server connections. However, paid Claude Pro or Team subscriptions offer higher usage limits and priority access during peak times, which can improve response speed for complex requests.

Conclusion & Next Steps

You've just unlocked a fundamentally different way to work with advertising metrics. Instead of wrestling with dashboards, exports, and pivot tables, you now have an AI co-pilot that retrieves live information, calculates performance indicators, and surfaces insights conversationally.

This isn't just a productivity hack—it's a shift in how growth teams operate. When you're not spending mental energy on wrangling spreadsheets, you can focus on what actually drives results: creative experimentation, audience hypotheses, and strategic iteration.

Recommended Starting Path:

If you're new to the Model Context Protocol and want the simplest setup, start with Method 1 (Direct MCP Server Connection). It's free, gives you full control, and takes about 30 minutes to configure.

If you manage multiple clients or want a no-code solution, explore Method 2 (Third-Party Platforms) like Adzviser or Composio.

If you're on a tight budget and don't need real-time metrics, the Google Sheets Workaround is a solid free option.

What to Do Next:

  1. Set up your first MCP server connection using the method that fits your needs

  2. Test with simple requests like "Show me my performance this week"

  3. Build a library of useful prompts for daily reporting, creative analysis, and budget monitoring

  4. Explore advanced workflows like multi-account management and custom metrics

  5. Share with your team so everyone can access insights without logging into the dashboard

The future of operations isn't about better dashboards—it's about conversational interfaces that eliminate dashboards entirely. The Model Context Protocol is the infrastructure that makes this possible.

And if you're looking for a platform that takes this even further—one that lets you design custom ai agents for growth workflows without code, connect them to your entire stack, and deploy them across your team—explore Metaflow AI. It's a natural language ai agent builder built for growth teams who want to move from one-off automations to durable, scalable AI workflows.

Run an SEO Agent

Out-of-the box Growth Agents

Comes with search data

Fully Cutomizable

Run an SEO Agent

Out-of-the box Growth Agents

Comes with search data

Fully Cutomizable

Get Geared for Growth.

Get Geared for Growth.

Get Geared for Growth.