mcp-duojie-image 0.16.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,13 +4,13 @@ MCP server for image generation via duojie.games GPT image API.
4
4
 
5
5
  ## Features
6
6
 
7
- - Text-to-image generation with the `gpt-image-2.5` model family (`gpt-image-2.5`, `gpt-image-2.5-flare`, `gpt-image-2.5-sunburst`), selectable per request via the `model` parameter (default `gpt-image-2.5`); the removed `gpt-image-2` is no longer offered
7
+ - Text-to-image generation with the `gpt-image-2.6` model family (default, added 2026-11-05) and the retained `gpt-image-2.5` family, each in `gpt-image-*`, `gpt-image-*-flare`, `gpt-image-*-sunburst` variants, selectable per request via the `model` parameter (default `gpt-image-2.6`); the removed `gpt-image-2` is no longer offered
8
8
  - Two business operations: new-image generation with optional references, and explicit local editing
9
9
  - Prompt structuring helpers for use case, asset type, constraints, and effective prompt echo
10
10
  - Native transparent output: ask for an alpha-channel PNG directly in `prompt`/`constraints` (see below)
11
11
  - Async submission with explicit accepted/terminal semantics and required task polling
12
12
  - File saving with overwrite/conflict handling
13
- - Size request templates for `1K`, `2K`, and `4K`, plus arbitrary custom aspect ratios (e.g. `9:21`) with neutral canvas-ratio guidance and exact local cropping
13
+ - Size request templates for `1K`, `2K`, and `4K`, plus arbitrary custom aspect ratios (e.g. `9:21`) with neutral canvas-ratio guidance; saved files keep upstream native dimensions (no local cropping)
14
14
 
15
15
  ## Configuration
16
16
 
@@ -45,7 +45,7 @@ Optional parameters:
45
45
  | Parameter | Type | Default | Description |
46
46
  |---|---|---:|---|
47
47
  | `size` | `1K` \| `2K` \| `4K` | `1K` | Output size tier |
48
- | `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`; custom ratios get neutral canvas-ratio prompt guidance (no art-direction wording) and an exact local crop |
48
+ | `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 upstream native dimensions (check `saved_dimensions`) |
49
49
  | `reference_images` | string[] | - | Local references used to create a new image |
50
50
  | `input_images` | object[] | - | Structured local image inputs with `path`, optional `role`, and optional `note` |
51
51
  | `asset_type` | string | - | Where the asset will be used |
@@ -243,8 +243,7 @@ is prompt-driven: explicit canvas-ratio guidance yields near-exact ratios (a
243
243
  guided 9:21 request returned `821x1916`), so custom ratios automatically inject a
244
244
  neutral canvas-only line (`Canvas: ... rectangle; sets the canvas aspect ratio
245
245
  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
246
- requests are fulfilled by local upscaling. Saved files are always cropped exactly
247
- to the requested ratio.
246
+ tiers do not unlock higher native resolution. Since 2026-11-05 saved files keep the upstream native ratio (actual size reported as `saved_dimensions`); the previous unconditional local crop truncated content whenever upstream deviated, which its soft-guidance behavior makes common.
248
247
 
249
248
  ## Transparent backgrounds
250
249
 
@@ -28,29 +28,3 @@ export async function readDimensions(imageBuffer) {
28
28
  const metadata = await sharp(imageBuffer, { failOn: "none" }).metadata();
29
29
  return `${metadata.width}x${metadata.height}`;
30
30
  }
31
- export async function fitImageToSize(imageBuffer, targetSize) {
32
- const match = targetSize.match(/^(\d+)x(\d+)$/);
33
- if (!match) {
34
- throw new AppError("E_INPUT_INVALID", `Invalid target image size: ${targetSize}`);
35
- }
36
- const width = Number(match[1]);
37
- const height = Number(match[2]);
38
- try {
39
- const metadata = await sharp(imageBuffer, { failOn: "none" }).metadata();
40
- if (metadata.width === width && metadata.height === height) {
41
- return imageBuffer;
42
- }
43
- return await sharp(imageBuffer, { failOn: "none" })
44
- .resize({
45
- width,
46
- height,
47
- fit: "cover",
48
- position: "attention",
49
- })
50
- .png()
51
- .toBuffer();
52
- }
53
- catch (err) {
54
- throw new AppError("E_SAVE_FAILED", `Cannot normalize image to ${targetSize}: ${err}`);
55
- }
56
- }
package/dist/index.js CHANGED
@@ -11,11 +11,11 @@ import { DEFAULT_IMAGE_MODEL, IMAGE_MODEL_IDS, MODEL_GUIDANCE } from "./models.j
11
11
  import { createTask, getTask, updateTask, waitForAllTasks } from "./task-queue.js";
