Grok Imagine Image MCP Server
Click on "Deploy 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 Imagine Image MCP Server generate 3 watercolor images of a mountain lake at 16:9"
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 Imagine Image MCP Server
MCP (Model Context Protocol) server for xAI's Grok Imagine Image API. Supports image generation from text prompts and editing existing images.
Quick Start with npx
# Set your API key
export XAI_API_KEY="xai-your-api-key"
# Run the server
npx grok-imagine-image-mcp-serverRelated MCP server: ImaginePro MCP Server
Features
Image Generation: Generate new images from text prompts
Image Editing: Edit existing images with prompts (grok-imagine-image only)
Batch Processing: Process multiple images via CLI
Various aspect ratios (1:1, 4:3, 16:9, and more)
Resolution: 1k (standard)
Generate multiple images at once (up to 10)
Optional thumbnail preview in MCP responses
Supported Models
Model | Price (1k) | Price (2k) | Image Editing | Notes |
| $0.02/image | $0.02/image | ✅ (+$0.002/input image) | Default — cheapest |
| $0.05/image | $0.07/image | ✅ (+$0.01/input image) | Alias of |
| $0.04 (low) / $0.06 (medium) | $0.06 (low) / $0.08 (medium) | ✅ (+$0.01/input image) | Latest — supports |
quality (low / medium, default medium) is accepted only by grok-imagine-image-2.0.
Pricing per xAI model docs.
Requirements
Node.js 22.23.4 or higher (use a patched release: 22.23.4+, 24.22.1+, or 26.12.1+)
xAI API key (get from console.x.ai)
Installation
Option 1: npx (Recommended)
npx grok-imagine-image-mcp-serverOption 2: Global Install
npm install -g grok-imagine-image-mcp-server
grok-imagine-image-mcp-serverConfiguration
Environment Variables
Variable | Required | Description |
| Yes | Your xAI API key |
| No | Set to |
| No | Default output directory for images |
| No | Set to |
Claude Desktop Configuration
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"grok-imagine-image": {
"command": "npx",
"args": ["-y", "grok-imagine-image-mcp-server"],
"env": {
"XAI_API_KEY": "xai-your-api-key-here"
}
}
}
}Tools
generate_image
Generate images from text prompts.
Parameter | Type | Required | Description |
| string | Yes | Text description of the image to generate |
| string | No | Output file path (default: generated_image.jpg) |
| string | No | Model to use (default: grok-imagine-image) |
| number | No | Number of images (1-10, default: 1) |
| string | No | Aspect ratio (default: 1:1) |
| string | No | Resolution (default: 1k) |
| string | No |
|
| boolean | No | Return base64 data (default: false) |
| boolean | No | Include thumbnail (default: false) |
edit_image
Edit existing images.
Parameter | Type | Required | Description |
| string | Yes | Description of desired edits |
| string | No* | Path to source image file |
| string | No* | Base64 encoded source image |
| string | No* | URL of source image |
| string | No | Output file path (default: edited_image.jpg) |
| string | No | Model to use (default: grok-imagine-image) |
| number | No | Number of images (1-10, default: 1) |
| string | No | Resolution (default: 1k). Aspect ratio is auto-detected from input image. |
| string | No |
|
*One of image_path, image_base64, or image_url is required
Note: The edit_image tool uses the source image as a reference and regenerates the entire image. It maintains the overall composition and style but is not pixel-level inpainting. Best suited for style transformations, subject replacements, and scene modifications.
Batch Processing CLI
Process multiple images at once using the batch CLI:
# Run batch with config file
npx grok-imagine-image-batch batch.json
# Estimate cost only
npx grok-imagine-image-batch batch.json --estimate-only
# Custom output directory
npx grok-imagine-image-batch batch.json --output-dir ./images --format jsonCLI Options
Option | Description | Default |
| Override output directory | From config |
| Output format |
|
| Timeout in milliseconds |
|
| Max concurrent jobs (1-10) |
|
| Estimate cost without executing | - |
| Allow any output path (CI/CD) | - |
Batch Configuration File
{
"jobs": [
{
"prompt": "A beautiful sunset over mountains",
"output_path": "sunset.jpg",
"aspect_ratio": "16:9"
},
{
"prompt": "Change to nighttime scene",
"image_path": "input.jpg",
"output_path": "edited.jpg"
}
],
"output_dir": "./output",
"max_concurrent": 3,
"default_model": "grok-imagine-image",
"retry_policy": {
"max_retries": 2,
"retry_delay_ms": 1000
}
}See examples/ directory for more configuration examples.
Supported Aspect Ratios
Aspect Ratio | Use Case |
| Square, social media profiles (default) |
| Standard portrait/landscape |
| Smartphone / widescreen |
Supported Resolutions
Resolution | Description |
| Standard resolution (1024x1024, default) |
Usage Examples
# Image generation
Generate an image of a sunset over mountains with aspect ratio 16:9
# Image editing
Change the background of this image to spaceAPI Reference
Function | Endpoint |
Image Generation |
|
Image Editing |
|
Documentation: docs.x.ai/docs/guides/image-generations
Development
git clone https://github.com/ex-takashima/grok-imagine-image-mcp-server.git
cd grok-imagine-image-mcp-server
npm install
npm run build
npm startLicense
MIT
Author
Junji Takashima takajyun00@gmail.com
Available Tools
2 toolsedit_imageA
Edit an existing image using xAI Grok Imagine Image API. Models: grok-imagine-image ($0.02/image + $0.002/input image), grok-imagine-image-pro ($0.05/image at 1k or $0.07 at 2k + $0.01/input image), grok-imagine-image-2.0 ($0.04-$0.08/image + $0.01/input image). Provide a source image via file path, base64, or URL along with a prompt describing the desired changes. Supports up to 3 input images via image_paths/image_base64s/image_urls arrays.
Inputs: prompt (required), n, model, quality, +11 more.
generate_imageB
Generate a new image from a text prompt using xAI Grok Imagine Image API. Models: grok-imagine-image ($0.02/image at 1k or 2k), grok-imagine-image-pro ($0.05/image at 1k, $0.07/image at 2k), grok-imagine-image-2.0 (latest, $0.04-$0.08/image depending on resolution and quality). Supports aspect ratios: 1:1, 3:4, 4:3, 3:2, 2:3, 2:1, 1:2, 9:16, 16:9, 19.5:9, 9:19.5, 20:9, 9:20, auto. Can generate multiple images at once (up to 10).
Inputs: prompt (required), n, model, quality, +5 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
generate_image and edit_image target clearly distinct operations: one creates from a text prompt, the other modifies supplied source images. There is no plausible way an agent would confuse the two given the descriptions.
Both tools follow a strict verb_noun snake_case pattern (generate_image, edit_image) that reads predictably and maps one-to-one to the underlying actions.
Two tools is thin for a general-purpose server, but it matches the narrow scope of wrapping a generation/editing API. Still, it sits at the borderline where the surface feels minimal, with no utility operations offered.
The core lifecycle of creating and editing images is fully covered, including model selection, aspect ratios, batch generation, and multiple input images. Minor gaps remain, such as no model/price listing tool or separate upscale/variation operation, but these are workable.
Maintenance
Related MCP Connectors
Generate and edit images: article covers, pet portraits, product shots. Each call spends credits.
Image generation, image editing and text/image-to-video with credit quotes and connection budgets.
Commercially licensed image generation and editing with IP indemnification.
Generate, edit and upscale images with references, batch jobs, cost previews and original downloads.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to analyze images from URLs or local files using xAI's Grok API. Provides detailed image descriptions, technical metadata extraction, and optical character recognition (OCR) capabilities.7-
- AlicenseBqualityDmaintenanceEnables AI assistants to generate images and videos through natural language using ImaginePro's API. Supports text-to-image generation, video creation, image upscaling, variants, inpainting, and multi-modal generation with real-time progress tracking.849 npmMIT
- FlicenseNot gradedqualityCmaintenanceEnables image generation and editing using Google's Gemini models with support for model selection and custom aspect ratios. Users can generate high-quality images or modify existing ones through natural language prompts while controlling specific parameters like quality and dimensions.-
- AlicenseNot gradedqualityCmaintenanceEnables image generation and editing via the Grok Imagine Image 2.0 API, supporting text-to-image, image-to-image editing, multi-reference generation, local uploads, and asynchronous job polling.7MIT