Grok Image MCP server

Grok Image MCP server

grok2-image-generator•byfl0w1nd

An MCP server that generates and edits images through the xAI image API, exposing generate_image and edit_image tools over stdio.

License: MIT•Runtime: Awaiting documentation review•Category: media design

WHAT IT DOES

  • •Provides generate_image and edit_image tools that accept prompts, model choice, output count, aspect ratio, resolution, quality and response format.
  • •Edits images from public URLs, base64 data URIs, local paths or stored file IDs, with support for PNG, JPEG and WebP local files.
  • •Can return temporary image URLs or inline MCP image content blocks via b64_json.
  • •Persists generated images to the xAI Files API with configurable filename, expiry and optional public link, then reuses file IDs in later edits.

BEST FOR

  • •Generating new images from text prompts inside an MCP client.
  • •Editing existing local or hosted images with text instructions.
  • •Saving generated images and reusing them in follow-up edits within the same workflow.

ABOUT GROK2-IMAGE-GENERATOR

Grok Image MCP server is cataloged as an MCP server attributed to fl0w1nd. An MCP server that generates and edits images through the xAI image API, exposing generate_image and edit_image tools over stdio. It is categorized under media design. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Grok Image MCP server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which image models can the server use?

It supports grok-imagine-image, the default, and grok-imagine-image-2.0, selectable per call or via the XAI_IMAGE_MODEL variable.

How many images can be supplied as sources for an edit?

grok-imagine-image accepts 1–3 source images per edit, while grok-imagine-image-2.0 accepts 1–5.

Can generated images be returned inline instead of as links?

Yes; setting response_format to b64_json returns MCP image content blocks marked inline.

上游原版 README

在 GitHub 查看同一版本原文

README.md · f0ef32c63f27 · 采集于 2026-11-13 08:42:59 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Grok Image MCP

English | 中文

An MCP server for generating and editing images with the xAI image API. Supports model and quality selection, local images, stored files, and inline image results over stdio.

Requires Node.js 22.19+ and an xAI API key.

Quick start

Add this to your MCP client's configuration:

{
  "mcpServers": {
    "grok_image": {
      "command": "npx",
      "args": ["-y", "grok-image-mcp"],
      "env": {
        "XAI_API_KEY": "your-xai-api-key"
      }
    }
  }
}

The server exposes generate_image and edit_image. Example generate_image arguments:

{
  "prompt": "A watercolor illustration of a quiet mountain lake",
  "model": "grok-imagine-image-2.0",
  "quality": "low",
  "aspect_ratio": "16:9"
}

Models and quality

Capabilitygrok-imagine-imagegrok-imagine-image-2.0
Default modelYesSelect per call or set XAI_IMAGE_MODEL
Source images per edit1–31–5
Resolution1k, 2k1k, 2k
Quality parameter—low, medium, auto
Additional aspect ratios—21:9, 5:2

The model argument overrides XAI_IMAGE_MODEL. The default is grok-imagine-image.

On 2.0, quality defaults to auto: low for generation and medium for editing. See xAI pricing for costs.

Tools

Both tools accept these parameters:

ParameterTypeDescription
promptstring, requiredImage description or editing instructions
modelstringOne of the two models above
nintegerOutput count, 1–10; default 1
aspect_ratiostringGeneration defaults to auto; editing follows the first input
resolutionstring1k or 2k; default 1k
qualitystring2.0: low, medium, auto
response_formatstringurl (default) or b64_json for inline MCP image content
storage_optionsobjectSave generated images to the Files API

Aspect ratios: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, 19.5:9, 9:19.5, 20:9, 9:20, auto; 2.0 additionally supports 21:9 and 5:2.

Editing

For edit_image, supply one of these source lists:

  • image_urls: ordered array of public URLs, base64 data URIs, or local paths.
  • images: ordered array of { "url": "..." } or { "file_id": "..." } objects. url also accepts data URIs and local paths.
{
  "prompt": "Replace the background with a snowy forest",
  "image_urls": ["/absolute/path/to/photo.png"]
}

