Get the FREE Ultimate OpenClaw Setup Guide →

grok2-image

grok2-image mcp server

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio fl0w1nd-grok2-image-mcp-server npx grok-image-mcp \
  --env XAIAPI_KEY="your-xai-api-key"

How to use

This MCP server provides image generation and editing capabilities powered by the Grok image model from xAI. You can generate new images from text prompts or edit existing images by providing one to three source images and a natural language instruction. The server exposes two main tools: generate_image, which creates images from prompts with configurable aspect ratios and resolutions, and edit_image, which applies edits to supplied images based on a description. Optional image and HTTP proxies can help work around network restrictions. To run, start the server via npx grok-image-mcp (as shown in the installation example) and send MCP requests invoking the available tools with the required parameters.

How to install

Prerequisites:\n- Node.js and npm installed on your machine.\n- Access to npm registry (internet connection).\n\nInstallation steps:\n1) Ensure Node.js and npm are available:\n node -v\n npm -v\n2) Run the MCP server using npx (recommended):\n\n npm install -g npm@latest # optional, ensure npm is up to date\n npx grok-image-mcp\n\n This will start the Grok Image MCP server. If you need to pass API credentials, set the required environment variable, e.g.:\n\n XAIAPI_KEY=your-xai-api-key npx grok-image-mcp\n3) Alternatively, configure the server in a local script or with your package manager as shown in the README example:\n\n "mcpServers": {\n "grok_image": {\n "command": "npx",\n "args": ["grok-image-mcp"],\n "env": {\n "XAIAPI_KEY": "your-xai-api-key"\n }\n }\n }\n\nPrerequisites recap:\n- Access to the Grok Image MCP package (via npx).\n- A valid XAI API key (XAIAPI_KEY).\n- Optional: XAIAPI_BASE_URL, IMAGE_PROXY_DOMAIN, HTTP_PROXY if needed for network routing.

Additional notes

Notes and tips:\n- The server uses the Grok image model for generation and editing. Ensure your XAI API key has the necessary permissions.\n- If you encounter network restrictions, configure XAIAPI_BASE_URL to a proxy URL, IMAGE_PROXY_DOMAIN to rewrite returned image URLs, and HTTP_PROXY for outbound requests.\n- The documentation calls out 1–3 source images for edit_image; supply URLs, base64 data URIs, or local file paths.\n- If you previously used grok2-image-mcp-server, be aware this is the newer grok-image-mcp setup and may require updating environment variables or parameters.\n- The defaults typically use 1k resolution and 1 image by default; adjust n, aspect_ratio, and resolution as needed per tool.

Related MCP Servers

Sponsor this space

Reach thousands of developers