+ Integration Guide
How to Connect Twitter MCP to Claude Code
Set up FetchLayer's Twitter/X MCP server in Claude Code (Anthropic's terminal agent) so you can search tweets and scrape data from 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 sk-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 sk-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 sk-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
What’s Next
- 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