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 调用后立即返回,图片就绪后会通过日志通知。多张图片可并行生成。
Available Tools
2 toolsgenerate_imageA
Generate an image from a text prompt using the company image2 model. Use async_mode=true (default) for fire-and-forget — returns immediately, image saves to disk in the background. Use async_mode=false to wait for the image and see it in the response. Size: Presets: 1024x1024, 1024x1536, 1536x1024, 2048x1152, 2048x2048, 2160x3840, 3840x2160, auto. Custom: WxH (max 3840px per side, multiples of 16, ratio ≤ 3.0:1, pixels 655,360–8,294,400)
| Name | Required | Description | Default |
|---|---|---|---|
| size | Yes | ||
| prompt | Yes | ||
| quality | No | auto | |
| filename | No | ||
| async_mode | No | ||
| output_dir | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations, the description discloses key behaviors: async mode behavior, size limits and ratio rules. Does not mention failure handling or auth, but covers the main behavioral traits.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
Two sentences, front-loaded with purpose. Second sentence packs size details efficiently. No superfluous text.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
With an output schema present, description focuses on behavioral aspects. Covers async vs sync and size constraints, which are critical. Missing details on quality and error handling, but adequate for generation tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema coverage is 0%, so description must compensate. Explains async_mode and size in detail, but does not cover 'quality,' 'filename,' or 'output_dir' parameters. Adds partial value but leaves gaps.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
Clearly states 'Generate an image from a text prompt using the company image2 model,' specifying the action and model. Distinguishes from sibling 'list_images' which lists existing images.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
Provides clear context for async mode usage (fire-and-forget vs wait) and size constraints. No explicit when-not or alternatives beyond the sibling, but sufficient for the tool's domain.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
list_imagesA
List recently generated images in the output directory. Useful after async/fire-and-forget generation to see what's been created.
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | ||
| output_dir | No |
Output Schema
| Name | Required | Description |
|---|---|---|
| result | Yes |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the full burden. It states the tool lists recent images but does not disclose details like sorting order, recency definition, or whether it returns metadata. The behavior is minimally described but not fully transparent.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is extremely concise—two short sentences with no extraneous information. Every word serves a purpose: stating the action and providing usage context.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Despite having an output schema, the description lacks parameter explanations and a definition of 'recently.' For a simple listing tool, it is adequate but not comprehensive; agents may need to infer or experiment.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
Schema description coverage is 0%, yet the description offers no explanation for the two parameters ('limit' and 'output_dir'). Agents receive no guidance on how to use these parameters, which is a significant gap.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose: 'List recently generated images in the output directory.' The verb 'List' and resource 'recently generated images' are specific, and the sibling tool 'generate_image' contrasts as a creation tool, making the distinction clear.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description explicitly mentions usefulness 'after async/fire-and-forget generation to see what's been created,' providing clear context for when to use this tool. However, it lacks explicit when-not-to-use or alternative suggestions beyond the implied sibling.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
TDQS
The two tools have clearly distinct purposes: generating images and listing generated images. There is no overlap or ambiguity.
Both tools follow a consistent verb_noun pattern: 'generate_image' and 'list_images'. The convention is uniform and predictable.
With only 2 tools, the server feels thin for its domain, but it covers the essential generation and listing operations. It is borderline reasonable but lacks additional supporting tools.
The server covers core image generation and listing. However, it lacks individual image retrieval, deletion, or progress tracking for async operations, which are minor but notable gaps.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
MCP server for Wan AI video generation
MCP server for ByteDance Seedream AI image generation
MCP server for Grok Imagine AI video generation
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.6758MIT
- AlicenseAqualityDmaintenanceMCP server for multi-provider AI image generation (AWS Bedrock, OpenAI, Google Gemini) enabling image generation, transformation, and editing through a unified interface.41MIT
- FlicenseNot gradedqualityDmaintenanceAn 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.5120Apache 2.0
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