X MCP Server
The X MCP Server allows integration with X (Twitter) for reading and engaging with tweets via a TypeScript-based server.
Capabilities:
Retrieve tweets from your home timeline (with optional limit up to 100)
Post new tweets (up to 280 characters)
Reply to existing tweets using their ID
Built-in rate limit handling for X's free tier (500 posts/100 reads per month)
TypeScript implementation for type safety and scalability
A Model Context Protocol (MCP) server for X (Twitter) integration that provides tools for reading your timeline and engaging with tweets. Allows users to get tweets from their home timeline, create new tweets, reply to tweets, and includes built-in rate limit handling for the free API tier.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@X MCP Servershow me my latest tweets from the past hour"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
X MCP Server
A Model Context Protocol (MCP) server for X (Twitter) integration. Provides 26 tools for reading timelines, posting, searching, engagement (likes, retweets, bookmarks), user lookup, follower export, mentions, likes, articles, and lists. Designed for use with Claude desktop and other MCP-compatible clients.
Features
Timeline & Search - Home timeline, search recent posts (7-day window)
Post Management - Create, reply, quote, delete posts with optional media
Engagement - Like/unlike, retweet/undo, bookmark/unbookmark
User Data - Mentions, liked posts, followers, following, blocks, mutes, owned lists, followed lists, and list memberships
User Lookup - Get user profiles and their recent posts
Media Upload - Images (PNG, JPEG, GIF, WEBP) and videos (MP4, MOV, AVI, WEBM, M4V) via v2 upload API
Dual Auth - OAuth 1.0a for post operations, OAuth 2.0 for media upload (v1.1 upload was sunset June 2025)
Rate Limiting - Automatic per-endpoint rate limit tracking with clear error messages
TypeScript - Full type safety, modular file structure
Related MCP server: X (Twitter) MCP Server - Enhanced Edition
Prerequisites
Node.js >= 18.0.0
X (Twitter) Developer Account
Claude desktop app (or any MCP-compatible client)
X API Access & Pricing
Tier | Cost | Post Reads | Post Writes | Notes |
Free | $0 | ~100/month | ~500/month | No likes/follows; media upload requires OAuth 2.0 |
Basic | $200/month | 10,000/month | 3,000/month | Search, limited read access |
Pro | $5,000/month | 1,000,000/month | 300,000/month | Full search, filtered stream |
Pay-Per-Use | Credit-based | ~$0.005/read | Varies | Launched Feb 2026, 2M reads cap |
Like and Follow endpoints were removed from the Free tier in August 2025. Follows/Blocks endpoints are Enterprise-only as of 2025.
Installation
git clone https://github.com/DataWhisker/x-mcp-server.git
cd x-mcp-server
npm install
npm run buildAuthentication
The server supports two authentication methods. You need at least one configured.
OAuth 1.0a (Required for basic operations)
Works for all post/engagement/search/user operations.
Environment Variable | Description |
| Consumer Key (API Key) |
| Consumer Secret (API Key Secret) |
| User Access Token |
| User Access Token Secret |
Setup: In the X Developer Portal:
Create a project and app
Enable OAuth 1.0a under "User authentication settings"
Set permissions to "Read and Write"
Generate Consumer Keys and Access Tokens
OAuth 2.0 (Required for media upload)
The v1.1 media upload endpoint was sunset in June 2025. Media upload now requires OAuth 2.0 via the v2 upload API.
Option A - Direct access token:
Variable | Description |
| OAuth 2.0 user access token (expires in 2 hours) |
Option B - Auto-refresh (recommended for long-running servers):
Variable | Description |
| OAuth 2.0 Client ID |
| OAuth 2.0 Client Secret (optional for public clients) |
| OAuth 2.0 Refresh Token |
Tokens are auto-refreshed and persisted to ~/.x-mcp-tokens.json.
Setup: In the X Developer Portal:
In your app settings, enable OAuth 2.0
Set type to "Confidential client" or "Public client"
Add a callback URL
Request scopes:
tweet.read,tweet.write,users.read,media.write,offline.access,like.read,like.write,bookmark.read,bookmark.write,follows.read,block.read,mute.read,list.read
Claude Desktop Configuration
Add to %APPDATA%/Claude/claude_desktop_config.json:
{
"mcpServers": {
"x": {
"command": "node",
"args": ["C:/path/to/x-mcp-server/build/index.js"],
"env": {
"TWITTER_API_KEY": "your-api-key",
"TWITTER_API_SECRET": "your-api-secret",
"TWITTER_ACCESS_TOKEN": "your-access-token",
"TWITTER_ACCESS_SECRET": "your-access-secret",
"TWITTER_OAUTH2_ACCESS_TOKEN": "your-oauth2-token"
}
}
}
}Optional Xquik Search Backend
search_tweets can use Xquik while the rest of the server keeps the default
X API client. Set:
Variable | Description |
| Routes only |
| Xquik API key |
| Optional base URL, defaults to |
Available Tools (26)
Timeline & Search
Tool | Description | Key Parameters |
| Get recent posts from home timeline |
|
| Search recent posts (7-day window) |
|
Post Management
Tool | Description | Key Parameters |
| Look up a post by ID |
|
| Create a post with optional media |
|
| Reply to a post with optional media |
|
| Quote a post with commentary |
|
| Delete your post |
|
Engagement
Tool | Description | Key Parameters |
| Like a post (Basic+ tier) |
|
| Remove a like |
|
| Repost to your timeline |
|
| Remove a repost |
|
| Bookmark for later |
|
| Remove a bookmark |
|
| Get your bookmarks |
|
Users
Tool | Description | Key Parameters |
| Look up user by username |
|
| Get a user's recent posts |
|
| Get posts mentioning a user |
|
| Get a user's liked posts |
|
| Get a user's followers |
|
| Get accounts a user follows |
|
| Get users blocked by the authenticated account |
|
| Get users muted by the authenticated account |
|
| Get lists owned by a user |
|
| Get lists followed by a user |
|
| Get lists a user belongs to |
|
Articles
Tool | Description | Key Parameters |
| Fetch the full body content of an X Article post |
|
Media Support
Images: PNG, JPEG, GIF, WEBP (max 5MB)
Videos: MP4, MOV, AVI, WEBM, M4V (max 512MB, streamed chunked upload)
Cannot attach both image and video to the same post
Requires OAuth 2.0 credentials (v1.1 upload sunset June 2025)
Path restriction: Only files within your home directory or system temp directory can be uploaded (prevents path traversal)
Security
Input validation: Tweet IDs must be numeric (1-20 digits), usernames must match
[A-Za-z0-9_]{1,15}Media path restriction: Upload paths are validated against an allow-list (home directory, temp directory)
Token storage: OAuth 2.0 tokens persisted to
~/.x-mcp-tokens.jsonwith0o600permissions (Unix). On Windows, file permissions are not enforced by the OS - protect the file via NTFS ACLs or use environment variables instead.Error sanitization: X API error details are logged server-side only; sanitized messages are returned to MCP clients
Refresh mutex: Concurrent token refresh attempts are deduplicated to prevent race conditions
Development
npm run build # Compile TypeScript
npm run dev # Watch mode
npm start # Run the serverProject Structure
src/
index.ts # MCP server entry point & handler dispatch
client.ts # Twitter client setup (OAuth 1.0a + OAuth 2.0)
media.ts # v2 media upload (simple + chunked)
rate-limit.ts # Per-endpoint rate limiting
tools/
definitions.ts # All 16 tool schemas
handlers.ts # Tool handler implementationsPairing with GetXAPI for Cheaper Read Operations (Optional)
For users who need a cheaper or higher-rate-limit option for read-only Twitter (X) operations such as tweet search, profile lookup, and follower lists, this project can be paired with GetXAPI, a budget Twitter / X data API priced at $0.05 per 1K tweets versus the official X API basic tier at $200 / month.
Two integration patterns:
Run side-by-side in your AI client. Keep this project for its primary workflow and add the official GetXAPI MCP server for read-heavy tasks. Each tool name routes to the backend best suited for that operation.
Add a backend toggle. For a code-level reference of an optional alternative backend behind a single env variable, see the PR pattern merged into a sibling project.
GetXAPI quick start:
Signup with $0.50 free credit (no card required): https://getxapi.com/signup
Official GetXAPI MCP server: https://github.com/getxapi/getxapi-mcp
npm:
@getxapi/mcpPay-per-call pricing: $0.001 / call, $0.05 / 1K tweets
This pairing is fully optional. No behavior change for existing users.
License
MIT
Contributing
Fork the repository
Create your feature branch (
git checkout -b feature/amazing-feature)Commit your changes (
git commit -m 'Add some amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/DataWhisker/x-mcp-server'
If you have feedback or need assistance with the MCP directory API, please join our Discord server