Click on "Install 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/X MCP Serversearch for the most recent tweets about AI agents"
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/X MCP Server
A Model Context Protocol server that gives AI assistants full read/write access to Twitter/X through cookie-based authentication. No Developer account or OAuth app required.
Features
12 tools covering timelines, search, profiles, trends, posting, likes, retweets, and replies
Cookie-based auth -- uses your browser session cookies, no Twitter API keys needed
Dual-engine architecture -- fast HTTP via undici for reads, headless Puppeteer with stealth plugin for writes
Anti-bot bypass -- puppeteer-extra-plugin-stealth avoids Twitter automation detection (error 226)
Auto CSRF refresh -- ct0 tokens refreshed transparently when Twitter rotates them
Clean JSON output -- nested GraphQL responses parsed into simple, structured objects
Type-safe -- strict TypeScript with Zod schema validation on every tool input
MCP standard -- works with Claude Desktop, Claude Code, and any MCP-compatible client
Prerequisites
Node.js >= 18.0.0
npm >= 8.0.0
A Twitter/X account with an active browser session
Installation
git clone https://github.com/aditya-ai-architect/twitter-mcp.git
cd twitter-mcp
npm install
npm run buildGetting Your Twitter Cookies
Open x.com and log in
Open Developer Tools (F12)
Go to Application > Cookies >
https://x.comCopy these two values:
Cookie | Description |
| Session authentication token |
| CSRF protection token |
Both cookies must come from the same active session.
Configuration
Environment Variables
Variable | Required | Description |
| Yes | The |
| Yes | The |
Create a .env file in the project root:
TWITTER_AUTH_TOKEN=your_auth_token_here
TWITTER_CT0=your_ct0_hereClaude Desktop
Add to your Claude Desktop config:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"twitter": {
"command": "node",
"args": ["/absolute/path/to/twitter-mcp/build/index.js"],
"env": {
"TWITTER_AUTH_TOKEN": "your_auth_token_here",
"TWITTER_CT0": "your_ct0_here"
}
}
}
}Claude Code
claude mcp add twitter -- node /absolute/path/to/twitter-mcp/build/index.jsTools
Read Operations
Tool | Description |
| Fetch tweets from the authenticated user's home timeline |
| Get a user profile by username |
| Get recent tweets from a specific user |
| Get a single tweet by ID |
| Search tweets with full operator support |
| Get current trending topics |
Write Operations
Tool | Description |
| Post a new tweet |
| Like a tweet |
| Remove a like |
| Retweet a tweet |
| Remove a retweet |
| Reply to a specific tweet |
Architecture
MCP Client (Claude) <--stdio--> twitter-mcp Server
|
+---------------+---------------+
| |
undici HTTP Puppeteer + Stealth
(Read ops) (Write ops)
| |
+---------------+---------------+
|
x.com GraphQL APIRead operations use direct HTTP for speed. Write operations use a headless browser with stealth to bypass automation detection.
Development
npm run dev # Watch mode
npm run build # Build once
npm start # Run the serverProject Structure
twitter-mcp/
src/
index.ts # MCP server setup and tool registration
twitter-client.ts # Twitter API client (HTTP + Puppeteer)
types.ts # TypeScript interfaces
build/ # Compiled output
package.json
tsconfig.jsonTroubleshooting
Issue | Solution |
HTTP 401/403 | Cookies expired -- extract fresh ones from browser |
HTTP 429 | Rate limited -- wait a few minutes |
Error 226 | Stealth browser handles this; if persistent, post manually once then retry |
Empty responses | Twitter may have rotated GraphQL query IDs |
Tech Stack
Runtime: Node.js (ES2022)
Language: TypeScript 5.x (strict mode)
MCP SDK: @modelcontextprotocol/sdk
HTTP Client: undici
Browser: Puppeteer + puppeteer-extra-plugin-stealth
Validation: Zod
License
ISC
Built by Aditya Gaurav
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.