Local files support PNG, JPEG and WebP. Relative paths resolve from the server's working directory.

Results

structuredContent.images contains image URLs, revised prompts, MIME types and stored-file metadata. Model, quality and usage are included when returned by xAI.

  • url: temporary image links, also returned as Markdown. Use storage_options to save images.
  • b64_json: MCP image content blocks, with inline: true in the corresponding structured entry.

Save images and reuse them

Add storage_options to either tool to persist output in the xAI Files API:

{
  "prompt": "A small cabin in a pine forest",
  "model": "grok-imagine-image-2.0",
  "quality": "low",
  "storage_options": {
    "filename": "cabin.jpg",
    "expires_after": 86400
  }
}

This saves the image privately for one day. Use structuredContent.images[0].file_output.file_id in a subsequent edit:

{
  "prompt": "Change the season to winter",
  "model": "grok-imagine-image-2.0",
  "quality": "low",
  "images": [{ "file_id": "file-id-from-the-previous-result" }]
}
Storage optionDescription
filenameRequired filename for the stored image
expires_afterFile lifetime in seconds, 3600–2592000; default: permanent
public_urltrue creates a shareable public link; default: private
public_url.expires_afterUse public_url: { "expires_after": 86400 } to set a link lifetime

See xAI storage documentation for details.

Configuration and networking

Environment variableDescription
XAI_API_KEYxAI API key; takes precedence over XAIAPI_KEY
XAIAPI_KEYAlternative API-key variable
XAI_IMAGE_MODELDefault model; grok-imagine-image when omitted
XAIAPI_BASE_URLAPI base URL; default https://api.x.ai/v1
XAI_TIMEOUT_MSRequest timeout in milliseconds; default 180000
HTTPS_PROXYNetwork proxy for API requests; takes precedence over HTTP_PROXY
HTTP_PROXYNetwork proxy, e.g. http://127.0.0.1:7890
IMAGE_PROXY_DOMAINReverse proxy for returned imgen.x.ai URLs, e.g. https://images.example.com

For IMAGE_PROXY_DOMAIN, configure your reverse proxy to forward paths and query strings to https://imgen.x.ai.

For long generations, set the MCP client's tool timeout to XAI_TIMEOUT_MS or longer.

Development

npm ci
npm test

To use a local build, configure your MCP client to run node with the absolute path to dist/index.js.

License

MIT


基于 xAI 图像 API 的 MCP 服务,支持选择模型与质量、编辑本地图片或已存储的图片,并返回图片链接或内联图片。使用 stdio 传输。

需要 Node.js 22.19+ 和 xAI API 密钥。

快速开始

在 MCP 客户端中添加:

{
  "mcpServers": {
    "grok_image": {
      "command": "npx",
      "args": ["-y", "grok-image-mcp"],
      "env": {
        "XAI_API_KEY": "你的 xAI API 密钥"
      }
    }
  }
}

服务提供 generate_image 和 edit_image 两个工具。generate_image 调用示例:

{
  "prompt": "一幅宁静山间湖泊的水彩插画",
  "model": "grok-imagine-image-2.0",
  "quality": "low",
  "aspect_ratio": "16:9"
}

模型与质量

能力grok-imagine-imagegrok-imagine-image-2.0
默认模型是每次调用指定,或设置 XAI_IMAGE_MODEL
编辑源图数量1–3 张1–5 张
分辨率1k、2k1k、2k
质量参数—low、medium、auto
新增宽高比—21:9、5:2

调用时的 model 优先于环境变量 XAI_IMAGE_MODEL,默认值为 grok-imagine-image。

2.0 的质量默认为 auto:生成对应 low,编辑对应 medium。费用见 xAI 定价。

工具参数

两个工具共用以下参数:

