MCP Twitter is a server based on the Model Context Protocol that allows direct interaction with Twitter/X. It enables AI models and applications to perform various Twitter actions through a standardized interface, including posting tweets, retrieving user information, and managing interactions on the platform.
You can install and run the MCP Twitter server using either local installation or NPX.
# Clone the repository
git clone https://github.com/0xhijo/mcp_twitter.git
# Install dependencies and build the project
pnpm build
# Launch the server
node ./build/index.js
For a quicker setup, you can run the server directly using NPX:
npx mcp_twitter
Before using the server, you need to configure Twitter authentication. You can choose between two authentication methods: Twitter Scraper (using credentials) or Twitter API.
.env
file in the root directory of the projectTWITTER_AUTH_MODE = "CREDENTIALS"
TWITTER_USERNAME="YOUR_TWITTER_USERNAME"
TWITTER_PASSWORD="YOUR_TWITTER_PASSWORD"
TWITTER_EMAIL="YOUR_TWITTER_EMAIL"
.env
file with:TWITTER_AUTH_MODE = "API"
TWITTER_API="YOUR_TWITTER_API"
TWITTER_API_SECRET="YOUR_TWITTER_API_SECRET"
TWITTER_ACCESS_TOKEN="YOUR_TWITTER_ACCESS_TOKEN"
TWITTER_ACCESS_TOKEN_SECRET="YOUR_TWITTER_ACCESS_TOKEN_SECRET"
To use MCP Twitter with Claude AI, you need to add it to Claude's MCP configuration.
Add the following entry to your claude_mcp_config.json
file:
"mcp_twitter": {
"command": "npx",
"args": ["mcp_twitter"],
"env": {
"TWITTER_AUTH_MODE": "CREDENTIALS",
"TWITTER_USERNAME": "YOUR_TWITTER_USERNAME",
"TWITTER_PASSWORD": "YOUR_TWITTER_PASSWORD",
"TWITTER_EMAIL": "YOUR_TWITTER_EMAIL"
}
}
Remember to replace the placeholder credentials with your actual Twitter account information.
The MCP Twitter server provides the following Twitter functionality:
create_twitter_post
: Create a new X/Twitter postreply_twitter_tweet
: Reply to a specific X/Twitter post by IDget_last_tweet
: Get the most recent post from a specified accountget_last_tweets_options
: Get a specified number of posts matching a search querycreate_and_post_twitter_thread
: Create and publish a threadfollow_twitter_from_username
: Follow a user by usernameget_twitter_profile_from_username
: Get complete profile data by usernameget_twitter_user_id_from_username
: Get user ID from usernameget_last_tweet_and_replies_from_user
: Get recent posts and replies from a userget_last_tweet_from_user
: Get recent posts from a userget_own_twitter_account_info
: Get current account profile dataThere are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"cursor-rules-mcp": {
"command": "npx",
"args": [
"-y",
"cursor-rules-mcp"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.