X (Twitter) Scraper MCP server

Integrates with X using the agent-twitter-client library, enabling tweet retrieval and posting within Docker containers with proxy support for network isolation.
Back to servers
Provider
takiAA
Release date
Mar 06, 2025
Language
TypeScript
Stats
1 star

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

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • Twitter account credentials

Installation

To set up the Twitter MCP server:

  1. Clone the repository
  2. Install dependencies:
npm install
# or
yarn install
  1. Create a .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

Usage

Running the Server

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

Available Tools

Getting a Tweet

The getTweet tool retrieves a tweet by its ID.

Parameters:

  • tweetId (string): The ID of the tweet to retrieve

Example:

getTweet({"tweetId": "1734609533274853865"})

Posting a Tweet

The sendTweet tool posts a new tweet to your Twitter account.

Parameters:

  • text (string): The text content of the tweet to send

Example:

sendTweet({"text": "Hello World from MCP!"})

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