An MCP server for posting tweets and threads to X (Twitter).
Project description
X Twitter Posting MCP Server
An MCP (Model Context Protocol) server that allows language models to post tweets and threads to X (formerly Twitter).
Features
- Post Single Tweet: Provides a tool (
post_tweet) to post a single status update. - Post Thread: Provides a tool (
post_thread) to post a sequence of tweets as a thread.
Prerequisites
- Python 3.10+
- An X Developer account with API v2 access (Essential access or higher).
- API Key, API Key Secret, Access Token, and Access Token Secret from your X Developer App dashboard.
Installation
pip install x-twitter-posting-mcp
(Note: This package is not yet published on PyPI. This is the intended installation command once published.)
Alternatively, install directly from source:
git clone https://github.com/DevRico003/x-twitter-posting-mcp.git
cd x-twitter-posting-mcp
pip install .
Configuration
This server requires X API credentials to function. Set the following environment variables:
TWITTER_API_KEY: Your X App's API KeyTWITTER_API_KEY_SECRET: Your X App's API Key SecretTWITTER_ACCESS_TOKEN: Your X App's Access TokenTWITTER_ACCESS_TOKEN_SECRET: Your X App's Access Token Secret
You can set these directly in your environment or place them in a .env file in the directory where you run the server. See .env.example for a template.
Usage
Running the Server Standalone
You can run the server directly using the installed script:
x-twitter-posting-mcp
This will start the server using the default stdio transport.
Integrating with MCP Clients (e.g., Claude Desktop)
Configure your MCP client to launch the server. Add an entry similar to this in your client's configuration (e.g., claude_desktop_config.json).
Method 1: Using the installed script (if in PATH)
This assumes x-twitter-posting-mcp is installed in a location accessible by your system's PATH and you have configured credentials via a .env file or system environment variables.
{
"mcpServers": {
"x-twitter-posting": {
"command": "x-twitter-posting-mcp"
// Optional: Specify absolute path if needed
// "command": "/path/to/your/virtualenv/bin/x-twitter-posting-mcp"
}
}
}
Method 2: Using uv run and passing credentials directly (Recommended for Claude Desktop)
This method uses uv to run the server directly from the source directory and passes credentials securely within the configuration, avoiding the need for a separate .env file for the client environment.
{
"mcpServers": {
"x-twitter-posting": {
"command": "uv",
"args": [
"run",
"x-twitter-posting-mcp"
],
"env": {
"TWITTER_API_KEY": "YOUR_API_KEY_HERE",
"TWITTER_API_KEY_SECRET": "YOUR_API_KEY_SECRET_HERE",
"TWITTER_ACCESS_TOKEN": "YOUR_ACCESS_TOKEN_HERE",
"TWITTER_ACCESS_TOKEN_SECRET": "YOUR_ACCESS_TOKEN_SECRET_HERE"
}
}
}
}
After adding the configuration, restart your MCP client. The post_tweet and post_thread tools should now be available to the language model.
Tools Provided
post_tweet(text: str): Posts a single tweet.text: The content of the tweet (max 280 characters).- Returns: Confirmation message with Tweet ID or an error message.
post_thread(tweets: List[str]): Posts a thread.tweets: A list of strings, each representing a tweet in the thread. The first tweet is the head, subsequent tweets are replies.- Returns: Confirmation message with all Tweet IDs or an error message (may indicate partial posting).
Development
- Clone the repository.
- Create and activate a virtual environment:
python -m venv .venv && source .venv/bin/activate(or.venv\Scripts\activateon Windows). - Install dependencies:
pip install -e ".[dev]"(You might need to define a[dev]extra inpyproject.tomlfor development dependencies likepytest). - Create a
.envfile with your credentials. - Run tests (TODO: Add tests).
- Run the server:
python -m x_twitter_posting_mcp.server
License
TODO: Specify License (e.g., MIT License). See LICENSE file.
Contributing
Contributions are welcome! Please open an issue or submit a pull request. (TODO: Add contribution guidelines).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file x_twitter_posting_mcp-0.1.0.tar.gz.
File metadata
- Download URL: x_twitter_posting_mcp-0.1.0.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3df5698c8629b784be1620f597ebc6145a476b60b2f1087dbc5309ea513f54d
|
|
| MD5 |
c770ed0a57ad3be01b6b10bc059d2e3d
|
|
| BLAKE2b-256 |
13afa3a07d886ed86dd977071763d81b7f80877d1aaa64112dd5b9b061c16297
|
File details
Details for the file x_twitter_posting_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: x_twitter_posting_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0340d71524ada592ca21735823a8b5f34fdaf8575dfe312f05e7c21b1234a8d1
|
|
| MD5 |
c3a998c29b31facbd11b996fde3c2ce1
|
|
| BLAKE2b-256 |
a103e0e41ba2d74d8dd4905b223accf5c82f812f21f82e98475dc46ef9484871
|