grok-video-mcp
MCP server that gives AI agents xAI Grok video generation — submit a prompt, poll the render, download the clip. Works with OpenCode, Claude Desktop, Cursor, VS Code, and any MCP client.
README
grok-media-mcp
MCP server that gives AI agents xAI Grok media generation — images and video. Submit a prompt, get a real file back. Works with OpenCode, Claude Desktop, Cursor, VS Code, and any MCP client.
Companion to vision-mcp: one agent can generate a clip or image and verify it — a full media loop.
Why
Text-based agents can't generate media. grok-media-mcp exposes xAI's
grok-imagine-video and grok-imagine-image models as plain MCP tools so any
agent can produce real images and video clips from a prompt — no shell
scripts, no manual API calls, no hand-rolled polling loops.
Tools
| Tool | What it does |
|---|---|
generate_video(prompt, duration?, aspectRatio?, resolution?) |
Submit a generation → returns requestId |
get_generation(requestId) |
Poll: PENDING → COMPLETED / FAILED (with progress) |
get_video(requestId, outDir?) |
Download the finished clip to disk |
generate_and_wait(prompt, ...) |
Submit + poll + download in one call (agent-friendly) |
generate_image(prompt, model?, n?, size?, outDir?) |
Generate an image — synchronous, returns the saved file path (~10-30s, ~$0.06) |
Requirements
- Node.js ≥ 18
- An xAI API key — https://console.x.ai (or docs.x.ai)
Install
npx from GitHub (recommended)
npx -y github:pongsakornp/grok-media-mcp
npx clones the repo, installs deps, auto-builds via the
preparescript, and runs the server over stdio.
From source
git clone https://github.com/pongsakornp/grok-media-mcp.git
cd grok-media-mcp
npm install
npm run build
Usage
OpenCode (opencode.jsonc)
{
"mcp": {
"grok-media-mcp": {
"type": "local",
"command": ["npx", "-y", "github:pongsakornp/grok-media-mcp"],
"environment": {
"XAI_API_KEY": "xai-..."
},
"enabled": true
}
}
}
Claude Desktop (claude_desktop_config.json)
{
"mcpServers": {
"grok-media-mcp": {
"command": "npx",
"args": ["-y", "github:pongsakornp/grok-media-mcp"],
"env": {
"XAI_API_KEY": "xai-..."
}
}
}
}
VS Code / Cursor (.vscode/mcp.json)
{
"servers": {
"grok-media-mcp": {
"type": "stdio",
"command": "npx",
"args": ["-y", "github:pongsakornp/grok-media-mcp"],
"environment": {
"XAI_API_KEY": "xai-..."
}
}
}
}
Keys live in the MCP config — no shell profile edits needed.
Configuration
| Env var | Default | Description |
|---|---|---|
XAI_API_KEY |
— | required — xAI API key |
GROK_VIDEO_MODEL |
grok-imagine-video |
Model (grok-imagine-video-1.5 = 1080p) |
GROK_IMAGE_MODEL |
grok-imagine-image-2.0 |
Image model (grok-imagine-image-quality = higher quality) |
GROK_OUTPUT_DIR |
~/.grok-media-mcp/output |
Where media is saved |
GROK_VIDEO_TIMEOUT_MS |
900000 (15 min) |
Max wait for a generation |
GROK_VIDEO_POLL_BASE_MS |
5000 |
Initial poll interval |
GROK_VIDEO_POLL_MAX_MS |
30000 |
Max poll interval (×1.5 backoff) |
How it works
Video — xAI's video API is async:
POST /v1/videos/generations → { request_id }
GET /v1/videos/{request_id} → poll until status: "done"
GET video.url → mp4 bytes
generate_and_wait encapsulates submit → poll (5s→30s backoff, progress
reported) → download → save, returning the file path.
Images — synchronous, one call:
POST /v1/images/generations → { data: [{ url, mime_type }], usage }
GET image.url → jpeg/png bytes
generate_image encapsulates generate → download → save in one call.
(Verified live: 1248×832 output, ~30s, ~$0.06/image.)
Pricing: video roughly $0.005 per second (~$0.04 for an 8s clip), images ~$0.06 each — an order of magnitude cheaper than Google Veo Lite ($0.05–0.08/s).
Development
npm run build # TypeScript → dist/
npm test # 28 tests (vitest)
npm run typecheck # tsc --noEmit
Test coverage: config parsing, video + image request/response mapping (mocked fetch), polling backoff/timeout/FAILED handling, and the full MCP stdio protocol.
License
MIT — see LICENSE.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。