mcp-duojie-image
v0.19.0MCP server for image generation via duojie.games
MCP server for image generation via duojie.games GPT image API. Creates a new image. reference_images and input_images are optional guidance for style, identity, composition, or material; they are never edit canvases. A submitted response is not a successful generation. Call check_image_task until it returns status: "done" or status: "failed", or — after submitting a batch — call wait_all_tasks once to wait for all of them instead of polling one by one. Non-terminal responses intentionally omit success; only terminal responses use success: true or success: false.
Summary extracted from the README.
mcp-duojie-image
MCP server for image generation via duojie.games GPT image API.
Features
- Text-to-image generation with the
gpt-image-2.6family trimmed to two tiers, selectable per request via themodelparameter:gpt-image-2.6-flare(default, fastest, drafts) andgpt-image-2.6-sunburst(best quality, slowest); the standardgpt-image-2.6, thegpt-image-2.5family, andgpt-image-2are no longer offered - Two business operations: new-image generation with optional references, and explicit local editing
- Prompt structuring helpers for use case, asset type, constraints, and effective prompt echo
- Native transparent output: ask for an alpha-channel PNG directly in
prompt/constraints(see below) - Async submission with explicit accepted/terminal semantics and required task polling
- File saving with overwrite/conflict handling
- Size request templates for
1K,2K, and4K, plus arbitrary custom aspect ratios (e.g.9:21) with neutral canvas-ratio guidance; saved files keep the upstream native aspect ratio (no local cropping), upscaled to the requested pixel budget when smaller
Configuration
Required:
| Variable | Default | Description |
|---|---|---|
DUOJIE_API_KEY |
required | duojie.games API key |
DUOJIE_BASE_URL |
https://api.duojie.games |
API base URL |
Tool: generate_image
Creates a new image. reference_images and input_images are optional guidance
for style, identity, composition, or material; they are never edit canvases.
A submitted response is not a successful generation. Call
check_image_task until it returns status: "done" or status: "failed",
or — after submitting a batch — call wait_all_tasks once to wait for all
of them instead of polling one by one.
Non-terminal responses intentionally omit success; only terminal responses use
success: true or success: false.
Required parameters:
| Parameter | Type | Description |
|---|---|---|
prompt |
string | Image prompt |
output_dir |
string | Absolute output directory |
output_filename |
string | Filename without extension |
Optional parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
size |
1K | 2K | 4K |
1K |
Pixel budget tier; smaller upstream output is upscaled to it (no added detail) |
aspect_ratio |
preset or custom W:H |
1:1 |
Presets 1:1 | 3:2 | 2:3 | 16:9 | 9:16, or any custom ratio such as 9:21; soft guidance only — custom ratios get neutral canvas-ratio prompt guidance, saved files keep the upstream native aspect ratio (check saved_dimensions) |
reference_images |
string[] | - | Local references used to create a new image |
input_images |
object[] | - | Structured local image inputs with path, optional role, and optional note |
asset_type |
string | - | Where the asset will be used |
constraints |
string | - | Must-keep or must-avoid constraints |
format |
png | jpg | jpeg | webp |
png |
Output format; content is encoded to match the extension |
overwrite |
boolean | false |
Overwrite existing file |
negative_prompt |
string | - | Content to avoid |
reference_max_side |
number | 512 / 256 |
Default 512 for one generation reference and 256 for multiple |
preserve_reference_detail |
boolean | false |
Upload reference inputs without resizing |
silent |
boolean | false |
Disable desktop notification |
Supported input_images.role values:
referencestyle_referencecomposition_referenceinsert_source
| Tool | Meaning | Endpoint |
|---|---|---|
generate_image |
Create a new image; references are optional inputs | /v1/images/generations |
edit_image |
Modify one explicit target and preserve unspecified content | /v1/images/edits |
When an image should only guide a new result, use generate_image. Use
edit_image only for an explicit local change such as removing an object or
changing one color while keeping the original. If the user intent is unclear,
ask before calling either tool. Supplying both image fields returns
E_INPUT_MODE_CONFLICT.
Response:
{
"accepted": true,
"terminal": false,
"status": "submitted",
"task_id": "uuid",
"poll_required": true,
"retry_after_ms": 1000,
"resolved_intent": "generate",
"effective_prompt": "Primary request: ...",
"prompt_stats": {
"characters": 123,
"utf8Bytes": 145,
"lines": 4
},
"message": "已接受异步生成任务;这不代表图片已生成,必须轮询 check_image_task"
}
Tool: edit_image
Edits exactly one original image. It shares the output, sizing, optional supporting-reference, and asynchronous polling parameters above, and adds:
| Parameter | Type | Description |
|---|---|---|
edit_target |
string | Required local path of the single image to modify |
The edit target is always uploaded first. Supporting reference_images or
input_images follow it. The effective prompt tells the model to preserve every
unspecified detail.
Provider output is locally fitted to the requested size template before saving,
so upstream-native dimensions such as 1254x1254 or 1536x1024 do not leak
through the public contract.
Tool: check_image_task
Checks async task status and failure details.
| Parameter | Type | Description |
|---|---|---|
task_id |
string | Task id returned by generate_image or edit_image |
Done response:
{
"success": true,
"terminal": true,
"task_id": "uuid",
"status": "done",
"saved_path": "D:/images/output.png",
"model": "gpt-image-2.6-flare",
"aspect_ratio": "9:21",
"saved_dimensions": "864x2016"
}
Polling responses carry only the status fields above plus
poll_required/retry_after_ms; process metadata such as effective_prompt
and prompt_stats is returned once, on the submission response.
Failed response:
{
"success": false,
"terminal": true,
"task_id": "uuid",
"status": "failed",
"error": "E_PROVIDER_EMPTY_RESPONSE",
"message": "Provider returned HTTP 200 but data contained no image",
"details": {
"request_id": "provider-request-id",
"response_summary": {
"status": 200,
"content_type": "application/json",
"body": {
"kind": "json_object",
"keys": ["data"],
"data_length": 1,
"data_0_keys": []
}
}
}
}
Provider diagnostics contain only response metadata and JSON shape/key summaries; prompt text, image payloads, authorization values, and arbitrary upstream body content are not echoed. The configured provider timeout covers receiving headers, reading the response body, and downloading a returned image URL.
Tool: wait_all_tasks
Blocks server-side until every in-flight task (from generate_image /
edit_image) reaches a terminal state, then returns all results in one
response — each done task carries saved_path, each failed task its error.
This replaces per-task check_image_task polling (and blind sleeps) when you
submit a batch: submit N tasks, then call this once.
| Parameter | Type | Description |
|---|---|---|
timeout_seconds |
number | Optional. Max seconds to block, default 300, range 1–600 |
Semantics:
- The wait set is snapshotted at call time: every task that is still
pending/running. Tasks submitted later are not awaited. - Results never miss a finished image: tasks created since the previous
wait_all_taskscall that already finished are included too (harvest watermark), so images completing before you call wait are still returned — and the same task is never returned twice. failedis also terminal: one failure does not abort the wait; all results come back together inresults.- Returns immediately when nothing is running.
- On timeout it returns completed results plus the still-pending tasks
(
timed_out: true, not an error) — call again to keep waiting, or fall back tocheck_image_task. - If the MCP client cancels the long-running call, the wait stops with the current snapshot; background tasks keep running and stay queryable.
Done response:
{
"all_done": true,
"timed_out": false,
"timeout_seconds": 300,
"elapsed_ms": 76000,
"summary": { "total": 5, "done": 4, "failed": 1, "pending": 0 },
"results": [
{ "task_id": "uuid-1", "status": "done", "saved_path": "D:/images/a.png", "success": true },
{ "task_id": "uuid-2", "status": "failed", "error": "E_PROVIDER_TIMEOUT", "success": false }
],
"message": "全部 5 个任务已到达终态,其中 1 个失败,详见 results。"
}
GPT size request templates
The server maps size tiers and ratios to these request dimensions. Actual output dimensions still depend on the upstream provider response.
size |
1:1 |
3:2 |
2:3 |
16:9 |
9:16 |
|---|---|---|---|---|---|
1K |
1024x1024 |
1536x1024 |
1024x1536 |
1792x1024 |
1024x1792 |
2K |
2048x2048 |
2304x1536 |
1536x2304 |
2560x1440 |
1440x2560 |
4K |
2880x2880 |
3456x2304 |
2304x3456 |
3840x2160 |
2160x3840 |
512px is intentionally unsupported because direct API testing returned Invalid size ... below the current minimum pixel budget.
Custom ratios (measured 2026-09-16)
Any W:H ratio (1-4 digit positive integers) is accepted, e.g. 9:21. The size is
derived by simplifying the ratio and scaling a 16-aligned factor within the tier's
pixel budget (1K ≈ 1.83M, 2K ≈ 3.69M, 4K ≈ 8.29M) with sides capped at 4096:
9:21 maps to 864x2016 (1K), 1248x2912 (2K), 1728x4032 (4K).
The upstream gpt-image-2.5 (measured then; the 2.6 family is expected to behave
the same, still unverified) treats size/aspect_ratio as soft guidance and
silently falls back (a 1024x1024 request can return 1312x1199). Output framing
is prompt-driven: explicit canvas-ratio guidance yields near-exact ratios (a
guided 9:21 request returned 821x1916), so custom ratios automatically inject a
neutral canvas-only line (Canvas: ... rectangle; sets the canvas aspect ratio only; do not reinterpret it as composition, framing, or art direction). Native output stays around 1.5-1.9M pixels regardless of tier; 2K/4K
tiers do not unlock higher native resolution — the gap is filled by proportional local upscaling (no added detail). Since 2026-11-05 saved files keep the upstream native aspect ratio (actual size reported as saved_dimensions); the previous unconditional local crop truncated content whenever upstream deviated, which its soft-guidance behavior makes common.
Transparent backgrounds
The upstream model outputs native alpha when asked — no dedicated parameter is
needed. Put the requirement in prompt or constraints:
Output a true transparent-background PNG with a real alpha channel:
every background pixel must have alpha = 0, the subject stays fully opaque.
Do NOT simulate transparency with a checkerboard pattern or a solid background color.
Loose wording ("transparent background") also works. Both generate_image and
edit_image support this. Verified against the live upstream API on 2026-09-18:
8/8 transparent requests returned genuine RGBA with natural semi-transparent
edges (icons clean; extreme fur edges may show slight color fringe — add
"clean edges, no color fringe" to the prompt if needed). Keep format as
png; encoding to jpg/jpeg discards the alpha channel.
Example
generate_image(
prompt="A futuristic city at sunset",
asset_type="website hero",
constraints="no text, no watermark",
size="2K",
aspect_ratio="16:9",
output_dir="D:/ai-images",
output_filename="city_sunset"
)
check_image_task(task_id="uuid")
Batch workflow — submit everything first, then wait once:
generate_image(...output_filename="shot_01")
generate_image(...output_filename="shot_02")
generate_image(...output_filename="shot_03")
wait_all_tasks(timeout_seconds=300)