Get the FREE Ultimate OpenClaw Setup Guide →

x

MCP server for X(Twitter) based on its Official API

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio geli2001-x-mcp-server docker run -i x-mcp-server-image \
  --env RUST_LOG="info" \
  --env X_BEARER_TOKEN="YOUR_BEARER_TOKEN"

How to use

X MCP Server exposes a Rust-based MCP endpoint that interfaces with the X (formerly Twitter) API to provide read-only access to tweets, user information, and search capabilities, as well as MCP-style tooling compatible with AI agents. The server implements common MCP tools such as get_user (to fetch user profiles by username or ID), search_tweets (to search for tweets with filters), get_tweet (to fetch a single tweet by ID), and get_user_tweets (to retrieve a user’s recent tweets). The project emphasizes secure usage by requiring an X API Bearer token and supports standard MCP integration patterns via stdio-based transport. To use it, you typically run the server in a container or directly on a host, providing the required credentials via environment variables, and connect MCP clients to its standard input/output streams.

After starting the server, MCP clients (including Claude Desktop or other MCP-compatible tools) can issue JSON-encoded requests to the server’s stdin and read responses from stdout. The included example shows how to configure Claude Desktop to connect and pass authentication via environment variables. The tooling is designed to be straightforward for AI systems to perform common Twitter data lookups and searches without posting new content.

How to install

Prerequisites:

  • A system with Rust and Cargo or a container runtime (Docker) available
  • A valid X API Bearer Token for read-only access to the API (as required by your app)

Option A: Install a prebuilt binary via Cargo (recommended if available in your environment)

  1. Install Rust and Cargo from https://www.rust-lang.org/tools/install
  2. Build the server from source:
git clone https://github.com/yourusername/x-mcp-server
cd x-mcp-server
cargo build --release
  1. Run the server directly (example):
X_BEARER_TOKEN=your_bearer_token ./target/release/x-mcp-server

Option B: Run via Docker (containerized)

  1. Ensure Docker is installed and running.
  2. Build or pull a container image for the server (example placeholder):
# If you have a Dockerfile
docker build -t x-mcp-server-image .

# Or pull from a registry if available
# docker pull some-registry/x-mcp-server:latest
  1. Run the container with the required environment variable:
docker run -i -e X_BEARER_TOKEN=your_bearer_token x-mcp-server-image

Option C: From crates.io (if a binary is published) using cargo install

  1. Install the binary:
cargo install x-mcp-server
  1. Run the server:
X_BEARER_TOKEN=your_bearer_token x-mcp-server

Notes:

  • Replace your_bearer_token with a valid Bearer Token from your X developer credentials.
  • Optionally set RUST_LOG for debugging (e.g., RUST_LOG=debug).

Additional notes

Tips and caveats:

  • The server uses X_BEARER_TOKEN for authentication; never log credentials.
  • If you run behind a proxy or firewall, ensure TCP/STDIO endpoints are accessible to MCP clients.
  • The MCP integration section shows a sample config for Claude Desktop and similar clients; you can adapt the env block to pass credentials.
  • This project emphasizes read-only operations; if you need write capabilities (tweet posting), verify current capabilities and permissions on the X API and confirm MCP tool availability.
  • If you encounter rate-limit concerns, monitor the per-endpoint quotas listed in the README and consider implementing client-side throttling.
  • For development, enable verbose logs by setting RUST_LOG=debug to diagnose transport or parsing issues.

Related MCP Servers

Sponsor this space

Reach thousands of developers