twitter mcp server
Provides 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.
Provides 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.
A powerful Twitter integration for AI agents that leverages the Model Context Protocol (MCP) standard, providing a comprehensive set of Twitter functionality through a clean and consistent interface.
This server provides access to Twitter's features through MCP tools, allowing seamless integration with AI assistants and other MCP-compatible clients. It's built on top of the agent-twitter-client
library and provides robust error handling, rate limiting, and consistent response formatting.
get_tweets
- Fetch recent tweets from a userget_profile
- Get a User is profile informationsearch_tweets
- Search for tweets by hashtag or keywordlike_tweet
- Like or unlike a tweetretweet
- Retweet or undo retweetpost_tweet
- Post a new tweet with optional mediacreate_thread
- Create a Twitter threadget_timeline
- Get tweets from different timeline typesget_list_tweets
- Get tweets from a Twitter listget_trends
- Get current trending topicsget_user_relationships
- Get followers or following listfollow_user
- Follow or unfollow a userInstall dependencies:
npm install
Build the server:
npm run build
Configure environment variables:
# Required: Twitter Account Credentials (for user authentication)
TWITTER_USERNAME=your_username
TWITTER_PASSWORD=your_password
TWITTER_EMAIL=your_email
# Twitter API Authentication (Optional)
TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET_KEY=your_api_secret_key
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret
Add the server config to your MCP client:
On MacOS:
~/Library/Application Support/Claude/claude_desktop_config.json
On Windows:
%APPDATA%/Claude/claude_desktop_config.json
Configuration:
{
"mcpServers": {
"twitter-mcp-server": {
"command": "/path/to/twitter-mcp-server/build/index.js"
}
}
}
For development with auto-rebuild:
npm run watch
Since MCP servers communicate over stdio, you can use the MCP Inspector for debugging:
npm run inspector
The Inspector will provide a URL to access debugging tools in your browser.
The server implements comprehensive error handling: - Input validation for all parameters - Rate limiting protection - Detailed error messages - Proper error propagation - Logging for debugging
All tools return responses in a consistent format:
{
content: [{
type: "text",
text: string // JSON stringified response or error message
}]
}
Contributions are welcome! Please feel free to submit a Pull Request.
MIT License - see LICENSE file for details