X Ads connector for Claude Code

Use Porter’s X Ads connector for Claude Code to pull promoted post, engagement and spend data into your terminal, then turn it into files, scripts and scheduled reports in your own project.

  • Save X Ads data as CSV in your repo
  • Rank promoted posts by cost per engagement
  • Run a weekly X Ads report from a script
  • Compare X with LinkedIn Ads for B2B
G2★★★★★Rated 4.6/5 from 288 G2 reviews (October 2026) · Used by 1,600+ marketing teams and agencies

By · Last updated November 26, 2026

Claude Codeporter connected
Rank last month’s promoted posts by cost per engagement and save it to reports/x-posts.csv
porter / X Ads / Trailgear Demo✓ 4 rows
Saved reports/x-posts.csv with 4 posts. The trail guide thread earns engagements cheapest; the sale post costs the most.
PostSpendEngagements
Trail guide thread$4203,180
Gear checklist$6102,940
Founder story$3801,260
Sale post$520690
Demo data, Trailgear Demo account
330 X Ads fields
01Setup

How to connect X Ads to Claude Code

Connecting X Ads to Claude Code takes 3 steps and no API keys: connect your X ad accounts in Porter with your X account, add Porter’s MCP server to Claude Code with one command, then sign in from /mcp and ask. The same server also works in Cursor, VS Code and Codex, as Porter’s X Ads MCP server page shows. Using the Claude app instead? See the X Ads connector for Claude.

Before you start

  • You need Claude Code installed (Anthropic’s Claude Code overview), a free Porter account and an X user with access to the ad account.
  • Works with any Claude model in Claude Code, from Opus to Sonnet and Haiku.
  1. Step 1: Connect X Ads in Porter

    Sign up free at Porter, pick X Ads as the source and sign in with your X account. Tick every X ad account you want Claude Code to read.

  2. Step 2: Add Porter to Claude Code

    In your terminal, run this command. It adds Porter for every project on your machine; drop --scope user to add it to the current project only.

    Terminal
    claude mcp add --transport http --scope user porter https://mcp.portermetrics.com/mcp

    Or, inside Claude Code, install Porter’s plugin, which adds the server and Porter’s skill together: /plugin marketplace add portermetrics/porter, then /plugin install porter-metrics@portermetrics.

  3. Step 3: Sign in and ask

    Start claude, type /mcp, pick porter and sign in with the Google account you use in Porter. When porter shows as connected, paste this prompt:

    Prompt
    Which X ad accounts can you see? For the last 30 days, show Spend, Impressions and Engagements by Campaign name and save the table to reports/x-campaigns.csv.

Guides and videos

app.portermetrics.com / create
Porter's Select accounts window for X Ads with a demo account and the Connect button
First, in Porter, open X Ads and select Connect.
X sign-in screen you see when you connect X Ads to Porter
Then, sign in to X and authorize Porter Metrics.
$ claude mcp add --transport http --scope user porter https://mcp.portermetrics.com/mcp

$ claude mcp list
porter: https://mcp.portermetrics.com/mcp (HTTP)
Then, add Porter's MCP server from your terminal.
> /mcp
porter · needs authentication → Authenticate

> Which X Ads accounts can you see?
● porter - list_accounts (MCP)
Trailgear Demo
After you sign in from /mcp, Claude Code lists your X Ads accounts.
02Use cases and prompts

What you can do in Claude Code

Claude Code works inside your project, so X Ads answers can become files, scripts and dashboards instead of chat replies. Each use case has a prompt to copy and uses the X Ads fields Porter reads.

Can Claude Code export X Ads data?

The problemX Ads Manager exports need cleanup before anyone can use them.

What Claude Code doesClaude Code pulls Spend, Impressions, Engagements and Link clicks by campaign and ad group through Porter and writes them to a CSV.

What you getA clean data file in your repo, ready for a notebook or a teammate.

Prompt
For the last 30 days, by Campaign name and Ad Group name, pull Spend, Impressions, Engagements and Link clicks from X Ads and save it as data/x-ads-30d.csv.

Can Claude Code find my cheapest promoted posts?

The problemThe posts that earn engagement cheaply are buried in a long list.

What Claude Code doesClaude Code pulls each promoted post with its Tweet text, calculates cost per engagement and writes a ranked list.

What you getA short list of posts worth more budget, and the ones to stop promoting.

Prompt
For the last 30 days, by Promoted Tweet id and Tweet text, show Spend, Impressions, Engagements and Link clicks. Calculate cost per engagement and save the posts ranked from cheapest to most expensive to reports/x-posts.csv.

Can I schedule an X Ads report with Claude Code?

The problemX Ads results sit in their own dashboard, so they rarely make it into the weekly paid social report.

What Claude Code doesA weekly claude -p job pulls Spend, Impressions, Engagements and Link clicks per X Ads campaign for both weeks.

