grok-live-mcp
# grok-live-mcp
[](https://github.com/olivia-1106/grok-live-mcp/actions/workflows/lint.yml)
[](https://www.python.org/)
[](https://modelcontextprotocol.io/)
A lightweight Python [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) 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.
## Architecture
```mermaid
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
- Python 3.10+
- An xAI API key from [console.x.ai](https://console.x.ai/)
### Setup with `uv` (recommended)
```bash
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`
```bash
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
```
## IDE & Client Configuration
### Cursor (`~/.cursor/mcp.json` or `.cursor/mcp.json`)
```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`)
```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
```bash
ruff check .
ruff format --check .
pytest -v
```
## License
MIT
TDQS
Scored across 3 tools
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.
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.
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.
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.