Grok MCP
Grok MCP is an MCP server that provides comprehensive access to xAI's Grok API capabilities. You can access multiple Grok models (Grok-4, Grok-4-Fast, Grok-3-Mini, and more) for chat completion with extensive customization options including temperature, max tokens, and system prompts. The server supports reasoning models that provide detailed reasoning alongside responses, image generation from text descriptions, and vision analysis of images using natural language queries (supporting both local files and URLs). It offers live web search with real-time results, source citations, date range filters, country localization, and custom RSS feed integration from news, web, X (Twitter), and RSS sources. You can maintain stateful conversations with context preserved across multiple requests, conversation history management, and the ability to retrieve and delete stored responses (kept for 30 days). Additional features include model discovery to list all available Grok models with their details and creation information.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Grok MCPgenerate an image of a futuristic city skyline at sunset"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Grok-MCP
MCP server for xAI's Grok API with agentic tool calling, image and video generation, vision, 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.20-0309-reasoning, grok-4-1-fast-reasoning 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)
Installation
Clone the repository:
git clone https://github.com/merterbak/Grok-MCP.git
cd Grok-MCPCreate a venv environment:
uv venv
source .venv/bin/activate # macOS/Linux or .venv\Scripts\activate on WindowsInstall dependencies:
uv syncConfiguration
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.pyOr if you have a .env file with your key:
claude mcp add grok-mcp -- uv run --directory /path/to/Grok-MCP python main.pyVerify it's registered:
claude mcp listFilesystem 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.pyDocker:
docker compose up --buildMcp Inspector:
mcp dev main.pyAvailable 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.
License
This project is open source and available under the MIT License.
Appeared in Searches
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/merterbak/Grok-MCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server