What you getreports/x-weekly.md, so X sits in the same weekly folder as your other channels.

Prompt
claude -p "Compare last week with the week before for every X Ads campaign: Spend, Impressions, Engagements and Link clicks. Write a short summary to reports/x-weekly.md" --allowedTools "mcp__porter" "Write"

Can Claude Code compare X Ads and LinkedIn Ads?

The problemB2B teams run both, but each reports in its own columns.

What Claude Code doesClaude Code pulls spend, clicks and results from both through the same porter server and writes one table.

What you getOne file with both platforms side by side.

Prompt
For the last 30 days, pull Spend and Link clicks from X Ads and the same from LinkedIn Ads, by week, and save one comparison table to reports/x-vs-linkedin.csv.

Can Claude Code report X video ads?

The problemVideo starts and full views live in different columns, so cost per view takes a spreadsheet.

What Claude Code doesClaude Code pulls Video starts and Video views per promoted post and calculates cost per view.

What you getA video report you can drop into your weekly deck.

Prompt
For the last 30 days, by Promoted Tweet id and Tweet text, show Spend, Video starts and Video views, calculate cost per video view and save it to reports/x-video.csv.
03Why Porter

Why Porter for X Ads in Claude Code

Porter reads every X ad account your user can reach, with no developer app or API keys, and puts X next to 30+ other marketing sources behind the same server.

✓

One server for all your sources

The same porter server answers about X Ads, Meta Ads, Google Ads, GA4 and Shopify, so one script can pull every channel.

⊞

Changes only after you approve

Claude Code can pause ads and change budgets through Porter, and each change waits for your yes.

⚙

No developer app or keys

You sign in with X in Porter and with Google in Claude Code. There is no X developer app, API key or token to maintain.

↻

Hosted dashboards when a file isn’t enough

Ask for a Porter AI dashboard and it is published at its own link, synced automatically and ready to share with a client.

04Dashboard

Dashboard template

Start from a ready-made X Ads template, or ask Claude Code to build a live one with AI dashboards.

AI dashboards

Build a live X Ads dashboard from your terminal

Describe the dashboard in one sentence and Porter builds it. A client-ready dashboard in minutes, with no chart dragging and no BI tool to learn. Ask Claude Code:

Prompt
Build a live X Ads dashboard for my account with the last 30 days, the main KPIs and a weekly trend.
Live URLEach dashboard at its own link: no login, no app, no download
Auto-syncFresh X Ads data, nobody re-exports each period
Scheduled deliveryEmail or PDF sends on a set day
White labelYour logo and branding for clients
Sharing permissionsView or edit access per person

Or start from a template

05Pricing

Pricing

You can start free, since Porter’s X Ads connector for Claude comes with every plan. Use the calculator for your number of accounts, or see Porter pricing for every plan.

What you get

  • Free plan: never expires, with unlimited connected accounts and the last 15 days of data in Claude (30 days in Data Studio and Sheets)
  • Reporting: from $12.50 per account a month billed annually, or $15 month to month for one account
  • Billing: each connected X ad account counts as one account, with volume discounts and no per-seat fee
  • Changes: 1 AI credit per completed change; failed tasks are free, and the Free plan includes 100 credits a month
  • Trial: 14 days of full access, no card

Price calculator

$33.33/mo$6.67 per account

An account is one ad account, Stripe account, store, page or GA4 property. The Free plan never expires and has unlimited accounts, with the last 15 days of data in AI chats.

06Data and actions

X Ads data Claude can use

The X Ads connector gives Claude 330 fields: campaigns, ad groups, promoted posts, spend, delivery, engagements, followers, video, conversions, budgets, UTM tags and audience breakdowns. It also adds 18 actions to read, create, change and delete. The full X Ads field reference has the rest, while Claude works out CPE, CPM, CTR and engagement rate from raw counts.

The 12 X Ads fields Claude uses most

Most questions need only these 12.

FieldWhat it's for
Date · Weektwitter_ads_date · twitter_ads_weekDaily trends and weekly fatigue checks
Account Nametwitter_ads_account_nameOne row per ad account or client
Campaign name · Ad Group nametwitter_ads_campaign_name · twitter_ads_ad_group_nameRankings by campaign or ad group
Objectivetwitter_ads_objectiveComparing campaigns bought on the same result
Promoted Tweet id · Tweet texttwitter_ads_promoted_tweet_id · twitter_ads_tweet_textPost-level rankings with the copy
Spendtwitter_ads_spendEvery cost Claude calculates: CPM, CPE, CPC
Impressionstwitter_ads_impressionsCPM and every rate
Clicks · Link clickstwitter_ads_clicks · twitter_ads_link_clicksCTR and cost per link click
Engagements · Billed Engagementstwitter_ads_engagements · twitter_ads_billed_engagementsCPE and engagement rate
Followstwitter_ads_followsCost per follower (check against X Ads Manager)
Video views · 3s/100% video views · 6s video viewstwitter_ads_video_views · twitter_ads_video_3s100pct_views · twitter_ads_video_6s_viewsCost per view and view rates
Age · Gender · Platformtwitter_ads_age · twitter_ads_gender · twitter_ads_platformsAudience splits, one per question

