# grok-mcp [Health: Active]

**Category:** 🗣️ Conversational AI  
**Repository:** https://github.com/howardpen9/grok-mcp  
**GitHub Stars:** 11  
**npm Downloads (last month):** 333  
**Views:** 8  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/grok-mcp

## Description
Use xAI Grok as a peer reviewer + PR gate from Claude Code, Cursor, Cline and any MCP host.

## Tools
Capabilities this server exposes over MCP:

- **grok_chat** — Send a one-shot prompt to xAI Grok and return its reply. Stateless — for multi-turn use grok_consult.
- **grok_review** — Have Grok review a git diff. If no diff is provided, runs `git diff <base_ref>...HEAD` (default base: main). Returns a per-dimension review. Use format='json' for CI gating (verdict + scores + blockers).
- **grok_consult** — Continue a conversation with Grok by replaying the full message history each call. Stateless on the server side — the caller owns the thread.
- **grok_challenge** — Ask Grok to adversarially break a piece of code: edge cases, race conditions, security holes, adversarial inputs. Returns severity-ranked issues with reproductions.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "grok-mcp": {
    "command": "npx",
    "args": ["-y","grok-cli-mcp"],
    "env": {
      "XAI_API_KEY": "",
      "GROK_MCP_TIMEOUT": "",
      "GROK_MCP_PATH_SECRET": ""
    }
  }
}
```

**Requires environment variables:** `XAI_API_KEY`, `GROK_MCP_TIMEOUT`, `GROK_MCP_PATH_SECRET` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What grok-mcp MCP server does

The grok-mcp MCP server connects an MCP client to xAI Grok as a secondary reviewer and consultant. It is designed for workflows where a primary agent such as Claude Code, Cursor, or Cline asks another model to inspect code, challenge an approach, or answer a focused question.

Four MCP tools are available:

- `grok_chat` sends a single prompt and returns Grok's response.
- `grok_review` examines a supplied unified diff, or can obtain a local Git diff when running locally.
- `grok_consult` processes a complete message history for multi-turn discussions.
- `grok_challenge` looks for bugs, race conditions, edge cases, and security problems in code and its context.

All four tools are stateless. Review output can be returned as Markdown or JSON, making `grok_review` suitable for automated checks as well as interactive development.

## How it works

The grok-mcp MCP server selects its backend from the available authentication setup. When `XAI_API_KEY` is set, it calls the xAI HTTP API directly and does not require a local Grok executable. Without that variable, it can use the official Grok CLI, which requires an interactive browser OAuth login beforehand.

The server communicates over plain stdio for local MCP hosts. It also includes a Streamable HTTP server for deployments that need a URL, such as Claude web connectors. In HTTP mode, a path secret protects the endpoint, and the server provides a `/health` route for platform checks.

For local review requests, omitting `diff` allows the server to run `git diff <base_ref>...HEAD` in the configured working directory. Remote deployments cannot inspect the caller's local repository, so HTTP clients must provide the diff explicitly. The caller owns the full conversation history for `grok_consult` and sends it again for each request.

## Setup and configuration

Node.js 18 or newer is required. Install the npm package globally with `npm install -g grok-cli-mcp`, or run it without a permanent installation using `npx grok-cli-mcp`.

For API mode, provide an `XAI_API_KEY` from the xAI console. This is the documented option for MCP, CI, and automation. CLI mode requires installing the Grok CLI and completing its browser-based login. The server also accepts `GROK_MCP_TIMEOUT` for extending request limits, which can matter for longer Grok reasoning calls.

Local clients can start `npx -y grok-cli-mcp` as a stdio server. Claude Code, Cursor, Cline, and Claude Desktop use configuration entries containing the command, package arguments, and optional environment variables. For remote use, deploy the HTTP process on a Node-capable host, set `GROK_MCP_PATH_SECRET`, and expose the resulting `/mcp/<secret>` URL. Keep API keys and the HTTP path secret out of public configuration; the path secret controls access to the xAI-backed endpoint.

## Tools and capabilities

`grok_chat` accepts a prompt and optional model and timeout values. `grok_review` accepts a base reference, focus, format, working directory, or explicit diff. Its review can include a verdict, scores for correctness, readability, architecture, security, and performance, plus concrete fixes. JSON format is intended for machine-readable PR gating.

`grok_consult` accepts messages with roles such as system, user, and assistant, allowing the calling agent to preserve the thread. `grok_challenge` accepts code and contextual information, then returns severity-ranked findings with reproductions and patches.

The grok-mcp MCP server is therefore a fit for second-opinion review, focused design consultation, adversarial code analysis, and CI-oriented diff evaluation rather than general repository hosting or source-control mutation.

## Limitations and notes

The server does not maintain conversation state; the caller must provide the complete consultation history. Local Git discovery is unavailable through the remote HTTP endpoint, so remote review calls need an explicit diff. Long reasoning requests may require a timeout compatible with the hosting platform.

API usage is pay-per-call and depends on the xAI account. CLI authentication instead uses the user's Grok plan limits. API credentials placed in an MCP configuration file are stored in that file, so the file should be treated as sensitive. The remote URL should also be treated as a credential because anyone who obtains its secret path may be able to consume the configured xAI access.

_Full upstream README: https://allmcps.com/mcp/grok-mcp/readme_

