X MCP Server
Enables AI assistants to automate Twitter/X actions through the X API v2, supporting over 50 tools for posting, searching, user management, and more.
README
X MCP Server 🐦
A powerful Model Context Protocol (MCP) Server for interacting with the X (Twitter) API v2. This server enables AI assistants like ChatGPT, Claude, and other MCP-compatible clients to automate Twitter/X actions.
Note: This server is limited to endpoints available in the Free tier of X API.
📋 Table of Contents
- Features
- Getting X API Credentials
- Installation
- Configuration
- Connecting to AI Clients
- Available Tools
- Rate Limits
- License
✨ Features
- 54+ automation tools for X/Twitter
- Post, delete, search, and interact with tweets
- User management (follow, mute, block)
- Lists, bookmarks, and spaces support
- Media upload (images/videos)
- Detailed rate limit handling
- Easy integration with AI assistants
🔑 Getting X API Credentials
To use this MCP server, you need X API credentials. Follow these steps:
Step 1: Create a Developer Account
- Go to developer.x.com
- Sign in with your X (Twitter) account
- Click "Sign up for Free Account" (or apply for elevated access if needed)
- Complete the developer agreement and verification
Step 2: Create a Project & App
- Navigate to Developer Portal → Projects & Apps
- Click "+ Add Project"
- Name your project (e.g., "MCP Automation")
- Select use case: "Exploring the API" or "Making a bot"
- Click "+ Add App" within your project
- Name your app (e.g., "X-MCP-Server")
Step 3: Generate API Keys
- In your App settings, go to "Keys and Tokens"
- Under Consumer Keys, click "Regenerate" to get:
API_KEY(API Key / Consumer Key)API_SECRET(API Secret / Consumer Secret)
- Under Authentication Tokens, generate:
ACCESS_TOKEN(Access Token)ACCESS_TOKEN_SECRET(Access Token Secret)
- Under Bearer Token, generate:
BEARER_TOKEN
Step 4: Enable App Permissions
- Go to User authentication settings
- Enable OAuth 1.0a
- Set App permissions to "Read and Write"
- Add a Callback URL (e.g.,
http://localhost:3000/callback) - Save changes
⚠️ Important: Keep your credentials secure! Never commit them to version control.
💻 Installation
Prerequisites
- Python 3.10+
- uv (recommended) or pip
Install with uv (Recommended)
# Clone the repository
git clone https://github.com/Lnxtanx/x-mcp-server.git
cd x-mcp-server
# Install dependencies
uv sync
Install with pip
# Clone the repository
git clone https://github.com/Lnxtanx/x-mcp-server.git
cd x-mcp-server
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install fastmcp tweepy python-dotenv
⚙️ Configuration
Step 1: Create Environment File
Copy the template and add your credentials:
cp .env.template .env
Step 2: Add Your Credentials
Edit .env with your X API credentials:
API_KEY=your_api_key_here
API_SECRET=your_api_secret_here
ACCESS_TOKEN=your_access_token_here
ACCESS_TOKEN_SECRET=your_access_token_secret_here
BEARER_TOKEN=your_bearer_token_here
🤖 Connecting to AI Clients
Claude Desktop
Add this configuration to your claude_desktop_config.json:
Windows: %APPDATA%\Claude\claude_desktop_config.json
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"x-api": {
"command": "uv",
"args": [
"run",
"--directory",
"C:/path/to/x-mcp-server",
"fastmcp",
"run",
"main.py"
]
}
}
}
Replace C:/path/to/x-mcp-server with your actual installation path.
After adding, restart Claude Desktop. You'll see the X API tools available in Claude.
ChatGPT / OpenAI
ChatGPT doesn't natively support MCP, but you can connect via:
Option 1: MCP Bridge/Proxy
Use an MCP-to-REST bridge to expose tools as API endpoints:
# Run MCP server with HTTP transport
uv run fastmcp dev main.py --transport http --port 8000
Then configure ChatGPT to call your endpoints via Custom GPT Actions or function calling.
Option 2: LangChain Integration
from langchain_openai import ChatOpenAI
from langchain_mcp import MCPClient
# Connect to local MCP server
mcp_client = MCPClient("http://localhost:8000")
tools = mcp_client.get_tools()
# Use with ChatGPT
llm = ChatOpenAI(model="gpt-4")
llm_with_tools = llm.bind_tools(tools)
Other MCP Clients
Running the Server Locally
# Development mode (with inspector)
uv run fastmcp dev main.py
# Production mode
uv run fastmcp run main.py
SSE Transport (for web clients)
uv run fastmcp run main.py --transport sse --port 8080
Stdio Transport (for CLI clients)
uv run fastmcp run main.py --transport stdio
🛠️ Available Tools (54 total)
Tweets
| Tool | Description | Rate Limit |
|---|---|---|
create_tweet |
Post a new tweet | 17/24h |
delete_tweet |
Delete a tweet | 17/24h |
get_tweet |
Get tweet by ID | 1/15min |
get_tweets |
Get multiple tweets | 1/15min |
search_recent_tweets |
Search tweets (7 days) | 1/15min |
get_user_tweets |
Get user's timeline | 1/15min |
get_user_mentions |
Get mentions | 1/15min |
get_home_timeline |
Get home feed | 1/15min |
Engagement
| Tool | Description | Rate Limit |
|---|---|---|
like_tweet / unlike_tweet |
Like/unlike | 1/15min |
retweet / unretweet |
Retweet/undo | 1/15min |
bookmark_tweet / remove_bookmark |
Bookmark | 1/15min |
Users
| Tool | Description | Rate Limit |
|---|---|---|
get_me |
Get authenticated user | 25/24h |
get_user_by_username |
Lookup by handle | 3/15min |
follow_user / unfollow_user |
Follow/unfollow | 1/15min |
mute_user / unmute_user |
Mute/unmute | 1/15min |
Lists & Media
| Tool | Description |
|---|---|
create_list / delete_list / update_list |
Manage lists |
add_list_member / remove_list_member |
List members |
upload_media |
Upload images/videos |
⏱️ Rate Limits (Free Tier)
| Operation | Limit |
|---|---|
| Create/Delete Tweet | 17 requests / 24 hours |
| Get Authenticated User | 25 requests / 24 hours |
| Lookup by Username | 3 requests / 15 mins |
| Most Other Endpoints | 1 request / 15 mins |
❌ Not Available in Free Tier
- Direct Messages
- Trends by WOEID
- User Search
- Full Archive Search
- Filtered Stream
📝 Tips for Free Tier
- Cache responses – With 1 req/15 min limits, cache everything
- Batch requests – Use multi-ID endpoints when possible
- Use username lookup – Has 3 req/15 min (better than most)
- Post sparingly – Only 17 tweets/day allowed
📄 License
This project is licensed under the VivekMind License.
Created by Lnxtanx
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
📞 Support
- Issues: GitHub Issues
- Creator: @Lnxtanx
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。