Skip to main content
Glama
phiclin

X Search MCP Server

by phiclin

X Search MCP Server

让 Claude Code 搜索 X (Twitter) 实时内容的 MCP Server。

功能

  • search_x — 搜索 X 上的帖子、讨论、趋势

  • search_web_via_grok — 通过 Grok 搜索网页

  • search_combined — 同时搜索 X 和网页

Related MCP server: Grok MCP Server

快速开始

1. 获取 xAI API Key

访问 https://console.x.ai 注册,新用户送 $25 免费额度。

2. 克隆项目

git clone https://github.com/your-repo/x-search-mcp.git
cd x-search-mcp

3. 安装依赖

npm install
npm run build

4. 配置环境变量

创建 .env 文件:

XAI_API_KEY=your-api-key-here

5. 配置 Claude Code

将以下配置添加到 ~/.claude/settings.local.json

{
  "mcpServers": {
    "x-search": {
      "command": "node",
      "args": ["x-search-mcp/build/index.js"],
      "env": {
        "XAI_API_KEY": "your-api-key-here"
      }
    }
  }
}

6. 重启 Claude Code

重启后,你就可以直接让 Claude 搜索 X 上的内容了:

"搜一下 X 上关于 Claude Code 的最新讨论"

费用说明

  • 每次 X 搜索约消耗 5000-7000 tokens ≈ $0.001-0.003

  • 新用户 $25 免费额度足够搜索数千次

  • 可通过数据共享计划获得 $150/月额外免费额度

项目结构

x-search-mcp/
├── src/
│   └── index.ts      # 源码
├── build/
│   └── index.js      # 编译产物
├── package.json
├── tsconfig.json
└── README.md

技术栈

  • TypeScript

  • @modelcontextprotocol/sdk

  • xAI Grok API

License

MIT

Available Tools

3 tools
search_combinedB

Search both X (Twitter) and the web simultaneously for comprehensive results. Grok will automatically decide which source to use or combine both. Best for getting a complete picture of a topic from social media AND web sources.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query.
to_dateNoEnd date for X search range (YYYY-MM-DD format)
from_dateNoStart date for X search range (YYYY-MM-DD format)

TDQS

B3.4/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It does disclose a genuine behavioral trait — that Grok auto-selects or merges sources — which is useful routing context. However, it says nothing about permissions, rate limits, result volume, or return shape.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short sentences with the core behavior front-loaded. There is mild redundancy between 'comprehensive results' and 'complete picture ... from social media AND web sources', but nothing that impedes comprehension.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a three-parameter search tool with no output schema and no annotations, the description covers the source-selection behavior but omits result format, result volume, and how the date range interacts with the two sources. Adequate but with clear gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% and each parameter is self-documented, so the baseline is 3. The description adds no syntax, format, or scope detail beyond the schema (e.g., it never clarifies that from_date/to_date apply only to the X half of the search).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('search both X and the web') and distinguishes itself from its single-source siblings (search_x, search_web_via_grok) by emphasizing 'simultaneously' and 'combine both'. It never names the siblings explicitly, but the differentiation is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

'Best for getting a complete picture of a topic from social media AND web sources' gives a positive usage cue, but there is no when-not guidance and the alternatives (search_x, search_web_via_grok) are never named as the preferred choice for single-source queries.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_web_via_grokA

Search the web for real-time information via Grok. Returns summarized results from web pages. Useful for current events, documentation, news, and general knowledge.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe web search query.
allowed_domainsNoComma-separated domains to restrict search to (e.g. 'github.com,stackoverflow.com'). Max 5.

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full behavioral burden. It does disclose the return shape ('summarized results from web pages') and that results are real-time, which is genuine added context, but says nothing about authentication, rate limits, cost, or freshness caveats.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three tight, front-loaded sentences with no wasted clauses; the mechanism and return format come early. 'General knowledge' is slightly filler-ish but not enough to detract.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a read-only search tool with fully documented params and no output schema, the description covers purpose, return shape, and typical use cases. The only meaningful gap is the absence of sibling routing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so both query and allowed_domains are already documented with format and constraints (comma-separated, max 5). The description adds nothing about either parameter, so the baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (Search) and resource (the web) with mechanism (via Grok), and the 'web' scope implicitly differentiates it from the sibling search_x. It does not, however, explicitly name or distinguish itself from search_combined, which likely also touches the web.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The sentence 'Useful for current events, documentation, news, and general knowledge' implies when the tool fits but offers no when-not guidance and no routing to search_x or search_combined. Usage is left to inference from the topic list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

search_xA

Search X (Twitter) for real-time posts, discussions, and trends on any topic. Powered by Grok's x_search, returns summarized results with original quotes from users. Supports filtering by date range and specific X handles.

ParametersJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query. Can be a topic, keyword, hashtag, or question.
to_dateNoEnd date for search range (YYYY-MM-DD format)
from_dateNoStart date for search range (YYYY-MM-DD format)
x_handlesNoComma-separated X handles to limit search to (e.g. 'elonmusk,openai'). Max 10.

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden, and it does disclose something beyond the name: that results are Grok-summarized with original user quotes, which sets expectations for output shape. However, it says nothing about authentication, rate limits, result volume, or failure behavior, which are meaningful gaps for an unannotated external-API tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three sentences, front-loaded with the core action and corpus, then capability and output expectations. Every sentence contributes, though 'Powered by Grok's x_search' is closer to marketing context than actionable guidance.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

No output schema exists, and the description compensates by describing returns as summarized results with original quotes. Combined with 100% parameter coverage in the schema, an agent has enough to call it correctly; only auth/limits behavior is left unaddressed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents query, date bounds, and handles. The description's line 'Supports filtering by date range and specific X handles' restates the schema rather than adding format, syntax, or limit details (the 10-handle cap lives only in the schema). Baseline 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource ('Search X (Twitter) for real-time posts, discussions, and trends'), which is concrete and distinguishable from the sibling web-search tools by naming the X/Twitter corpus. It never names the siblings explicitly, so the differentiation is implicit rather than stated.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The phrase 'real-time posts, discussions, and trends' implies the use case (current social sentiment/topics), but there is no explicit when-to-use or when-not guidance and no mention of search_web_via_grok or search_combined as alternatives. An agent must infer the routing decision from the corpus name alone.

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. 3 tool updatesv1.0.0
    • First observedsearch_combined
    • First observedsearch_web_via_grok
    • First observedsearch_x

TDQS

A3.5/5.0

Scored across 3 tools

Disambiguation3/5

search_x and search_web_via_grok clearly target distinct sources, but search_combined is a superset of both, so an agent may reasonably wonder why it would ever pick the narrower tools. The descriptions do clarify intent, keeping them mostly distinguishable.

Naming Consistency4/5

All three share the search_ prefix, which is good, but the suffixes vary in style (search_x, search_web_via_grok, search_combined) rather than following one predictable pattern. Still readable and mostly consistent.

Tool Count3/5

Three tools is on the thin side for a search server, and one of them (search_combined) arguably subsumes the other two, making the surface feel slightly redundant rather than lean.

Completeness4/5

The core search domain is covered across X, web, and combined sources, but finer operations like thread retrieval, user/timeline lookup, or pagination are absent. Minor gaps an agent can work around.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables real-time search of X.com (Twitter) posts, users, threads, and trends via xAI's Grok API, directly from Claude.
    5
    3
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    22 npm
    4
    MIT
  • F
    license
    Not graded
    quality
    D
    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
    -