home / mcp / x (twitter) mcp mcp server
Python MCP server to post tweets, threads, and fetch tweet metrics from X API.
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.
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.
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-mcpStep 2: Create and activate a Python virtual environment.
python -m venv venv
# On Unix/macOS:
source venv/bin/activate
# On Windows:
venv\Scripts\activateStep 3: Install dependencies.
pip install -r requirements.txtStep 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.pyAdd 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": {}
}
}
}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")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.
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.
Planned enhancements include media upload, quote tweets, and batch metrics support.
Verify authentication and retrieve your profile information.
Post a single tweet with a maximum of 280 characters.
Post a thread by sending multiple tweets separated with the separator \n\n---\n\n.
Retrieve tweet details and metrics such as likes, retweets, replies, impressions, quotes, and bookmarks.
Delete a tweet by its ID.
Reply to an existing tweet by ID with new text.