How to Use Claude with the Twitter (X) API

- Claude reads live Twitter/X data through an MCP server — TwitterAPI.io hosts one at
https://mcp.twitterapi.io/mcp - Add it to Claude Code (
claude mcp add) or as a Claude.ai Connector, paste your API key, and Claude gains tweet-search / user / mention tools - No OAuth, no X developer account — API key + one config line, about 5 minutes
- Pay-per-result (~$0.15 / 1,000 tweets), no monthly floor; free starter credits (for new accounts that pass the automatic bot check, one per person and network, expires after 31 days) need no card
To give Claude live access to Twitter/X data, connect it to TwitterAPI.io's MCP server at https://mcp.twitterapi.io/mcp — Claude then calls tools like tweet search, user lookup, and mention tracking, and reasons over the JSON results in the same conversation, with no OAuth flow and no X developer account needed. This guide walks through the full setup for both Claude Code (the CLI) and the Claude.ai Connector, with working examples you can run in about five minutes.
The reason this is suddenly easy is the Model Context Protocol (MCP) — an open standard that lets Claude call external tools. Instead of writing custom glue code to fetch tweets and feed them to Claude, you point Claude at an MCP server that exposes Twitter data as native tools. Claude decides when to call them, passes the parameters, and reads the structured results. TwitterAPI.io, a pay-per-use X (Twitter) API, hosts a ready-made MCP server, so there's nothing for you to deploy.
This works for two audiences: developers building AI agents that need social data (monitoring, research, summarization), and anyone who just wants to ask Claude questions about live tweets in a chat. Both paths are covered below. One thing up front — the MCP server ships read tools only; posting, liking, following and DMs are REST endpoints on TwitterAPI.io that you call from your own code, not Claude tools.
Connecting Claude to live Twitter data via the TwitterAPI.io MCP server takes about 5 minutes: sign in with Google, copy an API key, run one claude mcp add command (or add a Claude.ai Connector). The official X API path requires an OAuth flow plus an X developer account with a saved payment card before you can make the first authenticated call — and $0.005 per post read after that.
What is the Model Context Protocol (MCP)?
MCP (Model Context Protocol) is an open standard that lets an AI model like Claude call external tools and data sources in a structured way. An MCP server advertises a set of tools (each with a name, description, and parameters); the AI client (Claude Code, the Claude.ai app, or any MCP-compatible client) discovers those tools and can invoke them mid-conversation, then read the results. For the protocol itself, including stdio vs Streamable HTTP and the stateless 2026-07-28 revision, see our explainer on what an MCP server is and how clients talk to it.
The key benefit over writing your own integration: you don't build a fetch-format-inject pipeline. The MCP server describes its tools to Claude automatically, Claude decides which tool to call and with what arguments based on your request, and the results come back as structured data Claude reasons over. You connect once; Claude figures out the rest per conversation. If you would rather write your own server with custom tools, our step-by-step Python tutorial shows how to build an MCP server in Python with the official SDK and connect it to Claude Code and Cursor.
For Twitter data specifically, TwitterAPI.io runs a hosted MCP server at https://mcp.twitterapi.io/mcp. It exposes the same underlying capabilities as the REST API — tweet search, user lookup, followers, mentions, real-time rules — as MCP tools. You don't deploy or maintain anything; you just point your Claude client at the URL and authenticate with your API key.
How does Claude access Twitter data through MCP?
The data flow is: Claude → MCP server (mcp.twitterapi.io) → Twitter (X) data → JSON back to Claude. When you ask Claude something like "what is @openai tweeting about this week?", Claude recognizes it needs the tweet-search tool, calls the MCP server with the right parameters, the server queries Twitter data and returns structured JSON, and Claude reads that JSON to answer you — all in one conversation turn.
Authentication is a single API key (no OAuth). You include it once when you configure the MCP connection; every tool call Claude makes is authenticated with that key behind the scenes. Claude never sees or handles OAuth tokens, callback URLs, or refresh flows — the MCP server abstracts all of that.
Crucially, your request target is always mcp.twitterapi.io — Claude is not connecting to twitter.com or x.com directly. The MCP server fetches the public Twitter data on its side and returns it. This is the same SaaS-API model as any other tool integration, not a browser automation or a proxy. The same server URL also works as a remote MCP server for Anthropic's hosted agents: see our guide to Claude Managed Agents, which stores the key as a vault credential.
How to set up the Twitter MCP server with Claude (step-by-step)
There are two ways to connect, depending on which Claude you use. Both need a TwitterAPI.io API key first — sign in with Google at twitterapi.io, copy the key from the dashboard (new accounts that pass the bot check, one per person or network, get free starter credits, no card required, expiring after 31 days). Running Z.ai's ZCode instead? The same hosted server goes under mcp.servers in ~/.zcode/cli/config.json; see how to use ZCode with the Twitter (X) API. If you call Claude from your own code instead of the app, you also need an Anthropic key from the Claude Console; our guide on how to get a Claude API key covers the Console steps, billing and the ANTHROPIC_API_KEY variable. New to Claude Code? If a subscriber sent you a guest pass, our Claude guest pass guide explains how to redeem the free week of Pro without being charged by mistake.
Option A — Claude Code (the CLI): add the MCP server with one command, then Claude Code can call Twitter tools in any session:
Option B — Claude.ai Connector (the web/desktop app): in Claude.ai settings, add a custom Connector pointing at https://mcp.twitterapi.io/mcp, paste your API key when prompted, and the Twitter tools become available in your chats. (Connector availability depends on your Claude plan.)
If your editor is Cursor rather than Claude Code, the same server drops into .cursor/mcp.json; see how to use Cursor with the Twitter (X) API. Using Google's CLI instead? The same hosted server plugs into Gemini CLI through an mcpServers entry in ~/.gemini/settings.json; see how to use Gemini with the Twitter (X) API.
Once connected, test it by asking Claude a natural-language question that needs live data — e.g. "Search the last 24 hours of tweets mentioning 'MCP server' and summarize the themes." Claude will call the search tool, get the JSON, and summarize. If it works, you're done — no further wiring needed.
If you would rather give Claude Code a plain-text skill than a server, the same six reads are packaged as a SKILL.md in our SKILL.md explained guide, installable with one npx skills add command. To roll that skill out to a whole team, list it in a plugin catalog as shown in our Claude Code skills marketplace guide.
What can Claude do with Twitter data once connected?
Once the MCP server is connected, Claude can do anything that combines reasoning with live Twitter data. Common patterns:
Sentiment + theme summarization: "Pull the last 200 tweets mentioning my brand and group them by sentiment and topic." Claude searches, reads the results, and produces a structured summary — no separate NLP pipeline.
Real-time monitoring digests: "Every time you run, check what these 10 competitor accounts posted since yesterday and flag anything about pricing or launches." Claude calls the user-timeline tool per account and reasons over the deltas.
Research + fact-gathering: "Find the highest-engagement tweets from AI researchers this week about long-context models." Claude uses advanced search with engagement filters and ranks the results.
Lead/prospect discovery: "Find people tweeting that they're looking for a Twitter data API and summarize who they are." Claude searches intent phrases, looks up profiles, and synthesizes a list.
Because Claude orchestrates the tool calls itself, you describe the outcome in plain language and Claude figures out which tools to chain — you don't script the API calls. To run the same workflows from your own Python or TypeScript program instead of the Claude app, see our guide to building an X research agent with the Claude Agent SDK.
How much does it cost to run Claude on Twitter data?
Two cost layers, both modest. Claude usage is your normal Claude subscription or API billing — unchanged by adding an MCP server. Twitter data is billed by TwitterAPI.io at pay-per-result: about $0.15 per 1,000 tweets returned ($0.00015 per tweet, so a full 20-tweet page is $0.003; the minimum per request is $0.00015), with no monthly floor and no monthly cap. For per-model token rates, Batch API and caching discounts, and an estimated cost to tag 1,000 real tweets on each model, see our Claude API pricing breakdown. Which model you run matters more than the data: our guide to the best Claude model for coding prices the same X-data task on Opus 5.5, Sonnet 5.5, Haiku 5.5 and Fable 5.1.
A new TwitterAPI.io account that passes the automatic bot check includes free starter credits (one per person and network) with no card required, expiring after 31 days — enough for Claude to run a batch of real queries while you evaluate. For ongoing use, a typical Claude-driven monitoring or research workflow calling a few thousand times a month costs single-digit to low-double-digit dollars.
Compared to the official X API (which requires OAuth, an X developer account with a saved payment card, and $0.005 per post read with a 3,000,000-read monthly cap), the pay-per-result model is about 33x cheaper per read ($0.00015 against $0.005 per post) and suits the bursty, exploratory call patterns that AI-agent workflows produce — you pay only for the calls Claude actually makes. If you are choosing between Claude and Grok Bot for X work, our Grok Bot vs Claude comparison prices the same 20-account digest on both lanes.
What are the limits of running Claude on Twitter data?
A few constraints worth knowing before you build on this:
No write tools. The MCP server ships read tools only, so Claude cannot post, like, follow or send a DM through it. Writes are REST endpoints on TwitterAPI.io that act as your own logged-in X account; call them from your own code, keep a human pace, and expect X to rate-limit or lock an account that posts too fast. The MCP server ships read tools only, so Claude cannot send a DM through it. Sending a DM is a REST endpoint, send_dm_to_user ($0.0006 per message), which posts from your own logged-in X account with the same caveats as the other write endpoints; it is not exposed as a Claude tool.
Data freshness is near-real-time, not instant. Tweets are typically available seconds to tens of seconds after posting. If you need new tweets pushed to you instead of having Claude poll, use Twitter Stream account monitoring, where the majority of tweets arrive within seconds.
Write operations need human-paced frequency. Claude can post, like, retweet, and follow through the tools, but those actions must stay within human-like rates and within X's automation rules. Don't have Claude batch-like hundreds of tweets in a loop.
Claude's context window bounds result size. A search returning thousands of tweets won't all fit in context — paginate (the tools return cursors) and have Claude process in batches, or pre-filter with a tighter query.
Common errors and fixes
"MCP server not found" / connection fails: confirm the URL is exactly https://mcp.twitterapi.io/mcp and that your Claude client restarted after adding it (Claude Code: re-run the session; Claude.ai: reload).
"Unauthorized" / 401 on tool calls: your API key is missing or wrong in the MCP config. Re-copy it from the TwitterAPI.io dashboard and re-add the connection.
Claude doesn't use the tools: be explicit in your prompt that you want live data ("search Twitter for…"). If Claude still doesn't call a tool, confirm the server is connected (Claude Code: it lists connected MCP servers; Claude.ai: the Connector shows as active).
Timeout on large searches: tighten the query (add a time window, language, or engagement filter) so the result set is smaller, or ask Claude to paginate with the returned cursor instead of pulling everything at once.
# Option A — Claude Code (CLI): add the TwitterAPI.io MCP server
# (get YOUR_KEY from the twitterapi.io dashboard — free starter credits for new accounts: bot check, one per person or network, expires after 31 days, no card)
claude mcp add --transport http twitterapi https://mcp.twitterapi.io/mcp \
--header "Authorization: Bearer YOUR_KEY"
# Verify it's connected:
claude mcp list
# → twitterapi https://mcp.twitterapi.io/mcp (connected)
# Now in any Claude Code session, just ask in natural language:
# "Search the last 24h of tweets mentioning 'MCP server' and
# summarize the main themes."
# Claude calls the search tool on mcp.twitterapi.io, reads the JSON,
# and summarizes — no code from you.
# Option B — Claude.ai Connector (web/desktop):
# Settings → Connectors → Add custom connector
# URL: https://mcp.twitterapi.io/mcp
# Header: Authorization: Bearer YOUR_KEY
# Save → the Twitter tools appear in your chats.
# Prefer raw REST (no MCP)? The same data is one curl away:
curl -s -H "X-API-Key: YOUR_KEY" \
"https://api.twitterapi.io/twitter/tweet/advanced_search?query=MCP+server&queryType=Latest" \
| head -c 600Researching this?Free starter credits cover end-to-end testing — Google sign-in, no card. Get a key.
Questions readers ask
Can Claude read tweets in real time?
Yes. Once you connect the TwitterAPI.io MCP server, Claude can search and read tweets that are seconds to tens of seconds old. If you need new tweets pushed to you rather than having Claude poll, use Twitter Stream account monitoring, where the majority of tweets arrive within seconds — but for conversational use, the search tools return current data fast enough.
Do I need a Twitter (X) developer account to connect Claude?
No. The TwitterAPI.io MCP server only needs a TwitterAPI.io API key: Google sign-in, no card, and free starter credits for new accounts (bot check, one per person or network, expires after 31 days). You do not need an X developer account, OAuth credentials, or a payment card saved on X. That's the main reason this setup takes ~5 minutes.
Does this work with both Claude Code and Claude.ai?
Yes. Claude Code (the CLI) connects via claude mcp add --transport http twitterapi https://mcp.twitterapi.io/mcp --header "Authorization: Bearer YOUR_KEY". Claude.ai (web/desktop) connects by adding a custom Connector pointing at the same URL with the API key header. Both expose the same Twitter tools; Connector availability on Claude.ai depends on your plan.
Can Claude post tweets, not just read them?
Not through the MCP server: it ships read tools only. Posting, liking, retweeting and following are REST endpoints on TwitterAPI.io that you call from your own code, acting as your own logged-in X account (keep the frequency human-paced and within X's automation rules). The MCP server ships read tools only, so Claude cannot send a DM through it. Sending a DM is a REST endpoint, send_dm_to_user ($0.0006 per message), which posts from your own logged-in X account with the same caveats as the other write endpoints; it is not exposed as a Claude tool.
How is the MCP server different from the official X API?
The MCP server is a connection layer that lets Claude call Twitter tools natively; underneath, TwitterAPI.io fetches the data. Versus the official X API: no OAuth, no X developer account, about $0.00015 per tweet instead of $0.005 per post read (about 33x cheaper per read), and no 3,000,000-read monthly cap. The official X API is still required for things like Ads API access or official partner status.
Is my API key safe in the MCP config?
Your key is stored in your local Claude Code config (or your Claude.ai Connector settings) and sent as an Authorization: Bearer header on tool calls to mcp.twitterapi.io over HTTPS. Treat it like any API secret — don't commit it to a public repo or paste it into shared prompts. You can rotate it anytime from the TwitterAPI.io dashboard.
What can I actually build with Claude + Twitter data?
Common builds: real-time brand-monitoring digests, competitor-tracking reports, sentiment summaries, intent-based lead discovery, and research over public conversations. Because Claude orchestrates the tool calls from your natural-language request, you describe the outcome and Claude chains the search / user-lookup / mention tools itself — no scripted API pipeline.
Continue
- Model Context Protocol — official specification and introduction
- Anthropic: connecting MCP servers to Claude Code
- Anthropic: Model Context Protocol overview
- X (Twitter) API — official product page (for comparison)
- X API MCP server: 12 read-only Twitter/X tools, copy-paste config for Claude and Cursor
- TwitterAPI.io MCP + API docs →
- Pay-per-use pricing →
- The best third-party Twitter API in 2026 →
- How much does the X API cost in 2026? →
- How to use Cursor with the Twitter (X) API
- How to use Gemini with the Twitter (X) API
- LangChain + Twitter (X) API: document loader, tools and agent
- Vercel AI SDK with the Twitter (X) API
- CrewAI with the Twitter (X) API
- OpenClaw Twitter (X) skill and MCP setup
- OpenAI Codex with the Twitter (X) API
- SKILL.md explained guide
- Grok Bot vs Claude comparison
- how to use ZCode with the Twitter (X) API
- What an MCP server is and how clients talk to it
- Build an MCP server in Python
- Claude API pricing breakdown
- how to get a Claude API key
- building an X research agent with the Claude Agent SDK
- Claude Managed Agents
- best Claude model for coding
- Claude guest pass: what it is, who can send one and how to redeem it
- Claude Code skills marketplace guide
- 01Soft Block on Twitter (X): What It Is, What They See, and When to Use Remove Follower Instead
- 02Twitter (X) 2FA: How to Turn On Two-Factor Authentication
- 03Twitter (X) API + Streamlit: Build a Live Hashtag Dashboard
- 04X API 402 Payment Required: What It Means on Twitter (X) Pay-Per-Use and How to Fix It
- 05x-rate-limit-reset and the Other Twitter (X) API Rate-Limit Headers, Decoded
- 06Claude Cowork vs Claude Code: Which Anthropic Agent Fits Your Work (and Your Twitter (X) Data)?
- 07How Will You Use the Twitter (X) API or Twitter Data? Answering the Developer Sign-Up Question
- 08Perplexity vs Claude for research, and how to give either one live Twitter (X) data
Writing about something you built with TwitterAPI.io? Our community rewards program pays API credits for honest tutorials, build logs and videos.
Stop reading. Start building.
Starter credits cover real testing on real data. Google sign-in, no card, no application queue.
Get an API keyAlready building with TwitterAPI.io? Publish an honest tutorial or build log about it and earn up to $200 a month in API credits.