MCP_X
X(Formely Twitter) MCP Server
A Model Context Protocol (MCP) server implementation that provides seamless integration with Twitter/X API, allowing AI models to interact with Twitter functionalities through a standardized interface.

🌟 Features
-
Tweet Management
- Create and post tweets
- Reply to existing tweets
- Like and retweet functionality
- Thread viewing capabilities
-
Data Retrieval
- Fetch tweet details
- Search functionality
- Thread reconstruction
- Metrics tracking (likes, retweets)
-
Security
- Environment-based configuration
- Secure credential management
- Error handling and validation
📋 Prerequisites
- Python 3.10 or higher
- MCP CLI (
mcp[cli]) - Twitter Developer Account with API credentials
- Virtual environment management tool (venv)
- Tweepy library
🚀 Installation
-
Clone the repository
git clone https://your-repository-url.git cd twitter-mcp-server -
Create and activate virtual environment
python3.10 -m venv .venv source .venv/bin/activate -
Install dependencies
pip install "mcp[cli]" tweepy python-dotenv -
Configure environment variables Create a
.envfile in the project root:TWITTER_API_KEY=your_api_key_here TWITTER_API_SECRET=your_api_secret_here TWITTER_ACCESS_TOKEN=your_access_token_here TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret_here -
Install the MCP server
mcp install main.py
🛠️ Configuration
MCP Server Configuration
Create or update your MCP configuration file:
For Claude Desktop (~/Library/Application Support/Claude/claude_desktop_config.json):
{
"mcpServers": {
"twitter": {
"command": "python",
"args": ["path/to/main.py"],
"env": {
"PYTHONPATH": "path/to/project"
}
}
}
}
🔧 Available Tools
1. Post Tweet
post_tweet(content: str) -> Dict
Posts a new tweet to your account.
- Parameters:
content: Tweet text (max 280 characters)
- Returns:
- Success response with tweet ID and content
- Error response if validation fails
2. Reply to Tweet
reply_to_tweet(tweet_id: str, content: str) -> Dict
Creates a reply to an existing tweet.
- Parameters:
tweet_id: ID of the tweet to reply tocontent: Reply text (max 280 characters)
3. Get Tweet
get_tweet(tweet_id: str) -> Dict
Retrieves details of a specific tweet.
- Parameters:
tweet_id: ID of the tweet to fetch
- Returns:
- Tweet details including metrics
4. Like Tweet
like_tweet(tweet_id: str) -> Dict
Likes a specific tweet.
- Parameters:
tweet_id: ID of the tweet to like
5. Retweet
retweet(tweet_id: str) -> Dict
Retweets a specific tweet.
- Parameters:
tweet_id: ID of the tweet to retweet
6. Get Tweet Thread
get_tweet_thread(tweet_id: str) -> dict
Retrieves a complete thread starting from a tweet.
- Parameters:
tweet_id: ID of the thread's root tweet
7. Search Tweets
search_tweets(query: str) -> List[dict]
Searches for tweets containing specific text.
- Parameters:
query: Search query string
📝 Usage Examples
Basic Tweet
response = post_tweet("Hello from Twitter MCP Server!")
print(response)
Reply to Tweet
response = reply_to_tweet("1234567890", "This is a reply!")
print(response)
View Thread
thread = get_tweet_thread("1234567890")
print(thread)
🔒 Security
- Never commit
.envfile to version control - Regularly rotate API credentials
- Monitor API usage and rate limits
- Validate input data before making API calls
🐛 Debugging
-
Check MCP Server Logs
tail -n 20 -F ~/Library/Logs/Claude/mcp*.log -
Enable Developer Tools
echo '{"allowDevTools": true}' > ~/Library/Application\\ Support/Claude/developer_settings.json -
Test Server Connection
mcp dev main.py
📊 Rate Limits
Twitter API has rate limits that vary by endpoint:
- Tweet creation: 200 per 15 minutes
- Likes: 1000 per 24 hours
- Retweets: 1000 per 24 hours
🤝 Contributing
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Twitter API Documentation
- MCP Protocol Specification
- Tweepy Library Documentation
- Claude Desktop Development Team
📞 Support
For support, please:
- Check the documentation
- Review existing issues
- Create a new issue with detailed information
🔄 Version History
- 1.0.0
- Initial release
- Basic Twitter functionality
- MCP integration
🚧 Roadmap
- [ ] Media attachment support
- [ ] Direct message functionality
- [ ] Advanced search options
- [ ] Analytics integration
- [ ] Batch operations
- [ ] Rate limit handling
⚠️ Important Notes
- Keep API credentials secure
- Monitor rate limits
- Test thoroughly before production use
- Keep dependencies updated
Recommend MCP Servers 💡
@microsoft/clarity-mcp-server
A Model Context Protocol (MCP) server that integrates with Microsoft Clarity's data export API, enabling users to query analytics data from Clarity using MCP-compatible clients like Claude for Desktop.
@modelcontextprotocol/server-filesystem
A Node.js server implementing the Model Context Protocol (MCP) to enable AI models to perform various filesystem operations, including reading, writing, creating, listing, moving, searching files and directories, and retrieving file metadata, with dynamic access control via MCP Roots.
AutoML
An automated machine learning platform offering data analysis, preprocessing, model selection, and hyperparameter tuning via Model Context Protocol (MCP) tools.
ChandekarDhruvin/claude-openweather-mcp
Enables Claude to interact with live weather data (current + forecast) using the OpenWeather API via an MCP server.
@llmindset/mcp-miro
A Model Context Protocol server to connect to the MIRO Whiteboard Application.
arxiv_mcp
An MCP service for searching and interpreting academic papers from arXiv.