Can Claude create, pause or change X Ads campaigns?

Yes. Claude creates campaigns with budgets and dates, as well as ad groups with objective, product type, placements, bid and budget.

It also creates Promoted-only posts from text, or from media and cards already in your X account. Then it promotes a post in an ad group or removes it. In addition, it pauses or resumes campaigns and ad groups, changes names, budgets, bids and end dates, and deletes campaigns and ad groups.

Media uploads, cards, custom audiences, targeting and promotion edits stay in X Ads Manager, where you handle them as usual.

How fresh is the data, and how far back?

Totals reach Claude in near real time. Most metrics are final after 24 hours, per X's notes on when ad metrics are final. Spend, however, can stay an estimate for up to 3 days. Age, gender and platform splits can also lag up to an hour.

Ask for a year or less per question. Paid Porter plans have no history cap, while the free plan reads 15 days in AI chats (30 days in Data Studio and Sheets).

Product stats

WhatX Ads connector
Fields330 across campaigns, ad groups, promoted posts, delivery, engagements, video, conversions, budgets and audience splits
Actions18 to read, create, change and delete; media, cards, custom audiences and targeting stay in X Ads Manager
FreshnessNear real time; most metrics final after 24 hours, spend can stay an estimate for up to 3 days
HistoryNo cap on paid plans, a year or less per question; 30 days on the Free plan, 15 in AI chats
Rate limits250 analytics requests per 15 minutes per user, set by X
BreakdownsAge, gender or platform, one per question
AccessX's own sign-in; valid until you revoke it

See all 330 X Ads fields

07Security

Is it safe?

Yes, with approvals: the X Ads connector for Claude Code shows every change before Porter sends it, so nothing changes until you confirm. Deletes and removed promotions are permanent, so pausing is the safer fix. Porter signs in with X's own OAuth, so it only gets the access your X user already has on the ad account.

How approvals work

Claude lists each campaign, ad group, budget or post change, then waits for your yes before Porter writes it. Budgets and bids travel in X's micros (1,000,000 per currency unit), and Claude converts them for you.

Deleting a campaign, ad group or promotion is permanent, so pause when you might want it back. A live promotion stays as you approved it, so review it first. Each completed change also uses 1 AI credit.

What the connector needs from X Ads

When you connect, use an X user with access to the ad account. Agencies can also work through access an advertiser grants their @username, as X's guide to ad account access explains.

X access tokens stay valid until you or the account admin revoke the app (X's OAuth FAQ on access tokens). If an account shows no data, reconnect X Ads in Porter.

08FAQ

FAQ

Answers on setup, scope, scripts and credits, plus fixes for the most common Claude Code errors with X Ads. Setup questions every source shares, like where Claude Code saves the server and how to share it with your team, are in the Claude Code hub FAQ.

Can I add LinkedIn Ads to the X Ads report?

Yes. Connect LinkedIn Ads in Porter and ask for Spent and Clicks next to the X Ads fields in one prompt. Claude Code writes both platforms to the same file.

Do Claude Code questions use Porter credits?

Reading X Ads data uses no AI credits. Each completed change, such as pausing an ad group, uses 1 credit, and every Porter account gets 100 free credits a month.

Troubleshooting

Why does /mcp show porter as needing authentication?

Claude Code adds the server before you sign in. Pick porter in /mcp, choose Authenticate and sign in with the Google account you use in Porter.

Why does my claude -p script stop and ask for permission?

Scripts can’t answer permission prompts. Pass the tools the script may use, for example --allowedTools "mcp__porter" "Write", so Claude Code can read Porter and save files without stopping.

Why does Claude Code see my ad accounts but return no data?

Usually the X user lost access to that ad account, or the date range had no delivery. Reconnect X Ads in Porter and ask again with a range that had spend.

09Next

More Claude connectors

Porter brings more than X Ads into Claude, and also sends X Ads to more places than Claude. Browse all Claude connectors for another ad platform, or pick free Data Studio dashboard templates or a warehouse or spreadsheet route for your X data. Each page also lists that connection's setup and data.

Not only Claude. Send X Ads data anywhere

The same Porter account and connection also send X Ads data to these destinations, at no extra cost.

Try the connector in Claude Code

Porter’s X Ads connector for Claude Code takes one command, so your first X Ads file can land in your project today. Start with a CSV, then rank your posts or schedule a weekly script.

Free plan · 14-day trial · No card needed

B2B marketers: X and LinkedIn spend land in one file from the terminal.

Agencies: one script builds the Monday report for every client ad account.

Social media managers: promoted post costs get ranked without an export.