X (Twitter) MCP server
About
An MCP server for interacting with the X (Twitter) API, requiring developer credentials.
Details
- Author
- rafaljanicki
- GitHub stars
- 34
- Downloads
- 414
- Categories
- Communication, Other
Jump to
- Fetch user profiles, followers, and following lists
- Post, delete, and favorite tweets
- Search Twitter for tweets and trends
- Manage bookmarks and timelines
- Built-in rate limit handling for the Twitter API
- Uses Twitter API v2 with proper authentication
- Complete implementation of Twitter API v2 endpoints
Setting up with Highlight
This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:
- Download and install Highlight from highlightai.com/download
- Navigate to the plugins tab and select "Add Custom Plugin"
-
Configure the plugin with the settings below
Plugin Name
X (Twitter) MCP serverCommand (node, npx, python, etc.)Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.
- Enable "Start Automatically" if you want the plugin to start when Highlight launches
From the repository
Install via Smithery (recommended for Claude Desktop), from PyPI (pip install x-twitter-mcp), or from source. Set required Twitter API credentials as environment variables (TWITTER_API_KEY, TWITTER_API_SECRET, TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET, TWITTER_BEARER_TOKEN). Run the server either as a Streamable HTTP service (Docker or local ASGI) or as a STDIO CLI script (x-twitter-mcp-server). For Claude Desktop, configure the server in claude_desktop_config.json with the appropriate command and environment variables.
Claude Desktop / Cursor
Paste into your MCP client config file to install this server.
{
"mcpServers": {
"x (twitter) mcp server": {
"x-twitter-server": {
"type": "stdio",
"command": "x-twitter-mcp-server",
"args": [],
"env": {
"TWITTER_API_KEY": "<TWITTER_API_KEY>",
"TWITTER_API_SECRET": "<TWITTER_API_SECRET>",
"TWITTER_ACCESS_TOKEN": "<TWITTER_ACCESS_TOKEN>",
"TWITTER_ACCESS_TOKEN_SECRET": "<TWITTER_ACCESS_TOKEN_SECRET>",
"TWITTER_BEARER_TOKEN": "<TWITTER_BEARER_TOKEN>"
}
}
}
}
}
McpServers
{
"x-twitter-server": {
"type": "stdio",
"command": "x-twitter-mcp-server",
"args": [],
"env": {
"TWITTER_API_KEY": "<TWITTER_API_KEY>",
"TWITTER_API_SECRET": "<TWITTER_API_SECRET>",
"TWITTER_ACCESS_TOKEN": "<TWITTER_ACCESS_TOKEN>",
"TWITTER_ACCESS_TOKEN_SECRET": "<TWITTER_ACCESS_TOKEN_SECRET>",
"TWITTER_BEARER_TOKEN": "<TWITTER_BEARER_TOKEN>"
}
}
}
X (Twitter) MCP server
A Model Context Protocol (MCP) server for interacting with Twitter (X) via AI tools. This server allows you to fetch tweets, post tweets, search Twitter, manage followers, and more, all through natural language commands in AI Tools.
<a href="https://glama.ai/mcp/servers/@rafaljanicki/x-twitter-mcp-server">
</a>
Features
- Fetch user profiles, followers, and following lists.
- Post, delete, and favorite tweets.
- Search Twitter for tweets and trends.
- Manage bookmarks and timelines.
- Built-in rate limit handling for the Twitter API.
- Uses Twitter API v2 with proper authentication (API keys and tokens), avoiding the username/password hack to minimize the risk of account suspensions.
- Provides a complete implementation of Twitter API v2 endpoints for user management, tweet management, timelines, and search functionality.
Prerequisites
- Python 3.10 or higher: Ensure Python is installed on your system.
- Twitter Developer Account: You need API credentials (API Key, API Secret, Access Token, Access Token Secret, and Bearer Token) from the Twitter Developer Portal.
- Optional: Claude Desktop: Download and install the Claude Desktop app from the Anthropic website.
- Optional: Node.js (for MCP integration): Required for running MCP servers in Claude Desktop.
- A package manager like uv or pip for Python dependencies.
Installation
Option 1: Installing via Smithery (Recommended)
To install X (Twitter) MCP server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @rafaljanicki/x-twitter-mcp-server --client claude
Option 2: Install from PyPI
The easiest way to installx-twitter-mcp is via PyPI:
pip install x-twitter-mcp
Option 3: Install from Source
If you prefer to install from the source repository:1. Clone the Repository:
git clone https://github.com/rafaljanicki/x-twitter-mcp-server.git
cd x-twitter-mcp-server
2. Set Up a Virtual Environment (optional but recommended):
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
3. Install Dependencies:
Using uv (recommended, as the project uses uv.lock):
uv sync
Alternatively, using
pip: pip install .
4. Configure Environment Variables:
- Create a .env file in the project root (you can copy .env.example if provided).
- Add your Twitter API credentials:
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
TWITTER_BEARER_TOKEN=your_bearer_token
- To use bookmark tools (
get_bookmarks, delete_all_bookmarks), also add an OAuth 2.0 user access token: TWITTER_OAUTH2_USER_ACCESS_TOKEN=your_oauth2_user_token
See Obtaining an OAuth 2.0 User Token below.
Obtaining an OAuth 2.0 User Token
The bookmark endpoints (GET /2/users/:id/bookmarks, DELETE /2/users/:id/bookmarks/:tweet_id) require OAuth 2.0 User Context — they reject both app-only bearer tokens and OAuth 1.0a. You need to perform the PKCE authorization flow once to obtain a user-scoped token.
Steps
1. In the Twitter Developer Portal, open your app → Settings → User authentication settings and enable OAuth 2.0. Set a callback URL (e.g. https://localhost/).
2. Run the PKCE flow using Tweepy:
```python
import tweepy
handler = tweepy.OAuth2UserHandler(
client_id="YOUR_CLIENT_ID", # OAuth 2.0 Client ID (from Developer Portal)
redirect_uri="https://localhost/",
scope=["bookmark.read", "bookmark.write", "users.read", "offline.access"],
client_secret="YOUR_CLIENT_SECRET", # Optional for public clients
)
print(handler.get_authorization_url())
Sign in to leave a review
Use Google, GitHub, or an email account so ratings stay tied to real people.
No reviews posted yet.




