Skip to main content
Glama

grok-live-mcp

Lint & Test Python MCP

A lightweight Python Model Context Protocol (MCP) server that exposes xAI Grok's real-time Web Search, X (Twitter) Search, and Code Reasoning tools via xAI's Responses API (/v1/responses) to Cursor, Claude Desktop, and local AI agents.

Why Responses API?

xAI retired the legacy search_parameters Chat Completions beta on January 12, 2026. Plain /v1/chat/completions calls do not perform live web or X retrieval. This server uses AsyncOpenAI against https://api.x.ai/v1 with /v1/responses server-side agentic tools (web_search, x_search, and code_interpreter), returning structured answers with deduplicated citation links.

Related MCP server: grok-build-plugin

Architecture

flowchart LR
    A["Cursor / Claude Desktop / Local Agent"] <-->|"MCP (STDIO JSON-RPC)"| B["grok-live-mcp (FastMCP)"]
    B -->|"AsyncOpenAI /v1/responses"| C["xAI Grok API"]
    C --> D["web_search"]
    C --> E["x_search"]
    C --> F["code_interpreter"]

Available MCP Tools

Tool

Description

Default Model

ask_grok_realtime

Real-time Web Search, X Search, or both, with optional domain and UTC date filters (YYYY-MM-DD).

grok-4.3

search_x_posts

Dedicated X (Twitter) search with handle allow/exclude filters (up to 20), date windows, and optional image/video understanding.

grok-4.3

grok_code_reasoning

Deep coding, debugging, and quantitative reasoning with optional server-side code_interpreter and web_search.

grok-4.7

Installation

Prerequisites

Setup with uv (recommended)

git clone https://github.com/<olivia-1106>/grok-live-mcp.git
cd grok-live-mcp
cp .env.example .env
# Edit .env and set XAI_API_KEY
uv venv
uv pip install -e ".[dev]"

Setup with pip

python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"

IDE & Client Configuration

Cursor (~/.cursor/mcp.json or .cursor/mcp.json)

{
  "mcpServers": {
    "grok-live-mcp": {
      "command": "uv",
      "args": [
        "--directory",
        "/ABSOLUTE/PATH/TO/grok-live-mcp",
        "run",
        "grok-live-mcp"
      ],
      "env": {
        "XAI_API_KEY": "xai-your-api-key-here"
      }
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "grok-live-mcp": {
      "command": "/ABSOLUTE/PATH/TO/grok-live-mcp/.venv/bin/grok-live-mcp",
      "env": {
        "XAI_API_KEY": "xai-your-api-key-here"
      }
    }
  }
}

Environment Variables

Variable

Default

Description

XAI_API_KEY

(required)

Your xAI API key.

XAI_BASE_URL

https://api.x.ai/v1

xAI OpenAI-compatible base URL.

XAI_DEFAULT_MODEL

grok-4.3

Default model for ask_grok_realtime and search_x_posts.

XAI_REASONING_MODEL

grok-4.7

Default model for grok_code_reasoning.

XAI_TIMEOUT_SECONDS

120

HTTP request timeout in seconds.

LOG_LEVEL

INFO

Logging verbosity (always written to stderr).

Development & Testing

ruff check .
ruff format --check .
pytest -v

License

MIT

Available Tools

3 tools
ask_grok_realtimeA

Query Grok with real-time Web Search and/or X Search via xAI's Responses API.

Args: query: Question or research prompt requiring up-to-date information. search_mode: Which live search tools to enable ("both", "web", or "x"). model: Optional xAI model ID (defaults to XAI_DEFAULT_MODEL / grok-4.3). allowed_domains: Restrict web search to at most 5 domains (mutually exclusive with excluded_domains). excluded_domains: Exclude up to 5 domains from web search. from_date: Optional X search start date in YYYY-MM-DD format (UTC). to_date: Optional X search end date in YYYY-MM-DD format (UTC, exclusive).

Inputs: query (required), model, to_date, from_date, +3 more. Returns: result

grok_code_reasoningA

Use Grok's frontier reasoning model for debugging, architecture review, or quantitative analysis.

Args: prompt: Code snippet, bug report, math/data problem, or architecture question. model: Optional xAI model ID (defaults to XAI_REASONING_MODEL / grok-4.7). enable_code_interpreter: Allow Grok to execute Python on xAI's server-side sandbox to verify calculations. enable_web_search: Also enable live web search (e.g., to verify latest library APIs or CVEs).

Inputs: prompt (required), model, enable_web_search, enable_code_interpreter. Returns: result

search_x_postsA

Search real-time public posts, threads, and sentiment on X (Twitter) via Grok.

Args: query: Topic, keywords, or question to investigate on X. model: Optional xAI model ID (defaults to XAI_DEFAULT_MODEL / grok-4.3). allowed_x_handles: Only search posts from these X handles (max 20, with or without '@'). excluded_x_handles: Ignore posts from these X handles (max 20, mutually exclusive with allowed_x_handles). from_date: Start date in YYYY-MM-DD format (00:00 UTC). to_date: End date in YYYY-MM-DD format (exclusive, 00:00 UTC). enable_image_understanding: Allow Grok to inspect images attached to X posts. enable_video_understanding: Allow Grok to inspect videos attached to X posts.

Inputs: query (required), model, to_date, from_date, +4 more. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A3.9/5.0

    Scored across 3 tools

    Disambiguation4/5

    Each tool has a clear primary domain: X post search, general real-time web/X research, and code/math reasoning. The main ambiguity is that ask_grok_realtime with search_mode='x' overlaps with search_x_posts, though the latter is more specialized with X handle filters and sentiment focus.

    Naming Consistency3/5

    All names use snake_case and are readable, but the pattern is mixed: two begin with verbs (search_x_posts, ask_grok_realtime) while grok_code_reasoning is a noun phrase. The deviation is minor but keeps it from a fully predictable verb_noun convention.

    Tool Count4/5

    Three tools is a reasonably tight surface for a focused Grok live-search and reasoning server, and each tool covers a distinct capability. It is slightly minimal but not obviously missing a tool that would justify a larger set.

    Completeness4/5

    The server covers its apparent core: X post search, live web/X research, and code-oriented reasoning. Minor gaps exist, such as no dedicated single-post retrieval or general non-search Grok chat tool, but agents can work around these via the provided tools.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community 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
      52 PyPI
      4
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Live 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.
      111 npm
      29
      Apache 2.0
    • F
      license
      A
      quality
      D
      maintenance
      Enables searching X (Twitter) using the xAI Grok API to get summarised answers with citations. Supports filtering by handles, date range, and image/video understanding.
      1
      2
      -
    • 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