grok-mcp-server
Click on "Deploy 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., "@grok-mcp-server explain this error: TypeError: Cannot read properties of undefined"
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
Give any MCP-compatible agent access to Grok.
Tools · Setup · Protocol support · Development · Contributing
A tiny Model Context Protocol (MCP) server that brings Grok (xAI) into any MCP-compatible agent, IDE or desktop client.
Highlights
Zero dependencies. About 200 lines of plain Node.js that speak JSON-RPC 2.0 over stdio.
4 focused tools. Ask, code review, error explanation and summarization.
Safe failures. API errors come back as tool errors, so your agent keeps running.
Uses the xAI Responses API (
POST /v1/responses) withstore: false.
Related MCP server: grok-build-mcp
Tools
Tool | What it does | Required args |
| Ask Grok anything: second opinions, research, brainstorming |
|
| Review a snippet for bugs, security, performance and readability |
|
| Root cause, fix and verification steps for an error or stack trace |
|
| Summarize long text as |
|
Every tool also accepts optional arguments (system, model, language, focus, context, style).
Setup
Get an API key from the xAI console.
Add the server to your MCP client configuration. Most clients use this shape:
{
"mcpServers": {
"grok": {
"command": "npx",
"args": ["-y", "github:myn4ki/grok-mcp-server"],
"env": {
"XAI_API_KEY": "xai-...",
"GROK_MODEL": "grok-4.7"
}
}
}
}Or clone it and point to the file directly:
git clone https://github.com/myn4ki/grok-mcp-server{
"mcpServers": {
"grok": {
"command": "node",
"args": ["/path/to/grok-mcp-server/bin/grok-mcp-server.js"],
"env": { "XAI_API_KEY": "xai-..." }
}
}
}Environment variables
Variable | Default | Purpose |
| (required) | xAI API key |
|
| Default model for all tools |
|
| Override for proxies or gateways |
Try it by hand
The server reads newline-delimited JSON-RPC on stdin:
printf '%s\n' \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18"}}' \
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}' \
'{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"ask_grok","arguments":{"prompt":"Explain MCP in one sentence"}}}' \
| XAI_API_KEY=xai-... node bin/grok-mcp-server.jsProtocol support
initialize, which negotiates2025-11-25,2025-06-18,2025-03-26and2024-11-05pingtools/listtools/callNotifications such as
notifications/initializedare accepted silently.
Development
npm test # node --test, no install required
npm start # run the server on stdioAdd a tool by appending an entry to src/tools.js with a name, description,
JSON inputSchema and a build(args) function that returns { prompt, system }.
Project layout:
bin/grok-mcp-server.js Executable entry point
src/server.js JSON-RPC 2.0 / MCP message handling over stdio
src/tools.js Tool definitions and prompt builders
src/grok.js Minimal xAI Responses API client
test/ node:test suitesContributing
Contributions are welcome, and new tools especially. Please read CONTRIBUTING.md and our Code of Conduct. To report a vulnerability, see SECURITY.md.
License
Released under the MIT License.
Available Tools
4 toolsask_grokB
Ask Grok (xAI) any question and get its answer. Useful for a second opinion, research or brainstorming.
Inputs: prompt (required), model, system.
grok_explain_errorA
Explain an error message or stack trace with Grok: likely root cause and step-by-step fix.
Inputs: error (required), context.
grok_review_codeA
Have Grok review a code snippet for bugs, security issues, performance and readability.
Inputs: code (required), focus, language.
grok_summarizeC
Summarize long text (docs, logs, discussions) with Grok.
Inputs: text (required), style, language.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
The specialized tools for code review, error explanation, and summarization are clearly distinct from each other. However, ask_grok is a general-purpose tool that overlaps with all three specialized tools, so an agent may sometimes be unsure whether to use the general or specialized variant.
All names are snake_case and include the provider name, but the pattern is mixed: ask_grok starts with the action verb, while grok_review_code, grok_explain_error, and grok_summarize use a provider prefix followed by the action. The naming remains readable but is not fully consistent.
Four tools is a well-scoped size for an LLM-provider wrapper. Each tool has a clear, non-redundant purpose and the count avoids both thinness and bloat.
The surface covers common Grok use cases: general Q&A, code review, error explanation, and summarization. Minor gaps exist around multi-turn conversation, custom system prompts, or file-based input, but the core workflows are represented.
Maintenance
Related MCP Connectors
Connect Grok by xAI to AI assistants via UniversalMCP stateless Streamable HTTP.
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Your org's AI agents, tasks, runs, search, and brain files as MCP tools and resources.
MCP tool marketplace for AI agents: web, OSINT, security and research tools through one key.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server that wraps the xAI Grok API, allowing Claude and other AI agents to delegate thinking, planning, and real-time search tasks to Grok. It provides a single tool with options for different use cases including web search, Twitter/X search, and multi-agent reasoning.2MIT
- AlicenseAqualityDmaintenanceMCP server that wraps the Grok CLI to enable code review, adversarial testing, and chat with xAI's Grok model, integrating into any MCP host as a peer reviewer, adversary, and consultant.4121 npm12MIT
- FlicenseAqualityCmaintenanceEnables using the xAI Grok CLI as an MCP sub-agent for code review, asking questions, and continuing conversations within MCP hosts like Claude Code.4-
- AlicenseNot gradedqualityNot gradedmaintenanceEnables any MCP-compatible AI to use xAI Grok's full toolset, including live X/Twitter search, web search, chat, image generation and editing, vision, video generation, structured outputs, and reasoning, all from a remotely hosted Cloudflare Worker.MIT