Twitter MCP server

Integrates with Twitter's API to enable posting tweets, searching content, managing profiles, and handling follower relationships with robust error handling for rate limits and authentication issues.
Back to servers
Provider
Dishant27
Release date
Apr 06, 2025
Language
TypeScript
Stats
1 star

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.

Installation and Setup

Prerequisites

  • X Developer account with API keys (obtain from X Developer Portal)
  • Node.js 18.x or higher

Installation Steps

  1. Clone the repository:

    git clone https://github.com/Dishant27/twitter-mcp.git
    
  2. Install dependencies:

    npm install
    
  3. 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
    

Using with Claude

To use this MCP server with Claude, you need to set up the proper configuration in Claude's MCP config directory:

  • Windows: %APPDATA%\AnthropicClaude\mcp-servers
  • macOS: ~/Library/Application Support/AnthropicClaude/mcp-servers
  • Linux: ~/.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"
}

Available Tools

Post Operations

  • post_tweet: Post new content to X (up to 280 characters)
  • search_tweets: Search for content on X with customizable result count

Account Management

  • get_profile: Get profile information for any user or the authenticated account
  • update_profile: Update the authenticated user's profile details (name, bio, location, website URL)
  • follow_user: Follow a user
  • unfollow_user: Unfollow a user
  • list_followers: List followers for any user or the authenticated account
  • list_following: List accounts that a user is following

List Management

  • create_list: Create new lists (public or private)
  • get_list_info: Get information about specific lists
  • get_user_lists: Retrieve all lists owned by the authenticated user

Environment Variables

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

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