grok-mcp
grok-mcp
MCP server that wraps the xAI Grok API. Lets Claude and other AI agents delegate thinking, planning, and real-time search to Grok.
Quick Start
One-liner to add to Claude Code on any device:
claude mcp add grok -e XAI_API_KEY=your-key -- npx -y @pkwadsy/grok-mcpYou need an xAI API key from console.x.ai.
Alternative: project config
Add to your project's .mcp.json:
{
"mcpServers": {
"grok": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@pkwadsy/grok-mcp"],
"env": {
"XAI_API_KEY": "your-xai-api-key"
}
}
}
}Tools
ask_grok
Ask Grok a question with optional file context, web search, and X/Twitter search.
Parameter | Type | Required | Description |
| string | yes | The question or task for Grok |
| string[] | no | Files to include in context (see file syntax below) |
| number | no | Override max file count (default 50) |
| number | no | Override max per-file size in KB (default 32) |
| string | no | Custom system prompt |
| string | no | Model to use (default: |
| boolean | no | Web search, enabled by default |
| boolean | no | Enable X/Twitter search |
check_files
Dry-run file resolution. Validates all files and shows sizes without calling Grok. If check_files passes, ask_grok will too.
Parameter | Type | Required | Description |
| string[] | yes | Files to check (same syntax as |
| number | no | Override max file count (default 50) |
| number | no | Override max per-file size in KB (default 32) |
File syntax
Files are passed as an array of strings with compact syntax:
Syntax | Description |
| Whole file |
| Lines 10 to 30 |
| Just line 10 |
| Glob pattern |
| Bypass per-file size limit |
| Combine line range with force |
Safety limits
Limit | Default | Override |
Files per call | 50 |
|
Per-file size | 32 KB |
|
Total context | 256 KB | Hard cap, not overridable |
Available models
grok-4.20-multi-agent— multi-agent mode, great for architecture and planning (default)grok-4.20-reasoning— flagship reasoninggrok-4.20-non-reasoning— fast, no reasoninggrok-4.1-fast-reasoning— cheaper reasoninggrok-4.1-fast-non-reasoning— cheapest, fast
Examples
Ask with file context:
prompt: "Review this code for bugs"
files: ["src/index.ts", "src/utils.ts:20-50"]Search the web:
prompt: "What happened in tech news today?"Search X/Twitter:
prompt: "What are people saying about the new React release?"
x_search: trueCheck files before asking:
files: ["src/**/*.ts"]License
MIT