Use xAI Grok as a peer reviewer + PR gate from Claude Code, Cursor, Cline and any MCP host.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Use Grok as a peer code reviewer and rigorous second-opinion consultant inside Claude Code, Cursor, Cline, OpenClaw, and any other MCP host β talking to xAI's API directly (just an
XAI_API_KEY, no install) or via the official Grok CLI.
grok-mcp (npm: grok-cli-mcp) is a Model Context Protocol server for Grok. It gives your primary agent (Claude, Cursor, etc.) four tools so it can delegate to Grok for high-quality second opinions and rigorous validation without leaving the session. As of v0.3.0 it talks to xAI's API directly β no grok binary required β and still supports the CLI for OAuth users:
grok_review β structured diff review with per-dimension scoresgrok_challenge β thorough analysis for bugs, races, edge cases and security issuesgrok_consult β multi-turn consultation (caller owns history)grok_chat β one-shot questionsEnglish | ηΉι«δΈζ
Most "Grok MCP" packages expose Grok's chat/search/image capabilities so Claude can use Grok. grok-mcp lets your main coding agent (Claude/Cursor/β¦) ask Grok for a rigorous second opinion on its own work. A different model providing thorough review often catches issues that single-model loops miss.
Four tools, all stateless, all stdout-only:
| Tool | Use it for |
|---|---|
grok_chat | One-shot prompt β Grok's reply |
grok_review | Pass a unified diff (or auto-grab git diff main...HEAD) and get a per-dimension code review |
grok_consult | Replay a message history for multi-turn β caller owns the thread |
grok_challenge | Rigorous analysis: ask Grok to surface bugs, race conditions, edge cases, and security issues |
XAI_API_KEY from console.x.ai. The server calls xAI's HTTP API directly β no extra binary needed.XAI_API_KEY is set:
Then authenticate with browser OAuth (run grok once interactively). See Authentication below.Why the npm name is
grok-cli-mcpinstead ofgrok-mcp? The baregrok-mcpname on npm was already taken by an unrelated project (a Grok HTTP-API integration). The brand, GitHub repo, and MCP server identity staygrok-mcp; only the npm install identifier isgrok-cli-mcpβ chosen to highlight that this server wraps the official Grok CLI.
There are two auth methods, each tied to a backend:
| Method | Backend | Best for | Rate limits |
|---|---|---|---|
API key (XAI_API_KEY env var) | API mode β no grok binary needed | MCP / CI / automation | Pay-per-call, no subscription cap |
Browser OAuth (grok interactive login) | CLI mode | Local interactive use | Subject to your grok.com plan tier |
Setting XAI_API_KEY switches the server to API mode, so you can keep your browser login for interactive grok use and use a key just for this MCP server via its env block:
Treat the key file as a secret β it ends up in your MCP host's config (e.g. ~/.claude.json), which is plain JSON on disk.
Recommended β use add-json so the env block parses cleanly:
Why
add-jsonnotclaude mcp add -e ...? The-e KEY=valflag is variadic and will greedily consume the server name as another env value if you pass more than one.add-jsonsidesteps that footgun entirely.
Or edit ~/.claude.json directly. Minimal (OAuth fallback):
Create .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
Settings β Cline β MCP Servers:
Claude Desktop still supports local stdio servers: Settings β Developer β Edit Config (claude_desktop_config.json), then paste the same JSON block as Claude Code above.
Claude's Settings β Connectors β Add custom connector dialog needs an HTTPS URL, not a command β so deploy the bundled Streamable HTTP server and paste its URL:
Then add the connector in Claude with the URL:
No OAuth needed β leave the Client ID/Secret fields blank. Claude only starts an OAuth flow if the server asks for it.
Remote-mode notes:
grok_review needs an explicit diff over HTTP β the server can't see your local repo, so auto git diff is disabled in remote mode.GROK_MCP_TIMEOUT below your platform's request timeout (and disable scale-to-zero) β grok-4 reasoning can run for minutes.GET /health is available for platform health checks; see .env.example for all knobs (GROK_MCP_ALLOWED_HOSTS, GROK_MCP_CORS_ORIGINS, ...).grok-mcp speaks plain stdio MCP. Point any client at npx -y grok-cli-mcp and it works. HTTP hosts can point at the remote endpoint above instead.
grok_chatOptional: model to override the default Grok model; timeout (seconds) to extend the per-call limit for long grok-4 reasoning. All four tools accept timeout.
grok_reviewIf diff is omitted, runs git diff <base_ref>...HEAD in cwd (defaults to your host's working directory). Returns a markdown review by default with verdict, per-dimension scores (correctness / readability / architecture / security / performance), and concrete fix-it items.
Pass "format": "json" to get machine-parseable output suitable for CI gating β see Use as a PR gate.
grok_consultThe server is stateless β the caller passes the full thread each time. Most MCP hosts handle this naturally.
grok_challengeReturns severity-ranked issues (Critical / High / Medium / Low) with concrete reproductions and patches.
| Env var | Default | Purpose |
|---|---|---|
XAI_API_KEY | (unset β falls back to OAuth) | API key from console.x.ai. When set, the server uses API mode (direct HTTP) and bills pay-per-call with no subscription rate cap. See Authentication. |
GROK_MCP_BACKEND | auto | Which backend to use: api (direct HTTP), cli (shell out to grok), or auto (API when XAI_API_KEY is set, else CLI). See Backends. |
GROK_MCP_MODEL | grok-4 | Model used in API mode. (CLI mode reads ~/.grok/config.toml.) |
GROK_MCP_BASE_URL | https://api.x.ai/v1 | API base URL β point at a proxy or compatible gateway in API mode. |
GROK_MCP_BIN | grok | Path to the grok binary (CLI mode only) |
GROK_MCP_TIMEOUT | 300000 | Default per-call timeout in milliseconds |
The server can reach Grok two ways and chooses one at startup (it logs which to stderr):
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/grok-mcp)<a href="https://allmcps.com/mcp/grok-mcp"><img src="https://allmcps.com/api/badge/grok-mcp?style=directory" alt="Grok MCP on AllMCPs" /></a>