参数类型说明
promptstring,必填图片描述或编辑指令
modelstring上表中的模型之一
ninteger输出数量,1–10,默认 1
aspect_ratiostring生成默认 auto;编辑默认跟随第一张源图
resolutionstring1k 或 2k,默认 1k
qualitystring2.0:low、medium、auto
response_formatstring默认 url;b64_json 返回 MCP 原生图片内容
storage_optionsobject将输出保存至 Files API

宽高比支持 1:1、16:9、9:16、4:3、3:4、3:2、2:3、2:1、1:2、19.5:9、9:19.5、20:9、9:20、auto;2.0 还支持 21:9、5:2。

编辑图片

edit_image 的源图列表使用以下一种形式:

  • image_urls:按顺序提供公开 URL、base64 data URI 或本地路径。
  • images:按顺序提供 { "url": "..." } 或 { "file_id": "..." } 对象。url 也接受 data URI 和本地路径。
{
  "prompt": "将背景替换成雪中的森林",
  "image_urls": ["/absolute/path/to/photo.png"]
}

本地文件支持 PNG、JPEG、WebP。相对路径以服务的工作目录为基准。

返回结果

structuredContent.images 包含图片 URL、修改后的提示词、MIME 类型和文件存储信息;模型、质量、用量信息随 xAI 返回内容提供。

  • url:临时图片链接,同时以 Markdown 返回。使用 storage_options 可保存图片。
  • b64_json:MCP image 内容块,对应的结构化条目标记为 inline: true。

保存与复用图片

为任一工具添加 storage_options,即可保存输出:

{
  "prompt": "松林中的一间小木屋",
  "model": "grok-imagine-image-2.0",
  "quality": "low",
  "storage_options": {
    "filename": "cabin.jpg",
    "expires_after": 86400
  }
}

上述配置将图片私有保存一天。从 structuredContent.images[0].file_output.file_id 取得文件 ID,随后编辑时复用:

{
  "prompt": "将季节改成冬季",
  "model": "grok-imagine-image-2.0",
  "quality": "low",
  "images": [{ "file_id": "上一次返回的文件 ID" }]
}
存储选项说明
filename必填,存储文件名
expires_after文件有效期,3600–2592000 秒;默认永久保存
public_url设为 true 创建公开分享链接;默认为私有存储
public_url.expires_after使用 public_url: { "expires_after": 86400 } 指定公开链接有效期

详见 xAI 存储文档。

环境变量与网络

变量说明
XAI_API_KEYAPI 密钥,优先于 XAIAPI_KEY
XAIAPI_KEYAPI 密钥的另一个变量名
XAI_IMAGE_MODEL默认模型,未设置时为 grok-imagine-image
XAIAPI_BASE_URLAPI 基础地址,默认 https://api.x.ai/v1
XAI_TIMEOUT_MS请求超时毫秒数,默认 180000
HTTPS_PROXYAPI 网络代理,优先于 HTTP_PROXY
HTTP_PROXYAPI 网络代理,例如 http://127.0.0.1:7890
IMAGE_PROXY_DOMAIN返回图片的反向代理地址,例如 https://images.example.com

使用 IMAGE_PROXY_DOMAIN 时,反向代理需将路径与查询参数转发到 https://imgen.x.ai。

生成耗时较长时,将 MCP 客户端的工具超时设为 XAI_TIMEOUT_MS 或更长。

开发

npm ci
npm test

使用本地构建时,在 MCP 客户端中配置 node 和 dist/index.js 的绝对路径。

许可证

MIT

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Grok Image MCP server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/grok2-image-generator)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related media design MCP Servers

Alternative and complementary servers in the same category

View all in media design →

A Rust CAD application with an MCP server for creating, inspecting and rendering drawings, either headlessly or through a connection to the desktop app.

8K
Media & Design
Liquid Composer
liquid-composer•frontedu

Liquid Composer is a browser-based Liquid Glass icon design tool that offers a local MCP server for agent-driven icon workflows.

69
Media & Design

agent-media makes short drama series and other short vertical videos from Claude, ChatGPT or Codex through one MCP connection, with OAuth sign-in and no API keys.

1
Media & Design