image2-mcp
This server connects AI tools (like Claude Code) to a text-to-image API, enabling AI-driven image generation directly from prompts.
Generate images from text prompts (generate_image):
Preset resolutions:
1024x1024,1024x1536,1536x1024,2048x1152,2048x2048,2160x3840,3840x2160, orautoCustom resolutions: Any
WxHformat (max 3840px per side, multiples of 16, aspect ratio ≤ 3:1)Quality control:
low,medium,high, orautoCustom filenames: Specify a filename (without
.png) or let it auto-generateAsync mode (default): Returns immediately while the image saves in the background
Synchronous mode: Waits for the image and returns it directly in the response
Custom output directory: Override where the image is saved
List recently generated images (list_images): Browse images saved to the output directory, useful after async generation to check results. Supports a limit parameter and custom output directory.
Images are saved as PNG files. Requires a MAGENE_API_KEY for authentication.
Click on "Install 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., "@image2-mcpGenerate an image of a knight riding a dragon"
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.
image2-mcp
MCP Server for the company image2 text-to-image API. Allows Claude Code, Codex, and other MCP-compatible AI tools to generate images directly.
🚀 Quick Start
自动安装(推荐)
git clone <repo-url>
cd image2-mcp
bash scripts/setup.sh脚本会自动完成:
检查/安装
uv安装 Python 依赖(
uv sync)引导你输入 API Key(或从
~/.claude/.env复用已有 key)写入
~/.claude/.env环境配置将
image2注册到~/.claude.json(Claude Code 的 MCP 配置)运行健康检查验证一切正常
完成后重启 Claude Code,说「帮我生成一张图片」即可。
手动安装
# 1. 安装依赖
uv sync
# 2. 配置环境变量
cp .env.example ~/.claude/.env
# 编辑 ~/.claude/.env,将 MAGENE_API_KEY 改为你的真实 key:
# MAGENE_API_KEY=user_xxxxxxxx
# 3. 健康检查
uv run python -m image2_mcp --health-checkMCP 配置需要手动添加到 ~/.claude.json 的顶层 mcpServers 字段:
{
"mcpServers": {
"image2": {
"command": "bash",
"args": [
"-c",
"set -a; [ -f ~/.claude/.env ] && . ~/.claude/.env; [ -f .env ] && . ./.env; set +a; exec /Users/你的用户名/.local/bin/uv run --directory /path/to/image2-mcp python -m image2_mcp"
],
"env": {
"PATH": "/Users/你的用户名/.local/bin:/usr/local/bin:/usr/bin:/bin",
"HOME": "/Users/你的用户名"
},
"description": "文生图 — 调用公司统一 API 平台 image2 模型生成图片",
"type": "stdio"
}
}
}⚠️ 注意将
/Users/你的用户名/替换为实际路径。uv的路径可通过which uv获取。
Related MCP server: universal-image-mcp
⚙️ 环境变量
变量 | 必填 | 默认值 | 说明 |
| 是 | — | 公司 API 平台的 key |
| 否 |
| API 地址 |
| 否 | 自动检测(项目 | 图片保存路径 |
| 否 |
| 模型名称 |
图片输出目录的优先级:
显式参数
IMAGE2_OUTPUT_DIR环境变量CLAUDE_PROJECT_DIR→<项目>/output/(Claude Code 自动设)IMAGE2_PROJECT_DIR→<项目>/output/(legacy)当前工作目录
/output系统临时目录
/image2-output
💡 通常无需手动设置任何目录变量——如果你在某个项目中用 Claude Code 打开,图片会自动存到那个项目的
output/文件夹。
📐 工具参数
参数 | 类型 | 必填 | 默认值 | 说明 |
| string | 是 | — | 图片描述(最长 32000 字符) |
| string | 是 | — | 尺寸,见下方 |
| string | 否 |
|
|
| string | 否 | 自动生成 | 自定义文件名(不含 |
可用尺寸:
值 | 分辨率 |
| 1K 方形 |
| 1.5K 横版 |
| 1.5K 竖版 |
| 2K 方形 |
| 2K 横版 |
| 4K 横版 |
| 4K 竖版 |
| 自动 |
自定义尺寸:WxH 格式,每边 ≤ 3840px,16 的倍数,宽高比 ≤ 3:1,总像素 655,360–8,294,400。
🧪 开发
uv sync --group dev
uv run pytest --cov=src --cov-report=term-missing🔧 工作原理
AI: generate_image(prompt="a cat in a garden", size="1024x1024")
→ 服务端校验参数
→ POST 到公司 API
→ 解码 Base64 响应
→ 写入 PNG 到磁盘
→ 返回图片 + 路径 + 用量统计生成是异步的——AI 调用后立即返回,图片就绪后会通过日志通知。多张图片可并行生成。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- AlicenseAqualityDmaintenanceAn MCP server that provides AI image generation and editing capabilities using Google's Gemini 2.5 Flash Image API. It allows users to create new images from text, modify existing files, and perform iterative edits through natural language prompts.6924MIT
- AlicenseAqualityDmaintenanceMCP server for multi-provider AI image generation (AWS Bedrock, OpenAI, Google Gemini) enabling image generation, transformation, and editing through a unified interface.41MIT
- Flicense-qualityDmaintenanceAn MCP server for AI-powered image processing (generate, edit, vary, analyze) supporting OpenAI, Gemini, Ideogram, and custom relay endpoints.
- AlicenseAqualityAmaintenanceAn MCP server that enables AI image editing and generation using the GPT Image 2 model line via RunAPI, with task polling and pricing checks.5358Apache 2.0
Related MCP Connectors
MCP server for Wan AI video generation
MCP server for ByteDance Seedream AI image generation
MCP server for Grok Imagine AI video generation
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Paipai112/image2-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server