Access Grok API for Image, Search, and Reasoning
MCP server for xAI's Grok API exposing web/X search, vision, image and video generation, file chat, and stateful conversations as 22 tools.
Maintainer of this project? Claim this page to edit the listing.
1.0.1Add to Favorites
Why it matters
Integrate with the xAI Grok API to leverage advanced capabilities including image understanding, image generation, real-time search, and sophisticated reasoning models.
Outcomes
What it gets done
Analyze images using natural language queries.
Generate images from text descriptions.
Perform real-time internet searches with source citations.
Engage in stateful conversations with reasoning models.
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/vb-grok-mcp | bash Capabilities
Tools your agent gets
List all available Grok models with creation dates and owner information
Standard chat completion with extensive customization capabilities
Get detailed reasoning along with the response
Analyze images using natural language queries
Create images from text descriptions
Real-time internet search with source citations
Maintain conversation state across multiple requests on xAI servers
Retrieve previously saved conversation response
Delete saved conversation from xAI servers
Overview
Grok MCP Server
Grok-MCP is an MCP server exposing xAI's Grok API as 22 tools across chat, agentic web/X search, code execution, image and video generation, file handling, local chat history, and model listing, with Claude Desktop and Claude Code integration. Use it to give an MCP client direct Grok access for search, code execution, vision, or generation; requires an xAI API key, and Claude Desktop needs the Filesystem MCP server for local image access.
What it does
Grok-MCP is an MCP server for xAI's Grok API, exposing web and X search, vision, image and video generation, and file support as callable tools. Its features: agentic tool calling with multi-step reasoning (web search, X/Twitter search, and sandboxed code execution), access to multiple Grok models (grok-4.5, grok-4.3, grok-build-0.1, and others), image and video generation and editing via Grok Imagine, vision analysis of local or remote images with Grok's vision models, a Files API for uploading and chatting against documents, stateful conversations tracked by a response ID across requests, and optional local chat history saved as JSON files in a chats/ directory. It exposes 22 tools across six categories: chat and reasoning (chat, chat_with_vision, chat_with_files, stateful_chat, retrieve_stateful_response, delete_stateful_response), agentic tools (web_search with domain filters and citations, x_search with handle and date filters, code_executor for sandboxed Python, and grok_agent which unifies files, images, web search, X search, and code execution into one agent), image and video (generate_image with multi-reference editing, generate_video for text-to-video, image-to-video, or video editing, and extend_video), files (upload_file, list_files, get_file, get_file_content, delete_file), local chat history (list_chat_sessions, get_chat_history, clear_chat_history), and models (list_models, which lists Grok's language and image models with live pricing). Because Claude Desktop can't send uploaded chat images directly to an MCP tool, the source documents a specific workaround: run the official Filesystem MCP server alongside Grok-MCP, then reference a file's path directly in chat so Grok's vision tools can pick it up. Beyond the Claude integrations, it can also run over plain stdio, via Docker Compose, or through the MCP Inspector for development. Licensed MIT.
When to use - and when NOT to
Use it when you want Claude, or another MCP client, to call xAI's Grok models directly - for agentic web or X research, code execution, image and video generation, vision analysis, or document-grounded chat - rather than switching to a separate Grok interface. It requires an xAI API key and Python 3.11+ with Astral UV, so it's not usable without an xAI account with API access. If you need to pass local images or files to Grok's vision tools through Claude Desktop specifically, you'll also need the separate Filesystem MCP server running alongside it, since Claude Desktop can't forward uploaded chat images to an MCP tool on its own.
Inputs and outputs
Input depends on the tool called: text prompts for chat tools, search queries with optional domain, handle, or date filters for the agentic search tools, image or video generation prompts with optional reference images for editing, local file paths for vision or file tools, and file or session IDs for lookups and deletions. Output is the corresponding chat completion, search result set with citations, generated or edited image or video, file metadata or content, or a saved or retrieved chat session. Its Claude Desktop configuration, quoted verbatim:
{
"mcpServers": {
"grok": {
"command": "uv",
"args": [
"--directory",
"/path/to/Grok-MCP",
"run",
"python",
"main.py"
],
"env": {
"XAI_API_KEY": "your_api_key_here"
}
}
}
}
Integrations
Runs on xAI's Grok API, including Grok Imagine for image and video, Astral UV for Python environment management, and integrates with Claude Desktop, Claude Code (claude mcp add), plain stdio, Docker Compose, and the MCP Inspector. Pairs with the official Filesystem MCP server (@modelcontextprotocol/server-filesystem) to work around Claude Desktop's inability to forward uploaded images directly to MCP tools.
Who it's for
Developers who want Claude or another MCP client to drive Grok's full capability set - web and X search, code execution, vision, image and video generation, and document chat - through one server rather than juggling separate Grok integrations per capability.
Source README
Grok-MCP
MCP server for xAI’s Grok API with Web/X search, vision, image/video generation and file support.
Features
- Agentic Tool Calling: Web search, X search, and code execution with multi-step reasoning
- Multiple Grok Models: Access to latest models such as grok-4.5, grok-4.3, grok-build-0.1 and more
- Image and Video Generation: Create images and videos using Grok Imagine
- Vision Capabilities: Analyze images with Grok's vision models
- Files API: Upload, manage, and chat with documents
- Stateful Conversations: Maintain conversation context as id across multiple requests
- Local Chat History: Option to save persistent client side chat history as JSON files in chats/
Prerequisites
- Python 3.11 or higher
- xAI API key (Get one here)
- Astral UV
Installation
- Clone the repository:
git clone https://github.com/merterbak/Grok-MCP.git
cd Grok-MCP
- Create a venv environment:
uv venv
source .venv/bin/activate # macOS/Linux or .venv\Scripts\activate on Windows
- Install dependencies:
uv sync
Configuration
Claude Desktop Integration
Add this to your Claude Desktop configuration file:
{
"mcpServers": {
"grok": {
"command": "uv",
"args": [
"--directory",
"/path/to/Grok-MCP",
"run",
"python",
"main.py"
],
"env": {
"XAI_API_KEY": "your_api_key_here"
}
}
}
}
Claude Code Integration
Run this command from inside 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
Or if you have a .env file with your key:
claude mcp add grok-mcp -- uv run --directory /path/to/Grok-MCP python main.py
Verify it's registered:
claude mcp list
Filesystem MCP (Optional)
Claude Desktop can't send uploaded images in the chat to an MCP tool.
The easiest way to give access to files directly from your computer is official Filesystem MCP server.
After setting it up you’ll be able to just write the image’s file path (such as /Users/mert/Desktop/image.png) in chat and Claude can use it with any vision chat tool.
{
"mcpServers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/Users/<your-username>/Desktop",
"/Users/<your-username>/Downloads"
]
}
}
}
For stdio:
uv run python main.py
Docker:
docker compose up --build
Mcp Inspector:
mcp dev main.py
Available Tools
Each tool has a full docstring in src/server.py with its arguments and return format. MCP client surfaces those directly, so this list is just a quick map of what's available.
Note: For using images and files, you must provide paths to chat. See Filesystem MCP (Optional) for setup.
Chat and reasoning
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 viaresponse_id.retrieve_stateful_response- fetch a stored response by ID.delete_stateful_response- delete a stored response by ID.
Agentic tools
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.
Image and video
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.
Files
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.
Local chat history
list_chat_sessions- list saved sessions inchats/.get_chat_history- get a session's full transcript.clear_chat_history- delete a session's local history file.
Models
list_models- list all Grok language and image models with live pricing.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.