GrokSAFE
MCP server for xAI’s Grok API with Web/X search, vision, image/video generation and file support
Overview
From the repository's own README, as read at the audited commit. Badges and raw HTML are left out.
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, code execution, and image generation with multi-step reasoning
- Multiple Grok Models: Access to latest models such as grok-4.6, grok-4.5, 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:
2fddd3689c06OBSERVED · 2026-10-08Connect
Built from this server's own package name, version and transport as found in its source — not copied from anyone's documentation, so it cannot drift against a page we do not control. Replace the environment placeholders with a token scoped to the least it needs.
claude mcp add mcp-grok --env XAI_API_KEY=${XAI_API_KEY} -- uvx mcp-grok{
"mcpServers": {
"mcp-grok": {
"command": "uvx",
"args": [
"mcp-grok"
],
"env": {
"XAI_API_KEY": "${XAI_API_KEY}"
}
}
}
}Exposed tools (22)
14 read · 5 write · 3 destructive. Blast radius: 3 tools can delete or overwrite — an agent that can be talked into calling a tool can be talked into calling this one.
| Tool | Risk | Description |
|---|---|---|
chat | write | Send a text prompt to a Grok model and return its reply. |
chat_with_files | read | Chat with Grok using one or more previously uploaded files as context. |
chat_with_vision | read | Analyze one or more images with a Grok vision model. |
clear_chat_history | destructive | Delete the local history file for a chat session. |
code_executor | write | Solve a task by letting Grok run Python in a stateful sandbox. |
delete_file | destructive | Permanently delete an uploaded file from xAI. |
delete_stateful_response | destructive | Delete a stored chat completion from xAI |
extend_video | read | Extend an existing video with a follow-up prompt. |
generate_image | write | Generate new images or edit existing ones with Grok Imagine. |
generate_video | write | Generate or edit videos with Grok Imagine. |
get_chat_history | read | Return the full message history for a local chat session. |
get_file | read | Fetch metadata for a single uploaded file. |
get_file_content | read | Download the raw content of an uploaded file as text. |
grok_agent | read | All-in-one Grok agent combining files, vision, web/X search, code execution, and image generation. |
list_chat_sessions | read | List all local chat sessions stored under `chats/`. |
list_files | read | List files previously uploaded to xAI. |
list_models | read | List all Grok language and image models with live pricing from the xAI API. |
retrieve_stateful_response | read | Fetch a stored chat completion from xAI by its response ID. |
stateful_chat | read | Continue a server-side stored conversation using xAI |
upload_file | write | Upload a local file to xAI so it can be attached to later chats. |
web_search | read | Answer a query using agentic real-time web search. |
x_search | read | Answer a query using agentic search over X (Twitter). |
Trust audit
SAFEgrade B · trust 89/100 Nothing in the source contradicts what it says it does. Grade A is reserved for packages that have also passed the behavioural sandbox.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | PASS |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | WARN |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- declared (3 observation(s))
- Network
- declared (1 observation(s))
- Shell
- none-observed
- Dependencies
- pinned
- Secrets in source
- none-found
Findings (1)
clear_chat_history, delete_file, delete_stateful_response
Gates applied: no_behavioural_pass.
2fddd3689c06full audit observations/trust-audit/mcp-server/merterbak__grok-3.json · Report an issue / request a re-scanAudit history
Every audit this server has had. A grade with a past is a grade somebody is still checking.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-08 | 2fddd3689c06 | SAFE | B | 89 | first audit |
Questions
What is the Grok MCP server?
MCP server for xAI’s Grok API with Web/X search, vision, image/video generation and file support
What tools does Grok expose?
22 in total: 14 read-only, 5 that write, and 3 that can delete or overwrite (clear_chat_history, delete_file, delete_stateful_response). Every one is listed on this page with its risk.
Is Grok safe to connect to an agent?
The audit found nothing in the source that contradicts what it says it does, and graded it B (89/100). Grade A is held back for packages that have also passed a sandboxed behavioural run, which is why a clean server reads B. Separately from the audit: 3 of its tools can destroy data, so scope the token you give it to what you actually need.
What credentials does Grok need?
It reads XAI_API_KEY from the environment. Give it a token scoped to the least it needs — an agent that can be talked into calling a tool can be talked into calling it with your credentials.
How does Grok run?
It speaks stdio, so it runs as a local process your client starts. It is published on PyPI as mcp-grok.
How current is this page?
The grade is for one exact copy of the source (2fddd3689c06), read on 2026-10-08. The repository is watched and re-audited when it changes.