Twitter MCP server

Integrates with Twitter/X to enable direct actions like posting, replying, following users, and retrieving profile data through a Node.js server with dual authentication options.
Back to servers
Provider
Etienne Duclos
Release date
Mar 21, 2025
Language
TypeScript
Package
Stats
193 downloads
7 stars

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.

Installation

You can install and run the MCP Twitter server using either local installation or NPX.

Local Installation

# 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

Installation via NPX

For a quicker setup, you can run the server directly using NPX:

npx mcp_twitter

Configuration

Before using the server, you need to configure Twitter authentication. You can choose between two authentication methods: Twitter Scraper (using credentials) or Twitter API.

Configuration via Twitter Scraper

  1. Create a .env file in the root directory of the project
  2. Add the following variables:
TWITTER_AUTH_MODE = "CREDENTIALS"
TWITTER_USERNAME="YOUR_TWITTER_USERNAME"
TWITTER_PASSWORD="YOUR_TWITTER_PASSWORD"
TWITTER_EMAIL="YOUR_TWITTER_EMAIL"

Configuration via Twitter API

  1. First, ensure you have a Twitter Developer Account with API credentials
  2. Configure the .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"

Integrating with Claude

To use MCP Twitter with Claude AI, you need to add it to Claude's MCP configuration.

Adding 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.

Available Actions

The MCP Twitter server provides the following Twitter functionality:

  • Create posts: Post new tweets to your account
  • Reply to tweets: Respond to specific tweets by ID
  • Retrieve tweets: Get recent posts from specific accounts
  • Create threads: Publish multi-tweet threads
  • Follow users: Follow accounts by username
  • Get profile information: Retrieve user profile data

Specific Actions

  • create_twitter_post: Create a new X/Twitter post
  • reply_twitter_tweet: Reply to a specific X/Twitter post by ID
  • get_last_tweet: Get the most recent post from a specified account
  • get_last_tweets_options: Get a specified number of posts matching a search query
  • create_and_post_twitter_thread: Create and publish a thread
  • follow_twitter_from_username: Follow a user by username
  • get_twitter_profile_from_username: Get complete profile data by username
  • get_twitter_user_id_from_username: Get user ID from username
  • get_last_tweet_and_replies_from_user: Get recent posts and replies from a user
  • get_last_tweet_from_user: Get recent posts from a user
  • get_own_twitter_account_info: Get current account profile data

How to add this MCP server to Cursor

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.

Adding an MCP server to Cursor globally

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"
            ]
        }
    }
}

Adding an MCP server to a project

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.

How to use the MCP server

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.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later