
Grok-MCP
MCP server for xAI's Grok API: agentic tool calling, image/video generation, vision, and file support.
Add to your client
Copy the config for your MCP client and paste it into its config file.
git clone https://github.com/merterbak/Grok-MCP.git && cd Grok-MCP && uv venv && uv syncPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"grok-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/Grok-MCP",
"run",
"python",
"main.py"
],
"env": {
"XAI_API_KEY": "your_api_key_here"
}
}
}
}Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Python 3.11 or higher
- xAI API key (from https://console.x.ai)
- Astral UV package manager
About Grok-MCP
Grok-MCP wraps xAI's Grok API behind the Model Context Protocol. It offers chat and reasoning, vision and file-grounded chat, stateful conversations, agentic tools (web search, X search, Python code execution, and a unified grok_agent), image and video generation/editing with Grok Imagine, full Files API management, local chat history utilities, and live model/pricing listing. It runs over stdio via uv and authenticates with an xAI API key.
Tools & capabilities (22)
chatStandard chat completion with optional persistent history and multi-agent support.
chat_with_visionAnalyze local or remote images with a Grok vision model.
chat_with_filesChat grounded on previously uploaded documents.
stateful_chatContinue a server-side stored conversation via response_id.
retrieve_stateful_responseFetch a stored response by ID.
delete_stateful_responseDelete a stored response by ID.
web_searchAutonomous web research with domain filters and citations.
x_searchAutonomous search over X (Twitter) posts, with handle and date filters.
code_executorSolve tasks by running Python in a sandbox.
grok_agentUnified agent that mixes files, images, web search, X search, and code execution.
generate_imageCreate or edit images with Grok Imagine (multi-reference editing supported).
generate_videoText-to-video, image-to-video, or video editing with Grok Imagine.
extend_videoExtend an existing generated video with a follow-up prompt.
upload_fileUpload a local document.
list_filesList uploaded files with sorting.
get_fileFetch file metadata by ID.
get_file_contentDownload file content as text.
delete_fileDelete a file by ID.
list_chat_sessionsList saved sessions in chats/.
get_chat_historyGet a session's full transcript.
clear_chat_historyDelete a session's local history file.
list_modelsList all Grok language and image models with live pricing.
When to use it
- Run agentic web and X (Twitter) searches with citations from inside Claude Desktop or Claude Code.
- Generate or edit images and videos with Grok Imagine via natural-language prompts.
- Analyze local or remote images with Grok's vision models.
- Upload documents and chat grounded on their content via the Files API.
- Execute Python in a sandbox to solve computational tasks.
- Maintain stateful, server-side conversation context across multiple requests.
Security notes
Requires an xAI API key (XAI_API_KEY) passed via environment. Claude Desktop cannot send uploaded chat images to MCP tools; the README recommends pairing with the official Filesystem MCP so you can reference local image/file paths in chat. Usage incurs xAI API costs (chat, image/video generation, agentic tools).
Grok-MCP FAQ
How do I authenticate?
Set the XAI_API_KEY environment variable in your MCP client config with a key from the xAI console (https://console.x.ai).
Why can't I send an image directly in Claude Desktop chat?
Claude Desktop can't pass uploaded chat images to an MCP tool. The README recommends installing the official Filesystem MCP so you can reference a local file path (e.g. /Users/me/Desktop/image.png) in chat for the vision tools.
How do I install it for Claude Code?
Run from the project directory: claude mcp add grok-mcp -e XAI_API_KEY=your_api_key_here -- uv run --directory /path/to/Grok-MCP python main.py
Is it official?
No. It is a community project (MIT-licensed) by merterbak that wraps xAI's Grok API; it is not published by xAI.
Alternatives to Grok-MCP
Compare all alternatives →Official MCP server providing persistent, file-backed knowledge-graph memory across sessions.
Structured step-by-step reasoning tool for breaking problems into revisable thought sequences.
Fully managed remote server for AWS docs, blogs, What's-New and Well-Architected guidance — no key.
Compare Grok-MCP with: