# merterbak/Grok-MCP [Health: Active]

**Category:** 🗣️ Conversational AI  
**Repository:** https://github.com/merterbak/Grok-MCP  
**GitHub Stars:** 57  
**Views:** 12  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/merterbak-grok-mcp

## Description
MCP server for xAI's Grok API with agentic tool calling, image generation, vision, and file support.

## Tools
Capabilities this server exposes over MCP:

- **chat** — standard chat completion with optional persistent history, 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, 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.

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/merterbak/Grok-MCP), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
git clone https://github.com/merterbak/Grok-MCP.git
```

2. Install:

```sh
cd Grok-MCP
```

3. Install:

```sh
uv venv
```

4. Install:

```sh
uv sync
```

5. Add to Claude Code:

```sh
claude mcp add grok-mcp -e XAI_API_KEY=your_api_key_here -- uv run --directory /path/to/Grok-MCP python main.py
```

6. Add to Claude Code:

```sh
claude mcp add grok-mcp -- uv run --directory /path/to/Grok-MCP python main.py
```

## Documentation

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

_Full upstream README: https://allmcps.com/mcp/merterbak-grok-mcp/readme_

