The Twitter MCP Server is a comprehensive API integration platform that allows interaction with Twitter's API for various operations:
Tweet Operations: Post tweets (with or without media), reply to tweets, delete tweets, retrieve tweets by ID or in batches
User Operations: Get user information, follow/unfollow users, retrieve user timelines, followers, and following lists (some features currently have availability issues)
Engagement: Like/unlike tweets, retweet/undo retweets, and get lists of retweets and liked tweets
Search & Analytics: Search for tweets and get hashtag analytics (some features currently have availability issues)
List Management: Create lists, add/remove users from lists, and retrieve list members and user-owned lists
Uses environment variables from .env files to store Twitter API credentials securely
Uses npm for dependency management and running build/development scripts
Uses TypeScript for implementation of parameter validation and error handling
X (Twitter) MCP Server
A comprehensive Model Context Protocol server implementation for X (Twitter) API integration with professional workflow automation, enhanced error handling, and real-time documentation.
🚀 Features
- 53 Total Tools - 33 Twitter API + 20 enhanced SocialData.tools research capabilities
- Advanced Analytics - Thread analysis, network mapping, sentiment analysis, viral tracking
- Bypasses API Restrictions - Enhanced research tools work without Pro tier requirements
- Professional Error Handling - Clear upgrade guidance and graceful API key handling
- 5 Workflow Prompts - Pre-built automation templates
- 6 Dynamic Resources - Real-time API documentation and status
- Full MCP Compliance - Tools, prompts, and resources support
📋 Quick Start
Prerequisites
- Node.js 18+
- npm or yarn
- X (Twitter) API credentials (Basic tier minimum - $200/month)
Local Installation
- Clone and Install
- Environment SetupRequired Environment Variables:
- Build and Run
- Test the Server
🔑 X (Twitter) API Setup
Required Credentials
Add these to your .env
file:
API Access Levels
Tier | Cost | Working Tools | Limited Tools |
---|---|---|---|
Basic | $200/month | 18/22 tools | searchTweets, getHashtagAnalytics |
Pro | $5,000/month | All 22 tools | None |
🛠️ Available Tools (53 Total)
🐦 Twitter API Tools (33 tools)
✅ Tweet Operations (All Working)
postTweet
- Post new tweetsgetTweetById
- Retrieve specific tweetsreplyToTweet
- Reply to tweetsdeleteTweet
- Delete your tweets
✅ Engagement (All Working)
likeTweet
/unlikeTweet
- Like/unlike tweetsretweet
/undoRetweet
- Retweet/undo retweetsgetRetweets
- Get retweet users
✅ User Management (Most Working)
getUserInfo
- Get user profiles ✅getUserTimeline
- Get user tweets ✅followUser
/unfollowUser
- Follow/unfollow users ✅getFollowers
- Get followers ⚠️ (403 - requires special permissions)getFollowing
- Get following ⚠️ (403 - requires special permissions)
✅ List Management (All Working)
createList
- Create X (Twitter) listsgetUserLists
- Get user's listsaddUserToList
/removeUserFromList
- Manage list membersgetListMembers
- Get list members
⚠️ Search & Analytics (Limited)
searchTweets
- Search tweets (requires Pro tier - $5,000/month)getHashtagAnalytics
- Hashtag analytics (requires Pro tier)getLikedTweets
- Get liked tweets (API access issue)
🔍 SocialData.tools Enhanced Research (20 tools)
Note: These tools gracefully handle missing API keys with helpful setup instructions
🔎 Advanced Search (6 tools)
advancedTweetSearch
- Complex queries with operators, bypasses API tier restrictionshistoricalTweetSearch
- Access historical tweets beyond standard API limitstrendingTopicsSearch
- Real-time trend analysis and popular content discoverybulkUserProfiles
- Multi-user profile analysis in single requestsuserGrowthAnalytics
- User growth pattern analysis over timeuserInfluenceMetrics
- Engagement scoring and influence calculations
🧵 Thread & Conversation Analysis (3 tools)
getFullThread
- Reconstruct complete Twitter threads with engagement metricsgetConversationTree
- Map conversation structure including replies and quotesgetThreadMetrics
- Thread performance analysis and engagement distribution
🌐 Network Analysis (3 tools)
findMutualConnections
- Discover mutual connections via interactionsanalyzeFollowerDemographics
- Follower patterns and demographic analysismapInfluenceNetwork
- Influence mapping and connection strength analysis
📈 Advanced Analytics (3 tools)
getHashtagTrends
- Hashtag performance tracking over time with trend analysisanalyzeSentiment
- Sentiment analysis with keyword frequency trackingtrackVirality
- Viral spread patterns and engagement velocity analysis
📱 Direct Messages & Moderation (5 tools)
- Various DM and user moderation tools
🔑 API Keys Setup
Twitter API (Required)
Get these from Twitter Developer Portal:
SocialData.tools API (Optional)
Enables 20 enhanced research tools that bypass Twitter API limitations:
- Sign up at SocialData.tools
- Get your API key from the dashboard
- Add to .env file:
Without SocialData API key: Enhanced research tools will show helpful setup instructions instead of errors.
🧪 Testing SocialData.tools Integration
Test Enhanced Research Tools
Test Without API Key
🆚 When to Use Which Tools
Twitter API vs SocialData.tools Comparison
Use Case | Twitter API Tool | SocialData.tools Alternative | Advantage |
---|---|---|---|
Basic Search | searchTweets ⚠️ (Pro tier $5k/month) | advancedTweetSearch ✅ | Bypasses API restrictions |
User Analysis | getUserInfo ✅ | userInfluenceMetrics ✅ | Enhanced analytics |
Historical Data | Limited by API tier | historicalTweetSearch ✅ | Access older tweets |
Sentiment Analysis | Not available | analyzeSentiment ✅ | Built-in sentiment scoring |
Thread Analysis | Manual reconstruction | getFullThread ✅ | Automated thread mapping |
Network Mapping | Not available | mapInfluenceNetwork ✅ | Connection analysis |
Hashtag Trends | getHashtagAnalytics ⚠️ (Pro tier) | getHashtagTrends ✅ | No tier restrictions |
Recommended Workflow
- Start with Twitter API tools for posting, engagement, and basic operations
- Use SocialData.tools for research, analytics, and advanced insights
- Combine both for comprehensive Twitter automation and analysis
🎯 MCP Workflow Prompts
Our server includes 5 professional workflow templates:
1. Tweet Composition (compose-tweet
)
Interactive guidance for creating engaging tweets with hashtags, mentions, and media.
2. Analytics Reporting (analytics-report
)
Comprehensive X (Twitter) analytics workflow for business insights.
3. Content Strategy (content-strategy
)
Strategic content planning and audience engagement workflows.
4. Community Management (community-management
)
Customer service and community engagement best practices.
5. Hashtag Research (hashtag-research
)
Industry-specific hashtag research and trend analysis.
📊 Dynamic Resources
Real-time information accessible via MCP:
- API Rate Limits - Live usage monitoring
- Access Level Status - Current tier capabilities
- Tool Status Report - Working vs limited tools
- Quick Start Guide - Getting started documentation
- Workflow Templates - Pre-built automation examples
- User Profile Data - Dynamic user information (live API calls)
🧪 Testing
Manual Testing
Test Results Summary
- 18 Tools Working on Basic tier
- 4 Tools Limited by API tier/permissions
- Professional error messages with upgrade guidance
- All core functionality operational
🔧 Integration Examples
MCP Client (Cursor/Claude)
Direct JSON-RPC
📝 API Documentation
Tweet Operations
postTweet
getTweetById
replyToTweet
User Operations
getUserInfo
followUser
Engagement
likeTweet
retweet
🚨 Error Handling
Professional Error Messages
Our enhanced error handling provides:
- Clear API tier explanations for limited tools
- Upgrade pricing information ($5,000/month Pro tier)
- Direct upgrade links to Twitter Developer Portal
- Alternative solution suggestions
Example error response:
📁 Project Structure
🔄 Development
Build & Run
Adding New Tools
- Add handler function in appropriate
src/handlers/
file - Register tool in
src/index.ts
- Add documentation to this README
- Test with JSON-RPC calls
Contributing
- Follow existing code patterns
- Add proper error handling with professional messages
- Test with both working and failing scenarios
- Update documentation
📋 Known Limitations
API Tier Restrictions
- searchTweets: Requires Pro tier ($5,000/month)
- getHashtagAnalytics: Requires Pro tier
- getFollowers/getFollowing: Requires special permissions (403 errors)
- getLikedTweets: Parameter validation issues
Recommendations
- Current Setup: Excellent for basic X (Twitter) automation
- For Advanced Analytics: Consider Pro tier upgrade
- For Followers/Following: Request elevated permissions
🆘 Troubleshooting
Common Issues
Error: "fetch is not defined"
403 Permission Errors
- Check API credentials are correct
- Verify account has required permissions
- Some endpoints need special approval
400 Bad Request Errors
- Review parameter formats
- Check our enhanced error messages for guidance
- Verify API tier supports the endpoint
Getting Help
- Check error messages - Our enhanced error handling provides clear guidance
- Review API documentation - X (Twitter) Developer Portal
- Test with working tools first - Verify basic setup
- Check environment variables - Ensure all credentials are set
📊 Current Status
- 53 Total Tools: 33 Twitter API + 20 SocialData.tools enhanced research
- Advanced Analytics: Thread analysis, network mapping, sentiment analysis, viral tracking
- Graceful API Key Handling: Enhanced tools show helpful setup instructions when API key missing
- Bypasses API Restrictions: Research tools work without Twitter Pro tier requirements
- Professional Error Handling: Clear upgrade guidance and user-friendly messages
- Full MCP Compliance: Tools, prompts, resources
- Production Ready: Enhanced reliability, comprehensive analytics, and excellent UX
Built with ❤️ using the Model Context Protocol and SocialData.tools integration
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Tools
Enables interaction with Twitter through a Model Context Protocol, allowing large language models to post tweets, search for tweets, and reply to tweets.
Related Resources
Related MCP Servers
- -securityFlicense-qualityProvides AI agents with comprehensive Twitter functionality through the Model Context Protocol standard, enabling reading tweets, posting content, managing interactions, and accessing timeline data with robust error handling.Last updated -414
- -securityAlicense-qualityA Model Context Protocol server that enables AI to interact with Twitter, allowing functions like searching tweets, comparing sentiments across accounts, and retrieving timeline content.Last updated -MIT License
- -securityAlicense-qualityA Model Context Protocol server that enables AI models and applications to interact directly with Twitter/X, providing capabilities to create posts, reply to tweets, retrieve user data, and manage account actions.Last updated -19MIT License
- -securityAlicense-qualityA Model Context Protocol server that enables AI agents to interact with Twitter without direct API access, supporting tweet operations, user interactions, and Grok AI integration.Last updated -1016MIT License