home / mcp / twitter mcp server
A Unofficial Twitter MCP Server with cookie auth.
Configuration
View docs{
"mcpServers": {
"gkydev-twitter-mcp-server": {
"command": "python",
"args": [
"server.py"
],
"env": {
"TWITTER_CT0": "your_ct0_cookie_here"
}
}
}
}This MCP server lets you interact with Twitter programmatically through a cookie-based authentication flow. You provide the required cookies in tool calls, and the server handles actions like posting tweets, reading timelines, sending DMs, and more, with built-in session caching for efficiency.
You use this server by sending tool calls from your MCP client. Each call includes the action you want to perform and the necessary Twitter cookies (ct0 and auth_token). The server handles authentication automatically, caches sessions for reuse, and returns the requested data or confirmation of actions like posting, liking, or messaging.
Prerequisites: Python 3.8 or newer, and a working network connection.
# Step 1: Install Python dependencies
pip install -r requirements.txt
# Step 2: Run the MCP Twitter server
python server.pyConfiguration is driven by the cookies you provide in tool calls. The server expects ct0 and auth_token with every operation. The following cookie values are required for all actions:
ct0: your_ct0_cookie_here
auth_token: your_auth_token_cookie_hereThis server uses an unofficial API to interact with Twitter. Treat cookie values as sensitive credentials. Do not share cookies or expose tool calls that include them. The server caches authenticated sessions to improve performance, but you should rotate cookies if you suspect they may be compromised.
If you encounter authentication errors, double-check that you provided valid ct0 and auth_token cookies in every request. Ensure cookies have not expired and that you are sending them with the correct tool calls.
Test authentication by providing ct0 and auth_token cookies to verify that you can establish a session with Twitter.
Post a new tweet with the given text and authentication cookies.
Retrieve profiles and statistics for a specified Twitter user.
Search tweets matching a query and return results.
Fetch tweets from your home timeline.
Like a tweet by its ID.
Retweet a specific tweet by its ID.
Send a direct message to a user by username with given text.
Retrieve direct message history with a specific user.
Add an emoji reaction to a direct message.
Delete a direct message by its ID.
Get replies to a specific tweet by ID.
Fetch trending topics by category (trending, for-you, news, sports, entertainment).