grok-mcp
Click on "Deploy 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-mcp Generate an image of a futuristic city skyline at sunset with flying cars"
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
把 Grok2API 上的 Grok Console 画图 / 改图 / 视频 / 对话搜索能力,同时提供:
MCP Server — 给 Claude Code / Codex / Cursor 等 Agent 调用
Web Console — 风格对齐 grok2api 管理端的创作台(Chat / Image / Video)
能力边界(Console)
默认模型全部来自 Grok Console:
模型 | 类型 | 网关接口能力 |
| 对话 | Chat Completions、Responses、Messages |
| 对话 | Chat Completions、Responses、Messages |
| 对话 | Chat Completions、Responses、Messages |
| 对话 | Chat Completions、Responses、Messages |
| 对话 | Chat Completions、Responses、Messages |
| 对话 | Chat Completions、Responses、Messages |
| 图像 + 图像编辑 | Images Generations、Images Edits |
| 图像 + 图像编辑 | Images Generations、Images Edits |
| 视频 | Videos |
能力 | Grok2API 路径 | 默认模型 |
文生图 |
|
|
图编辑 |
| 同上(无单独 edit 模型 id) |
视频 |
|
|
搜索 / 对话 |
| 搜索 |
Related MCP server: Grok Imagine Video MCP Server
架构
Claude Code / Codex / Cursor
│ MCP HTTP (/mcp)
▼
grok-mcp (本仓库)
│ OpenAI-compatible HTTPS
▼
Grok2API → Grok Console网页控制台是另一条线:浏览器 → FastAPI → Grok2API。
仓库结构
grok-mcp/
├── src/grok_mcp/ # MCP server + Grok2API client
├── backend/app/ # FastAPI:Web API + /mcp 挂载 + 静态前端
├── frontend/ # React + Vite + Tailwind 控制台
├── examples/ # Claude Code / Codex 接入样例
├── scripts/ # 本地开发脚本
└── tests/快速开始
1. 配置
cp .env.example .env至少填写:
GROK2API_BASE_URL=http://127.0.0.1:8000
GROK2API_API_KEY=g2a_xxx_xxx
MCP_TOKEN=change-me-mcp-token
PUBLIC_BASE_URL=http://127.0.0.1:8790
ADMIN_PASSWORD=change-me
SESSION_SECRET=change-me-session-secret2. 本地开发
uv sync --extra dev
# 终端 1 — API / MCP :8790
./scripts/dev-backend.sh
# 终端 2 — 前端 :5173
./scripts/dev-frontend.sh浏览器打开 http://127.0.0.1:5173。
3. Docker
cd frontend && pnpm install && pnpm build && cd ..
docker compose up -d --build服务默认:
Web:
http://127.0.0.1:8790MCP:
http://127.0.0.1:8790/mcp登录:
ADMIN_USERNAME/ADMIN_PASSWORD
MCP 接入
Claude Code / CC Switch
推荐连接已部署的 grok-mcp HTTP 端点(见 examples/mcp.claude.json):
{
"mcpServers": {
"grok": {
"type": "http",
"url": "http://127.0.0.1:8790/mcp",
"headers": {
"Authorization": "Bearer change-me-mcp-token"
}
}
}
}写入 ~/.claude.json 的 mcpServers,或项目 .mcp.json,然后重开会话。
Codex
[features]
rmcp_client = true
[mcp_servers.grok]
url = "http://127.0.0.1:8790/mcp"
bearer_token_env_var = "MCP_BEARER_TOKEN"
startup_timeout_sec = 30
tool_timeout_sec = 600export MCP_BEARER_TOKEN="change-me-mcp-token"MCP Tools
Tool | 作用 |
| 静态 Console 模型表 |
| 目录 + 网关模型 |
| 画图 / 改图(下载到本地并返回可展示内容) |
| 视频任务(完成后提供 |
| 搜索 / 对话 |
Web 页面
路由 | 说明 |
| 概览 |
| 创作台:对话 / 图片 / 视频 |
| 本地图片历史 |
| 本地视频任务历史 |
| MCP 接入向导 + 配置展示 |
设计说明
不重新实现 Grok 上游协议;只做 Grok2API 适配层。
Agent 配置里应出现本服务的
/mcp,不要把g2a_key 写进 Claude/Codex。图片会物化到
GROK_MCP_MEDIA_DIR,并通过 MCPImageContent//media提供给客户端。上游图库清理优先使用 Grok2API 自带的媒体自动清理;本仓库默认不强制删除上游。
开发
uv sync --extra dev
uv run pytest
cd frontend
pnpm install
pnpm exec tsc -p tsconfig.app.json --noEmit
pnpm buildLicense
MIT
Available Tools
9 toolschatB
Console chat completion via Grok2API POST /v1/chat/completions. Default model: grok-4.20-0309-non-reasoning. Optional enable_web_search. Also supports grok-4.3 / grok-4.5 / grok-4.20-0309-reasoning / grok-4.20-multi-agent-0309 / grok-build-0.1.
Inputs: prompt (required), model, system_prompt, enable_web_search. Returns: result
edit_imageA
Edit existing image(s) via Grok2API Console models, download results locally, return MCP Image content, and optionally delete remote gallery assets after success. Provide 1-8 publicly reachable image URLs.
Inputs: prompt (required), image_urls (required), size, model, +4 more.
generate_imageA
Generate images via Grok2API Console models, download them to the grok-mcp host, and return MCP Image content for inline display. Default model: grok-imagine-image; quality=true uses grok-imagine-image-quality. After a successful local download, remote gallery assets are deleted when GROK2API_ADMIN_* credentials are set. aspect_ratio examples: 1:1, 16:9, 9:16.
Inputs: prompt (required), n, model, quality, +3 more.
generate_videoA
Create an asynchronous Console video job via Grok2API (model grok-imagine-video). Returns request_id immediately. Then call wait_video to download the finished file to grok-mcp, get a public /media URL, and optionally delete the remote gallery job. duration 1-15s (default 8). aspect_ratio: 1:1|16:9|9:16|... resolution: 480p|720p|1080p.
Inputs: model, prompt, duration, image_urls, +2 more. Returns: result
get_video_statusA
Poll a video job once. status is pending|done|failed. If done and materialize=true, download to local storage and return public_url.
Inputs: request_id (required), materialize, delete_remote. Returns: result
list_console_catalogA
Return the static Grok Console model catalog used by this MCP (chat / image / video), without calling the gateway.
Inputs: no named parameters. Returns: result
list_modelsA
List Grok Console models targeted by this MCP, plus whatever the connected Grok2API gateway currently exposes via GET /v1/models.
Inputs: no named parameters. Returns: result
wait_videoA
Block until a video job finishes, then download the mp4 to the grok-mcp host and return public_url (http://host/media/...). After successful download, deletes the remote Grok2API video job when admin credentials are configured. timeout defaults to GROK2API_VIDEO_POLL_TIMEOUT (600s).
Inputs: request_id (required), timeout, materialize, delete_remote, +1 more. Returns: result
web_searchA
Search / research through Grok2API chat completions with hosted web_search enabled. Default Console model: grok-4.3. Other Console chat models also work: grok-4.5, grok-4.20-0309-*, grok-4.20-multi-agent-0309, grok-build-0.1.
Inputs: query (required), model, system_prompt. Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 9 tools
Most tools target distinct actions (generate, edit, chat, search, video lifecycle). list_models and list_console_catalog overlap slightly but are differentiated by static vs dynamic sources, and get_video_status vs wait_video serve separate polling vs blocking needs.
The majority follow a consistent snake_case verb_noun pattern (list_models, generate_image, wait_video). 'chat' and 'web_search' are minor deviations but remain clear and predictable.
9 tools are well-scoped for the server's purpose of exposing Grok chat, web search, image, and video capabilities. Each tool contributes a distinct function without unnecessary bloat.
The tool surface covers the full lifecycle for its domain: chat, web search, image generation/editing, and video creation (submit, poll, wait/download). No obvious missing operations are evident.
Related MCP Connectors
MCP server for Grok Imagine AI video generation
Use AI models for chat, image, and video generation from Claude Code and other MCP hosts.
- mcp-soraDeprecatedio.github.AceDataCloud
MCP server for OpenAI Sora AI video generation
MCP server for Qwen Image 3 AI image generation
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceMCP server that bridges ChatGPT Plus/Pro to Claude Code, enabling chat, deep research, and image generation via your own account.52 PyPI51MIT
- AlicenseAqualityCmaintenanceMCP server for generating, editing, and batch processing videos using xAI's Grok Imagine Video API, with support for text-to-video, image-to-video, and video editing via natural language prompts.469 npm1MIT
- AlicenseNot gradedqualityDmaintenanceA single-file MCP server that enhances Claude Desktop with real-time web and X search, multi-tool agent, and image/video generation via xAI's Grok.MIT
- AlicenseAqualityBmaintenanceAn MCP server for Grok (xAI) that enables chat, reasoning, vision, and video generation using the AceDataCloud API.82MIT