Grok2API MCP Server
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., "@Grok2API MCP Server search the web for recent SpaceX launches"
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.
Grok2API MCP Server
English · 中文
An MCP (Model Context Protocol) server that provides real-time web search via Grok. Returns structured results with source URLs, confidence scores, key points, and multi-language support.
How It Works
Claude / Cursor / etc. ──MCP──> grok-mcp-server ──HTTP──> grok2api ──> GrokThis server bridges MCP clients to a grok2api-compatible backend, exposing Grok's real-time web search through an OpenAI-compatible API.
Related MCP server: grok-mcp-server
Features
Real-time web & Twitter/X search via Grok
Structured JSON output — summary, key points with citations, source list, confidence score
Multiple output modes —
brief,analyst,rawMulti-language support — respond in any language
Time range filtering —
24h,7d,30d,allSource freshness control — prefer recent sources
Domain allowlist preference — prioritize trusted domains (best-effort)
Automatic retries with exponential backoff
Runtime metrics via
grok_statstool
Prerequisites
You need a running grok2api instance (or any OpenAI-compatible API endpoint backed by a Grok model with web search).
Setting Up the grok2api Backend
It is strongly recommended to use a secondary/alt Grok account for this, not your primary account.
1. Deploy grok2api
Choose the method that fits your environment:
Requires Docker and Docker Compose installed on your server.
git clone https://github.com/chenyme/grok2api
cd grok2api
docker compose up -dThe admin panel will be available at http://your-server-ip:8000/admin (default password: grok2api).
Requires Python 3.11+ and uv.
# Install uv if you don't have it
brew install uv
# Clone and run
git clone https://github.com/chenyme/grok2api
cd grok2api
uv sync
uv run main.pyThe admin panel will be at http://localhost:8000/admin (default password: grok2api).
Requires Python 3.11+ and uv.
# Install uv (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Clone and run
git clone https://github.com/chenyme/grok2api
cd grok2api
uv sync
uv run main.pyThe admin panel will be at http://localhost:8000/admin (default password: grok2api).
Requires Python 3.11+ and uv.
# Install uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone and run
git clone https://github.com/chenyme/grok2api
cd grok2api
uv sync
uv run main.pyThe admin panel will be at http://localhost:8000/admin (default password: grok2api).
For cloud deployments (Vercel, Render), see the grok2api README.
2. Get Your Grok Cookie
Log into grok.com with your Grok account
Open browser DevTools (
F12orCmd+Opt+I)Go to the Application tab
In the left sidebar, expand Storage → Cookies
Find the cookie named
ssoorsso-rwCopy its value
3. Add Token to grok2api
Open the grok2api admin panel (
http://your-server:8000/admin)Click Add to add a new token
Paste the cookie value you just copied
Select your account type based on your Grok subscription:
Basic — 80 requests per 20 hours
Super — 140 requests per 2 hours
The GROK_API_KEY in your .env is the admin key configured in grok2api (the app.app_key value, default: grok2api).
Installation
Option A: Global install (recommended)
git clone https://github.com/wousp112/grok2api-mcp-server.git
cd grok-mcp-server
cp .env.example .env
# Edit .env with your API URL and key
npm install
npm linkOption B: Local install
git clone https://github.com/wousp112/grok2api-mcp-server.git
cd grok-mcp-server
cp .env.example .env
# Edit .env with your API URL and key
npm installConfiguration
Copy .env.example to .env and fill in your values:
Variable | Required | Default | Description |
| Yes | — | Your grok2api endpoint (e.g. |
| Yes | — | API key for authentication |
| No |
| Grok model name |
| No |
| Request timeout (ms) |
| No |
| Max retry attempts |
| No |
| Base backoff delay for retries (ms) |
| No | Same as request timeout | Axios timeout (ms) |
MCP Client Configuration
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"grok-search": {
"command": "grok-mcp-server",
"args": [],
"env": {
"PATH": "/usr/local/bin:/usr/bin:/bin"
}
}
}
}{
"mcpServers": {
"grok-search": {
"command": "grok-mcp-server",
"args": []
}
}
}Add to .cursor/mcp.json:
{
"mcpServers": {
"grok-search": {
"command": "grok-mcp-server",
"args": []
}
}
}Note: If you skipped
npm link, use the full path instead:"command": "/path/to/grok-mcp-server/index.js"
Tools
grok_web_search
Search the web or Twitter/X via Grok with structured output.
Parameter | Type | Required | Default | Description |
| string | Yes | — | The question or topic to search for |
|
| No |
| Response detail level |
| string | No |
| Response language code |
|
| No |
| Search lookback window |
| integer | No | — | Prefer sources within N days |
| integer | No |
| Max sources in output (1–20) |
| string[] | No | — | Preferred source domains, best-effort (max 30) |
Response structure:
{
"summary": "Concise factual summary",
"key_points": [
{ "point": "Key finding", "source_urls": ["https://..."] }
],
"sources": [
{
"title": "Article Title",
"url": "https://...",
"publisher": "Publisher Name",
"published_at": "2025-01-01T00:00:00Z",
"relevance_note": "Why this source matters"
}
],
"confidence": 0.85,
"as_of": "2025-01-01T12:00:00Z",
"notes": "Additional context or caveats"
}grok_stats
Returns runtime metrics: call counts, error distribution, uptime.
Acknowledgements
grok2api by chenyme — the backend that makes Grok accessible via OpenAI-compatible API
License
MIT
Available Tools
2 toolsgrok_statsA
Return runtime call counters for this MCP process (tool calls, retries, error code distribution).
Inputs: no named parameters.
grok_web_searchB
Search the web or Twitter(X) via Grok for real-time information and up-to-date events, with structured result and source URLs.
Inputs: query (required), language, time_range, max_sources, +3 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools target entirely different concerns: live web/Twitter search versus internal runtime diagnostics. There is no plausible way an agent could confuse a search call with a stats call.
Both tools follow the same predictable `grok_<noun>` snake_case pattern with a shared server prefix. Nothing deviates from the convention.
Two tools is on the thin side for a server that advertises itself as a Grok API gateway; a diagnostics counter tool sitting alongside a single functional tool feels sparse. The count isn't wrong per se, but the surface feels under-built.
The only functional capability exposed is web/X search; there is no direct Grok chat/completion tool, no page-fetch or URL-content retrieval, and no configuration or model-selection operation. An agent hoping to use Grok for anything beyond search hits a dead end.
Maintenance
Related MCP Connectors
Live web search and fetch plus Twitter, Reddit, GitHub, Amazon, YouTube, Telegram data. No API keys.
Real-time Google search (AI Overview, People also ask), Maps and Jobs. API key or x402 per call.
Low-cost live web search for current facts, news, research, docs, and web grounding via x402.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides comprehensive web, news, and Twitter search capabilities using the xAI Grok API with both basic and deep analysis modes. It includes advanced features like timeline generation, sentiment analysis, and built-in reliability through caching and retry logic.519MIT
- AlicenseNot gradedqualityDmaintenanceSearch X (formerly Twitter) in real-time from your AI assistant using xAI's Grok API, with no X API account required.479 npmMIT
- AlicenseAqualityDmaintenanceEnables real-time search of X.com (Twitter) posts, users, threads, and trends via xAI's Grok API, directly from Claude.552 PyPI4MIT
- AlicenseAqualityDmaintenanceEnables searching X (Twitter) posts, discussions, trends, and web content via Grok API using natural language.31MIT