Research & Benchmarks Optimization AI Ads Analytics Why Madgicx? About Us Blog Careers Case Studies Events Glossary Guides Answers Pricing Login Try for Free

How to Connect Facebook Ads to Claude Code

Category
AI Marketing
Date updated
Nov 12, 2026
Reading time
30 mins
How to Connect Facebook Ads to Claude Code

One terminal command connects Claude Code to your Facebook ad accounts through the Madgicx MCP. Learn the scopes, the sign-in and the first prompts to try.

To connect Facebook ads to Claude Code, run one command in your terminal, claude mcp add --transport http madgicx https://mcp.madgicx.com/mcp, then type /mcp inside Claude Code and sign in with your Madgicx login. After you pick a team, you can ask Claude Code about your Facebook ad accounts straight from the terminal.

This guide follows Anthropic's Claude Code documentation. If you use Claude on the web or desktop instead, read how to connect Facebook ads to Claude.

Connect Claude Code to your Facebook ads

One command adds the Madgicx MCP. Sign in, then ask about your ad accounts from the terminal. Included in the 7-day free trial.

Start your 7-day free trial

What you need before you connect Facebook ads to Claude Code

  • A Madgicx subscription or the 7-day free trial. The trial includes the MCP, so you can set this up before you pay.
  • A Facebook ad account connected in Madgicx. If it shows under Settings, Ad Accounts in Madgicx, the assistant can reach it.
  • Claude Code installed and signed in. Anthropic's overview says most surfaces need a Claude subscription or an Anthropic Console account. Check your own plan in Claude Code.

For the bigger picture, see Madgicx's Meta ads MCP server, which lists what the connection can read and change. To connect other assistants, here is how to connect your AI assistant.

Set up the Madgicx MCP in Claude Code, step by step

  1. Open a terminal in the project folder you work from.
  2. Add the server:
    claude mcp add --transport http madgicx https://mcp.madgicx.com/mcp
  3. Choose where the setting lives with the --scope flag. Claude Code supports three scopes: local (the default) keeps the server private to you in the current project, project shares it with everyone through a .mcp.json file, and user makes it available in all your projects. For your own ad accounts, user scope is usually the most convenient:
    claude mcp add --transport http --scope user madgicx https://mcp.madgicx.com/mcp
    Avoid project scope unless your whole team should share the connection, since that file goes into your repository.
  4. Start Claude Code if it is not already running.

Sign in with your Madgicx login

Inside Claude Code, type /mcp, select madgicx and follow the steps in your browser. Log in to Madgicx, pick a team and approve access. The team decides which Facebook ad accounts Claude Code can use. Claude Code refreshes the tokens automatically after that.

You can also start the sign-in from the shell with claude mcp login madgicx. To disconnect later, choose Clear authentication in the /mcp menu.

Check that the connection works

Run /mcp again. The panel shows the tool count next to each connected server, so madgicx should list its tools. Then ask: “What Madgicx team am I connected to?” Claude Code should answer with your name and team.

How to get clear answers from Claude Code

Claude Code only knows what the Madgicx MCP returns, so be specific. Name the ad account if you have more than one, give a date range such as the last 7 days, and say which numbers you care about, such as spend, cost per result or ROAS. If an answer looks off, ask Claude Code to show which account and dates it used, then compare with Ads Manager. Keep early questions read only until you trust the setup.

Three prompts to try first in Claude Code

Start with questions that only read, and name the date range each time so the answer is clear.

  1. Who am I connected as? “What Madgicx team am I connected to, and which Facebook ad accounts can you see?” Once that works, you can audit a Facebook ad account in one conversation.

  2. List my ad accounts. “List my Facebook ad accounts with their status, currency and amount spent.” If you run several, here is how to manage multiple ad accounts.

  3. Last 7 days by campaign. “Show the last 7 days by campaign: spend, results, cost per result and ROAS, as a table.” To turn that into a shareable summary, see how to make a Facebook ads report.

Results come back as one total per campaign for the dates you choose, using Meta's own calculated rates. To see a trend, ask for two periods separately, such as this week and last week.

What the Madgicx MCP reads and changes

The connection can read your ad accounts, campaigns, ad sets, ads, creatives, Facebook Pages and posts, results at every level, the account change history and Event Match Quality.

It can also change things: pause and restart campaigns, ad sets and ads, change budgets and bids, and edit names in bulk. Every change needs your confirmation. Claude Code shows the exact change first, such as which campaign and what new budget, and waits for you to say yes before anything runs. See how to pause ads after you confirm and scale budgets after you confirm. For how access is limited, read how to connect AI assistants to Meta ads safely.

Add the Google Ads MCP to Claude Code (read only)

Madgicx also runs a Google Ads MCP. It only reads: Claude Code can analyze search terms, keywords, placements and performance by device or hour, and it changes nothing in Google Ads. It needs a Google Ads account linked in Madgicx. The same Madgicx login authorizes both servers, and Claude Code picks the right one for each question.

Add the Google Ads server as a second entry:

claude mcp add --transport http --scope user madgicx-google https://mcp-google-ads.madgicx.com/mcp
Then run /mcp and sign in for that server too. Both servers appear in the panel.

Troubleshooting

  • No sign-in prompt. Run /mcp and select madgicx to start the browser sign-in, or run claude mcp login madgicx. If your setup cannot open a browser, use the client ID and secret from Workspace Settings, MCP Integration in Madgicx.
  • Tools do not show in the /mcp panel. Confirm your Madgicx subscription or trial is active and a Facebook ad account is connected in Madgicx. Restart Claude Code, then check the panel again.
  • Claude Code shows the wrong accounts. The team you picked at sign-in sets the accounts. Clear authentication in /mcp and sign in again to pick another team.
  • A long answer gets cut off. Claude Code warns when a tool result is very large. Ask for one campaign or a shorter date range instead.

More detail is in the Madgicx MCP docs.

Try it on your own ad account

The MCP gives Claude Code a read on your Facebook ad accounts. Madgicx is also the agentic AI advertising platform for Meta ads and an official Meta Business Partner, with an AI marketer that prepares actions for you to approve. To see the connection working before you commit, the 7-day free trial includes the MCP.

Try Madgicx free for 7 days

FAQ

How do I connect Facebook ads to Claude Code?

Run claude mcp add --transport http madgicx https://mcp.madgicx.com/mcp, then type /mcp in Claude Code and sign in with your Madgicx login. Pick a team when asked.

Which scope should I use?

Local keeps the server private to you in one project, user makes it available in every project, and project shares it with your team through a .mcp.json file. Most people use user scope for their own ad accounts.

How do I know it is connected?

Open /mcp. The panel shows the tool count next to the madgicx server. You can also ask what Madgicx team you are connected to.

Can Claude Code change my Facebook campaigns?

It can pause and restart ads and change budgets and bids, but only after it shows the exact change and you confirm.

Do I need a paid Madgicx plan?

You need a Madgicx subscription or the 7-day free trial, which includes the MCP.

Working in a different assistant? See how to use ChatGPT for Facebook ads, connect Meta ads to Gemini, connect Meta ads to Grok or automate Meta ads with n8n.

You scrolled so far. You want this. Trust us.