The X (Twitter) MCP server enables interactions with the X platform through Model Context Protocol, allowing for posting tweets, searching content, managing accounts, and organizing lists.
Clone the repository:
git clone https://github.com/Dishant27/twitter-mcp.git
Install dependencies:
npm install
Configure API keys using one of these methods:
Option 1: Using environment variables directly:
TWITTER_API_KEY=your_api_key \
TWITTER_API_SECRET=your_api_secret \
TWITTER_ACCESS_TOKEN=your_access_token \
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret \
npm start
Option 2: Using a .env file:
# Create a .env file with your X API keys
echo "TWITTER_API_KEY=your_api_key
TWITTER_API_SECRET=your_api_secret
TWITTER_ACCESS_TOKEN=your_access_token
TWITTER_ACCESS_TOKEN_SECRET=your_access_token_secret" > .env
# Start the server
npm start
To use this MCP server with Claude, you need to set up the proper configuration in Claude's MCP config directory:
%APPDATA%\AnthropicClaude\mcp-servers
~/Library/Application Support/AnthropicClaude/mcp-servers
~/.config/AnthropicClaude/mcp-servers
Create a configuration file with this structure:
{
"name": "x",
"display_name": "X",
"description": "X MCP allows Claude to interact with X (formerly Twitter)",
"path": "path/to/twitter-mcp/dist/index.js",
"startup": {
"env": {
"TWITTER_API_KEY": "your_api_key",
"TWITTER_API_SECRET": "your_api_secret",
"TWITTER_ACCESS_TOKEN": "your_access_token",
"TWITTER_ACCESS_TOKEN_SECRET": "your_access_token_secret"
}
},
"transport": "stdio"
}
The server requires the following environment variables:
Variable | Description |
---|---|
TWITTER_API_KEY | Your X API key |
TWITTER_API_SECRET | Your X API secret |
TWITTER_ACCESS_TOKEN | Your X access token |
TWITTER_ACCESS_TOKEN_SECRET | Your X access token secret |
There 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.