x
MCP server for X(Twitter) based on its Official API
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)
- Install Rust and Cargo from https://www.rust-lang.org/tools/install
- Build the server from source:
git clone https://github.com/yourusername/x-mcp-server
cd x-mcp-server
cargo build --release
- Run the server directly (example):
X_BEARER_TOKEN=your_bearer_token ./target/release/x-mcp-server
Option B: Run via Docker (containerized)
- Ensure Docker is installed and running.
- 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
- 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
- Install the binary:
cargo install x-mcp-server
- 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
goose
an open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM
cunzhi
告别AI提前终止烦恼,助力AI更加持久
probe
AI-friendly semantic code search engine for large codebases. Combines ripgrep speed with tree-sitter AST parsing. Powers AI coding assistants with precise, context-aware code understanding.
mcp-center
A centralized platform for managing and connecting MCP servers. MCP Center provides a high-performance proxy service that enables seamless communication between MCP clients and multiple MCP servers.
backlog -rust
MCP server for Backlog, project management service.
perplexity-web-api
🔍 Perplexity AI MCP without API key