MCP server for xAI's Grok API with agentic tool calling, image and video generation, vision, and file support. - Agentic Tool Calling: Web search, X search, and code execution with multi-step reasoning - Multiple Grok Models: Access to Grok-4.1-Fast-Reasoning, Grok-4.1-Fast-Non-Reasoning, Grok-4-Fast, and more - Image and Video Generation: Create images and videos using Grok Imagine - Vision Capab
Add this skill
npx mdskills install merterbak/grok-mcpComprehensive MCP server with extensive Grok API tooling, well-documented parameters, and clear setup instructions
1# Grok-MCP23MCP server for xAI's Grok API with agentic tool calling, image and video generation, vision, and file support.456<a href="https://glama.ai/mcp/servers/@merterbak/Grok-MCP">7 <img width="380" height="200" src="https://glama.ai/mcp/servers/@merterbak/Grok-MCP/badge" />8</a>910## Features1112- **Agentic Tool Calling**: Web search, X search, and code execution with multi-step reasoning13- **Multiple Grok Models**: Access to Grok-4.1-Fast-Reasoning, Grok-4.1-Fast-Non-Reasoning, Grok-4-Fast, and more14- **Image and Video Generation**: Create images and videos using Grok Imagine15- **Vision Capabilities**: Analyze images with Grok's vision models16- **Files API**: Upload, manage, and chat with documents17- **Stateful Conversations**: Maintain conversation context as id across multiple requests1819## Prerequisites2021- Python 3.11 or higher22- xAI API key ([Get one here](https://console.x.ai))23- [Astral UV](https://docs.astral.sh/uv/getting-started/installation/)2425## Installation26271. Clone the repository:28```bash29git clone https://github.com/merterbak/Grok-MCP.git30cd Grok-MCP31```32332. Create a venv environment:34```bash35uv venv36source .venv/bin/activate # macOS/Linux or .venv\Scripts\activate on Windows37```38393. Install dependencies:4041```bash42uv sync43```444546## Configuration4748### Claude Desktop Integration4950Add this to your Claude Desktop configuration file:5152```json53{54 "mcpServers": {55 "grok": {56 "command": "uv",57 "args": [58 "--directory",59 "/path/to/Grok-MCP",60 "run",61 "python",62 "main.py"63 ],64 "env": {65 "XAI_API_KEY": "your_api_key_here"66 }67 }68 }69}70```7172### Filesystem MCP (Optional)7374Claude Desktop can't send uploaded images in the chat to an MCP tool.75The easiest way to give access to files directly from your computer is official Filesystem MCP server.76After 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.7778```json79{80 "mcpServers": {81 "filesystem": {82 "command": "npx",83 "args": [84 "-y",85 "@modelcontextprotocol/server-filesystem",86 "/Users/<your-username>/Desktop",87 "/Users/<your-username>/Downloads"88 ]89 }90 }91}9293```9495---9697For stdio:9899```bash100uv run python main.py101```102Docker:103104```bash105docker compose up --build106```107Mcp Inspector:108109```bash110mcp dev main.py111```112113114# Available Tools115116Note: For using images and files, you must provide paths to chat. See [Filesystem MCP (Optional)](#filesystem-mcp-optional) for setup.117118### `list_models`119List all available Grok models.120121---122123### `chat`124Standard chat completion.125126| Parameter | Type | Default | Description |127|-----------|------|---------|-------------|128| `prompt` | str | required | Your message |129| `model` | str | grok-4 | Model to use |130| `system_prompt` | str | None | System instruction |131| `store_messages` | bool | False | Enable conversation history |132133---134135### `chat_with_vision`136Analyze images with text.137138| Parameter | Type | Default | Description |139|-----------|------|---------|-------------|140| `prompt` | str | required | Question about the image |141| `model` | str | grok-4 | Vision model |142| `image_paths` | List[str] | None | Local image file paths |143| `image_urls` | List[str] | None | Image URLs |144| `detail` | str | auto | auto, low, or high |145146**Returns:** Content + usage with `prompt_image_tokens`147148---149150### `generate_image`151Create or edit images from text.152153| Parameter | Type | Default | Description |154|-----------|------|---------|-------------|155| `prompt` | str | required | Image description or edit instruction |156| `model` | str | grok-imagine-image | Image model |157| `image_path` | str | None | Local image path to edit |158| `image_url` | str | None | Image URL to edit |159| `n` | int | 1 | Number of images (1-10) |160| `aspect_ratio` | str | None | like "16:9", "1:1" |161162---163164### `generate_video`165Create or edit videos from text, images, or existing videos.166167| Parameter | Type | Default | Description |168|-----------|------|---------|-------------|169| `prompt` | str | required | Video description or edit instruction |170| `model` | str | grok-imagine-video | Video model |171| `image_path` | str | None | Local image path to animate |172| `image_url` | str | None | Image URL to animate |173| `video_path` | str | None | Local video path to edit (max 20MB) |174| `video_url` | str | None | Video URL to edit |175| `duration` | int | None | Duration in seconds (1-15) |176| `aspect_ratio` | str | None | like "16:9", "4:3" |177| `resolution` | str | None | "720p" or "480p" |178179---180181### `web_search`182Agentic web search with autonomous research.183184| Parameter | Type | Default | Description |185|-----------|------|---------|-------------|186| `prompt` | str | required | Search query |187| `model` | str | grok-4-1-fast | Model |188| `allowed_domains` | List[str] | None | Restrict to domains (max 5) |189| `excluded_domains` | List[str] | None | Exclude domains (max 5) |190| `enable_image_understanding` | bool | False | Analyze images in results |191| `include_inline_citations` | bool | False | Embed citations in text |192| `max_turns` | int | None | Limit reasoning turns |193194**Returns:** Content, citations, tool_calls, usage195196---197198### `x_search`199Agentic X (Twitter) search.200201| Parameter | Type | Default | Description |202|-----------|------|---------|-------------|203| `prompt` | str | required | Search query |204| `model` | str | grok-4-1-fast | Model |205| `allowed_x_handles` | List[str] | None | Only these handles (max 10) |206| `excluded_x_handles` | List[str] | None | Exclude handles (max 10) |207| `from_date` | str | None | Start date (DD-MM-YYYY) |208| `to_date` | str | None | End date (DD-MM-YYYY) |209| `enable_image_understanding` | bool | False | Analyze images |210| `enable_video_understanding` | bool | False | Analyze videos |211| `include_inline_citations` | bool | False | Embed citations |212| `max_turns` | int | None | Limit turns |213214**Returns:** Content, citations, tool_calls, usage215216---217218### `grok_agent`219Unified agent combining files, images, and all agentic tools (web search, X search, code execution).220221| Parameter | Type | Default | Description |222|-----------|------|---------|-------------|223| `prompt` | str | required | Your query |224| `model` | str | grok-4-1-fast | Model |225| `file_ids` | List[str] | None | Uploaded file IDs to search |226| `image_urls` | List[str] | None | Image URLs to analyze |227| `image_paths` | List[str] | None | Local image paths |228| `use_web_search` | bool | False | Enable web search |229| `use_x_search` | bool | False | Enable X search |230| `use_code_execution` | bool | False | Enable code execution |231| + all web_search and x_search params | | | |232233**Returns:** Content, citations, tool_calls, code_outputs, uploaded_file_ids, usage234235---236237### `code_executor`238Execute Python code for calculations and analysis.239240| Parameter | Type | Default | Description |241|-----------|------|---------|-------------|242| `prompt` | str | required | Task description |243| `model` | str | grok-4-1-fast | Model |244| `max_turns` | int | None | Limit turns |245246**Returns:** Content, tool_calls, code_outputs, usage247248---249250### `stateful_chat`251Maintain conversation state across requests.252253| Parameter | Type | Default | Description |254|-----------|------|---------|-------------|255| `prompt` | str | required | Your message |256| `model` | str | grok-4 | Model |257| `response_id` | str | None | Previous response ID to continue a conversation |258| `system_prompt` | str | None | System instruction |259260**Returns:** Content, response_id, usage261262---263264### `retrieve_stateful_response`265Retrieve a stored conversation.266267---268269### `delete_stateful_response`270Delete a stored conversation.271272273### `upload_file`274Upload a document (max 48 MB).275276| Parameter | Type | Default | Description |277|-----------|------|---------|-------------|278| `file_path` | str | required | Local file path |279280**Supported formats:** .txt, .md, .py, .js, .csv, .json, .pdf, and more281282---283284### `list_files`285List uploaded files with sorting.286287| Parameter | Type | Default | Description |288|-----------|------|---------|-------------|289| `limit` | int | 100 | Max files to return |290| `order` | str | desc | asc or desc |291| `sort_by` | str | created_at | created_at, filename, or size |292293---294295### `get_file`296Get file metadata by ID.297298---299300### `get_file_content`301Download file content by ID.302303| Parameter | Type | Default | Description |304|-----------|------|---------|-------------|305| `file_id` | str | required | File ID |306| `max_bytes` | int | 500000 | Max bytes to return |307308---309310### `delete_file`311Delete a file by ID.312313---314315### `chat_with_files`316Chat with uploaded documents using agentic document search.317318| Parameter | Type | Default | Description |319|-----------|------|---------|-------------|320| `prompt` | str | required | Question about docs |321| `model` | str | grok-4-1-fast | Model |322| `file_ids` | List[str] | None | File IDs to search |323| `system_prompt` | str | None | System instruction |324325Returns: Content, citations, usage326327328329---330331332## License333334This project is open source and available under the MIT License.335
Full transparency — inspect the skill content before installing.