MCP Directory

Grok-MCP

MCP server for xAI's Grok API: agentic tool calling, image/video generation, vision, and file support.

Unverified
stdio (local)
API key
Python

Add to your client

Copy the config for your MCP client and paste it into its config file.

Install / run
git clone https://github.com/merterbak/Grok-MCP.git && cd Grok-MCP && uv venv && uv sync

Paste 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)

chat

Standard chat completion with optional persistent history and multi-agent support.

chat_with_vision

Analyze local or remote images with a Grok vision model.

chat_with_files

Chat grounded on previously uploaded documents.

stateful_chat

Continue a server-side stored conversation via response_id.

retrieve_stateful_response

Fetch a stored response by ID.

delete_stateful_response

Delete a stored response by ID.

web_search

Autonomous web research with domain filters and citations.

x_search

Autonomous search over X (Twitter) posts, with handle and date filters.

code_executor

Solve tasks by running Python in a sandbox.

grok_agent

Unified agent that mixes files, images, web search, X search, and code execution.

generate_image

Create or edit images with Grok Imagine (multi-reference editing supported).

generate_video

Text-to-video, image-to-video, or video editing with Grok Imagine.

extend_video

Extend an existing generated video with a follow-up prompt.

upload_file

Upload a local document.

list_files

List uploaded files with sorting.

get_file

Fetch file metadata by ID.

get_file_content

Download file content as text.

delete_file

Delete a file by ID.

list_chat_sessions

List saved sessions in chats/.

get_chat_history

Get a session's full transcript.

clear_chat_history

Delete a session's local history file.

list_models

List 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.

Verified
stdio (local)
No auth
TypeScript
9 tools
Updated 5 months agoRepo

Structured step-by-step reasoning tool for breaking problems into revisable thought sequences.

Verified
stdio (local)
No auth
TypeScript
1 tool
Updated 6 months agoRepo

Fully managed remote server for AWS docs, blogs, What's-New and Well-Architected guidance — no key.

Verified
HTTP (remote)
No auth
Hosted
6 tools
Updated 5 months agoRepo