image-gen-mcp
Image Gen MCP
OpenAI 画像モデルを使用して画像を生成・編集するための TypeScript MCP サーバー。
このサーバーは generate_image と edit_image ツールを登録し、返された画像バイトをディスクに書き込みます。Stdio モードでは要求された絶対ファイルパスに書き込み、SSE およびストリーミング可能な HTTP ではファイルを自動保存して画像 URL を返します。
環境
名前 | 必須 | デフォルト | 説明 |
| いいえ | AI SDK OpenAI のデフォルト | OpenAI API の URL プレフィックス。例: |
| はい | - | OpenAI API キー。 |
| いいえ |
| OpenAI 画像モデル。 |
| いいえ |
| SSE/HTTP モードで自動保存されるファイルのディレクトリ。Docker ではデフォルトで |
Related MCP server: openai-imagegen-mcp
ツール
generate_image
引数:
名前 | 必須 | デフォルト | 説明 |
| はい | - | 画像プロンプト。 |
| Stdio | - | Stdio のみ。絶対出力パス。親ディレクトリは自動的に作成されます。 |
| いいえ |
| 画像の数。 |
| いいえ |
|
|
| いいえ |
|
|
| いいえ | - |
|
| いいえ |
|
|
| いいえ | - |
|
| いいえ | - |
|
| Stdio |
| Stdio のみ。既存の出力ファイルを置き換えることを許可します。 |
既知のモデルサイズ制限は、アップストリーム API を呼び出す前に検証されます。たとえば、gpt-image-* モデルは 1024x1024、1536x1024、1024x1536 をサポートし、dall-e-2 は 256x256、512x512、1024x1024 をサポートします。
n > 1 の場合、/tmp/image.png のようなファイルパスは /tmp/image-1.png、/tmp/image-2.png などになります。
SSE およびストリーミング可能な HTTP モードでは、filepath と overwrite は公開されません。生成されたファイルは ${FILE_DIR}/YYYY-MM-DD/<uuid>.<ext> として保存され、http://localhost:3000/file/YYYY-MM-DD/<uuid>.png のような URL で返されます。
edit_image
引数:
名前 | 必須 | デフォルト | 説明 |
| はい | - | 編集指示。 |
| はい | - | 編集する元画像への絶対パス。 |
| いいえ | - | 編集マスク画像への任意の絶対パス。 |
| Stdio | - | Stdio のみ。絶対出力パス。親ディレクトリは自動的に作成されます。 |
| いいえ |
| 編集された画像の数。 |
| いいえ |
|
|
| いいえ |
|
|
| いいえ | - | 編集された画像の背景の動作。 |
| いいえ |
|
|
| いいえ | - |
|
| いいえ | - |
|
| Stdio |
| Stdio のみ。既存の出力ファイルを置き換えることを許可します。 |
このツールは、マルチパートフォームデータを使用して OpenAI 互換の /images/edits エンドポイントを呼び出します。出力ファイルは generate_image と同じファイルパスおよび自動保存の動作に従います。
開発
pnpm install
pnpm dev有用なチェック:
pnpm check
pnpm buildStdio MCP 設定
{
"mcpServers": {
"image-gen-mcp": {
"type": "stdio",
"command": "npx",
"args": ["image-gen-mcp"],
"env": {
"BASE_URL": "https://api.openai.com/v1",
"API_KEY": "sk-...",
"MODEL": "gpt-image-2"
}
}
}
}ストリーミング可能な HTTP
{
"mcpServers": {
"image-gen-mcp": {
"type": "http",
"url": "http://localhost:3000/mcp",
"headers": {
"openai-base-url": "https://api.openai.com/v1",
"openai-api-key": "sk-...",
"openai-model": "gpt-image-2"
}
}
}
}ヘッダーはサーバー側の環境設定を上書きします。ヘッダーを省略すると、環境変数の値にフォールバックします。Docker イメージはポート 3000 でストリーミング可能な HTTP を実行します。
SSE
SSE トランスポートは src/sse.ts にあり、/mcp で PORT(デフォルト 4000)をリッスンし、メッセージは /message に投稿されます。pnpm start:sse で直接実行します。Docker イメージでは起動されません。
{
"mcpServers": {
"image-gen-mcp": {
"type": "sse",
"url": "http://localhost:4000/mcp",
"headers": {
"openai-api-key": "sk-..."
}
}
}
}Docker
docker build -t image-gen-mcp .
docker run --rm -p 3000:3000 \
# 也可忽略apiKey,让使用方 headers 中传递
-e BASE_URL=https://api.openai.com/v1 \
-e API_KEY=sk-... \
-e MODEL=gpt-image-2 \
-v image-gen-data:/data \
image-gen-mcpAvailable Tools
2 toolsedit_imageA
Edit image(s) with the OpenAI Images Edit API. SSE/HTTP transports auto-save files and return image URLs; stdio requires filepath.
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images to generate. | |
| size | No | Image size. Supported values: auto, 256x256, 512x512, 1024x1024, 1536x1024, 1024x1536, 1792x1024, 1024x1792. Some models only support a subset. | |
| prompt | Yes | Image generation prompt. | |
| quality | No | Image generation quality. | |
| filepath | Yes | Absolute path where the generated image should be saved. | |
| mask_path | No | Optional absolute path to the edit mask image. | |
| overwrite | No | Allow replacing existing output files. | |
| background | No | Generated image background behavior. | |
| image_path | Yes | Absolute path to the source image to edit. | |
| moderation | No | Image moderation strictness. | |
| output_format | No | Output image format. jpg is normalized to jpeg for the API request. | |
| output_compression | No | Compression level for jpeg or webp outputs, from 0 to 100. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations present, the description carries the burden of behavioral disclosure. It usefully discloses transport-dependent behavior: SSE/HTTP auto-save files and return URLs, while stdio requires a filepath. However, it omits external API dependencies, authentication, network failure behavior, and whether output files may be overwritten, which is important for an editing tool.
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 compact, front-loaded with the primary purpose, and contains no filler. The second sentence efficiently packs transport-specific behavior into one clause, making it easy to scan.
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?
For a tool with 12 parameters, no annotations, and no output schema, this description is incomplete. It covers the core purpose and one transport distinction, but it does not address return-value behavior for stdio, authentication, or error handling. Still, it provides essential context and is not misleading.
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 100%, so the baseline is 3. The description adds meaning by clarifying that filepath is required for stdio and that SSE/HTTP transports auto-save files, which helps the agent understand the filepath parameter's role beyond its schema entry. Other parameters remain schema-documented, which is sufficient.
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 verb and resource: 'Edit image(s)' via the 'OpenAI Images Edit API.' The name and wording imply a distinction from the sibling generate_image, but it never explicitly names that alternative, so it falls just short of a 5.
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 implies use when editing existing images rather than generating new ones, and the sibling name generate_image hints at the alternative. However, there is no explicit when-to-use vs. when-not-to-use guidance, and it does not mention generate_image or other alternatives.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
generate_imageA
Generate image(s) with the OpenAI Images API. SSE/HTTP transports auto-save files and return image URLs; stdio requires filepath.
| Name | Required | Description | Default |
|---|---|---|---|
| n | No | Number of images to generate. | |
| size | No | Image size. Supported values: auto, 256x256, 512x512, 1024x1024, 1536x1024, 1024x1536, 1792x1024, 1024x1792. Some models only support a subset. | |
| prompt | Yes | Image generation prompt. | |
| quality | No | Image generation quality. | |
| filepath | Yes | Absolute path where the generated image should be saved. | |
| overwrite | No | Allow replacing existing output files. | |
| background | No | Generated image background behavior. | |
| moderation | No | Image moderation strictness. | |
| output_format | No | Output image format. jpg is normalized to jpeg for the API request. | |
| output_compression | No | Compression level for jpeg or webp outputs, from 0 to 100. |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries the burden of disclosing behavior. It usefully reveals that SSE/HTTP transports auto-save files and return URLs, which is behavioral context beyond the schema. Still, it does not mention other notable behaviors such as default overwrite behavior, moderation handling, or exactly what happens in stdio mode after generation.
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 two short sentences with no filler. The primary purpose is front-loaded, and the transport nuance is stated efficiently. Every sentence earns its place.
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?
The description covers the tool's purpose and a key transport difference, and the schema fully documents the parameters. However, with 10 parameters, no annotations, and no output schema, an agent might still be unsure what to expect as a result in stdio mode or how this tool relates to edit_image. The description is adequate but not fully complete.
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 100%, so the baseline is 3. The description adds almost no parameter-level detail beyond the schema; the only minor addition is the contextual note that stdio requires filepath, but that is already captured by the required field.
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 a specific action ('Generate image(s)') and resource ('with the OpenAI Images API'). It is easy to understand that this tool creates new images, and the sibling 'edit_image' suggests the complementary operation, though the description does not explicitly compare itself to that sibling.
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 gives transport-specific guidance: SSE/HTTP auto-save files and return image URLs, while stdio requires filepath. However, it does not explicitly explain when to choose this tool over edit_image; the use case is only implied by the tool name and the generate-vs-edit distinction.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
2 tool updates
v0.1.1- First observed
edit_image - First observed
generate_image
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: one generates new images from scratch, the other edits existing images. There is no ambiguity between them.
Both tool names follow the same verb_noun pattern: generate_image and edit_image. The naming is consistent and predictable.
With only 2 tools, the server is on the thin side. While adequate for basic image generation and editing, it feels minimal and could reasonably include additional related operations.
The server covers the two primary actions for an image API service. Missing common operations like image variations or model listing, but the core generation and editing workflows are fully represented.
Maintenance
Related MCP Connectors
Generate and edit images, create videos, quote credit costs, and retrieve private results.
Generate AI images and videos from any compatible MCP client.
LLM chat, text tools, image generation, editing, batch image jobs, and asynchronous video generation
AI image + video generation for agents: --flag prompt DSL, async generate/poll, x402 pay-per-use.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables image generation and editing using OpenAI's GPT Image API (gpt-image-1, 1.5, 2) with support for multi-image generation, history management, and batch processing.1295 npm1MIT
- FlicenseNot gradedqualityDmaintenanceEnables image generation and editing via OpenAI's gpt-image-1 model, with options for saving, format control, and transparency.-
- AlicenseBqualityBmaintenanceEnables generating images from text or transforming existing images using GPT-Image-compatible APIs, with support for OpenAI and Agnes AI backends.2MIT
- AlicenseAqualityBmaintenanceEnables image generation and editing through OpenAI's gpt-image-2 model, supporting text-to-image, reference-guided generation, and editing with local files or URLs.2119 npm2MIT