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
Getting 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:
Claude Desktop
Add to your Claude Desktop config:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Claude Code
Tools
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
Read operations use direct HTTP for speed. Write operations use a headless browser with stealth to bypass automation detection.
Development
Project Structure
Troubleshooting
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