The Twitter MCP server provides a simple interface for interacting with Twitter using the agent-twitter-client library. It offers tools to retrieve tweets and post new content through the Model Context Protocol (MCP).
To set up the Twitter MCP server:
npm install
# or
yarn install
.env
file in the root directory with your Twitter credentials:TWITTER_USERNAME=your_twitter_username
TWITTER_PASSWORD=your_twitter_password
[email protected] (optional)
TWITTER_2FA_SECRET=your_2fa_secret (optional)
# Optional API credentials (used as fallback)
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
You can run the server using the FastMCP CLI tools:
# For development and testing in the terminal
npx fastmcp dev
# For visual inspection with the MCP Inspector
npx fastmcp inspect
The getTweet
tool retrieves a tweet by its ID.
Parameters:
tweetId
(string): The ID of the tweet to retrieveExample:
getTweet({"tweetId": "1734609533274853865"})
The sendTweet
tool posts a new tweet to your Twitter account.
Parameters:
text
(string): The text content of the tweet to sendExample:
sendTweet({"text": "Hello World from MCP!"})
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.