Generate images through MCP protocol integration
MCP server for AI image generation across OpenRouter, Together AI, Replicate, and fal.ai.
Why it matters
Enable AI assistants and applications to create visual content on demand by providing a standardized Model Context Protocol interface for image generation capabilities.
Outcomes
What it gets done
Connect AI models to image generation services via MCP
Process natural language image descriptions into visual outputs
Return generated images in standard formats for downstream use
Handle image generation requests through protocol-compliant messaging
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/mcp-image-generator | bash Overview
MCP Image Generator
An MCP server that generates AI images from text prompts across four providers - OpenRouter, Together AI, Replicate, and fal.ai. It exposes a generate_image tool with prompt, model, provider, aspect ratio, resolution, and seed parameters, plus a list_providers tool. Use when you want an AI agent to generate images on request without switching to a separate image-generation tool or UI.
What it does
This MCP server generates AI images from text prompts, giving Claude Code, Cursor, Claude Desktop, OpenCode, Charm (Crush/Mods), or any MCP-compatible agent access to four image-generation providers - OpenRouter (default), Together AI, Replicate, and fal.ai - through a single consistent tool interface.
When to use - and when NOT to
Use it when you want an AI agent to generate images on request - specifying a prompt, model, provider, aspect ratio, resolution, or seed - without switching to a separate image-generation UI. Requires at least one provider API key (OpenRouter, Together AI, Replicate, or fal.ai); with multiple keys set, you can pick a provider per request. It only supports image-generation models across its four providers - not general-purpose chat or text models from the same providers.
Capabilities
Two tools: generate_image (a required text prompt, plus optional model ID, provider selection, aspect_ratio - 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, or 2:3 - image_size - 1K default, 2K, or 4K - negative_prompt for exclusions on providers that support it, a seed for reproducibility, and a custom save_to file path) and list_providers (lists all configured providers and their available image models, optionally filtered by provider name). Supported provider and model combinations: OpenRouter (Gemini Flash Image, FLUX 2, Sourceful Riverflow, GPT-5 Image), Together AI (FLUX.1 Schnell/Dev/Pro, Stable Diffusion XL), Replicate (FLUX Schnell, FLUX 1.1 Pro, SDXL, Ideogram), and fal.ai (FLUX Dev/Schnell/2 Pro, Recraft V3).
How to install
No install step - run directly via npx with a provider API key:
OPENROUTER_API_KEY="sk-or-v1-..." npx -y mcpimg
Register it in your client's MCP config with command: "npx", args: ["-y", "mcpimg"], and the relevant provider key in env - Claude Code (claude mcp add or .mcp.json), Cursor (~/.cursor/mcp.json), Claude Desktop (platform-specific config path), OpenCode (opencode.json), Charm Crush (crush.json), or Charm Mods (mods.yml). It uses standard stdio transport, so any MCP-compatible agent can launch it the same way. At least one of OPENROUTER_API_KEY, TOGETHER_API_KEY, REPLICATE_API_TOKEN, or FAL_KEY is required; IMAGE_OUTPUT_DIR optionally overrides the default save location of ~/generated-images/. With multiple keys set, a specific call like generate_image(prompt="a cat", provider="together", model="black-forest-labs/FLUX.1-schnell") routes that one request to a chosen provider and model without changing the server configuration. The project is MIT-licensed.
Who it's for
Developers and AI-agent users who want on-demand image generation available as a tool call across multiple providers and models, without hardcoding a single provider or building separate image-generation tooling for each client.
Source README
MCP Image Generator
MCP server for AI image generation. Works with Claude Code, Cursor, Claude Desktop, OpenCode, Charm (Crush/Mods), and any MCP-compatible AI agent.
Providers supported (image models only):
- OpenRouter (default) - Gemini Flash Image, FLUX 2, Sourceful Riverflow, GPT-5 Image
- Together AI - FLUX.1 Schnell/Dev/Pro, Stable Diffusion XL
- Replicate - FLUX Schnell, FLUX 1.1 Pro, SDXL, Ideogram
- fal.ai - FLUX Dev/Schnell/2 Pro, Recraft V3
Quick Start
No install needed - just use npx:
OPENROUTER_API_KEY="sk-or-v1-..." npx -y mcpimg
Tools
generate_image
Generate an image from a text prompt.
| Parameter | Type | Description |
|---|---|---|
prompt |
string (required) | Text description of the image |
model |
string | Model ID (e.g. google/gemini-2.5-flash-image) |
provider |
string | openrouter (default), together, replicate, fal |
aspect_ratio |
string | 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3 |
image_size |
string | 1K (default), 2K, 4K |
negative_prompt |
string | What to exclude (not all providers support this) |
seed |
number | Random seed for reproducibility |
save_to |
string | Custom file path to save the image |
list_providers
List all configured providers and their available image models.
| Parameter | Type | Description |
|---|---|---|
provider |
string | Filter by provider name |
Setup for AI Agents / IDEs
Claude Code
claude mcp add --scope user --transport stdio image-gen \
--env OPENROUTER_API_KEY=sk-or-v1-xxx \
-- npx -y mcpimg
Or create .mcp.json in your project root:
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["-y", "mcpimg"],
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-..."
}
}
}
}
Cursor
Edit ~/.cursor/mcp.json:
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["-y", "mcpimg"],
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-..."
}
}
}
}
Claude Desktop
Edit the config file:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
{
"mcpServers": {
"image-gen": {
"command": "npx",
"args": ["-y", "mcpimg"],
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-..."
}
}
}
}
OpenCode (by SST)
Edit ~/.config/opencode/opencode.json or opencode.json in project root:
{
"mcp": {
"image-gen": {
"type": "local",
"command": ["npx", "-y", "mcpimg"],
"environment": {
"OPENROUTER_API_KEY": "sk-or-v1-..."
},
"enabled": true,
"timeout": 120000
}
}
}
Charm Crush
Add to crush.json in your project root:
{
"mcp": {
"image-gen": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mcpimg"],
"env": {
"OPENROUTER_API_KEY": "sk-or-v1-..."
}
}
}
}
Charm Mods
Edit mods.yml (mods --settings):
mcp-servers:
image-gen:
command: [npx]
args:
- -y
- mcpimg
env:
- OPENROUTER_API_KEY=sk-or-v1-...
Any MCP-compatible agent
This server uses stdio transport (JSON-RPC over stdin/stdout). Any agent that supports MCP stdio can use it:
npx -y mcpimg
# Required environment variables (at least one)
OPENROUTER_API_KEY=... # OpenRouter (default)
TOGETHER_API_KEY=... # Together AI
REPLICATE_API_TOKEN=... # Replicate
FAL_KEY=... # fal.ai
Using Multiple Providers
Set multiple API keys to use different providers:
export OPENROUTER_API_KEY="sk-or-v1-..."
export TOGETHER_API_KEY="..."
export FAL_KEY="..."
Then specify the provider when generating:
generate_image(prompt="a cat", provider="together", model="black-forest-labs/FLUX.1-schnell")
Environment Variables
| Variable | Provider | Required |
|---|---|---|
OPENROUTER_API_KEY |
OpenRouter | At least one |
TOGETHER_API_KEY |
Together AI | provider key |
REPLICATE_API_TOKEN |
Replicate | is required |
FAL_KEY |
fal.ai | |
IMAGE_OUTPUT_DIR |
- | Optional. Default: ~/generated-images/ |
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.