askgrokmcp
Click on "Install 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., "@askgrokmcpwhat are the latest AI news?"
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.
Grok MCP Server
A Model Context Protocol (MCP) server that brings xAI's Grok API into Claude Code as native tools.
Ask Grok questions, generate images with Aurora, run multi-round consensus analysis, and explore available models — directly from your terminal.
Tools
Tool | Description |
| Send a prompt to Grok with optional system prompt and sampling parameters |
| Generate images using Grok's Aurora model and save them locally |
| List all xAI models available to your account |
| Run a full Consensus Validation Protocol (CVP) for deep, multi-round analysis |
| Run a rigorous multi-round Validation Protocol on any artifact (code, plan, prompt, PR) with scorecard + improved version |
Related MCP server: xAI MCP Server
Built-in Protocols
Consensus Validation Protocol (CVP)
The 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.
> Run CVP on whether large language models can reason
> Ask Grok to validate the claim that sleep deprivation affects decision-making — use 5 rounds
> Consensus check with Grok on the future of nuclear energyThe entire protocol executes server-side in a single tool call. Each round builds on the full conversation history for genuine iterative refinement.
Default: 3 rounds | Max: 10 rounds | Full protocol documentation
Validation Protocol
The 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.
> grok_validate with artifact is [paste your plan or code here]
> grok_validate with artifact is [auth module] criteria is security, input validation rubric is security-focused
> grok_validate with artifact is [your plan] reference is [original output] rounds is 6 rubric is strictSupports four rubric presets: balanced (default), strict, innovative, and security-focused. An optional reference argument enables side-by-side comparison with another model's output.
Default: 5 rounds | Max: 10 rounds
Prerequisites
Node.js >= 18
Claude Code CLI installed
xAI API key — get one at console.x.ai
Setup
Option A: Install from npm
npm install -g askgrokmcpThen register with Claude Code:
claude mcp add grok -e XAI_API_KEY=your_api_key_here -- grok-mcpOption B: Clone from source
git clone https://github.com/marceloceccon/askgrokmcp.git
cd askgrokmcp
npm installThen register with Claude Code:
claude mcp add grok -e XAI_API_KEY=your_api_key_here -- node /path/to/askgrokmcp/grok-mcp.mjsReplace /path/to/askgrokmcp with the actual path where you cloned the repository.
Replace your_api_key_here with your xAI API key in either option. That's it — the tools are now available in Claude Code.
Usage
Once registered, you can use the tools naturally in Claude Code:
Ask Grok a question
> ask grok what the latest news in AI areUse a system prompt
> ask grok to review this code, using a system prompt that says "You are a senior security auditor"Control sampling parameters
> ask grok to generate test data with temperature 0 and max_tokens 500Use a specific model for one call
> ask grok to summarize this document using grok-3Generate an image
> ask grok to generate an image of a sunset over mountains and save it as images/sunset.pngGenerate multiple variations
> ask grok to generate 4 variations of a logo for a coffee shop and save them as images/logo.pngWhen generating multiple images, files are automatically numbered (e.g., logo-1.png, logo-2.png, ...).
Run a consensus analysis
> run CVP on the effectiveness of carbon capture technology
> ask grok to validate whether quantum computers will break RSA by 2030 — use 5 roundsList available models
> list the available grok models
> list grok chat models only
> list grok image modelsModel Selection
The server uses a three-level priority system for model selection:
Priority | Mechanism | Scope |
1st (highest) |
| Single request |
2nd |
| Server lifetime |
3rd (default) | Built-in defaults (see below) | Fallback |
Built-in defaults
At startup the server probes the xAI /models endpoint and selects the best available model:
Purpose | Frontier (preferred) | Fallback |
Chat |
|
|
Image generation |
|
|
If the frontier model is not available on your account, the server automatically falls back to the safe default.
Change defaults via environment variable
claude mcp add grok \
-e XAI_API_KEY=your_api_key_here \
-e GROK_CHAT_MODEL=grok-3 \
-e GROK_IMAGE_MODEL=grok-2-image \
-- grok-mcpOverride per call
Just tell Claude which model to use:
> ask grok to explain quantum computing using model grok-3Or use list_models first to discover what's available, then pick one.
File write safety
By 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.
To allow writes to a different location, set the SAFE_WRITE_BASE_DIR environment variable to an absolute path:
export SAFE_WRITE_BASE_DIR=/tmp/my-imagesOr pass it directly when registering the server:
claude mcp add grok \
-e XAI_API_KEY=your_api_key_here \
-e SAFE_WRITE_BASE_DIR=/tmp/my-images \
-- grok-mcpNote: Absolute paths that resolve outside the allowed base directory are rejected. Use relative paths (e.g.
images/output.png) or setSAFE_WRITE_BASE_DIRexplicitly.
Configuration
Variable | Default | Description |
| (required) | Your xAI API key |
|
| Default model for |
|
| Default model for |
|
| Base directory for image writes |
|
| Timeout per xAI API request in milliseconds |
|
| Number of retries for transient errors (429/5xx/network/timeout) |
|
| Base delay for exponential retry backoff |
|
| Logs tool/xAI request metadata to stderr |
|
| Includes full request payloads in logs (use carefully) |
Request logging
Request logging is optional and disabled by default.
Enable metadata-only logs:
export LOG_REQUESTS=trueTo also log full request payloads (including prompts), explicitly enable:
export LOG_REQUESTS=true
export LOG_REQUEST_PAYLOADS=trueImportant: Logs are written to stderr (not stdout) so MCP protocol communication remains safe.
Project Structure
askgrokmcp/
grok-mcp.mjs Server entry point, config, HTTP client
src/tools.js Tool definitions and handler implementations
protocols/ Protocol documentation
consensus-validation.md
grok-mcp.test.mjs Test suiteHow it works
This 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.
flowchart LR
A[Claude Code] -- stdio --> B[grok-mcp.mjs]
B -- HTTPS --> C[xAI API]For the grok_consensus tool, the server manages a multi-round conversation loop with Grok internally, returning the complete analysis in a single response:
sequenceDiagram
participant C as Claude Code
participant S as grok-mcp
participant G as xAI API
C->>S: grok_consensus(topic, rounds)
loop Each round
S->>G: chat/completions (with full history)
G-->>S: Round analysis
end
S-->>C: Structured CVP resultsLicense
Available Tools
5 toolsask_grokB
Ask Grok a question and get a response. Default model: grok-4.3. Supports system prompts and sampling parameters (temperature, max_tokens, top_p). Run list_models to see all available model options.
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | The question or prompt to send to Grok | |
| system_prompt | No | Optional system prompt to set Grok's behavior and persona for this request. | |
| model | No | Chat model to use for this request. Defaults to "grok-4.3". Use list_models to see available chat models. | |
| temperature | No | Sampling temperature (0-2). Lower values make output more deterministic. Default: model-dependent. | |
| max_tokens | No | Maximum number of tokens to generate in the response. | |
| top_p | No | Nucleus sampling: only consider tokens with cumulative probability up to this value (0-1). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description bears full responsibility. It discloses that the tool supports system prompts and sampling parameters, but does not describe response format, rate limits, authentication needs, or any behavioral traits beyond the basic action.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is three concise sentences with no wasted words. It front-loads the core purpose and efficiently lists supported parameters and additional guidance.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given 6 parameters, no output schema, and no annotations, the description is adequate but incomplete. It covers default model and parameter types, but lacks details on output format, error handling, or behavioral constraints for a chat tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so baseline is 3. The description adds minimal extra meaning: it mentions the default model 'grok-4.3' and that system prompt is optional, but otherwise does not enhance understanding of temperature, max_tokens, or top_p beyond their schema descriptions.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool asks Grok a question and gets a response, and mentions default model and supported parameters. However, it does not differentiate from siblings like grok_consensus or grok_validate, which limits clarity on when to use this specific tool.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Usage is implied: ask a question and get a response. It suggests using list_models for model options, but provides no explicit guidance on when to use this tool versus alternatives like grok_consensus, nor any exclusion criteria.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_imageB
Generate an image using Grok's Aurora image model and save it to a local file. Default model: grok-imagine-image-quality. Use the optional 'model' parameter to use a different image model.
| Name | Required | Description | Default |
|---|---|---|---|
| prompt | Yes | Text description of the image to generate | |
| file_path | Yes | Path where the image file should be saved. Relative paths resolve from cwd; absolute paths must be within SAFE_WRITE_BASE_DIR (or cwd if unset). Example: images/output.png | |
| n | No | Number of image variations to generate (1-10, default 1) | |
| model | No | Image model to use for this request. Defaults to "grok-imagine-image-quality". Use list_models to see available image models. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so the description must carry the behavioral disclosure burden. It mentions saving to local file and default model, but omits critical details like file overwrite behavior, supported formats, permissions, rate limits, or error handling.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two concise sentences with no unnecessary words. The most important action ('generate an image... and save to a local file') is front-loaded.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
No output schema and the description does not mention return value. Given the tool creates and saves a file, missing info on what is returned (e.g., saved path, success status) reduces completeness.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema covers 100% of parameters with clear descriptions. The description adds useful context about default model and linking to list_models, but does not provide significant additional meaning beyond the schema.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it generates an image using Grok's Aurora model and saves to file. It distinguishes from sibling tools (ask_grok, grok_consensus, grok_validate, list_models) which serve different purposes.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description gives guidance on using the 'model' parameter to switch image models, but does not provide explicit when-to-use or when-not-to-use instructions relative to siblings.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
grok_consensusA
Runs a full iterative Consensus Validation Protocol (CVP) between Claude and Grok. Returns a structured final summary. Default 3-5 rounds. Supports custom round count via the 'rounds' argument.
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | The topic, claim, or question to analyze through the consensus protocol. | |
| rounds | No | Number of analysis rounds to run. Omit for the default (3 rounds). Higher values (up to 10) yield deeper analysis at the cost of latency. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
The description discloses the iterative nature, default round count, and customizable rounds, but lacks details on costs (latency), model participation specifics, and limitations. With no annotations, the description carries full burden but falls short of full transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is two sentences long, front-loads the core function and return type, and avoids redundancy. Every sentence provides essential information.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the complexity of a multi-round consensus protocol between two models, the description provides basic understanding but omits details on output structure, round mechanics, and use case scenarios. Adequate but not comprehensive.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The description adds value beyond the schema by clarifying default rounds (3-5) and explaining the trade-off for higher round counts (deeper analysis vs. latency). Both parameters are covered in schema, so this additional context is beneficial.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool runs an iterative Consensus Validation Protocol between two models, which distinguishes it from siblings like ask_grok (simple Q&A) and generate_image (image generation). It specifies the return type (structured final summary) and key parameters.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description implies the tool is for deep analysis requiring consensus but does not explicitly state when to use it over alternatives or provide exclusions. Siblings are named but no comparative guidance.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
grok_validateA
Runs a rigorous Validation Protocol on any artifact (code, plan, research, prompt, PR, architecture, etc.). Produces a scored scorecard, identifies weaknesses, and returns an improved version. Use this as your mandatory quality gate before shipping complex work. Default model: grok-4.3.
| Name | Required | Description | Default |
|---|---|---|---|
| artifact | Yes | The artifact to validate (code, plan, research output, prompt, PR description, etc.) | |
| criteria | No | Optional focus areas or custom evaluation criteria (e.g. 'security, performance, maintainability') | |
| reference | No | Optional reference output from another model for side-by-side comparison | |
| rounds | No | Number of validation rounds (1-10, default 5). Higher = deeper analysis. | |
| rubric | No | Evaluation style preset (default: balanced) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden. It adequately describes outcomes (scored scorecard, identifies weaknesses, returns improved version) and mentions the default model. It could be more explicit about side effects (e.g., does not modify the original artifact), but overall it provides sufficient behavioral disclosure for a non-destructive analysis tool.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise: three sentences covering function, outputs, and usage recommendation. It front-loads the core action and avoids any fluff. Every sentence earns its place.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given there is no output schema, the description adequately explains return value (scored scorecard, identified weaknesses, improved version). With 5 parameters (1 required) and no nested objects, the description covers the essential context. It could benefit from mentioning the output format or that the artifact is not mutated, but it is sufficient for an AI agent.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 100%, so the schema already documents all 5 parameters thoroughly. The description adds no additional semantic detail beyond the schema (e.g., it doesn't elaborate on valid values for 'rounds' or 'rubric'), making it merely adequate. The default model mention is not a parameter.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states it runs a validation protocol on any artifact, produces a scorecard, identifies weaknesses, and returns an improved version. The verb 'validate' and resource 'artifact' are specific, and it distinguishes from siblings like 'ask_grok' (Q&A) and 'generate_image' (image generation).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly recommends use as a 'mandatory quality gate before shipping complex work,' providing clear when-to-use guidance. It does not explicitly state when not to use, but the sibling tool list (ask_grok, generate_image, etc.) implies alternatives. The default model mention adds useful context.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_modelsA
List all xAI models available to your account, including their IDs and capabilities. Use this to discover which models you can pass to ask_grok or generate_image. You can also filter by type: 'chat' for language models or 'image' for image generation.
| Name | Required | Description | Default |
|---|---|---|---|
| filter | No | Filter models by capability. 'chat' returns language/reasoning models, 'image' returns image generation models, 'all' returns everything (default). |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations provided, so description carries the burden. It discloses listing with IDs and capabilities and filtering, but does not mention permissions, rate limits, or side effects. For a read-only listing, this is adequate but not exceptional.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with main purpose, no redundant information. Efficient and clear.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the simple tool (one optional parameter, no output schema, siblings that are consumers), the description fully covers what an agent needs: purpose, filter usage, and integration with other tools.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 100% and the description adds context by linking filter values to model types ('chat' for language models, 'image' for image generation). This adds value beyond the schema description but is minor, so baseline 3 is appropriate.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool 'List all xAI models available to your account', specifying the verb 'List' and the resource 'xAI models'. It distinguishes from siblings by mentioning they consume the model IDs (ask_grok, generate_image).
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Explicitly states when to use: 'to discover which models you can pass to ask_grok or generate_image'. Provides filter options but does not explicitly state when not to use, though context is clear.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
5 tool updates
v1.5.0- First observed
ask_grok - First observed
generate_image - First observed
grok_consensus - First observed
grok_validate - First observed
list_models
TDQS
Each tool has a clearly distinct purpose: Q&A, image generation, consensus validation, artifact validation, and model listing. No overlap or ambiguity.
All names use lowercase with underscores, but there is a slight inconsistency: most tools follow verb_noun (ask_grok, generate_image, list_models) while two start with the product prefix 'grok_' (grok_consensus, grok_validate), breaking the verb-first pattern.
5 tools is well-scoped for a server that wraps Grok API functionality—enough to cover key interactions without bloat.
The tool surface covers core Grok capabilities: query, image generation, consensus, validation, and model discovery. No obvious missing operations for the intended scope.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Source-checked CLI guides and model-aware planning for Claude Code, Codex, and Grok Build.
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
Agent personas for Claude. 16 tools, 13 personas, 3 workflows. Zero extra API cost. Free.
Live SEO workflow tools for Claude Code, Codex, and AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceIntegrates Google Gemini API capabilities into Claude Code, supporting text generation, image analysis, and AI image creation. It features specialized tools for creative brainstorming and managing multi-turn chat sessions.70MIT
- AlicenseAqualityDmaintenanceIntegrates xAI's Grok APIs into Claude Code to enable image and video generation, real-time web searches, and multi-modal image analysis. It provides a suite of tools for interacting with Grok models directly through natural language prompts during a Claude session.5401MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables Claude to query Grok as a peer for collaborative reasoning, code reviews, and architecture debates. It provides access to real-time web research and multiple specialized reasoning modes through the xAI API.-
- FlicenseBqualityNot gradedmaintenanceIntegrates Grok AI into Claude Code to enable real-time X/Twitter search and deep analysis of social media links. It supports a dual-mode architecture featuring a browser-based free mode for SuperGrok subscribers and a cost-controlled API mode.2481-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/entropyvortex/askgrokmcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server