{"id":50423673,"url":"https://github.com/entropyvortex/askgrokmcp","last_synced_at":"2026-05-31T09:31:02.137Z","repository":{"id":345096071,"uuid":"1181549822","full_name":"entropyvortex/askgrokmcp","owner":"entropyvortex","description":"A Model Context Protocol (MCP) server that brings xAI's Grok API into Claude Code as native tools. ","archived":false,"fork":false,"pushed_at":"2026-05-25T18:43:14.000Z","size":181,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-25T20:14:43.009Z","etag":null,"topics":["claude-code","xai"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/entropyvortex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-14T09:44:12.000Z","updated_at":"2026-05-25T18:42:50.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/entropyvortex/askgrokmcp","commit_stats":null,"previous_names":["marceloceccon/askgrokmcp"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/entropyvortex/askgrokmcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entropyvortex%2Faskgrokmcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entropyvortex%2Faskgrokmcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entropyvortex%2Faskgrokmcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entropyvortex%2Faskgrokmcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/entropyvortex","download_url":"https://codeload.github.com/entropyvortex/askgrokmcp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/entropyvortex%2Faskgrokmcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33726718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["claude-code","xai"],"created_at":"2026-05-31T09:31:02.073Z","updated_at":"2026-05-31T09:31:02.125Z","avatar_url":"https://github.com/entropyvortex.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Grok MCP Server\n\n[![npm version](https://img.shields.io/npm/v/askgrokmcp)](https://www.npmjs.com/package/askgrokmcp)\n[![Node.js](https://img.shields.io/badge/node-%3E%3D18-brightgreen)](https://nodejs.org)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n\nA [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that brings xAI's Grok API into [Claude Code](https://docs.anthropic.com/en/docs/claude-code) as native tools.\n\nAsk Grok questions, generate images with Aurora, run multi-round consensus analysis, and explore available models — directly from your terminal.\n\n---\n\n## Tools\n\n| Tool | Description |\n|------|-------------|\n| `ask_grok` | Send a prompt to Grok with optional system prompt and sampling parameters |\n| `generate_image` | Generate images using Grok's Aurora model and save them locally |\n| `list_models` | List all xAI models available to your account |\n| `grok_consensus` | Run a full Consensus Validation Protocol (CVP) for deep, multi-round analysis |\n| `grok_validate` | Run a rigorous multi-round Validation Protocol on any artifact (code, plan, prompt, PR) with scorecard + improved version |\n\n## Built-in Protocols\n\n### Consensus Validation Protocol (CVP)\n\nThe `grok_consensus` tool implements a structured, multi-round analysis protocol. Instead of a single prompt-and-response, it runs 3-10 iterative rounds where Grok progressively deepens its analysis — challenging its own assumptions, evaluating evidence strength, and synthesizing a balanced conclusion.\n\n```\n\u003e Run CVP on whether large language models can reason\n\u003e Ask Grok to validate the claim that sleep deprivation affects decision-making — use 5 rounds\n\u003e Consensus check with Grok on the future of nuclear energy\n```\n\nThe entire protocol executes server-side in a single tool call. Each round builds on the full conversation history for genuine iterative refinement.\n\n**Default:** 3 rounds | **Max:** 10 rounds | [Full protocol documentation](protocols/consensus-validation.md)\n\n### Validation Protocol\n\nThe `grok_validate` tool runs a rigorous, multi-round quality gate on any artifact — code, plans, research, prompts, PR descriptions, architectures. Grok produces a scored scorecard (correctness, completeness, innovation/risk, clarity, best practices), identifies critical issues, and returns an improved version ready to copy-paste.\n\n```\n\u003e grok_validate with artifact is [paste your plan or code here]\n\u003e grok_validate with artifact is [auth module] criteria is security, input validation rubric is security-focused\n\u003e grok_validate with artifact is [your plan] reference is [original output] rounds is 6 rubric is strict\n```\n\nSupports four rubric presets: `balanced` (default), `strict`, `innovative`, and `security-focused`. An optional `reference` argument enables side-by-side comparison with another model's output.\n\n**Default:** 5 rounds | **Max:** 10 rounds\n\n---\n\n## Prerequisites\n\n- **Node.js** \u003e= 18\n- **Claude Code** CLI installed\n- **xAI API key** — get one at [console.x.ai](https://console.x.ai)\n\n## Setup\n\n### Option A: Install from npm\n\n```bash\nnpm install -g askgrokmcp\n```\n\nThen register with Claude Code:\n\n```bash\nclaude mcp add grok -e XAI_API_KEY=your_api_key_here -- grok-mcp\n```\n\n### Option B: Clone from source\n\n```bash\ngit clone https://github.com/marceloceccon/askgrokmcp.git\ncd askgrokmcp\nnpm install\n```\n\nThen register with Claude Code:\n\n```bash\nclaude mcp add grok -e XAI_API_KEY=your_api_key_here -- node /path/to/askgrokmcp/grok-mcp.mjs\n```\n\nReplace `/path/to/askgrokmcp` with the actual path where you cloned the repository.\n\n---\n\nReplace `your_api_key_here` with your xAI API key in either option. That's it — the tools are now available in Claude Code.\n\n## Usage\n\nOnce registered, you can use the tools naturally in Claude Code:\n\n### Ask Grok a question\n\n```\n\u003e ask grok what the latest news in AI are\n```\n\n### Use a system prompt\n\n```\n\u003e ask grok to review this code, using a system prompt that says \"You are a senior security auditor\"\n```\n\n### Control sampling parameters\n\n```\n\u003e ask grok to generate test data with temperature 0 and max_tokens 500\n```\n\n### Use a specific model for one call\n\n```\n\u003e ask grok to summarize this document using grok-3\n```\n\n### Generate an image\n\n```\n\u003e ask grok to generate an image of a sunset over mountains and save it as images/sunset.png\n```\n\n### Generate multiple variations\n\n```\n\u003e ask grok to generate 4 variations of a logo for a coffee shop and save them as images/logo.png\n```\n\nWhen generating multiple images, files are automatically numbered (e.g., `logo-1.png`, `logo-2.png`, ...).\n\n### Run a consensus analysis\n\n```\n\u003e run CVP on the effectiveness of carbon capture technology\n\u003e ask grok to validate whether quantum computers will break RSA by 2030 — use 5 rounds\n```\n\n### List available models\n\n```\n\u003e list the available grok models\n\u003e list grok chat models only\n\u003e list grok image models\n```\n\n## Model Selection\n\nThe server uses a three-level priority system for model selection:\n\n| Priority | Mechanism | Scope |\n|----------|-----------|-------|\n| 1st (highest) | `model` argument in the tool call | Single request |\n| 2nd | `GROK_CHAT_MODEL` / `GROK_IMAGE_MODEL` env vars | Server lifetime |\n| 3rd (default) | Built-in defaults (see below) | Fallback |\n\n### Built-in defaults\n\nAt startup the server probes the xAI `/models` endpoint and selects the best available model:\n\n| Purpose | Frontier (preferred) | Fallback |\n|---------|---------------------|----------|\n| Chat | `grok-4.3` | `grok-4.3` |\n| Image generation | `grok-imagine-image-quality` | `grok-imagine-image-quality` |\n\nIf the frontier model is not available on your account, the server automatically falls back to the safe default.\n\n### Change defaults via environment variable\n\n```bash\nclaude mcp add grok \\\n  -e XAI_API_KEY=your_api_key_here \\\n  -e GROK_CHAT_MODEL=grok-3 \\\n  -e GROK_IMAGE_MODEL=grok-2-image \\\n  -- grok-mcp\n```\n\n### Override per call\n\nJust tell Claude which model to use:\n\n```\n\u003e ask grok to explain quantum computing using model grok-3\n```\n\nOr use `list_models` first to discover what's available, then pick one.\n\n## File write safety\n\nBy default the server only writes images inside the **current working directory** (the directory Claude Code was launched from) and its subdirectories. Any path that resolves outside that directory is rejected with a clear error.\n\nTo allow writes to a different location, set the `SAFE_WRITE_BASE_DIR` environment variable to an absolute path:\n\n```bash\nexport SAFE_WRITE_BASE_DIR=/tmp/my-images\n```\n\nOr pass it directly when registering the server:\n\n```bash\nclaude mcp add grok \\\n  -e XAI_API_KEY=your_api_key_here \\\n  -e SAFE_WRITE_BASE_DIR=/tmp/my-images \\\n  -- grok-mcp\n```\n\n\u003e **Note:** Absolute paths that resolve outside the allowed base directory are rejected. Use relative paths (e.g. `images/output.png`) or set `SAFE_WRITE_BASE_DIR` explicitly.\n\n## Configuration\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `XAI_API_KEY` | *(required)* | Your xAI API key |\n| `GROK_CHAT_MODEL` | `grok-4.3` | Default model for `ask_grok`, `grok_consensus`, and `grok_validate` |\n| `GROK_IMAGE_MODEL` | `grok-imagine-image-quality` | Default model for `generate_image` |\n| `SAFE_WRITE_BASE_DIR` | `process.cwd()` | Base directory for image writes |\n| `XAI_REQUEST_TIMEOUT_MS` | `30000` | Timeout per xAI API request in milliseconds |\n| `XAI_MAX_RETRIES` | `2` | Number of retries for transient errors (429/5xx/network/timeout) |\n| `XAI_RETRY_BASE_DELAY_MS` | `500` | Base delay for exponential retry backoff |\n| `LOG_REQUESTS` | `false` | Logs tool/xAI request metadata to stderr |\n| `LOG_REQUEST_PAYLOADS` | `false` | Includes full request payloads in logs (use carefully) |\n\n## Request logging\n\nRequest logging is optional and disabled by default.\n\nEnable metadata-only logs:\n\n```bash\nexport LOG_REQUESTS=true\n```\n\nTo also log full request payloads (including prompts), explicitly enable:\n\n```bash\nexport LOG_REQUESTS=true\nexport LOG_REQUEST_PAYLOADS=true\n```\n\n\u003e **Important:** Logs are written to stderr (not stdout) so MCP protocol communication remains safe.\n\n## Project Structure\n\n```\naskgrokmcp/\n  grok-mcp.mjs          Server entry point, config, HTTP client\n  src/tools.js           Tool definitions and handler implementations\n  protocols/             Protocol documentation\n    consensus-validation.md\n  grok-mcp.test.mjs     Test suite\n```\n\n## How it works\n\nThis server implements the MCP protocol over stdio. When Claude Code starts, it launches the server as a subprocess and communicates with it via JSON-RPC over stdin/stdout. The server translates MCP tool calls into xAI API requests and returns the results.\n\n```mermaid\nflowchart LR\n    A[Claude Code] -- stdio --\u003e B[grok-mcp.mjs]\n    B -- HTTPS --\u003e C[xAI API]\n```\n\nFor the `grok_consensus` tool, the server manages a multi-round conversation loop with Grok internally, returning the complete analysis in a single response:\n\n```mermaid\nsequenceDiagram\n    participant C as Claude Code\n    participant S as grok-mcp\n    participant G as xAI API\n\n    C-\u003e\u003eS: grok_consensus(topic, rounds)\n    loop Each round\n        S-\u003e\u003eG: chat/completions (with full history)\n        G--\u003e\u003eS: Round analysis\n    end\n    S--\u003e\u003eC: Structured CVP results\n```\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentropyvortex%2Faskgrokmcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fentropyvortex%2Faskgrokmcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fentropyvortex%2Faskgrokmcp/lists"}