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-mcpWhat's trending on Twitter?"
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 Server
MCP (Model Context Protocol) server to interact with Twitter/X directly from any MCP-compatible AI assistant (like opencode). Uses your Twitter session cookies for authentication — no API keys needed.
Features
Post, delete, like, and retweet tweets
Search tweets by keyword
View home timeline, user timeline, and tweet details
Get current trending topics
Look up user profiles
Follow/unfollow users
Authenticated user profile info
Daily AI news automation (
ai_news_daily.py): fetches AI news from RSS feeds and posts via the MCP server on a cron schedule
Related MCP server: Twitter/X MCP Server
Quick Start
1. Get your Twitter cookies
Open Twitter/X in your browser (logged in)
Open DevTools (
F12) → Application → Cookies →https://x.comCopy the values for
auth_tokenandct0
2. Configure
Option A (recommended): Store cookies in secret-vault-mcp
If you have secret-vault-mcp installed and running:
Populate the vault with a
twitter-cookiesentry:add_secret name=twitter-cookies username=n8nfelipe \ password=<auth_token> \ notes='{"ct0": "<ct0>", "user_id": "<user_id>", "csrf_token": "<csrf_token>"}'Ensure
VAULT_MASTER_PASSWORDenv var is set (or inopencode.jsoncenv block).Set
TWITTER_USE_VAULT=auto(default) — the server will check the vault first, then fall back to.env.
Option B: .env file
cp .env.example .envEdit .env:
TWITTER_AUTH_TOKEN=seu_auth_token_aqui
TWITTER_CT0=seu_ct0_aqui3. Install dependencies
pip install -r requirements.txtNote: requirements.txt includes secret-vault-mcp as an editable dependency.
If you don't use the vault, you can remove the -e ../secret-vault-mcp line.
4. Run
python server.pyThe server will start and listen on stdio, ready for MCP connections.
Register with opencode
Add to ~/.config/opencode/opencode.jsonc:
{
"mcpServers": {
"twitter": {
"command": "python3",
"args": ["/path/to/twitter-mcp/server.py"],
"env": {
"VAULT_MASTER_PASSWORD": "your-passphrase",
"TWITTER_USE_VAULT": "auto"
}
}
}
}When VAULT_MASTER_PASSWORD is set, the server loads cookies from
secret-vault-mcp automatically (entry name twitter-cookies by default).
Override with TWITTER_VAULT_ENTRY.
Register with Claude Desktop
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"twitter": {
"command": "python3",
"args": ["/caminho/para/twitter-mcp/server.py"],
"env": {
"TWITTER_AUTH_TOKEN": "seu_token",
"TWITTER_CT0": "seu_ct0"
}
}
}
}Register with Codex (by Cursor)
Create/edit ~/.codex/config.json:
{
"mcpServers": {
"twitter": {
"command": "python3",
"args": ["/caminho/para/twitter-mcp/server.py"],
"env": {
"TWITTER_AUTH_TOKEN": "seu_token",
"TWITTER_CT0": "seu_ct0"
}
}
}
}Tools
Tool | Description | Arguments |
| Post a tweet |
|
| Delete a tweet |
|
| Like a tweet |
|
| Retweet a tweet |
|
| Search tweets |
|
| Your home timeline |
|
| Tweets from a user |
|
| User profile info |
|
| Full tweet details |
|
| Current trending topics | — |
| Your own profile | — |
| Follow a user |
|
How it works
The server authenticates via auth_token and ct0 session cookies, then makes requests directly to the Twitter/X internal GraphQL API. Query IDs are extracted from the official Twitter web client bundle, so no API keys or OAuth are needed.
Tests
The suite uses pytest with the HTTP layer fully mocked (no real Twitter calls). It covers the auth module, the GraphQL/REST client (success and error paths), the MCP server tools, and the daily AI news script.
python3 -m pytest -vMeasure coverage across all source modules:
python3 -m coverage run --source=auth,twitter_client,server,ai_news_daily -m pytest
python3 -m coverage reportCurrent coverage target: ≥ 80% (currently ~88%).
CI
On every push to main, GitHub Actions runs all tests and automatically creates a tag (v1.YYYYMMDD.HHMM).
Project structure
├── server.py # MCP server entry point (12 tools via FastMCP)
├── twitter_client.py # HTTP client for Twitter GraphQL API
├── auth.py # Authentication via session cookies
├── ai_news_daily.py # Cron script: posts daily AI news via the MCP server
├── test_twitter.py # Tests for auth + twitter_client (mocked API)
├── test_server.py # Tests for the MCP server tools
├── test_ai_news.py # Tests for the daily AI news script
├── requirements.txt # Python dependencies
├── .env.example # Cookie config template
├── .github/workflows/ # CI pipeline
└── README.mdThis server cannot be deployed
Maintenance
Related MCP Connectors
X / Twitter public post, comment, reply, user, and search tools.
X (formerly Twitter) posts, profiles, and search for AI agents. Free key, self-minted, no signup.
X/Twitter reads, search, monitors and posting. Pay-per-call in USDC — no signup, no API keys.
X (formerly Twitter): X (formerly Twitter) public and private data API for search, posts (Tweets).
Related MCP Servers
- FlicenseNot gradedqualityNot gradedmaintenanceConnects AI assistants to Twitter/X using cookie-based authentication to read timelines, search tweets, and perform actions like posting and liking. It leverages Twitter's internal GraphQL API to provide full functionality without requiring a developer account.8 npm-
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with Twitter/X through Playwright browser automation without requiring an official API key. It provides tools for posting content, searching tweets, reading feeds, and managing social interactions like follows and likes.3MIT
- AlicenseAqualityDmaintenanceEnables AI assistants to search X posts and read user timelines without API costs, using cookie authentication.2MIT
- AlicenseBqualityDmaintenanceEnables AI models to interact with Twitter, including posting tweets, searching, following users, and chatting with Grok, using cookie or credential authentication.141,629 npm1MIT