Grok MCP logo

Grok MCP

by merterbak

Connects xAI’s Grok API to MCP clients for chat, search, code execution, files, vision, and media generation.

Install Grok MCP

Run the project’s own setup commands, in order.

Setup steps from the project

merterbak/Grok-MCP installs with its own steps rather than a config we can generate, so these are copied as-is. Follow them in order and run the commands in a terminal. Source: github.com

  1. 1. Install
    git clone https://github.com/merterbak/Grok-MCP.git
    
  2. 2. Install
    cd Grok-MCP
    
  3. 3. Install
    uv venv
    
  4. 4. Install
    uv sync
    
  5. 5. Add to Claude Code
    claude mcp add grok-mcp -e XAI_API_KEY=your_api_key_here -- uv run --directory /path/to/Grok-MCP python main.py
    
  6. 6. Add to Claude Code
    claude mcp add grok-mcp -- uv run --directory /path/to/Grok-MCP python main.py
    

Overview

merterbak/Grok-MCP connects MCP clients to xAI’s Grok API through a Python stdio server. It exposes chat, vision, document-grounded conversations, stateful responses, web and X search, sandboxed Python execution, and Grok Imagine image and video generation. Uploaded files and local chat sessions can be managed through dedicated tools, while an agent tool combines several capabilities in one workflow. Reach for it when an MCP client needs Grok-specific research, multimodal analysis, file handling, or media generation.

Use cases

  • Research current topics across the web with citations
  • Search X posts using handles and date filters
  • Analyze images and uploaded documents with Grok
  • Generate or edit images and videos with Grok Imagine
  • Run Python-based problem solving in a sandbox

Key features

  • Grok chat with optional history and multi-agent support
  • Vision and document-grounded conversations
  • Web search and X search with filters
  • Sandboxed Python code execution
  • Image and video generation with Grok Imagine
  • File, response, model, and local history management

Tools22

What Grok MCP lets your agent do. Expand a tool for its parameters.

Self-reported~336 tokens of context

Security & health

What it can reach and how reliably it runs — from our own checks, not the maintainer’s claims.

ActiveLast checked

Recent health check succeeded.

22/22 checks healthy over the last 111d

Adoption & maintenance

Factual signals from GitHub, npm, and our automated checks — not a rating.

GitHub stars57Stargazers on the source repository.
Last commit5d agoMost recent push to the default branch.
Tools exposed22Callable tools this server registers over MCP.
Directory activity12 viewsConfig copies, upvotes, and views on AllMCPs.

How Grok MCP works

What merterbak/Grok-MCP does

merterbak/Grok-MCP exposes xAI’s Grok models as MCP tools. It covers ordinary chat as well as image analysis, document-grounded conversations, persistent response state, web research, searches across X, Python execution, image generation, and video generation. The server also provides file-management and local chat-history tools so an MCP client can work with uploaded documents and saved conversations.

The grok_agent tool combines several of these capabilities, including files, images, web search, X search, code execution, and server-side image generation. A separate list_models tool returns available Grok language and image models together with live pricing.

How it works

The project runs as a Python MCP server over stdio. Requests are sent to xAI using the XAI_API_KEY credential. Chat can use optional persistent local history, while stateful conversations use a response_id to continue, retrieve, or delete a server-side response.

Search tools support focused research: web search accepts domain filters and returns citations, and X search can filter by handles and dates. code_executor runs Python in a sandbox. Image results can be returned as temporary URLs or saved locally when the image-generation request enables saving; generated agent images are written to the images/ directory.

Setup and configuration

The server requires Python 3.11 or newer, an xAI API key, and Astral UV. Clone the repository, create and activate a virtual environment, then install dependencies with uv sync:

bash
uv venv
source .venv/bin/activate
uv sync

On Windows, use the corresponding .venv\\Scripts\\activate command. A stdio server can be started with:

bash
uv run python main.py

Claude Desktop can register it with a command of uv, arguments pointing to the project directory and main.py, and an environment entry for XAI_API_KEY. Claude Code can register the same server with claude mcp add and the uv run command. Docker Compose and MCP Inspector are also supported through docker compose up --build and mcp dev main.py.

For image or document workflows that need a local path, an MCP client must be able to provide that path. The project documents using the official Filesystem MCP server with Claude Desktop so local files can be referenced in chat.

Tools and capabilities

  • chat provides standard completions, optional history, multi-agent support, per-request service tiers, and guidelines.
  • chat_with_vision analyzes local or remote images with a Grok vision model.
  • chat_with_files grounds conversations in previously uploaded documents.
  • stateful_chat, retrieve_stateful_response, and delete_stateful_response manage stored responses.
  • web_search, x_search, code_executor, and grok_agent support research and agentic workflows.
  • generate_image, generate_video, and extend_video cover image creation or editing and video generation or continuation.
  • File tools upload, list, inspect, download, and delete documents.
  • Local history tools list sessions, retrieve transcripts, and remove saved history files.

Limitations and notes

An xAI API key is required for operation. Local image and document workflows depend on supplying usable file paths; Claude Desktop may need the separate Filesystem MCP server for direct access to files on the computer. Local chat history is stored as JSON files in chats/, while generated images can be stored in images/ when requested. The project is licensed under MIT.

Written by AllMCPs with AI assistance from the project’s README and listing data. How we build listings

Reviews

No reviews yet — be the first to share how it worked for you.

Frequently Asked Questions about Grok MCP

merterbak/Grok-MCP is an MCP server that connects MCP clients to xAI’s Grok API. Its main tools provide chat, vision, file-grounded conversations, web and X search, sandboxed Python execution, stateful responses, and Grok Imagine image and video generation.

Install it by cloning the repository, creating a Python 3.11+ virtual environment with UV, and running `uv sync`. Start the stdio server with `uv run python main.py`, or use Docker Compose with `docker compose up --build`.

Set `XAI_API_KEY` to an xAI API key. Claude Desktop and Claude Code pass this variable in their MCP server configuration, and the key is required for requests to the Grok API.

Yes, it includes configuration instructions for both Claude Desktop and Claude Code. Claude Desktop can launch it with UV, while Claude Code can register it using `claude mcp add` and the project’s `uv run` command.

Related MCP servers

Add a badge to your READMEShow it’s listed — live SVG, Markdown or HTML.

AllMCPs Directory Badge

Full Badge Customizer

Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.

Badge Style:
Live Dynamic SVG PreviewGrok MCP AllMCPs Directory Badge
Markdown (GitHub README)
[![AllMCPs](https://allmcps.com/api/badge/merterbak-grok-mcp?style=directory)](https://allmcps.com/mcp/merterbak-grok-mcp)
HTML Embed
<a href="https://allmcps.com/mcp/merterbak-grok-mcp"><img src="https://allmcps.com/api/badge/merterbak-grok-mcp?style=directory" alt="Grok MCP on AllMCPs" /></a>