x-ai-mcp
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-ai-mcp analyze the current sentiment around AI agents on X"
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-ai-mcp
X (Twitter) MCP server with Grok-powered intelligence. Personal account access + AI analysis in one package.
20 tools: 16 X API tools for reading/writing + 4 Grok intelligence tools for real-time analysis.
Setup
1. Install
git clone https://github.com/olivier-motium/x-ai-mcp.git
cd x-ai-mcp
python -m venv .venv && source .venv/bin/activate
pip install -e .2. Configure
Copy .env.example to .env and fill in:
# Required — X API bearer token (read-only operations)
X_BEARER_TOKEN=your_bearer_token
# Required — your X user ID
X_USER_ID=your_user_id
# Optional — OAuth for write ops (posting, DMs)
# Run: python scripts/auth_flow.py
X_CLIENT_ID=your_client_id
# Optional — xAI key for intelligence tools
XAI_API_KEY=your_xai_key3. Get OAuth tokens (for write operations)
python scripts/auth_flow.pyOpens browser, authorizes your account, saves token.json. Tokens auto-refresh.
4. Add to Claude Code
claude mcp add x-ai \
-e X_BEARER_TOKEN=xxx \
-e X_USER_ID=xxx \
-e XAI_API_KEY=xxx \
-- python -m src.serverTools
X API — Timeline & Tweets
Tool | Description |
| Your home timeline |
| A user's recent tweets |
| Get a specific tweet |
| Post a tweet (OAuth) |
| Delete your tweet (OAuth) |
| Search recent tweets (7 days) |
X API — DMs
Tool | Description |
| Recent DM messages |
| Read a DM conversation |
| Send a DM (OAuth) |
X API — Social
Tool | Description |
| Your bookmarked tweets |
| Liked tweets (you or others) |
| Like a tweet (OAuth) |
| User profile details |
| List followers |
| List following |
Intelligence — Grok-powered
Tool | Description |
| Real-time analysis of any topic on X |
| AI-powered daily briefing |
| Summarize a tweet thread |
| Deep analysis of any X account |
Daily Digest (standalone)
# Default (AI/tech focus)
python scripts/daily_digest.py
# Custom focus
python scripts/daily_digest.py --focus "crypto markets"
# Save to file
python scripts/daily_digest.py --focus "AI agents" --output digest.mdCron it for daily briefings:
0 9 * * * cd /path/to/x-ai-mcp && .venv/bin/python scripts/daily_digest.py >> ~/digests.logArchitecture
Bearer Token (read) ──┐
OAuth 2.0 PKCE (r/w) ─┤──→ X API v2 ──→ 16 MCP tools
│
xAI API Key ───────────┤──→ Grok (x_search + chat) ──→ 4 intelligence tools
│
Logfire (optional) ────┘──→ Observability dashboardX client: async httpx, auto rate-limit retry, OAuth token refresh
Grok client: Chat Completions API for analysis, Responses API with x_search for real-time X data
Output: Plain text, never raw JSON. Tweets formatted as
[date time] @user: text (metrics)
License
MIT
Available Tools
23 toolsx_analyze_accountB
Use Grok to analyze an X account — their posting patterns, key topics, influence, and recent activity.
Args:
username: X username (without @)
Inputs: username (required). Returns: result
x_analyze_topicB
Use Grok AI to analyze what X is saying about a topic right now. Returns insights with citations from real-time X data.
Args:
topic: Topic to analyze (e.g., 'AI agents', 'Claude Code', 'Bitcoin')
Inputs: topic (required). Returns: result
x_bookmarksB
Get your bookmarked tweets. Requires OAuth token.
Args:
count: Number of bookmarks (1-100, default 20)
Inputs: count. Returns: result
x_daily_digestB
Generate an AI-powered daily digest of what's happening on X. Uses Grok with real-time X search.
Args:
focus: Optional focus area (e.g., 'AI', 'crypto', 'tech startups'). Defaults to general tech/AI.
Inputs: focus. Returns: result
x_delete_tweetA
Delete one of your tweets. Permanent action.
Args:
tweet_id: ID of the tweet to delete
Inputs: tweet_id (required). Returns: result
x_dm_inboxA
List all DM conversations — both regular (REST API) and encrypted (XChat GraphQL).
Shows conversation list with participant info, last message preview,
and encryption status. Encrypted conversations are fetched from XChat
and decrypted if private key is available.
Args:
count: Max conversations to return (default 20)
Inputs: count. Returns: result
x_dm_read_conversationA
Read messages from a DM conversation.
Automatically detects encrypted conversations (IDs starting with 'e')
and uses XChat GraphQL + decryption. Regular conversations use REST API.
Args:
conversation_id: The conversation ID
count: Max messages to fetch (default 50)
Inputs: conversation_id (required), count. Returns: result
x_dm_sendB
Send a DM via X's internal API (regular conversations only).
Args:
conversation_id: The conversation ID to send to
text: Message text to send
Inputs: conversation_id (required), text (required). Returns: result
x_followersB
List followers for yourself or another user.
Args:
username: Username or user ID (default: your account)
count: Number of followers (1-1000, default 50)
Inputs: username, count. Returns: result
x_followingB
List accounts you (or another user) follow.
Args:
username: Username or user ID (default: your account)
count: Number of accounts (1-1000, default 50)
Inputs: username, count. Returns: result
x_get_tweetA
Get a specific tweet by ID with full details.
Args:
tweet_id: The tweet ID to fetch
Inputs: tweet_id (required). Returns: result
x_home_timelineA
Get your home timeline — tweets from people you follow. Requires OAuth token.
Args:
count: Number of tweets to fetch (1-100, default 20)
Inputs: count. Returns: result
x_liked_tweetsB
Get liked tweets for yourself or another user.
Args:
username: Username or user ID (default: your account)
count: Number of likes (1-100, default 20)
Inputs: username, count. Returns: result
x_like_tweetB
Like a tweet. Requires OAuth token.
Args:
tweet_id: ID of the tweet to like
Inputs: tweet_id (required). Returns: result
x_list_dmsA
List your actual DM conversations (where you've replied). Filters out unanswered message requests.
Args:
count: Number of DM events to scan (1-100, default 50). Higher = more conversations found.
Inputs: count. Returns: result
x_message_requestsB
List pending DM message requests — messages from people you haven't replied to.
Args:
count: Number of DM events to scan (1-100, default 50).
Inputs: count. Returns: result
x_post_tweetA
Post a new tweet. Requires OAuth token with tweet.write scope.
Args:
text: Tweet text (max 280 characters)
reply_to: Optional tweet ID to reply to
Inputs: text (required), reply_to. Returns: result
x_read_dmB
Read messages from a specific DM conversation.
Args:
conversation_id: The DM conversation ID
count: Number of messages (1-100, default 20)
Inputs: conversation_id (required), count. Returns: result
x_search_tweetsA
Search recent tweets (last 7 days). Supports X search operators.
Args:
query: Search query. Supports operators like 'from:user', 'has:links', '#hashtag', '-filter:retweets'
count: Number of results (10-100, default 20)
Inputs: query (required), count. Returns: result
x_send_dmA
Send a direct message to a user. Requires OAuth with dm.write scope.
Args:
user_id: The recipient's user ID
text: Message text
Inputs: user_id (required), text (required). Returns: result
x_summarize_threadB
Use Grok to find and summarize a tweet thread. Provides key points and analysis.
Args:
tweet_id: ID of the first tweet in the thread (or any tweet in it)
Inputs: tweet_id (required). Returns: result
x_user_infoB
Get detailed profile info for a user.
Args:
username: X username (without @) or user ID
Inputs: username (required). Returns: result
x_user_tweetsB
Get recent tweets from a specific user.
Args:
username: X username (without @) or user ID
count: Number of tweets (1-100, default 20)
Inputs: username (required), count. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 23 tools
Most tools have distinct purposes with clear boundaries, such as x_analyze_account for account analysis and x_post_tweet for tweeting. However, there is some overlap between x_dm_inbox and x_list_dms (both list DM conversations) and between x_dm_send and x_send_dm (both send DMs), which could cause minor confusion for an agent.
All tool names follow a consistent snake_case pattern with a clear 'x_' prefix, and most use descriptive verb_noun combinations (e.g., x_analyze_account, x_search_tweets). The naming is highly predictable and uniform across all 23 tools.
With 23 tools, the count is on the higher side for a Twitter/X-focused server, bordering on heavy. While it covers many aspects of the platform, it might feel overwhelming or slightly over-scoped compared to more streamlined servers, but it's not extreme.
The tool set provides comprehensive coverage for the Twitter/X domain, including account analysis, tweeting (post, delete, like), DMs (send, read, manage), user info, timelines, search, and advanced features like summarization and digests. There are no obvious gaps, and it supports full CRUD-like operations for tweets and DMs.
Related MCP Connectors
Hosted X (Twitter) MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Official MCP server for twitterapis.com. Twitter/X search, users, DMs, Grok, monitoring and writes.
Twitter/X read-only MCP server — 12 tools: search, users, tweets, followers, timelines, trends.
Official twitterapi.io hosted MCP: Twitter/X tweets, users, followers, trends. OAuth or API key.