home / mcp / twitter mcp server

Twitter MCP Server

Twitter MCP Tool

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "jalaj-pandey-twitter-mcp-tool": {
      "command": "mcp",
      "args": [
        "dev",
        "script.py"
      ],
      "env": {
        "X_api_key": "YOUR_API_KEY",
        "X_api_key_sec": "YOUR_API_SECRET",
        "GEMINI_API_KEY": "YOUR_GEMINI_API_KEY",
        "X_access_token": "YOUR_ACCESS_TOKEN",
        "X_bearer_token": "YOUR_BEARER_TOKEN",
        "X_access_token_sec": "YOUR_ACCESS_TOKEN_SECRET"
      }
    }
  }
}

The Twitter MCP Tool automates common social media tasks with Python, helping you post tweets, fetch recent activity, track username changes, and send direct messages. It streamlines repetitive actions so you can focus on content strategy and engagement.

How to use

You run the Twitter MCP Tool through an MCP client, using the provided stdio configuration to start the local tool. After setting up authentication keys in your environment, you can perform core actions like posting tweets (with or without images), retrieving another user’s recent tweets, tracking username history, and sending direct messages.

How to install

{
  "name": "twitter_mcp",
  "type": "stdio",
  "command": "mcp",
  "args": ["dev", "script.py"],
  "env": {
    "X_api_key": "YOUR_API_KEY",
    "X_api_key_sec": "YOUR_API_SECRET",
    "X_access_token": "YOUR_ACCESS_TOKEN",
    "X_access_token_sec": "YOUR_ACCESS_TOKEN_SECRET",
    "X_bearer_token": "YOUR_BEARER_TOKEN",
    "GEMINI_API_KEY": "YOUR_GEMINI_API_KEY"
  }
}

Additional setup and files

The following commands and files are used to set up and run the tool. Use them exactly as shown to ensure the MCP client can load and start the Twitter MCP Tool.

git clone https://github.com/jalaj-pandey/twitter-mcp-tool.git

uv venv
.venv\Scripts\activate
pip install -r requirements.txt
mcp dev script.py

Available tools

Tweet posting

Post tweets to Twitter, with optional images to accompany the text.

Query username changes

Track and retrieve the history of username changes for a Twitter account.

Fetch recent tweets

Retrieve the latest tweets from a public Twitter user's timeline.

Send DM

Send a direct message to a Twitter user.