home / mcp / twitter mcp server

Twitter MCP Server

A Unofficial Twitter MCP Server with cookie auth.

Installation
Add the following to your MCP client configuration file.

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.

How to use

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.

How to install

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.py

Additional notes

Configuration 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_here

Security and usage notes

This 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.

Troubleshooting tips

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.

Available tools

authenticate

Test authentication by providing ct0 and auth_token cookies to verify that you can establish a session with Twitter.

tweet

Post a new tweet with the given text and authentication cookies.

get_user_info

Retrieve profiles and statistics for a specified Twitter user.

search_tweets

Search tweets matching a query and return results.

get_timeline

Fetch tweets from your home timeline.

like_tweet

Like a tweet by its ID.

retweet

Retweet a specific tweet by its ID.

send_dm

Send a direct message to a user by username with given text.

get_dm_history

Retrieve direct message history with a specific user.

add_reaction_to_message

Add an emoji reaction to a direct message.

delete_dm

Delete a direct message by its ID.

get_tweet_replies

Get replies to a specific tweet by ID.

get_trends

Fetch trending topics by category (trending, for-you, news, sports, entertainment).