Skip to main content
Glama

x-search-mcp

npm version License: MIT

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

Local stdio

Your API key or eligible Grok subscription

Use one account from several devices

Single-account HTTP

One API key or eligible Grok subscription on the server

Let invited users share a URL and use their own xAI accounts

Multi-user HTTP

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-mcp

Save 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 oauth

X_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 --stdio

In 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-token

Connect 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 8000

See 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_search accepts 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: true lacks 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 pack

npm 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 tool

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.5/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool (x_search), there is no possibility of confusion or selection ambiguity. Its purpose of searching X is unambiguous.

    Naming Consistency4/5

    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.

    Tool Count3/5

    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.

    Completeness2/5

    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

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Enables 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.
      1
      28 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables real-time search of X (Twitter) posts, user timelines, and trends using either xAI's Responses API or the official X API v2.
      4
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables searching X (Twitter) posts, discussions, trends, and web content via Grok API using natural language.
      3
      1
      MIT