home / mcp / x (twitter) mcp mcp server

X (Twitter) MCP MCP Server

Python MCP server to post tweets, threads, and fetch tweet metrics from X API.

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "arnaldo-delisio-x-mcp": {
      "command": "/path/to/x-mcp/venv/bin/python",
      "args": [
        "/path/to/x-mcp/server.py"
      ]
    }
  }
}

This MCP server lets you interact with X (Twitter) by posting tweets and threads, retrieving tweet details and metrics, and managing tweets programmatically through a simple Python-based MCP server you run locally or in your environment.

How to use

You run the X MCP server locally and connect your MCP client to it. The server exposes a small set of functions you can call from your MCP client to perform common Twitter actions: post a tweet, post a thread, fetch tweet details and metrics, delete tweets, and reply to tweets. Use these functions exactly as named to perform the corresponding actions.

How to install

Prerequisites you need before installation: Python 3.10 or newer.

Step 1: Clone the MCP server repository.

git clone https://github.com/arnaldo-delisio/x-mcp.git
cd x-mcp

Step 2: Create and activate a Python virtual environment.

python -m venv venv
# On Unix/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activate

Step 3: Install dependencies.

pip install -r requirements.txt

Step 4: Configure credentials and settings.

cp .env.example .env
```
Edit the .env file to provide your Twitter API credentials as described in the setup steps (API key, API key secret, Access token, Access token secret).

Step 5: Run the MCP server.

# Start the server (example path; adjust to your setup)
/path/to/x-mcp/venv/bin/python /path/to/x-mcp/server.py

Configuration and integration

Add the MCP server configuration to your Claude/Code integration so your client can connect to it. Use the following structure to register the local stdio-based MCP server.

{
  "mcpServers": {
    "x": {
      "command": "/path/to/x-mcp/venv/bin/python",
      "args": ["/path/to/x-mcp/server.py"],
      "env": {}
    }
  }
}

Usage examples

Post a tweet by calling the corresponding function in your MCP client.

x_post_tweet("Hello world!")

Post a thread by joining tweets with the required separator and passing the combined text to x_post_thread.

x_post_thread("1/ First tweet here\n\n---\n\n2/ Second tweet continues\n\n---\n\n3/ Final tweet")

Fetch metrics for a specific tweet.

x_get_tweet("1234567890")

Notes on features and security

The server provides a set of endpoints to verify your profile, post content, retrieve metrics, delete tweets, and reply to tweets. Ensure you protect your OAuth credentials and avoid exposing the .env file in public environments.

Troubleshooting

If you encounter authentication errors, double-check your Twitter API credentials in the .env file and ensure OAuth 1.0a read/write permissions are enabled in your Twitter developer settings.

Roadmap

Planned enhancements include media upload, quote tweets, and batch metrics support.

Available tools

x_get_me

Verify authentication and retrieve your profile information.

x_post_tweet

Post a single tweet with a maximum of 280 characters.

x_post_thread

Post a thread by sending multiple tweets separated with the separator \n\n---\n\n.

x_get_tweet

Retrieve tweet details and metrics such as likes, retweets, replies, impressions, quotes, and bookmarks.

x_delete_tweet

Delete a tweet by its ID.

x_reply

Reply to an existing tweet by ID with new text.