x-mcp
The x-mcp server provides AI agents with full access to the X (Twitter) API through natural language commands. Here's what you can do:
Post & Manage Content
Create tweets with text, media, or polls (2–4 options, configurable duration)
Reply to tweets, quote-retweet with commentary, and delete posts
Read & Search
Fetch specific tweets by ID or URL (interchangeable)
Search recent tweets (last 7 days) using X's full query language (
from:user,#hashtag,has:media,is:reply, etc.)Get a user's timeline or your own mentions
User Management
Look up user profiles (bio, metrics, verification status) by username or user ID
List a user's followers or accounts they follow
Engagement
Like and retweet posts
Media
Upload images/videos as base64-encoded data; receive a media ID to attach to posts
Analytics
Retrieve engagement metrics (impressions, likes, retweets, replies, quotes, bookmarks) for tweets authored by the authenticated user
Technical Highlights
Pagination via
next_tokenfor search, timelines, mentions, followers, and followingRate limit details (remaining requests, total limit, reset time) included in every response
Compatible with Claude, Cursor, Windsurf, Cline, and other MCP clients
Requires 5 X API credentials with read/write permissions
Click on "Deploy 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 Search for the latest tweets about MCP and summarize the top results"
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
An MCP (Model Context Protocol) server that gives AI agents full access to the X (Twitter) API. Post tweets, search, read timelines, like, retweet, upload media -- all through natural language.
Works with Claude Code, Claude Desktop, OpenAI Codex, Cursor, Windsurf, Cline, and any other MCP-compatible client.
If you're an LLM/AI agent helping a user set up this project, read LLMs.md for step-by-step instructions you can walk the user through.
What Can It Do?
Category | Tools | What You Can Say | Status |
Post |
| "Post 'hello world' on X" | OK |
Read |
| "Show me @elonmusk's latest posts" | OK |
Users |
| "Look up @openai" / "Who does this user follow?" | OK |
Engage |
| "Retweet this" | OK |
Media |
| "Upload this image and post it with the caption..." | OK |
Analytics |
| "How many impressions did my last post get?" | OK |
Bookmarks |
| "Show my bookmarks" | Requires Basic+ tier |
Reply |
| "Reply to this tweet saying thanks" | Restricted (see below) |
Like |
| "Like that tweet" | Removed on Free tier (see below) |
Accepts tweet URLs or IDs interchangeably -- paste https://x.com/user/status/123 or just 123.
Related MCP server: tweetly
Setup
1. Clone and build
git clone https://github.com/INFATOSHI/x-mcp.git
cd x-mcp
npm install
npm run build2. Get your X API credentials
You need 5 credentials from the X Developer Portal. Here's exactly how to get them:
a) Create an app
Go to the X Developer Portal
Sign in with your X account
Go to Apps in the left sidebar
Click Create App (you may need to sign up for a developer account first)
Give it a name (e.g.,
my-x-mcp)You'll immediately see your Consumer Key (API Key), Secret Key (API Secret), and Bearer Token
Save all three now -- the secret won't be shown again
b) Enable write permissions
By default, new apps only have Read permissions. You need Read and Write to post tweets, like, retweet, etc.
In your app's page, scroll down to User authentication settings
Click Set up
Set App permissions to Read and write
Set Type of App to Web App, Automated App or Bot
Set Callback URI / Redirect URL to
https://localhost(required but won't be used)Set Website URL to any valid URL (e.g.,
https://x.com)Click Save
c) Generate access tokens (with write permissions)
After enabling write permissions, you need to generate (or regenerate) your Access Token and Secret so they carry the new permissions:
Go back to your app's Keys and Tokens page
Under Access Token and Secret, click Regenerate
Save both the Access Token and Access Token Secret
If you skip step (b) before generating tokens, your tokens will be Read-only and posting will fail with a 403 error.
3. Configure credentials
Copy the example env file and fill in your 5 credentials:
cp .env.example .envEdit .env:
X_API_KEY=your_consumer_key
X_API_SECRET=your_secret_key
X_BEARER_TOKEN=your_bearer_token
X_ACCESS_TOKEN=your_access_token
X_ACCESS_TOKEN_SECRET=your_access_token_secretConnect to Your Client
Pick your client below. You only need to follow one section.
Claude Code
claude mcp add --scope user x-twitter -- node /ABSOLUTE/PATH/TO/x-mcp/dist/index.jsReplace /ABSOLUTE/PATH/TO/x-mcp with the actual path where you cloned the repo. Then restart Claude Code.
Claude Desktop
Add to your claude_desktop_config.json:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"x-twitter": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/x-mcp/dist/index.js"],
"env": {
"X_API_KEY": "your_consumer_key",
"X_API_SECRET": "your_secret_key",
"X_ACCESS_TOKEN": "your_access_token",
"X_ACCESS_TOKEN_SECRET": "your_access_token_secret",
"X_BEARER_TOKEN": "your_bearer_token"
}
}
}
}Cursor
Add to your Cursor MCP config:
Global (all projects):
~/.cursor/mcp.jsonProject-scoped:
.cursor/mcp.jsonin your project root
{
"mcpServers": {
"x-twitter": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/x-mcp/dist/index.js"],
"env": {
"X_API_KEY": "your_consumer_key",
"X_API_SECRET": "your_secret_key",
"X_ACCESS_TOKEN": "your_access_token",
"X_ACCESS_TOKEN_SECRET": "your_access_token_secret",
"X_BEARER_TOKEN": "your_bearer_token"
}
}
}
}You can also verify the connection in Cursor Settings > MCP Servers.
OpenAI Codex
Option A: CLI
codex mcp add x-twitter --env X_API_KEY=your_consumer_key --env X_API_SECRET=your_secret_key --env X_ACCESS_TOKEN=your_access_token --env X_ACCESS_TOKEN_SECRET=your_access_token_secret --env X_BEARER_TOKEN=your_bearer_token -- node /ABSOLUTE/PATH/TO/x-mcp/dist/index.jsOption B: config.toml
Add to ~/.codex/config.toml (global) or .codex/config.toml (project-scoped):
[mcp_servers.x-twitter]
command = "node"
args = ["/ABSOLUTE/PATH/TO/x-mcp/dist/index.js"]
[mcp_servers.x-twitter.env]
X_API_KEY = "your_consumer_key"
X_API_SECRET = "your_secret_key"
X_ACCESS_TOKEN = "your_access_token"
X_ACCESS_TOKEN_SECRET = "your_access_token_secret"
X_BEARER_TOKEN = "your_bearer_token"Windsurf
Add to ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"x-twitter": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/x-mcp/dist/index.js"],
"env": {
"X_API_KEY": "your_consumer_key",
"X_API_SECRET": "your_secret_key",
"X_ACCESS_TOKEN": "your_access_token",
"X_ACCESS_TOKEN_SECRET": "your_access_token_secret",
"X_BEARER_TOKEN": "your_bearer_token"
}
}
}
}You can also add it from Windsurf Settings > Cascade > MCP Servers.
Cline (VS Code)
Open Cline's MCP settings (click the MCP Servers icon in Cline's top nav > Configure), then add to cline_mcp_settings.json:
{
"mcpServers": {
"x-twitter": {
"command": "node",
"args": ["/ABSOLUTE/PATH/TO/x-mcp/dist/index.js"],
"env": {
"X_API_KEY": "your_consumer_key",
"X_API_SECRET": "your_secret_key",
"X_ACCESS_TOKEN": "your_access_token",
"X_ACCESS_TOKEN_SECRET": "your_access_token_secret",
"X_BEARER_TOKEN": "your_bearer_token"
},
"alwaysAllow": [],
"disabled": false
}
}
}Other MCP Clients
This is a standard stdio MCP server. For any MCP-compatible client, point it at:
node /ABSOLUTE/PATH/TO/x-mcp/dist/index.jsWith these environment variables: X_API_KEY, X_API_SECRET, X_ACCESS_TOKEN, X_ACCESS_TOKEN_SECRET, X_BEARER_TOKEN.
API Restrictions (as of 2025-2026)
X has progressively restricted what automated/API clients can do. Here's what affects x-mcp:
Likes removed from Free tier (Aug 2025)
The like_tweet endpoint (POST /2/users/:id/likes) was removed from the Free API tier in August 2025. If you're on the Free tier, like_tweet will return a permissions error. Paid tiers (Basic, Pro, Enterprise) are unaffected.
Programmatic replies restricted (Feb 2026)
Replies via the API now only succeed if the original post's author @mentioned you or quoted your post. This applies to all self-serve tiers (Free, Basic, Pro, Pay-Per-Use). Only Enterprise is exempt. Use quote_tweet as a workaround.
Bookmarks require Basic+ tier
Bookmark endpoints have never been available on the Free tier. You need at least Basic ($200/mo) to use get_bookmarks, bookmark_tweet, and unbookmark_tweet.
Post volume caps
Free tier: 500 posts/month. Basic: 10,000/month. Pro: 1,000,000/month.
Troubleshooting
403 "oauth1-permissions" error when posting
Your Access Token was generated before you enabled write permissions. Go to the X Developer Portal, ensure App permissions are set to "Read and write", then Regenerate your Access Token and Secret.
401 Unauthorized
Double-check that all 5 credentials in your .env are correct and that there are no extra spaces or line breaks.
429 Rate Limited
The error message includes exactly when the rate limit resets. Wait until then, or reduce request frequency.
Reply fails with a permissions/restriction error
As of Feb 2026, X restricts programmatic replies via the API on all self-serve tiers. You can only reply if the original author @mentions you or quotes your post. This applies to Free, Basic, Pro, and Pay-Per-Use tiers (Enterprise is exempt). Use quote_tweet as a workaround.
Server shows "Connected" but tools aren't used
Make sure you added the server with the correct scope (user/global, not project-scoped if you want it everywhere), then restart your client.
Rate Limiting
Every response includes rate limit info: remaining requests, total limit, and reset time. When a limit is hit, you get a clear error with the exact reset timestamp.
Pagination
List endpoints return a next_token in the response. Pass it back to get the next page of results. Works on: search_tweets, get_timeline, get_mentions, get_followers, get_following.
Search Query Syntax
The search_tweets tool supports X's full query language:
from:username-- posts by a specific userto:username-- replies to a specific user#hashtag-- posts containing a hashtag"exact phrase"-- exact text matchhas:media/has:links/has:images-- filter by content typeis:reply/-is:retweet-- filter by post typelang:en-- filter by languageCombine with spaces (AND) or
OR
License
MIT
Available Tools
15 toolsdelete_tweetC
Delete a post on X by its ID.
Inputs: tweet_id (required).
get_followersC
List followers of a user by their numeric user ID.
Inputs: user_id (required), max_results, next_token.
get_followingC
List who a user follows by their numeric user ID.
Inputs: user_id (required), max_results, next_token.
get_mentionsC
Fetch recent mentions of the authenticated user.
Inputs: max_results, next_token.
get_metricsA
Get engagement metrics for a specific post (impressions, likes, retweets, replies, quotes, bookmarks). Requires the tweet to be authored by the authenticated user for non-public metrics.
Inputs: tweet_id (required).
get_timelineA
Fetch a user's recent posts. Requires the user's numeric ID (use get_user first to resolve username to ID).
Inputs: user_id (required), max_results, next_token.
get_tweetA
Fetch a tweet and its metadata by ID or URL. Returns author info, metrics, and referenced tweets.
Inputs: tweet_id (required).
get_userC
Look up a user profile by username or user ID. Returns bio, metrics, verification status, etc.
Inputs: username, user_id.
like_tweetC
Like a post on X.
Inputs: tweet_id (required).
post_tweetC
Create a new post on X (Twitter). Supports text, polls, and media attachments.
Inputs: text (required), poll_options, poll_duration_minutes, media_ids.
quote_tweetB
Quote retweet a post on X. Adds your commentary above the quoted post.
Inputs: tweet_id (required), text (required), media_ids.
reply_to_tweetC
Reply to an existing post on X. Provide the tweet ID or URL to reply to.
Inputs: tweet_id (required), text (required), media_ids.
retweetC
Retweet a post on X.
Inputs: tweet_id (required).
search_tweetsA
Search recent tweets by query. Supports keywords, hashtags, from:user, to:user, is:reply, has:media, etc. Uses the recent search endpoint (last 7 days).
Inputs: query (required), max_results, next_token.
upload_mediaB
Upload an image or video to X. Returns a media_id that can be attached to posts. Provide the file as base64-encoded data.
Inputs: media_data (required), mime_type (required), media_category.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 15 tools
Every tool has a clearly distinct purpose with no ambiguity; for example, get_tweet retrieves a single tweet, get_timeline fetches a user's recent posts, and search_tweets searches across tweets, all serving different functions. Actions like like_tweet, retweet, quote_tweet, and reply_to_tweet are well-separated in their specific interactions with posts, ensuring agents can easily select the correct tool.
All tool names follow a consistent verb_noun pattern using snake_case, such as get_user, post_tweet, and delete_tweet, with no deviations in style or convention. This predictability makes the tool set easy to navigate and understand at a glance, enhancing usability for agents.
With 15 tools, the server is well-scoped for interacting with X (Twitter), covering core functionalities like posting, retrieving, and engaging with tweets and users. Each tool earns its place by addressing specific needs without redundancy, making the count ideal for the domain's complexity.
The tool surface provides complete CRUD/lifecycle coverage for X interactions, including creating (post_tweet), reading (get_tweet, get_timeline, search_tweets), updating (like_tweet, retweet, quote_tweet, reply_to_tweet), and deleting (delete_tweet), along with user management and media handling. No obvious gaps exist, supporting seamless agent workflows.
Maintenance
Related MCP Connectors
Hosted MCP server from TwitterAPI.io that gives AI agents read-only access to Twitter/X data. 12 tools: tweet search with X operators, user profiles, a user's latest tweets, followers and followings, replies, quotes, retweeters, mentions and trends. Connect at https://mcp.twitterapi.io/mcp with a TwitterAPI.io API key or account sign-in; usage is paid per result returned.
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
X Ads (Twitter Ads) MCP server: run X campaigns, ad groups, ads and reports from AI.
Hosted MCP server for AI agents to post to LinkedIn profiles and X and upload to YouTube.
Related MCP Servers
- AlicenseAqualityNot gradedmaintenanceAn MCP server that integrates X (Twitter) API access with Grok-powered intelligence for real-time social media analysis and account management. It provides tools for reading and writing tweets, managing direct messages, and generating AI-powered topic summaries or daily briefings.23MIT
- AlicenseNot gradedqualityDmaintenanceAn MCP server that enables AI agents to automate actions on X (Twitter) through a real browser session, including posting, engaging, and reading via over 40 tools. It supports self-hosting and provides a panel for API key management.2 npm7MIT

X API FastMCP Serverofficial
FlicenseNot gradedqualityDmaintenanceA local MCP server that exposes the X API (formerly Twitter API) as tools, enabling operations like posting, searching, user management, and more via natural language commands.868-- AlicenseAqualityCmaintenanceMCP server for Twitter/X enabling AI agents to search, post, reply, and engage with tweets.1415 npm2MIT