x-search-mcp
This is a read-only MCP server for searching X/Twitter through xAI's Responses API.
Search X in real time with
x_searchusing a query up to 16,000 characters.Filter results by allowed or excluded X handles (up to 10, mutually exclusive) and by inclusive
from_date/ exclusiveto_date.Optionally enable image or video understanding for posts containing media.
Choose credentials with
auth_mode(auto,api_key, oroauth), supporting xAI API keys or eligible Grok subscription/OAuth.Get answers with citations and source links when xAI provides them; degraded results lack links.
Run as a local stdio MCP server, single-account HTTP, or multi-user HTTP with per-user encrypted xAI API key bindings.
Use from MCP clients such as Codex or Pi; multi-user HTTP provides
/mcpand/settings.
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-search-mcp search X for recent posts about the OpenAI DevDay and summarize the top reactions"
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-search-mcp
A read-only MCP server for searching X through the xAI Responses API. Its x_search tool supports account and date filters and returns source links when xAI provides them.
If you want to… | Use | xAI credentials |
Search from Codex, Pi, or another local MCP client | Your API key or eligible Grok subscription | |
Use one account from several devices | One API key or eligible Grok subscription on the server | |
Let invited users share a URL and use their own xAI accounts | Each user binds an API key and uses their own xAI API quota |
Quick start
Requires Node.js 22.19.0 or later.
npm install --global @scoheart/x-search-mcpSave your xAI API key in a private file and set XAI_API_KEY_FILE, or supply it through XAI_API_KEY. Then run a search from the terminal.
export XAI_API_KEY_FILE=/absolute/path/to/xai-api-key
x-search-mcp search "What did @SpaceX post about Starship this week?"For a personal Grok subscription, sign in with the device code and explicitly select OAuth for the test. X Search access depends on your account's subscription entitlements.
x-search-mcp auth login
x-search-mcp auth status
x-search-mcp search "What did @SpaceX post about Starship this week?" --auth oauthX_SEARCH_AUTH_MODE=oauth selects subscription credentials for local stdio or single-account HTTP. The default auto mode uses a configured API key first, then looks for a local OAuth login. See the authentication and configuration reference.
Related MCP server: grok-mcp-server
Connect a local MCP client
Run the command for your client after installing the package. The client launches x-search-mcp over stdio.
codex mcp add x-search -- x-search-mcp --stdio
# Or with Pi
pi mcp add x-search -- x-search-mcp --stdioIn your client, ask it to use x_search and include links to the source posts. If the client launches in a separate environment, put XAI_API_KEY_FILE or X_SEARCH_AUTH_MODE=oauth in the server's environment configuration. Use the absolute executable path if your client cannot find x-search-mcp.
See the Codex TOML and generic MCP JSON examples for running the package with npx from the client.
Run over HTTP
Both modes use the official MCP SDK with Streamable HTTP.
Single-account HTTP
Configure xAI credentials on the host that runs the service. Save a long, randomly generated MCP bearer token in a separate private file and start the server.
x-search-mcp http --token-file /absolute/path/to/mcp-tokenConnect to http://127.0.0.1:8000/mcp with Authorization: Bearer <MCP token>. All callers use the host's configured xAI account. For remote access, keep the server on loopback, terminate HTTPS at a reverse proxy, and pass its hostname with --allowed-host mcp.example.com. See x-search-mcp http --help and the HTTP configuration reference.
Multi-user HTTP
Deploy behind HTTPS with an MCP OAuth issuer and Alibaba Cloud KMS. Each invited user signs in to the same /mcp URL, opens /settings with the same identity, and binds their xAI API key. The server stores each binding encrypted and uses it for that user's searches. The settings page supports replacing and removing keys.
x-search-mcp http --multi-user --port 8000See the multi-user deployment guide for issuer setup, KMS permissions, reverse-proxy configuration, and Codex and Pi login commands. Grok subscription login is available in the personal modes.
Results and logs
x_searchaccepts a query, optional X account filters, and a date range. See the tool parameters.Results include the answer, citations, and available usage information. A result marked
degraded: truelacks source links.By default, stdio and single-account HTTP save local call logs under
~/.config/x-search-mcp/logs/. Multi-user HTTP disables those logs.
Development
git clone https://github.com/Scoheart/x-search-mcp.git
cd x-search-mcp
npm ci
npm test
npm packnpm test compiles the TypeScript and runs the tests. npm pack builds an installable tarball.
License
MIT © Scoheart. The implementation was inspired by Nous Research's Hermes Agent. See third-party notices.
Available Tools
1 toolx_searchARead-only
Search X (formerly Twitter) using xAI responses API with real-time index, account filters, and date ranges.
Inputs: query (required), to_date, auth_mode, from_date, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 1 tool
With only one tool (x_search), there is no possibility of confusion or selection ambiguity. Its purpose of searching X is unambiguous.
The sole tool name x_search follows a clear snake_case, subject_verb pattern. Consistency can't be verified across a set, but nothing is inconsistent or chaotic.
A single tool is thin for a standalone search server; per the rubric, 1 tool is borderline. It earns its place but the surface feels minimal.
The tool offers only raw search with filters—no companion operations like fetching a specific tweet, listing a user's posts, or retrieving threads. Agents may hit dead ends when they need follow-up lookups.
Maintenance
Related MCP Connectors
Real-time Google search (AI Overview, People also ask), Maps and Jobs. API key or x402 per call.
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).
Real-time web search, reasoning, and research through Perplexity's API
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables searching X (formerly Twitter) using xAI's Responses API with support for filtering by handles, date ranges, and media understanding, returning structured results with citations.128 npm1MIT
- AlicenseNot gradedqualityDmaintenanceSearch X (formerly Twitter) in real-time from your AI assistant using xAI's Grok API, with no X API account required.473 npmMIT
- FlicenseNot gradedqualityCmaintenanceEnables real-time search of X (Twitter) posts, user timelines, and trends using either xAI's Responses API or the official X API v2.4-
- AlicenseAqualityDmaintenanceEnables searching X (Twitter) posts, discussions, trends, and web content via Grok API using natural language.31MIT