mcp-duojie-image 0.7.0 → 0.9.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
@@ -5,7 +5,7 @@ MCP server for image generation via duojie.games GPT image API.
5
5
  ## Features
6
6
 
7
7
  - Text-to-image generation with `gpt-image-2`
8
- - Reference image editing via local image paths, with optional image roles
8
+ - Reference image support: requests with reference images route through `/v1/images/edits` (multipart form); text-only requests route through `/v1/images/generations` (JSON body)
9
9
  - Prompt structuring helpers for use case, asset type, constraints, and effective prompt echo
10
10
  - Optional chroma-key transparent background post-processing
11
11
  - Async submission with task status lookup
@@ -61,6 +61,8 @@ Supported `input_images.role` values:
61
61
  - `composition_reference`
62
62
  - `insert_source`
63
63
 
64
+ **Endpoint routing:** Any request with reference images is sent to `/v1/images/edits` as a multipart form, which correctly handles both reference images and the `size`/`aspect_ratio` parameters. Text-only requests (no reference images) are sent to `/v1/images/generations` as a JSON body. The `role` field on `input_images` is used only for prompt structuring, not for endpoint selection.
65
+
64
66
  When both `input_images` and `reference_images` are provided, `input_images` takes precedence. `generate_image` returns `effective_prompt` so callers can diagnose the exact prompt sent upstream.
65
67
 
66
68
  Response:
package/dist/index.js CHANGED
@@ -34,7 +34,7 @@ const server = new McpServer({
34
34
  version: "0.1.0",
35
35
  });
36
36
  server.registerTool("generate_image", {
37
- description: "Generate image async with gpt-image-2. Return after tool call; don't wait/check.",
37
+ description: "Generate image async with gpt-image-2. Reference images route through /v1/images/edits (multipart form); text-only requests route through /v1/images/generations. Return after tool call; don't wait/check.",
38
38
  inputSchema: z.object({
39
39
  prompt: z.string().min(1).describe("Prompt"),
40
40
  output_dir: z.string().describe("Absolute output dir"),
package/dist/prompt.js CHANGED
@@ -83,5 +83,6 @@ export function preparePrompt(opts) {
83
83
  return {
84
84
  prompt,
85
85
  imagePaths: inputImages?.map((image) => image.path) ?? [],
86
+ imageInputs: inputImages,
86
87
  };
87
88
  }
package/dist/provider.js CHANGED
@@ -105,12 +105,16 @@ async function generateOpenAIImage(config, opts) {
105
105
  const prompt = opts.prompt;
106
106
  const size = mapOpenAISize(opts.size, opts.aspectRatio);
107
107
  const hasReferenceImages = Boolean(opts.referenceImages?.length);
108
- const url = `${config.baseUrl}${hasReferenceImages ? "/v1/images/edits" : "/v1/images/generations"}`;
108
+ // 有参考图 → /v1/images/edits(multipart form)
109
+ // 无参考图 → /v1/images/generations(JSON body,纯文本)
110
+ const useEdits = hasReferenceImages;
111
+ const url = `${config.baseUrl}${useEdits ? "/v1/images/edits" : "/v1/images/generations"}`;
109
112
  let body;
110
113
  let headers = {
111
114
  Authorization: `Bearer ${config.apiKey}`,
112
115
  };
113
- if (hasReferenceImages) {
116
+ if (useEdits) {
117
+ // 有参考图:multipart form
114
118
  const form = new FormData();
115
119
  form.set("model", GPT_IMAGE_MODEL);
116
120
  form.set("prompt", prompt);
@@ -126,6 +130,7 @@ async function generateOpenAIImage(config, opts) {
126
130
  body = form;
127
131
  }
128
132
  else {
133
+ // 纯文本生成
129
134
  headers = { ...headers, "Content-Type": "application/json" };
130
135
  body = JSON.stringify({
131
136
  model: GPT_IMAGE_MODEL,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-duojie-image",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "MCP server for image generation via duojie.games",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",