twitter-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@twitter-mcpshow me recent tweets about AI"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
twitter-mcp
A lightweight Twitter MCP server for Claude Code. Zero compilation — edit and run instantly with Bun.
Architecture
┌──────────────────────────────────────────────────────────────┐
│ twitter-mcp v1.1 │
│ (MCP Server) │
├──────────────────────────────────────────────────────────────┤
│ 17 Tools + Media Upload │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ search_tweets│ │ get_tweet │ │ get_user │ │
│ │ search_users │ │ get_article │ │ get_user_timeline │ │
│ │ │ │ get_replies │ │ get_user_followers │ │
│ │ │ │ get_quotes │ │ get_user_following │ │
│ │ │ │ get_thread │ │ get_user_mentions │ │
│ │ │ │ get_trends │ │ │ │
│ └──────┬───────┘ └──────┬──────┘ └──────┬───────────────┘ │
│ └────────────────┼───────────────┘ │
│ │ │
│ API Router │
│ ┌────────────────┼─────────────────┐ │
│ ▼ ▼ ▼ │
│ ┌─────────────┐ ┌─────────────┐ ┌──────────────┐ │
│ │twitterapi.io│ │Official API │ │Cookie Client │ │
│ │ (API Key) │ │(OAuth 1.0a) │ │(ct0+auth) │ │
│ │ │ │ │ │ │ │
│ │ 13 read │ │ post_tweet │ │ reply │ │
│ │ tools │ │ like/unlike │ │ fallback │ │
│ │ │ │ retweet │ │ (auto on 403)│ │
│ │ │ │ delete │ │ │ │
│ │ │ │ media upload│ │ │ │
│ └─────────────┘ └─────────────┘ └──────────────┘ │
└──────────────────────────────────────────────────────────────┘Why Hybrid API?
API | Auth | Cost | Use Case |
twitterapi.io | API Key | ~$0.15/1K calls | Read operations (search, timeline, user info) |
Official Twitter API | OAuth 1.0a | Free tier | Write operations (post, like, retweet, delete) |
Cookie (browser session) | ct0 + auth_token | Free | Reply fallback (Free tier OAuth blocks replies to non-interacted tweets) |
Related MCP server: X (Twitter) MCP Server - Enhanced Edition
Setup
1. Install
git clone https://github.com/armatrix/twitter-mcp.git
cd twitter-mcp
bun install2. Configure
mkdir -p ~/.twitter-mcp
cp config.example.json ~/.twitter-mcp/config.jsonEdit ~/.twitter-mcp/config.json:
{
"reader": {
"provider": "twitterapi.io",
"api_key": "your-twitterapi-io-key"
},
"writer": {
"provider": "twitter-official",
"api_key": "your-consumer-api-key",
"api_secret_key": "your-consumer-api-secret",
"access_token": "your-access-token",
"access_token_secret": "your-access-token-secret"
},
"cookie": {
"ct0": "your-ct0-cookie",
"auth_token": "your-auth-token-cookie"
},
"defaults": {
"timeline_count": 20,
"search_count": 20
}
}Get credentials:
reader.api_key: twitterapi.io — sign up and copy API keywriter.*: Twitter Developer Portal → Create App → Keys and Tokenscookie.*: Browser DevTools → Application → Cookies → x.com → copyct0andauth_tokenvalues
Cookie section is optional. If omitted, reply fallback is disabled and OAuth 403 errors on replies are returned as-is.
3. Get Cookie Credentials
Open x.com in your browser and log in
Open DevTools (F12) → Application → Cookies →
https://x.comCopy the value of
ct0(CSRF token, rotates periodically)Copy the value of
auth_token(session token, long-lived)Paste both into
config.jsonunder thecookiesection
Note:
ct0rotates every few hours. When cookie auth starts failing, refresh it from the browser.
4. Add to Claude Code
claude mcp add twitter -- bun run /path/to/twitter-mcp/src/index.ts -config ~/.twitter-mcp/config.jsonVerify:
claude mcp listTools
Read (13 tools — twitterapi.io)
Tool | Description |
| Search tweets by keyword (advanced search syntax) |
| Search users by keyword |
| Get tweets by ID (supports comma-separated multiple IDs, includes viewCount) |
| Get X Article full content by tweet ID |
| Get replies to a tweet |
| Get quote tweets |
| Get full thread context |
| Get user profile by username |
| Get user's recent tweets |
| Get user's followers |
| Get accounts a user follows |
| Get tweets mentioning a user |
| Get trending topics by region (WOEID) |
Write (4 tools — Official Twitter API, OAuth 1.0a)
Tool | Description |
| Post a tweet with optional images, reply, quote-tweet. Auto-fallback to cookie auth on reply 403. |
| Like a tweet by ID |
| Remove a like from a tweet |
| Retweet a tweet by ID |
| Delete a tweet by ID |
Reply Fallback Flow
post_tweet(text, reply_to_tweet_id)
│
▼
OAuth 1.0a POST /2/tweets
│
├─ 200 OK → return result (method: "oauth")
│
└─ 403 Forbidden (Free tier reply restriction)
│
▼
Cookie client configured?
│
├─ Yes → GraphQL CreateTweet → return result (method: "cookie")
│
└─ No → return errorImage upload: Pass media_paths with up to 4 local file paths (png/jpg/gif/webp). Images are uploaded via Twitter v1.1 media endpoint, then attached to the tweet.
post_tweet(
text: "Hello world",
media_paths: ["/path/to/screenshot.png", "/path/to/chart.jpg"]
)Known Limitations
Issue | Workaround |
Official API Free tier blocks replies to non-interacted tweets (403) | Cookie fallback auto-handles this |
| Re-extract from browser when cookie auth fails |
| Use |
Cookie client doesn't support image upload | Images only via OAuth |
Development
No build step required. Edit any .ts file and restart the MCP server.
# Run directly
bun run src/index.ts -config ~/.twitter-mcp/config.json
# Type check
bun build src/index.ts --target=bunProject Structure
src/
├── index.ts # MCP server entry point
├── config.ts # Config types and loader
├── clients/
│ ├── reader.ts # twitterapi.io client (read operations)
│ ├── writer.ts # Official Twitter API client (OAuth 1.0a write)
│ └── cookie.ts # Cookie-based client (GraphQL, reply fallback)
└── tools/
├── search.ts # search_tweets, search_users
├── tweets.ts # get_tweet, get_article, get_replies, get_quotes, get_thread
├── users.ts # get_user, get_timeline, get_followers, get_following, get_mentions
├── discovery.ts # get_trends
└── write.ts # post_tweet, like_tweet, unlike_tweet, retweet, delete_tweetTech Stack
Runtime: Bun
MCP SDK: @modelcontextprotocol/sdk
OAuth: oauth-1.0a (Official API auth)
Cookie Auth: Direct fetch + Twitter internal GraphQL (no external deps)
License
MIT
This server cannot be deployed
Maintenance
Related MCP Connectors
Twitter/X read-only MCP server — 12 tools: search, users, tweets, followers, timelines, trends.
Official twitterapi.io hosted MCP: Twitter/X tweets, users, followers, trends. OAuth or API key.
Official MCP server for twitterapis.com. Read and write Twitter/X: search, users, tweets, DMs.
FastMCP server for posting formatted content to X (Twitter) — Tollbooth-monetized, DPYC-native
Related MCP Servers
- AlicenseBqualityDmaintenanceAn MCP server that enables Claude to interact with Twitter, allowing for posting tweets and searching Twitter content.2325 npm408MIT
- AlicenseNot gradedqualityFmaintenanceAn enhanced Model Context Protocol server that enables Claude to interact with Twitter/X, supporting tweet posting, searching, and deletion with both OAuth 1.0a and OAuth 2.0 authentication methods.111 npm24MIT
- AlicenseNot gradedqualityDmaintenanceModel Context Protocol server that enables programmatic interaction with Twitter API, allowing users to post tweets, search for content, and retrieve user timelines through standardized MCP tools.14 npmMIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server for interacting with the Twitter/X API v2, enabling AI assistants to retrieve tweets, post content, reply, quote, and more programmatically.1,462 npm13MIT