grok-x-search-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., "@grok-x-search-mcp Search X for what people are saying about NVIDIA earnings this week"
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.
grok-x-search-mcp
A free, open-source Model Context Protocol (MCP) server that gives Claude real-time access to X (Twitter) through the xAI Grok API. Search posts, analyze sentiment, track accounts, and cross-reference X with web sources — all from within Claude.
Free to use. This MCP server is open-source with no fees. You only pay xAI directly for API usage — roughly $0.005–$0.01 per search.
Why not just use the X API?
The traditional X (Twitter) API has become prohibitively expensive for most developers:
Approach | Monthly Cost | What you get |
X API Free | $0 | Write-only. No read access. |
X API Basic | $200/month | 15,000 post reads |
X API Pro | $5,000/month | 1M post reads |
X API Enterprise | $42,000+/mo | Custom limits |
xAI Grok x_search | $0 minimum | Pay $0.005 per search. No subscription floor. |
On top of the cost, the X API requires a developer application approval process, OAuth setup, and careful rate-limit management.
With this MCP server, you skip all of that. Grok's x_search tool has privileged, real-time access to X posts and threads built in. One xAI API key, one npm install, and you're querying X through Claude in minutes.
Related MCP server: grok-mcp
Tools
Tool | Description |
| Search X for posts, threads, and media on any topic. Returns summary, key themes, verbatim notable posts, and optional sentiment analysis. |
| Cross-reference what X is saying with web sources. Returns both sides plus a synthesis of where they agree or contradict. |
| Deep-dive a specific X account — dominant topics, tone, and verbatim recent posts. |
| Stateful monitoring — call repeatedly to track only new posts and sentiment shifts since last check. |
Prerequisites
Node.js >= 22
Claude Desktop or any MCP-compatible client
xAI API key — get one at console.x.ai
Setup
1. Clone and install
git clone https://github.com/0xnicholasy/grok-x-search-mcp.git
cd grok-x-search-mcp
npm install2. Configure environment
cp .env.example .envEdit .env and set your API key:
XAI_API_KEY=xai-your-api-key-here
GROK_MODEL=grok-4-1-fast
MAX_RETRIES=3
REQUEST_TIMEOUT_MS=45000
LOG_LEVEL=info3. Build
npm run build4. Register with Claude
Claude Desktop — add to your claude_desktop_config.json:
{
"mcpServers": {
"grok-x-search": {
"command": "node",
"args": ["/absolute/path/to/grok-x-search-mcp/dist/server.js"]
}
}
}Claude Code (CLI) — run once:
claude mcp add --scope user grok-x-search node /absolute/path/to/grok-x-search-mcp/dist/server.jsCursor / Windsurf / other MCP clients — add to your MCP config:
{
"mcpServers": {
"grok-x-search": {
"command": "node",
"args": ["/absolute/path/to/grok-x-search-mcp/dist/server.js"]
}
}
}Restart your client after registering. Verify with /mcp (Claude Desktop) or claude mcp list (Claude Code CLI).
Usage Examples
Once registered, just talk to Claude:
Search X for what people are saying about NVIDIA earnings this weekWhat is the X sentiment on Bitcoin today? Show me verbatim posts.Track @sama's posts this week — what topics is he focused on?Fact-check: is the claim that "inflation is rising" on X supported by web sources?Monitor X for "GPT-5" — I'll call this again later to see new postsAPI Cost
This MCP server is free and open-source. The only costs are xAI API charges billed directly to your account:
Component | Cost |
| $5.00 / 1k calls ($0.005 each) |
| $5.00 / 1k calls ($0.005 each) |
Input tokens (grok-4-1-fast) | $0.20 / 1M |
Output tokens (grok-4-1-fast) | $0.50 / 1M |
A typical search_x call costs roughly $0.005–$0.01 total. New xAI accounts get $25 in free credits to start.
Compare that to the X API Basic tier at $200/month minimum — just to get read access.
Configuration
Variable | Default | Description |
| (required) | Your xAI API key |
|
| Model to use — see xAI model pricing |
|
| Retry attempts on 429/5xx errors (max 5) |
|
| Request timeout in ms (5000–120000) |
|
| Log verbosity: |
Choosing a model
grok-4-1-fast is the recommended default — it is both the cheapest text model and delivers grok-4 quality. The dominant cost is the x_search tool invocation ($0.005/call), not tokens.
For maximum accuracy use grok-4-0709, but expect 30x higher token costs.
Development
# Run with hot-reload (no build needed)
npm run dev
# Interactive tool inspector
npm run inspect
# Run unit tests
npm run test:unit
# Run all tests (requires XAI_API_KEY in .env for integration tests)
npm test
# Type-check without building
npm run lintThe monitor_x tool persists state to .monitor-state.json in the project root (excluded from git). Delete this file to reset all monitoring history.
Project Structure
src/
server.ts # MCP server — tool definitions and request handlers
grokClient.ts # xAI Responses API client with retry + timeout
sentimentAnalyzer.ts # Prompt builder and response parser for search_x
monitorState.ts # State persistence and post deduplication for monitor_x
config.ts # Environment config with Zod validation
types.ts # Zod schemas and TypeScript types
utils.ts # Date range helpers
__tests__/
unit/ # Unit tests (no API key needed)
integration/ # Integration tests (requires XAI_API_KEY)License
MIT
Available Tools
4 toolsmonitor_xA
Monitor X for new posts about a query since the last time you checked. Call this repeatedly to track evolving conversations — it returns ONLY new posts and the sentiment delta since last check. State is persisted between calls. Perfect for tracking breaking news, token launches, or sentiment shifts in real-time.
Inputs: query (required), timeframe.
search_xA
Search X (Twitter) for real posts, articles, threads, and media about any topic. Use for: market sentiment on stocks/crypto, news reactions, public opinion, brand mentions, trend discovery, finding second-hand sources and community discussions. Returns a summary, key themes, verbatim notable posts, and optional sentiment analysis.
Inputs: query (required), focus, timeframe.
track_accountA
Deep-dive a specific X account — analyze what they post, their dominant topics, tone, and notable recent posts. Useful for research, due diligence on founders, tracking influencer positions, or monitoring competitor accounts.
Inputs: handle (required), timeframe.
web_plus_xA
Cross-reference what X (Twitter) is saying with what web sources report on the same topic. Ideal for fact-checking claims, detecting narrative gaps, validating hype, or comparing social media sentiment against published reporting. Returns both X posts and web sources, plus a synthesis of where they agree or contradict each other.
Inputs: query (required), timeframe.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinguishable angle: search_x is a one-off topical search, monitor_x is stateful delta tracking, track_account targets a single account, and web_plus_x adds cross-referencing with web sources. search_x and monitor_x overlap on 'query X for posts,' but the descriptions make the stateful/one-shot distinction reasonably clear.
All names are snake_case and mostly verb-led (search_x, monitor_x, track_account). The only deviation is web_plus_x, which encodes a combination rather than an action, though it remains readable in context.
Four tools is lean but defensible for a focused X research server, and each covers a genuinely different workflow (search, cross-reference, account analysis, ongoing monitoring). It sits at the low end without feeling padded or arbitrary.
Core discovery and monitoring are covered, but there is no way to retrieve a specific post or thread by ID/URL, list an account's raw timeline, or stop/clear an existing monitor. For a research workflow those are notable gaps an agent could hit when a user pastes a link or asks to end tracking.
Maintenance
Related MCP Connectors
X/Twitter search, posts, comments, user profiles, user posts/replies and video transcripts.
Real-time X/Twitter search, tweets, threads, replies & profiles MCP (-87% compact tokens & x402).
Real-time X/Twitter search, tweets, threads, replies & profiles MCP (-87% compact tokens & x402).
Publish and schedule tweets and threads on X (Twitter) from your AI assistant.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables seamless interaction with Twitter/X platform through Claude AI, allowing users to post tweets with images, search for tweets, and engage in conversations using natural language commands.1055 npm27MIT
- FlicenseBqualityNot gradedmaintenanceIntegrates Grok AI into Claude Code to enable real-time X/Twitter search and deep analysis of social media links. It supports a dual-mode architecture featuring a browser-based free mode for SuperGrok subscribers and a cost-controlled API mode.216 npm1-
- AlicenseNot gradedqualityDmaintenanceSearch X (formerly Twitter) in real-time from your AI assistant using xAI's Grok API, with no X API account required.1,701 npmMIT
- AlicenseAqualityDmaintenanceEnables real-time search of X.com (Twitter) posts, users, threads, and trends via xAI's Grok API, directly from Claude.54MIT