Grok2 Image Generator logo

Grok2 Image Generator

Community
fl0w1nd

grok image mcp server

Publisherfl0w1nd
Repositorygrok-image-mcp
LanguageTypeScript
Forks
5
Stars
29
Available tools
0
Transport typestdio
Categories
Links
  • Connect tools to AI workflows

    Grok2 Image Generator exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    29 stars and 5 forks from the linked repository.

Grok Image MCP

English | 中文


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 use grok-image-mcp instead.

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.ai to handle network restrictions
  • HTTP Proxy — Optional network proxy for API requests

Installation

Using npx (recommended)

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

Tools

generate_image

Generate images from text prompts.

ParameterTypeRequiredDescription
promptstring✅Text description of the image to generate
nnumberNumber of images (1–10, default 1)
aspect_ratiostringAspect ratio (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 2:1, 1:2, auto, etc.)
resolutionstringResolution (1k or 2k, default 1k)

edit_image

Edit existing images using a text prompt.

ParameterTypeRequiredDescription
promptstring✅Text description of the desired edits
image_urlsstring[]✅1–3 source images: URLs, base64 data URIs, or local file paths
nnumberNumber of output images (1–10, default 1)
aspect_ratiostringOverride output aspect ratio (default: follows first input image)
resolutionstringResolution (1k or 2k, default 1k)

Environment Variables

VariableRequiredDescription
XAIAPI_KEY✅xAI API key
XAIAPI_BASE_URLAPI base URL (default: https://api.x.ai/v1). Use a proxy if the API is inaccessible
IMAGE_PROXY_DOMAINProxy domain to replace imgen.x.ai in returned image URLs
HTTP_PROXYHTTP/HTTPS proxy for API requests (e.g. http://127.0.0.1:7890)

Proxy Examples

API proxy:

bash
XAIAPI_BASE_URL=https://api-proxy.me/xai/v1

Image proxy:

bash
IMAGE_PROXY_DOMAIN=https://image.proxy.workers.dev

Network proxy:

bash
HTTP_PROXY=http://127.0.0.1:7890

Using 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:

js
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


基于 MCP 协议的 Grok 图像生成与编辑服务。

注意: 此包的前身是 grok2-image-mcp-server,该包已弃用,请使用 grok-image-mcp。

功能

  • 图像生成 — 通过文本提示生成图像,可配置宽高比、分辨率和批量数量
  • 图像编辑 — 使用自然语言编辑现有图像,支持 1–3 张源图
  • 本地文件支持 — 可提供本地图片路径进行编辑,服务端自动读取并编码
  • 图片代理 — 可选代理域名替换 imgen.x.ai,解决网络访问问题
  • 网络代理 — 支持 HTTP/HTTPS 代理

安装

使用 npx(推荐)

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

工具

generate_image

通过文本提示生成图像。

参数类型必填说明
promptstring✅描述要生成的图像内容
nnumber生成数量(1–10,默认 1)
aspect_ratiostring宽高比(1:1、16:9、9:16、4:3、3:4、3:2、2:3、2:1、1:2、auto 等)
resolutionstring分辨率(1k 或 2k,默认 1k)

edit_image

使用文本提示编辑现有图像。

参数类型必填说明
promptstring✅描述所需的编辑内容
image_urlsstring[]✅1–3 张源图:URL、base64 data URI 或本地文件路径
nnumber输出图像数量(1–10,默认 1)
aspect_ratiostring覆盖输出宽高比(默认跟随第一张输入图)
resolutionstring分辨率(1k 或 2k,默认 1k)

环境变量

变量必填说明
XAIAPI_KEY✅xAI API 密钥
XAIAPI_BASE_URLAPI 基础地址(默认 https://api.x.ai/v1),可填写代理地址
IMAGE_PROXY_DOMAIN图片代理域名,替换返回 URL 中的 imgen.x.ai
HTTP_PROXYHTTP/HTTPS 网络代理地址(如 http://127.0.0.1:7890)

代理示例

API 代理:

bash
XAIAPI_BASE_URL=https://api-proxy.me/xai/v1

图片代理:

bash
IMAGE_PROXY_DOMAIN=https://image.proxy.workers.dev

网络代理:

bash
HTTP_PROXY=http://127.0.0.1:7890

使用 Cloudflare Workers 代理图片 URL

如果 imgen.x.ai 的图片无法访问,可部署 Cloudflare Worker 反向代理,然后将 IMAGE_PROXY_DOMAIN 设为你的自定义域名:

js
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

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "grok2_image": {
      "command": "npx",
      "args": [
        "grok2-image-mcp-server"
      ],
      "env": {
        "XAIAPI_KEY": "xAI Key"
      }
    }
  }
}

Use Grok2 Image Generator MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Grok2 Image Generator is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Grok2 Image Generator as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Grok2 Image Generator MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "grok2-image-generator": {
      "command": "npx",
      "args": [
        "-y",
        "grok2-image-mcp-server"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Grok2 Image Generator MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Grok2 Image Generator MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Grok2 Image Generator to help me with this task?
Grok2 Image Generator
Sure. I read it.
Here is what I found using Grok2 Image Generator.

Frequently asked questions

What is the Grok2 Image Generator MCP server used for?

Grok2 Image Generator is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Grok2 Image Generator MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Grok2 Image Generator with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Grok2 Image Generator MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Grok2 Image Generator connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Grok2 Image Generator MCP to TypingMind?

Grok2 Image Generator runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Grok2 Image Generator MCP provide in TypingMind?

Grok2 Image Generator exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Grok2 Image Generator MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Grok2 Image Generator requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