12
12
  import { setServerVersion, taskStatusResponse, taskSubmissionResponse, waitAllTasksResponse, } from "./task-response.js";
13
13
  import { REFERENCE_IMAGE_ROLES, preparePrompt, } from "./prompt.js";
14
- import { OUTPUT_FORMATS, fitImageToSize, readDimensions, } from "./image-processing.js";
14
+ import { OUTPUT_FORMATS, readDimensions, } from "./image-processing.js";
15
15
  const require = createRequire(import.meta.url);
16
16
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
17
  const notifier = require("node-notifier");
18
- export const SERVER_VERSION = "0.16.0";
18
+ export const SERVER_VERSION = "0.18.0";
19
19
  function notify(title, message) {
20
20
  try {
21
21
  notifier.notify({ title, message, sound: false });
@@ -106,8 +106,10 @@ async function submitImageTask(args, operation) {
106
106
  aspectRatio: args.aspect_ratio,
107
107
  referenceMaxSide,
108
108
  });
109
- const upstreamDimensions = await readDimensions(imageBuffer);
110
- imageBuffer = await fitImageToSize(imageBuffer, targetSize);
109
+ // 2026-11-05: 上游对 size/aspect_ratio 仅软引导, 输出比例经常偏离请求。
110
+ // 旧逻辑无条件 cover 裁切到 targetSize 兑现"精确比例"承诺, 导致大幅内容
111
+ // 截断 (用户反馈 + 实测 16:9 被吸到 2:3 时裁掉 62% 竖向内容)。改为落盘
112
+ // 上游原生图, 实际尺寸以 saved_dimensions 为准。
111
113
  const savedDimensions = await readDimensions(imageBuffer);
112
114
  const savedPath = await saveImage(imageBuffer, {
113
115
  outputDir: args.output_dir,
@@ -119,7 +121,6 @@ async function submitImageTask(args, operation) {
119
121
  status: "done",
120
122
  completedAt: Date.now(),
121
123
  savedPath,
122
- upstreamDimensions,
123
124
  savedDimensions,
124
125
  });
125
126
  await server.sendLoggingMessage({
@@ -163,7 +164,7 @@ const commonFields = {
163
164
  size: z.enum(IMAGE_SIZES).optional().describe("Default 1K"),
164
165
  model: z.enum(IMAGE_MODEL_IDS).optional().describe(MODEL_GUIDANCE),
165
166
  aspect_ratio: z.string().regex(new RegExp(CUSTOM_ASPECT_RATIO_PATTERN), "aspect_ratio must be W:H with 1-4 digit positive parts, e.g. 1:1, 16:9, 9:21").optional()
166
- .describe("W:H, e.g. 1:1, 16:9, 9:21. Default 1:1; output file matches exactly"),
167
+ .describe("W:H, e.g. 1:1, 16:9, 9:21. Default 1:1; soft guidance only — saved file keeps upstream native dimensions, check saved_dimensions"),
167
168
  format: z.enum(OUTPUT_FORMATS).optional().describe("Default png"),
168
169
  overwrite: z.boolean().optional().describe("Default false; same-name file fails"),
169
170
  negative_prompt: z.string().optional().describe("Content to avoid"),
package/dist/models.js CHANGED
@@ -1,27 +1,44 @@
1
1
  // 实测(2026-09-10,/v1/images/generations 与 /v1/images/edits):
2
2
  // 三个模型请求/响应结构一致,同步返回 b64_json,size 映射表通用。
3
3
  // gpt-image-2 已按上游要求下线,不再提供。
4
+ // gpt-image-2.6 家族(2026-11-05 上架):2.5 家族保留可显式指定;
5
+ // 2.6 尚无实测记录(size/比例软引导行为是否同 2.5 待验证,见 prompt.ts 实测注释)。
4
6
  export const IMAGE_MODELS = {
7
+ "gpt-image-2.6": {
8
+ id: "gpt-image-2.6",
9
+ name: "GPT Image 2.6",
10
+ description: "Newest generation (2026-11): latest quality, newly added and under evaluation.",
11
+ },
12
+ "gpt-image-2.6-flare": {
13
+ id: "gpt-image-2.6-flare",
14
+ name: "GPT Image 2.6 Flare",
15
+ description: "Speed-optimized variant of 2.6: fastest, best for drafts, iterations, and previews.",
16
+ },
17
+ "gpt-image-2.6-sunburst": {
18
+ id: "gpt-image-2.6-sunburst",
19
+ name: "GPT Image 2.6 Sunburst",
20
+ description: "Quality-optimized variant of 2.6: best detail and prompt adherence; slowest.",
21
+ },
5
22
  "gpt-image-2.5": {
6
23
  id: "gpt-image-2.5",
7
24
  name: "GPT Image 2.5",
8
- description: "Balanced default: solid quality and speed for everyday generation and editing.",
25
+ description: "Previous generation, verified behavior: solid quality and speed for everyday generation and editing.",
9
26
  },
10
27
  "gpt-image-2.5-flare": {
11
28
  id: "gpt-image-2.5-flare",
12
29
  name: "GPT Image 2.5 Flare",
13
- description: "Speed-optimized variant: fastest of the three, best for drafts, iterations, and previews.",
30
+ description: "Speed-optimized variant of 2.5: fastest of the 2.5 family, best for drafts, iterations, and previews.",
14
31
  },
15
32
  "gpt-image-2.5-sunburst": {
16
33
  id: "gpt-image-2.5-sunburst",
17
34
  name: "GPT Image 2.5 Sunburst",
18
- description: "Quality-optimized variant: best detail and prompt adherence for final deliverables; slowest.",
35
+ description: "Quality-optimized variant of 2.5: best detail and prompt adherence for final deliverables; slowest.",
19
36
  },
20
37
  };
21
38
  export const IMAGE_MODEL_IDS = Object.keys(IMAGE_MODELS);
22
- export const DEFAULT_IMAGE_MODEL = "gpt-image-2.5";
39
+ export const DEFAULT_IMAGE_MODEL = "gpt-image-2.6";
23
40
  export function isImageModelId(value) {
24
41
  return value in IMAGE_MODELS;
25
42
  }
26
43
  /** 供 model 参数 describe 使用的精简版模型选择说明;"未指定时先询问"的规则由 AGENTS.md 承担 */
27
- export const MODEL_GUIDANCE = `Default gpt-image-2.5 (balanced); flare = fastest, drafts; sunburst = best quality, slowest`;
44
+ export const MODEL_GUIDANCE = `Default gpt-image-2.6 (newest generation); 2.5 family retained; flare = fastest, drafts; sunburst = best quality, slowest`;
package/dist/provider.js CHANGED
@@ -3,7 +3,8 @@ import { resizeIfNeeded } from "./resizer.js";
3
3
  import { DEFAULT_IMAGE_MODEL } from "./models.js";
4
4
  export const ASPECT_RATIOS = ["1:1", "3:2", "2:3", "16:9", "9:16"];
5
5
  // 2026-09-16 实测: 上游 gpt-image-2.5 不精确执行 size/aspect_ratio (软引导 + 静默 fallback),
6
- // 自定义比例需语义引导贴近, 再由本地 fitImageToSize 裁到精确比例。
6
+ // 自定义比例需语义引导贴近。2026-11-05 起不再本地裁切兑现精确比例
7
+ // (曾用 cover 裁切, 因上游比例偏离常态化导致内容截断), 落盘保持上游原生比例。
7
8
  export const CUSTOM_ASPECT_RATIO_PATTERN = "^([1-9]\\d{0,3}):([1-9]\\d{0,3})$";
8
9
  const CUSTOM_ASPECT_RATIO_RE = new RegExp(CUSTOM_ASPECT_RATIO_PATTERN);
9
10
  export function isPresetAspectRatio(value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-duojie-image",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "MCP server for image generation via duojie.games",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",