x-search
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-searchFind three recent public X posts about the OpenAI DevDay keynote, with dates and links."
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.
magpie-x-search
An MCP x_search tool lets any calling model search public X content through
Grok's native search. The server uses an existing local magpie OAuth login.
GPT, Claude, DeepSeek, and other MCP clients receive the result through MCP.
The server returns a summary, structured posts, source URLs, and search counts. The server also shares cached results and concurrent searches across local terminals.
Licensed under the MIT License.
Setup
Requires Python 3.10 or later, a running magpie, and a
signed-in Grok provider. The npm launcher also requires Node.js 22 or later.
The default model is grok-plugin/grok-4.7.
The package has no npm dependencies and requires no Python packages.
Sign in to Grok in magpie through
@magpie-community/opencode-grok-auth. The plugin supplies OAuth credentials, token refresh, and the upstream proxy.Install the npm command:
npm install --global magpie-x-searchRegister the installed command:
codex mcp add x-search -- magpie-x-searchSet
tool_timeout_sec = 180in the[mcp_servers.x-search]section of Codex'sconfig.toml. The server's default total timeout is 150 seconds.Start a new Codex session so Codex discovers the server.
For other MCP clients, use the installed command:
{
"mcpServers": {
"x-search": {
"command": "magpie-x-search"
}
}
}If your MCP client does not search PATH, set command to the installed executable's absolute path.
On Windows, use magpie-x-search.cmd for clients that require the command extension.
Each machine needs its own magpie login. Terminals on one machine share the
local magpie gateway and the default cache database.
The launcher checks python3, then python on Linux and macOS.
On Windows, the launcher checks py -3, then python, then python3.
Set X_SEARCH_PYTHON to an executable path if detection fails.
The value must not contain command arguments. Paths with spaces work without extra quotes in the value.
The launcher writes startup failures to stderr and keeps MCP stdout free of startup messages.
You can also run the registry package with npx:
npx -y magpie-x-searchFor a pinned MCP registration, use:
codex mcp add x-search -- npx -y magpie-x-search@1.2.0The npm package page lists registry releases. The GitHub Release tarball remains an alternative installation source:
npm install --global --allow-remote=root https://github.com/cyberElar/magpie-x-search/releases/download/v1.2.0/magpie-x-search-1.2.0.tgznpm 12 requires --allow-remote=root for this GitHub tarball.
The option allows the direct tarball download for that command and does not change global npm settings.
Registry installs do not need this option.
For a source installation, clone the repository and register the Python entry point:
gh repo clone cyberElar/magpie-x-search
cd magpie-x-search
codex mcp add x-search -- python3 "$PWD/x_search_mcp.py"A source installation does not require Node.js.
To update a source installation, run git pull and restart the MCP client.
To update an npm installation, install the new release and restart the MCP client.
To remove the Codex registration, run codex mcp remove x-search.
Related MCP server: Grok MCP Server
Tool
{
"query": "from:example Find three recent public posts. Include dates and source links.",
"allowed_x_handles": ["example"],
"from_date": "2026-10-01",
"to_date": "2026-10-06",
"max_results": 3,
"cache_mode": "use"
}Only query is required. Handle filters accept 1 to 20 handles.
Dates use YYYY-MM-DD. max_results requests 1 to 20 posts in the answer.
A retrieved sample is not a complete account archive.
The default request allows up to five native search calls.
The bridge omits max_output_tokens unless you set X_SEARCH_MAX_OUTPUT_TOKENS.
Magpie and the model still apply their own output limits.
Environment settings can change both limits. The server does not retry upstream requests automatically.
The result contains these fields:
Field | Meaning |
| Grok's summary, with source links |
| Structured posts with |
| X URLs from native citation metadata |
| Native search, fetched-post, and fetched-user counts |
| The model that magpie served |
| UTC time of the original retrieval |
| Cache status and result age in seconds |
kind is original, reply, quote, repost, or unknown.
Unknown authors or dates are null. Profile-only searches can return no posts.
Each structured post must match a post ID in native citation metadata. The server rejects posts without matching citations. Post fields and the summary remain model extractions; a matching URL does not verify every statement.
The server returns an MCP tool error when native search execution is unconfirmed. The server also returns explicit errors for malformed output, truncated output, connection failures, rate limits, cache failures, and total timeouts.
Cache and cancellation
The cache uses a local SQLite database. Results expire after 300 seconds by default. The database retains at most 1000 completed entries. The cache key includes the query, filters, model, endpoint, output schema, and search limits.
| Behavior |
| Return a valid cached result, or join an equivalent search in progress |
| Ignore completed cached results; join an equivalent search in progress or start a search |
| Make an independent request without cache reads, writes, or shared execution |
Cache status is miss, hit, coalesced, or bypass.
A cache hit keeps the original retrieved_at and search_usage values.
Those counts describe the original retrieval; a cache hit makes no upstream request.
Use refresh when you need a fresh lookup.
Processes that share a cache path also share in-progress searches. The executor renews its database lease while the request runs. After a process exits unexpectedly, its lease expires within 15 seconds. A waiting request can then become the executor.
A failed search supplies the same error to callers that already await that search. A new explicit invocation can try again. The server does not serve old failures as normal cached results.
A caller's total timeout includes queue time, cache wait, and network operations. MCP cancellation stops that caller and suppresses its response. Cancelling a waiting caller does not stop another caller's search. Cancelling the executor closes its connection and releases its lease. Remaining callers can start a search.
The server closes active connections when stdin closes or a request stops. Magpie and xAI determine how quickly their own work stops after disconnection.
Configuration
Set environment variables on the MCP server process, then restart the MCP client. The server validates settings before accepting requests.
Variable | Default | Meaning |
| Automatic detection | Python executable path for the npm launcher |
|
| Local magpie Responses endpoint |
|
| Grok model served by magpie |
|
| Native search call limit, 1 to 100 |
| Unset | Optional output token limit, 256 to 32768; omitted from requests by default |
|
| Total request timeout, 1 to 3600 seconds |
|
| Concurrent searches per process, 1 to 32 |
|
| Cache lifetime; |
| OS cache directory plus | Shared SQLite database path |
The cache directory uses XDG_CACHE_HOME, then LOCALAPPDATA, then ~/.cache.
All terminals that should share searches must use the same database path.
The database must be on a local filesystem.
The bridge connects only to a loopback HTTP endpoint. Magpie supplies upstream credentials and proxy settings. The repository contains no login credentials. The bridge requires no magpie middleware.
Maintenance and validation
The source files are at the repository root:
File | Responsibility |
| npm command, Python detection, inherited stdio, and signal forwarding |
| MCP lifecycle, errors, concurrent calls, and cancellation notifications |
| Settings, query validation, magpie transport, SSE parsing, and result validation |
| Shared cache, database leases, and duplicate request merging |
Run the npm launcher, package installation, and Python tests:
npm ci --ignore-scripts
npm testThe package tests build a tarball and install it without lifecycle scripts.
The tests check npx, MCP communication, source files, UTF-8, and paths with spaces.
Run only the Python tests:
python3 -m unittest discover -vTests use local fixtures. Tests do not need a Grok account or call an external API. Tests cover malformed RPC, cancellation, total deadlines, rate limits, structured sources, cache expiry, failed searches, and duplicate requests across processes. GitHub Actions runs the tests on Linux with Python 3.10, 3.12, and 3.14, and on Windows with Python 3.12. Package tests run on Linux with Node.js 22, 24, and 26. Package tests also run on Windows and macOS with Node.js 24.
Version 1.0 was tested on 2026-10-06 with magpie 0.1.1082, Grok OAuth plugin 0.1.8, and Codex 0.160.1. GPT-6.1 Sol was the calling model. Version 1.1 was tested against the same magpie and OAuth plugin on 2026-10-06. Grok returned two structured posts with native citations. GPT-6.1 Sol then read both posts through MCP and confirmed two cache hits with the same retrieval time.
Version 1.1 adds structured output, shared cache, concurrent calls, and cancellation. Version 1.2 adds the npm launcher and package distribution.
Publishing
The package uses a files allowlist. The tarball contains the launcher, three
Python runtime files, package.json, README, and MIT license.
The package installs without download scripts or install scripts.
The prepack check rejects mismatched npm and MCP versions.
For the first registry release:
Enable two-factor authentication in your npm account settings.
Run
npm test.Run
npm pack --dry-runto check package contents.Run
npm login --registry=https://registry.npmjs.orgto sign in.Run
npm publish --access publicand complete npm's authentication steps.
For later releases, configure a trusted publisher in the npm package settings:
Setting | Value |
GitHub owner |
|
Repository |
|
Workflow filename |
|
Allowed action |
|
The workflow uses npm OIDC authentication and publishes provenance metadata. The repository does not need an npm token secret for that workflow.
Set the same new version in
package.jsonandx_search_mcp.py.Update
package-lock.jsonwithnpm install --package-lock-only --ignore-scripts.Update the release URL in this README.
Commit the release and push a matching tag, such as
v1.2.0.Run the
Publish npm packageworkflow with that tag.
References:
Available Tools
1 toolx_searchARead-only
Search public X/Twitter profiles, posts and threads using native xAI X search through local magpie OAuth. Returns a summary, structured posts, native source URLs and execution counts. Results are retrieved samples, not a complete archive. Use cache_mode=refresh for a fresh lookup.
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | ||
| to_date | No | Optional end date, YYYY-MM-DD. | |
| from_date | No | Optional start date, YYYY-MM-DD. | |
| cache_mode | No | use: shared cached results; refresh: fresh coalesced search; bypass: no cache or coalescing. | use |
| max_results | No | ||
| allowed_x_handles | No | Optional author filter; leading @ is accepted. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
Annotations already cover safety (readOnly, non-destructive, openWorld). The description adds genuinely useful context beyond them: the return shape (summary, structured posts, source URLs, execution counts), the OAuth auth path, and the important caveat that results are sampled rather than a complete archive.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Four short sentences, front-loaded with the core purpose followed by return behavior and the sampling caveat. No filler, though the auth-mechanism detail is slightly more than an agent needs to select the tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema exists, so the description appropriately covers return contents and the sampling limitation, and it notes caching behavior. The main residual gap is parameter-level detail for query and max_results, but overall it is sufficient to call the tool correctly.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
With 67% schema description coverage, the schema documents dates, cache_mode and allowed_x_handles. The description only calls out cache_mode=refresh, adding marginal meaning without explaining query construction or max_results behavior, so the baseline 3 fits.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
States a specific verb (Search) and precise resources (public X/Twitter profiles, posts and threads), plus the underlying mechanism (native xAI X search via local magpie OAuth). No sibling tools exist, so no differentiation is needed, but the purpose is unambiguous and concrete.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Offers one actionable usage hint ('Use cache_mode=refresh for a fresh lookup') and manages expectations ('Results are retrieved samples, not a complete archive'). However, there is no explicit when-to-use versus when-not-to-use guidance and no guidance on choosing between the other cache modes.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
1 tool update
v1.2.0- First observed
x_search
TDQS
Scored across 1 tool
The server exposes a single tool, so there is no possibility of misselection or overlapping purpose. Any agent request for X/Twitter profile, post, or thread search maps unambiguously to x_search.
x_search is a clean snake_case verb_noun name and mirrors the server name x-search. With only one tool there is no broader pattern to evaluate, so consistency is trivially satisfied rather than demonstrated.
One tool is at the thin end of the acceptable range; the rubric treats 1-2 tools as borderline. The scope (X/Twitter search) is narrow enough that a single tool is defensible, but it provides no alternative operations.
Search is covered with structured output, URLs, and cache control, but notable gaps exist: no fetch-by-post-ID, no profile lookup, no thread expansion, and no pagination or result-limit controls beyond cache_mode. Agents can work around this only by re-querying search.
Maintenance
Related MCP Connectors
X/Twitter search, posts, comments, user profiles, user posts/replies and video transcripts.
x402-gated web search gateway. Tools: search, search_enriched.
Search public X (Twitter) posts and read profiles, timelines, followers, trends and X Articles.
Low-cost live web search for current facts, news, research, docs, and web grounding via x402.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceSearch X (formerly Twitter) in real-time from your AI assistant using xAI's Grok API, with no X API account required.290 npmMIT
- AlicenseAqualityDmaintenanceEnables real-time search of X.com (Twitter) posts, users, threads, and trends via xAI's Grok API, directly from Claude.529 PyPI3MIT
- AlicenseNot gradedqualityBmaintenanceLive X (Twitter) and web search for any coding agent through your existing Grok subscription. Exposes a grok_search MCP tool, so no X API key or X developer account is needed.31 npm30Apache 2.0
- AlicenseNot gradedqualityDmaintenanceEnables real-time web and Twitter/X search via Grok, returning structured results with source URLs, confidence scores, and key points. Supports multiple output modes, language options, and time range filtering.290 npm4MIT