
How to add Grok-MCP to Cursor
MCP server for xAI's Grok API: agentic tool calling, image/video generation, vision, and file support. Paste the config into ~/.cursor/mcp.json and restart Cursor.
Last updated June 14, 2026 · 39★ · stdio · apikey
Cursor config for Grok-MCP
git clone https://github.com/merterbak/Grok-MCP.git && cd Grok-MCP && uv venv && uv sync{
"mcpServers": {
"grok-mcp": {
"command": "uv",
"args": [
"--directory",
"/path/to/Grok-MCP",
"run",
"python",
"main.py"
],
"env": {
"XAI_API_KEY": "your_api_key_here"
}
}
}
}Setup steps
- 1Open Cursor → Settings → MCP → Add new MCP server (or edit ~/.cursor/mcp.json directly).
- 2Paste the Grok-MCP config below into the "mcpServers" object.
- 3Fill in placeholder secrets, then save.
- 4Cursor reloads MCP servers automatically — check Settings → MCP for a green status dot.
- 5Ask Cursor to use one of Grok-MCP's tools to confirm it's connected.
Before you start
- Python 3.11 or higher
- xAI API key (from https://console.x.ai)
- Astral UV package manager
What Grok-MCP can do in Cursor
chatStandard chat completion with optional persistent history and multi-agent support.
chat_with_visionAnalyze local or remote images with a Grok vision model.
chat_with_filesChat grounded on previously uploaded documents.
stateful_chatContinue a server-side stored conversation via response_id.
retrieve_stateful_responseFetch a stored response by ID.
delete_stateful_responseDelete a stored response by ID.
web_searchAutonomous web research with domain filters and citations.
x_searchAutonomous search over X (Twitter) posts, with handle and date filters.
Security
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 + Cursor FAQ
Where is the Cursor config file?
Cursor reads MCP servers from ~/.cursor/mcp.json. Paste the Grok-MCP config there under the "mcpServers" key and restart the client.
Is Grok-MCP safe to use with Cursor?
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).
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