Grok Image MCP
Click on "Install 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 Image MCPGenerate a 16:9 image of a sunset over mountains"
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 Image MCP
An MCP (Model Context Protocol) server for image generation and editing using the Grok image model from xAI.
Note: This package was previously published as
grok2-image-mcp-server. That package is now deprecated — please usegrok-image-mcpinstead.
Features
Image Generation — Generate images from text prompts with configurable aspect ratio, resolution, and batch count
Image Editing — Edit existing images with natural language instructions, supporting 1–3 source images
Local File Support — Provide local image paths for editing; the server reads and encodes them automatically
Image Proxy — Optional proxy domain for
imgen.x.aito handle network restrictionsHTTP Proxy — Optional network proxy for API requests
Related MCP server: image-studio-mcp
Installation
Using npx (recommended)
{
"mcpServers": {
"grok_image": {
"command": "npx",
"args": ["grok-image-mcp"],
"env": {
"XAIAPI_KEY": "your-xai-api-key"
}
}
}
}Tools
generate_image
Generate images from text prompts.
Parameter | Type | Required | Description |
| string | ✅ | Text description of the image to generate |
| number | Number of images (1–10, default 1) | |
| string | Aspect ratio ( | |
| string | Resolution ( |
edit_image
Edit existing images using a text prompt.
Parameter | Type | Required | Description |
| string | ✅ | Text description of the desired edits |
| string[] | ✅ | 1–3 source images: URLs, base64 data URIs, or local file paths |
| number | Number of output images (1–10, default 1) | |
| string | Override output aspect ratio (default: follows first input image) | |
| string | Resolution ( |
Environment Variables
Variable | Required | Description |
| ✅ | xAI API key |
| API base URL (default: | |
| Proxy domain to replace | |
| HTTP/HTTPS proxy for API requests (e.g. |
Proxy Examples
API proxy:
XAIAPI_BASE_URL=https://api-proxy.me/xai/v1Image proxy:
IMAGE_PROXY_DOMAIN=https://image.proxy.workers.devNetwork proxy:
HTTP_PROXY=http://127.0.0.1:7890Using Cloudflare Workers to Proxy Image URLs
If image URLs from imgen.x.ai are inaccessible, deploy a Cloudflare Worker as a reverse proxy and set IMAGE_PROXY_DOMAIN to your custom domain:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const TARGET_DOMAIN = 'imgen.x.ai'
async function handleRequest(request) {
const url = new URL(request.url)
const targetUrl = `https://${TARGET_DOMAIN}${url.pathname}${url.search}`
const init = {
method: request.method,
headers: request.headers,
body: request.method === 'GET' || request.method === 'HEAD' ? undefined : request.body,
redirect: 'follow'
}
const response = await fetch(targetUrl, init)
const newHeaders = new Headers(response.headers)
newHeaders.set('Access-Control-Allow-Origin', '*')
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders
})
}License
MIT
注意: 此包的前身是
grok2-image-mcp-server,该包已弃用,请使用grok-image-mcp。
功能
图像生成 — 通过文本提示生成图像,可配置宽高比、分辨率和批量数量
图像编辑 — 使用自然语言编辑现有图像,支持 1–3 张源图
本地文件支持 — 可提供本地图片路径进行编辑,服务端自动读取并编码
图片代理 — 可选代理域名替换
imgen.x.ai,解决网络访问问题网络代理 — 支持 HTTP/HTTPS 代理
安装
使用 npx(推荐)
{
"mcpServers": {
"grok_image": {
"command": "npx",
"args": ["grok-image-mcp"],
"env": {
"XAIAPI_KEY": "你的 xAI API 密钥"
}
}
}
}工具
generate_image
通过文本提示生成图像。
参数 | 类型 | 必填 | 说明 |
| string | ✅ | 描述要生成的图像内容 |
| number | 生成数量(1–10,默认 1) | |
| string | 宽高比( | |
| string | 分辨率( |
edit_image
使用文本提示编辑现有图像。
参数 | 类型 | 必填 | 说明 |
| string | ✅ | 描述所需的编辑内容 |
| string[] | ✅ | 1–3 张源图:URL、base64 data URI 或本地文件路径 |
| number | 输出图像数量(1–10,默认 1) | |
| string | 覆盖输出宽高比(默认跟随第一张输入图) | |
| string | 分辨率( |
环境变量
变量 | 必填 | 说明 |
| ✅ | xAI API 密钥 |
| API 基础地址(默认 | |
| 图片代理域名,替换返回 URL 中的 | |
| HTTP/HTTPS 网络代理地址(如 |
代理示例
API 代理:
XAIAPI_BASE_URL=https://api-proxy.me/xai/v1图片代理:
IMAGE_PROXY_DOMAIN=https://image.proxy.workers.dev网络代理:
HTTP_PROXY=http://127.0.0.1:7890使用 Cloudflare Workers 代理图片 URL
如果 imgen.x.ai 的图片无法访问,可部署 Cloudflare Worker 反向代理,然后将 IMAGE_PROXY_DOMAIN 设为你的自定义域名:
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
const TARGET_DOMAIN = 'imgen.x.ai'
async function handleRequest(request) {
const url = new URL(request.url)
const targetUrl = `https://${TARGET_DOMAIN}${url.pathname}${url.search}`
const init = {
method: request.method,
headers: request.headers,
body: request.method === 'GET' || request.method === 'HEAD' ? undefined : request.body,
redirect: 'follow'
}
const response = await fetch(targetUrl, init)
const newHeaders = new Headers(response.headers)
newHeaders.set('Access-Control-Allow-Origin', '*')
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders
})
}许可证
MIT
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/fl0w1nd/grok-image-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server