+ Integration Guide
· Updated August 29, 2026
Search Twitter/X from Claude Code Using MCP
Add FetchLayer's Twitter/X MCP tool to Claude Code (Anthropic's terminal agent) so you can search tweets and scrape data without leaving the command line.
Written by Alex P.
- MCP
- Claude Code
- twitter scraping
- X scraping
- AI agent
- terminal
- Anthropic
Claude Code is Anthropic’s agentic coding tool that runs in the terminal. It supports MCP servers, which means you can give it access to Twitter/X data through FetchLayer — right from your command line.
Prerequisites
- Claude Code installed (
npm install -g @anthropic-ai/claude-code) - A FetchLayer API key — get one free (no credit card)
Option 1: Add via CLI
The fastest way to add the FetchLayer MCP server:
claude mcp add fetchlayer \
--transport streamable-http \
https://mcp.fetchlayer.dev \
-- --header "Authorization: Bearer ss-your-api-key"
This saves the config to ~/.claude/settings.json (global) so it’s available in all projects.
To add it for the current project only:
claude mcp add fetchlayer \
--transport streamable-http \
--scope project \
https://mcp.fetchlayer.dev \
-- --header "Authorization: Bearer ss-your-api-key"
This saves to .mcp.json in your project root.
Option 2: Edit config manually
If you prefer editing the config file directly, add this to ~/.claude/settings.json:
{
"mcpServers": {
"fetchlayer": {
"url": "https://mcp.fetchlayer.dev",
"headers": {
"Authorization": "Bearer ss-your-api-key"
}
}
}
}
Or for project-level config, create .mcp.json in your project root with the same content.
Verify it works
Run Claude Code and check that the MCP server is connected:
claude
Then type:
/mcp
You should see “fetchlayer” listed with its available tools.
Try it out
Once connected, just ask Claude Code to use Twitter/X data in your prompts:
> Search X/Twitter for "best API testing tools" and show me the top 5 results
> Get the latest tweets from @rauchg about Next.js
> Get the follower count and profile details for @openai
> Scrape the replies to this tweet: https://x.com/someuser/status/123... and summarize the key opinions
Claude Code will call the FetchLayer tools automatically and incorporate the results into its responses.
Real workflow example
Here’s a practical use case — competitive research while coding:
> I'm building a URL shortener. Search X/Twitter for "self-hosted URL shortener"
> discussions from the past month. What are people recommending and what
> features do they care about most?
Claude Code will:
- Call
twitter_searchwith the query - Potentially call
twitter_tweet_detailon the most relevant tweets to read replies - Synthesize the findings into an actionable summary
All without leaving your terminal.
Available Tools
All 10 FetchLayer Twitter/X tools are available:
- twitter_search — Search tweets by keyword (Top, Latest, People, Media, Lists)
- twitter_tweet_detail — Get a specific tweet by ID
- twitter_tweet_replies — Fetch replies to a tweet
- twitter_user_profile_details — Get user profile by handle
- twitter_about_profile — Extended profile metadata
- twitter_user_tweets / twitter_user_replies — User tweet/reply history
- twitter_following / twitter_followers — Follower graphs
- twitter_verified_followers — Verified accounts following a user
Troubleshooting
MCP server not connecting?
- Run
claude mcp listto see configured servers - Check that the URL is correct:
https://mcp.fetchlayer.dev - Verify your API key is valid
Permission denied?
- Claude Code may ask you to approve MCP tool usage — accept when prompted
- Check the Claude Code permission settings with
/permissions
Server added at project scope but a teammate doesn’t see it?
- Project-scope servers save to
.mcp.jsonin the repo root — confirm it’s actually committed and not.gitignore’d - Each teammate still needs their own
Authorizationheader value; don’t commit a real API key to.mcp.jsonon a shared repo — reference an environment variable in the header instead, and have each person set it locally
Global vs. project scope: which to use
claude mcp add without --scope project writes to ~/.claude/settings.json, which is global — every project you open with Claude Code gets FetchLayer access. That’s the right default for a personal API key you use across unrelated projects.
Use --scope project when you want the server definition itself checked into a specific repo — for example, a team project where everyone should have FetchLayer available without individually running the CLI command. The server config goes in .mcp.json and gets versioned with the rest of the repo; just keep the actual key out of that file (see the troubleshooting note above) so you’re not committing a shared secret.
You can run claude mcp list at any point to see which servers are active and at which scope, which is the fastest way to confirm you didn’t accidentally add a duplicate at both levels.
Why the terminal path fits certain workflows better
Claude Code’s advantage over a GUI-based client isn’t just “the same thing without a window” — it’s that MCP tool calls compose naturally with everything else Claude Code already does in that session: reading your codebase, running tests, editing files, and now, pulling live X/Twitter data, all in one continuous agentic loop with no context switch. A GUI client requires you to copy findings back into your editor manually; in Claude Code, the same session that searched X for competitor complaints can turn around and open the relevant file to address one. This is also why the /mcp and /permissions commands matter more here than in a chat-only client — you’re granting a tool-use agent live network access to your terminal session, and it’s worth actually looking at what’s connected rather than assuming it from memory.
Real workflow example, extended
Beyond the competitive-research example above, a common terminal-native use is triaging live feedback right after a deploy:
> I just shipped v2.3 of our CLI. Search X/Twitter for mentions of our project
> from the last 6 hours. If anyone reports an error, check whether it matches
> anything in our recent commits and draft a fix if it's clearly our bug.
Claude Code chains twitter_search to find mentions, twitter_tweet_replies on any thread with engagement, then reads your actual commit history and source files to check whether a reported symptom lines up with a specific change — all without you copying a single tweet into the terminal by hand. This is the case where the terminal-native approach pays off over a GUI client: the same session doing the search is the session that can immediately open a file and propose a diff.
What a tool call actually returns
Structured JSON, with the author nested on every result:
{
"results": [
{
"id": "1942939879222220800",
"text": "Migrated off their SDK this week. Docs were the dealbreaker.",
"author": { "handle": "example_dev", "displayName": "Example Dev", "followersCount": 12400 },
"likeCount": 284,
"retweetCount": 41,
"replyCount": 63,
"createdAt": "2026-08-18T10:00:00.000Z",
"url": "https://x.com/example_dev/status/1942939879222220800"
}
]
}
Since followersCount arrives alongside the engagement counts, the agent can rank by engagement rate rather than raw likes without a follow-up lookup per author — which is usually the ranking you actually want.
Request cost in an agentic session
Claude Code runs long multi-step tasks, so the cost model is worth knowing before you set one loose:
| Call | Cost |
|---|---|
search | 1 request, any result count |
tweet-detail, user-profile-details | 1 request |
tweet-replies | 1 request per page |
user-followers, user-following | 1 request per page — unbounded if you let it be |
| Reasoning over data already fetched | 0 |
The endpoints that page are where sessions get expensive. “Analyze @account’s audience” has no natural stopping point; “pull the first two pages of @account’s followers” does, and answers the same question for nearly every purpose.
Turning findings into code, in one pass
The terminal-native version of this is more useful than a browser because the agent can act on what it finds without leaving the repo:
“Search X for complaints about our error messages, find the matching strings in
src/, and draft clearer replacements.”
One search request, then ordinary file operations. The rewrite is grounded in the words users chose to describe their confusion rather than the model’s guess at what reads badly.
The same shape covers triage — pull recurring complaints, grep for the responsible module, open a PR — end to end in one session.
Handles, not URLs
The tools want a bare handle. A pasted profile URL is the usual cause of an empty response that looks like a server fault:
- ✅
rauchg - ❌
https://x.com/rauchg
Say “the account rauchg” rather than pasting a link and the ambiguity disappears.
What’s Next
- Twitter/X MCP: All Clients Compared — every supported AI tool in one place
- Twitter MCP + Cursor — GUI-based setup
- Twitter MCP + Claude Desktop — desktop app setup
- Twitter MCP + VS Code — VS Code Copilot setup
- How to Scrape Twitter/X in 2026 — all scraping methods
- FetchLayer API Reference — full endpoint docs