imageforge-mcp 0.4.0 → 0.6.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
@@ -2,20 +2,20 @@
2
2
 
3
3
  English | [中文](#中文说明)
4
4
 
5
- A lightweight TypeScript MCP server for generating and editing images with OpenAI `gpt-image-2`, and for text-to-image generation with Zhipu BigModel image models.
5
+ A lightweight TypeScript MCP server for image generation across 22 first-party providers, plus OpenAI image editing.
6
6
 
7
- - OpenAI text-to-image requests use `POST /v1/images/generations`; Zhipu uses `POST /api/paas/v4/images/generations`.
7
+ - Provider adapters follow each vendor's documented synchronous or submit-and-poll REST contract.
8
8
  - OpenAI image editing and reference-image generation use multipart `POST /v1/images/edits`.
9
9
  - Generated images are returned as native MCP `image` content blocks and can optionally be saved locally.
10
10
 
11
11
  ## Features
12
12
 
13
- - OpenAI model: `gpt-image-2`
14
- - Zhipu models: `glm-image`, `cogview-4-250304`, `cogview-4`, `cogview-3-flash`
15
- - MCP tools: `generate_image` and `edit_image`
13
+ - 22 provider IDs: `openai`, `zhipu`, `minimax`, `google`, `xai`, `stability`, `ideogram`, `recraft`, `tencent`, `baidu`, `playground`, `bfl`, `luma`, `krea`, `runway`, `leonardo`, `bria`, `freepik`, `alibaba`, `volcengine`, `kling`, and `hidream`
14
+ - MCP tools: `generate_image`, `list_image_providers`, and `edit_image`
16
15
  - Text-to-image generation
17
16
  - Image generation guided by one or more reference images
18
17
  - Zhipu text-to-image generation with optional server-side watermark control
18
+ - MiniMax text-to-image and single-subject reference generation
19
19
  - Editing one or more existing images
20
20
  - Local absolute paths and HTTP(S) URLs as image inputs
21
21
  - PNG, JPEG, and WebP input and output
@@ -27,16 +27,15 @@ A lightweight TypeScript MCP server for generating and editing images with OpenA
27
27
 
28
28
  ## Provider capability matrix
29
29
 
30
- | Capability | OpenAI | Zhipu |
30
+ | Group | Providers | Execution |
31
31
  | --- | --- | --- |
32
- | Text-to-image | Yes | Yes |
33
- | Reference-image generation | Yes, through `reference_images` | No; the tool returns an error before reading files or sending a request |
34
- | Image editing | Yes, through `edit_image` | No |
35
- | Models | `gpt-image-2` | `glm-image`, `cogview-4-250304`, `cogview-4`, `cogview-3-flash` |
36
- | Quality values | `auto`, `low`, `medium`, `high` | `glm-image`: `auto`, `hd`; other models: `auto`, `standard`, `hd` |
37
- | `watermark_enabled` | Ignored without error | Forwarded only when explicitly supplied |
38
- | `output_format` | Sent to the provider | Ignored; MIME type is detected from the downloaded image |
39
- | Provider response | Base64 image data | Temporary image URL, downloaded immediately by ImageForge |
32
+ | Existing compatibility | OpenAI, Zhipu, MiniMax | Synchronous |
33
+ | Additional synchronous APIs | Google Gemini, xAI, Stability AI, Ideogram, Recraft, Tencent Hunyuan, Baidu Qianfan, Playground, Volcengine Ark | Synchronous |
34
+ | Task APIs | Black Forest Labs, Luma, Krea, Runway, Leonardo, Bria, Freepik/Magnific, Alibaba Model Studio, Kling, HiDream | Submit once, then poll read-only status endpoints |
35
+
36
+ Call `list_image_providers` for the authoritative model list, default model, reference modes and limits, required environment-variable names, documentation URL, and contract-verification state. New 0.6.0 adapters are implemented from official documentation and covered by mocks; they are not represented as live credential verification.
37
+
38
+ `generate_image` keeps the existing common fields and adds `reference_mode` (`auto`, `content`, `style`, or `character`), `aspect_ratio`, `resolution`, `negative_prompt`, and `seed`. Unsupported combinations fail before provider access. `edit_image` remains OpenAI-only.
40
39
 
41
40
  ## Zhipu BigModel support
42
41
 
@@ -62,6 +61,20 @@ Zhipu returns one temporary image URL. ImageForge downloads it immediately and r
62
61
 
63
62
  See the [official Zhipu image generation API](https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E5%9B%BE%E5%83%8F%E7%94%9F%E6%88%90) for current provider-side size, quality, watermark, and account-policy rules.
64
63
 
64
+ ## MiniMax support
65
+
66
+ ImageForge calls `POST /v1/image_generation` with Bearer authentication, requests one Base64 image, and returns the MIME detected from the decoded bytes. It supports `image-01` and `image-01-live`; MiniMax credentials never fall back to OpenAI or Zhipu variables.
67
+
68
+ - `image-01`: `size` becomes explicit `width` and `height`; each must be 512–2048 and divisible by 8, with at least `1024×1024` total pixels.
69
+ - `image-01-live`: `size` is reduced to an exact supported aspect ratio. Unsupported ratios fail before the request.
70
+ - `quality` must be `auto`; the provider has no quality field.
71
+ - Output is JPEG. Omit `output_format` or set it to `jpeg`; `png` and `webp` fail before the request because ImageForge does not transcode images.
72
+ - `reference_images` accepts at most one PNG/JPEG under 10 MB. ImageForge safely loads it and sends a Base64 Data URL as a `character` subject reference.
73
+ - `watermark_enabled` maps to `aigc_watermark` only when explicitly supplied.
74
+ - Paid requests are never retried automatically and are never switched to another provider.
75
+
76
+ See the [official MiniMax image-generation guide](https://platform.minimaxi.com/docs/guides/image-generation) for current provider behavior.
77
+
65
78
  ## OpenAI-compatible CPA and gateway support
66
79
 
67
80
  ImageForge MCP works with OpenAI and with CPA, relay, or proxy services that implement a compatible OpenAI Images API. This includes deployments based on projects such as **New API**, **CLI Proxy API**, and similar OpenAI-compatible gateways.
@@ -78,7 +91,7 @@ A gateway that only implements `/v1/images/generations` can be used for text-to-
78
91
  ## Requirements
79
92
 
80
93
  - Node.js 22 or later
81
- - An OpenAI API key or a compatible gateway token; a Zhipu API key is needed only when using the `zhipu` provider
94
+ - A credential for the selected provider; see `.env.example` or `list_image_providers`
82
95
 
83
96
  ## Install and build
84
97
 
@@ -108,7 +121,7 @@ For production use, start the published npm package with `npx`. No repository cl
108
121
  }
109
122
  ```
110
123
 
111
- `-y` allows `npx` to download or update the package without an interactive install prompt. Pin a specific version when reproducible deployments are required, for example `"imageforge-mcp@0.4.0"`.
124
+ `-y` allows `npx` to download or update the package without an interactive install prompt. Pin a specific version when reproducible deployments are required, for example `"imageforge-mcp@0.6.0"`.
112
125
 
113
126
  For a Zhipu-default MCP server, use an independent credential and provider configuration:
114
127
 
@@ -117,7 +130,7 @@ For a Zhipu-default MCP server, use an independent credential and provider confi
117
130
  "mcpServers": {
118
131
  "imageforge-zhipu": {
119
132
  "command": "npx",
120
- "args": ["-y", "imageforge-mcp@0.4.0"],
133
+ "args": ["-y", "imageforge-mcp@0.6.0"],
121
134
  "env": {
122
135
  "IMAGEFORGE_PROVIDER": "zhipu",
123
136
  "ZHIPU_API_KEY": "your-zhipu-token",
@@ -130,6 +143,26 @@ For a Zhipu-default MCP server, use an independent credential and provider confi
130
143
 
131
144
  `ZHIPU_BASE_URL` is optional and defaults to `https://open.bigmodel.cn/api/paas/v4`. `ZHIPU_IMAGE_MODEL` is optional and defaults to `glm-image`. Zhipu credentials never fall back to OpenAI variables, and OpenAI credentials never fall back to Zhipu variables. A per-call `provider`, `api_key`, `base_url`, or `model` overrides the corresponding environment configuration.
132
145
 
146
+ For a MiniMax-default server:
147
+
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "imageforge-minimax": {
152
+ "command": "npx",
153
+ "args": ["-y", "imageforge-mcp@0.6.0"],
154
+ "env": {
155
+ "IMAGEFORGE_PROVIDER": "minimax",
156
+ "MINIMAX_API_KEY": "your-minimax-token",
157
+ "MINIMAX_IMAGE_MODEL": "image-01"
158
+ }
159
+ }
160
+ }
161
+ }
162
+ ```
163
+
164
+ `MINIMAX_BASE_URL` defaults to `https://api.minimaxi.com/v1`; `MINIMAX_IMAGE_MODEL` defaults to `image-01`. MiniMax credentials are isolated from OpenAI and Zhipu credentials.
165
+
133
166
  `OPENAI_BASE_URL` is optional. When it is unset, ImageForge MCP uses the official OpenAI endpoint `https://api.openai.com/v1`. Set it only when using New API, CLI Proxy API, or another OpenAI-compatible gateway:
134
167
 
135
168
  ```json
@@ -140,6 +173,8 @@ The value must point to the gateway's `/v1` root. ImageForge MCP appends `/image
140
173
 
141
174
  `IMAGEFORGE_INPUT_CONCURRENCY` optionally controls how many local or remote input images are loaded at once. It defaults to `4`, must be a positive integer, and is capped at the per-call limit of `16` input images. The combined input size remains capped at 200 MB.
142
175
 
176
+ Task-based providers submit a paid generation request exactly once and then poll read-only status endpoints. `IMAGEFORGE_ASYNC_TIMEOUT_MS` defaults to `300000` and accepts 30000–600000; `IMAGEFORGE_POLL_INTERVAL_MS` defaults to `2000` and accepts 500–10000. Polling honors numeric `Retry-After` values within the same bounds. ImageForge does not use webhooks, retry a paid create call, or fall back to another provider.
177
+
143
178
  DNS safety checks are enabled by default. Set `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS=true` only when private-network or DNS-proxy image URLs must be supported. This disables non-public address rejection and DNS pinning for every redirect hop, which can expose the MCP process to SSRF. HTTP(S)-only URLs, the credential restriction, redirect limit, size limits, and image signature validation remain enforced. Accepted true values are `true`, `1`, `yes`, and `on`; false values are `false`, `0`, `no`, and `off`.
144
179
 
145
180
  Do not commit real API keys to Git or write them into shared configuration files.
@@ -153,7 +188,7 @@ Create a project-scoped `.codex/config.toml` using paths that match your machine
153
188
  command = "/absolute/path/to/node"
154
189
  args = ["/absolute/path/to/ImageForgeMCP/dist/index.js"]
155
190
  cwd = "/absolute/path/to/ImageForgeMCP"
156
- env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL", "ZHIPU_API_KEY", "ZHIPU_BASE_URL", "ZHIPU_IMAGE_MODEL", "IMAGEFORGE_PROVIDER", "IMAGEFORGE_INPUT_CONCURRENCY", "IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS"]
191
+ env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL", "ZHIPU_API_KEY", "ZHIPU_BASE_URL", "ZHIPU_IMAGE_MODEL", "MINIMAX_API_KEY", "MINIMAX_BASE_URL", "MINIMAX_IMAGE_MODEL", "IMAGEFORGE_PROVIDER", "IMAGEFORGE_INPUT_CONCURRENCY", "IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS"]
157
192
  startup_timeout_sec = 10
158
193
  tool_timeout_sec = 300
159
194
  enabled = true
@@ -181,9 +216,12 @@ export ZHIPU_IMAGE_MODEL="glm-image"
181
216
  # Optional: export ZHIPU_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
182
217
  ```
183
218
 
219
+ For MiniMax, export `IMAGEFORGE_PROVIDER=minimax`, `MINIMAX_API_KEY`, and optionally `MINIMAX_IMAGE_MODEL=image-01` or `image-01-live`.
220
+
184
221
  Codex loads project-scoped `.codex/config.toml` only for trusted projects. After adding or changing the MCP configuration, restart Codex or open a new task, then use `/mcp verbose` to confirm that `imageforge_dev` exposes:
185
222
 
186
223
  - `generate_image`
224
+ - `list_image_providers`
187
225
  - `edit_image`
188
226
 
189
227
  After changing the TypeScript source, rebuild `dist/index.js` and restart the task using the MCP server:
@@ -199,18 +237,18 @@ See the [official Codex MCP documentation](https://developers.openai.com/codex/m
199
237
  | Parameter | Required | Default | Description |
200
238
  | --- | --- | --- | --- |
201
239
  | `prompt` | Yes | - | Image description |
202
- | `model` | No | Environment or provider default | OpenAI: `gpt-image-2`; Zhipu: `glm-image`, `cogview-4-250304`, `cogview-4`, `cogview-3-flash` |
203
- | `base_url` | No | `OPENAI_BASE_URL` or `ZHIPU_BASE_URL` | Per-call provider API base URL override |
204
- | `api_key` | No | `OPENAI_API_KEY` or `ZHIPU_API_KEY` | Per-call provider credential override; environment variables are preferred |
205
- | `provider` | No | `IMAGEFORGE_PROVIDER`, then `openai` | `openai` or `zhipu` |
240
+ | `model` | No | Environment or provider default | OpenAI: `gpt-image-2`; Zhipu models above; MiniMax: `image-01`, `image-01-live` |
241
+ | `base_url` | No | Provider environment variable or official default | Per-call provider API base URL override |
242
+ | `api_key` | No | Provider-specific API key | Per-call provider credential override; environment variables are preferred |
243
+ | `provider` | No | `IMAGEFORGE_PROVIDER`, then `openai` | `openai`, `zhipu`, or `minimax` |
206
244
  | `size` | No | `1024x1024` | Output size requested from the provider |
207
- | `quality` | No | `auto` | OpenAI: `auto/low/medium/high`; `glm-image`: `auto/hd`; other Zhipu models: `auto/standard/hd` |
208
- | `output_format` | No | `png` | `png`, `jpeg`, or `webp` |
245
+ | `quality` | No | `auto` | OpenAI and Zhipu values above; MiniMax accepts only `auto` |
246
+ | `output_format` | No | `png`; MiniMax: `jpeg` | OpenAI: `png/jpeg/webp`; Zhipu ignores it; MiniMax accepts only `jpeg` |
209
247
  | `output_path` | No | - | Local save path; relative paths resolve from the MCP working directory |
210
- | `watermark_enabled` | No | - | Sent only to Zhipu when set; `false` may require watermark-removal account permission. Unsupported providers ignore it |
211
- | `reference_images` | No | - | OpenAI reference images as local absolute paths or HTTP(S) URLs; Zhipu rejects this parameter |
248
+ | `watermark_enabled` | No | - | Sent to Zhipu or mapped to MiniMax `aigc_watermark` only when explicitly supplied |
249
+ | `reference_images` | No | - | OpenAI: 1–16; MiniMax: one PNG/JPEG under 10 MB; Zhipu rejects it |
212
250
 
213
- Without `reference_images`, the tool uses `/images/generations`. With OpenAI reference images, it uploads them as multipart `image[]` files to `/images/edits`.
251
+ For OpenAI, calls without `reference_images` use `/images/generations`; reference images use multipart `/images/edits`. MiniMax always uses `/image_generation` and maps its single reference to `subject_reference`.
214
252
 
215
253
  Zhipu supports synchronous text-to-image only. It rejects `reference_images` before reading the referenced files or making a request, does not support `edit_image`, and ignores `output_format`. No Authorization header is sent to the image CDN, and the returned MCP MIME type is based on the downloaded image bytes.
216
254
 
@@ -254,6 +292,33 @@ Faster CogView request using provider-standard quality:
254
292
 
255
293
  Common Zhipu failures are returned as tool errors with the HTTP status and a provider response excerpt of at most 500 characters. Authentication failures must be fixed rather than retried; HTTP 429 with business code `1113` means the account balance is insufficient, while other 429 codes can indicate rate, model-load, or account-plan limits. ImageForge does not automatically retry paid generation requests. See the [official Zhipu error-code reference](https://docs.bigmodel.cn/cn/faq/api-code) for current business-code meanings.
256
294
 
295
+ MiniMax text-to-image:
296
+
297
+ ```json
298
+ {
299
+ "provider": "minimax",
300
+ "model": "image-01",
301
+ "prompt": "A quiet coastal village at sunrise, cinematic light, no text",
302
+ "size": "1536x1024",
303
+ "output_format": "jpeg",
304
+ "output_path": "outputs/minimax-village.jpeg"
305
+ }
306
+ ```
307
+
308
+ MiniMax single-subject reference generation:
309
+
310
+ ```json
311
+ {
312
+ "provider": "minimax",
313
+ "model": "image-01",
314
+ "prompt": "Keep the reference character and place them in a quiet library, natural light",
315
+ "reference_images": ["/absolute/path/to/character.jpg"],
316
+ "output_format": "jpeg"
317
+ }
318
+ ```
319
+
320
+ MiniMax requires exactly one `reference_images` entry for this mode. `image-01-live` converts `size` to an exact supported aspect ratio instead of sending custom dimensions.
321
+
257
322
  ## `edit_image`
258
323
 
259
324
  `edit_image` uses the same model, API, output, and local-save parameters as `generate_image`, but requires `input_images`:
@@ -271,6 +336,22 @@ When `output_path` is supplied, ImageForge MCP returns the native MCP image cont
271
336
 
272
337
  Some OpenAI-compatible gateways may return dimensions different from the requested `size`; the actual returned file dimensions are authoritative.
273
338
 
339
+ ## Maintainer release script
340
+
341
+ Run the release workflow from a Git checkout of this repository:
342
+
343
+ ```bash
344
+ # Read-only checks; allows a dirty worktree but prints a warning.
345
+ bash script/release.sh
346
+
347
+ # Actual npm publication.
348
+ bash script/release.sh --publish
349
+ ```
350
+
351
+ The default check mode verifies version consistency, Git whitespace, TypeScript build, all tests, production dependency audit, the npm file list, npm publication dry-run, npm authentication when available, and whether the current version already exists in the Registry. If the version exists but its Registry shasum differs from the local package, the check fails and requires a version bump.
352
+
353
+ `--publish` additionally requires branch `main`, a clean worktree, local `HEAD` equal to `origin/main`, an authenticated npm account, and an unpublished package version. It publishes with public access and the `latest` tag, then waits for the exact version and `latest` tag to become visible in the Registry and prints the Registry shasum. The script intentionally does not change versions, create commits, push Git branches, create tags, retry a failed publication, or overwrite an existing npm version.
354
+
274
355
  ## Verification
275
356
 
276
357
  ```bash
@@ -288,19 +369,19 @@ Tests use a local HTTP mock. They do not call a real image API or incur generati
288
369
 
289
370
  # 中文说明
290
371
 
291
- ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,支持通过 OpenAI Images API 调用 `gpt-image-2`,并支持通过智谱 BigModel API 进行文生图。
372
+ ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,支持 22 个原厂生图 Provider,并保留 OpenAI 图片编辑能力。
292
373
 
293
- - OpenAI 纯文本生图调用 `POST /v1/images/generations`;智谱调用 `POST /api/paas/v4/images/generations`。
374
+ - Provider 按官方同步接口或“提交任务后轮询”REST 契约调用。
294
375
  - OpenAI 图片编辑和参考图生图调用 multipart `POST /v1/images/edits`。
295
376
  - 生成结果以原生 MCP `image` 内容块返回,也可以同时保存到本地。
296
377
 
297
378
  ## 功能
298
379
 
299
- - OpenAI 模型:`gpt-image-2`
300
- - 智谱模型:`glm-image`、`cogview-4-250304`、`cogview-4`、`cogview-3-flash`
301
- - MCP 工具:`generate_image`、`edit_image`
380
+ - 22 个 Provider ID:`openai`、`zhipu`、`minimax`、`google`、`xai`、`stability`、`ideogram`、`recraft`、`tencent`、`baidu`、`playground`、`bfl`、`luma`、`krea`、`runway`、`leonardo`、`bria`、`freepik`、`alibaba`、`volcengine`、`kling`、`hidream`
381
+ - MCP 工具:`generate_image`、`list_image_providers`、`edit_image`
302
382
  - 支持纯文本生图
303
383
  - 支持一张或多张参考图引导生图
384
+ - 支持 MiniMax 单张主体参考图生图
304
385
  - 支持一张或多张图片编辑
305
386
  - 输入图片支持本地绝对路径和 HTTP(S) URL
306
387
  - 输入与输出支持 PNG、JPEG、WebP
@@ -312,16 +393,15 @@ ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,
312
393
 
313
394
  ## 供应商能力矩阵
314
395
 
315
- | 能力 | OpenAI | 智谱 |
396
+ | 分组 | Provider | 执行方式 |
316
397
  | --- | --- | --- |
317
- | 文生图 | 支持 | 支持 |
318
- | 参考图生图 | 支持,通过 `reference_images` | 不支持;会在读取文件和发送请求前明确报错 |
319
- | 图片编辑 | 支持,通过 `edit_image` | 不支持 |
320
- | 模型 | `gpt-image-2` | `glm-image`、`cogview-4-250304`、`cogview-4`、`cogview-3-flash` |
321
- | quality | `auto`、`low`、`medium`、`high` | `glm-image`:`auto`、`hd`;其他模型:`auto`、`standard`、`hd` |
322
- | `watermark_enabled` | 静默忽略 | 仅显式传入时转发 |
323
- | `output_format` | 发送给供应商 | 忽略,以下载图片的真实 MIME 为准 |
324
- | 供应商响应 | Base64 图片数据 | 临时图片 URL,由 ImageForge 立即下载 |
398
+ | 现有兼容 | OpenAI、智谱、MiniMax | 同步 |
399
+ | 新增同步接口 | Google Gemini、xAI、Stability AI、Ideogram、Recraft、腾讯混元、百度千帆、Playground、火山方舟 | 同步 |
400
+ | 任务型接口 | Black Forest Labs、Luma、Krea、Runway、Leonardo、Bria、Freepik/Magnific、阿里 Model Studio、Kling、HiDream | 创建一次,随后只读轮询 |
401
+
402
+ 调用 `list_image_providers` 可查询权威模型列表、默认模型、参考图模式和上限、环境变量名、官方文档地址与合约验证状态。0.6.0 新增适配器均按官方文档和 Mock 合约测试实现,不宣称已经使用真实密钥验收。
403
+
404
+ `generate_image` 在原参数上新增 `reference_mode`(`auto`、`content`、`style`、`character`)、`aspect_ratio`、`resolution`、`negative_prompt` `seed`;不支持的组合会在访问供应商前失败。`edit_image` 仍仅支持 OpenAI。
325
405
 
326
406
  ## 智谱 BigModel 支持
327
407
 
@@ -347,6 +427,20 @@ ImageForge 使用 Bearer 认证调用智谱官方图片生成接口,各模型
347
427
 
348
428
  智谱服务端当前尺寸、质量、水印和账号政策应以[官方图片生成 API 文档](https://docs.bigmodel.cn/api-reference/%E6%A8%A1%E5%9E%8B-api/%E5%9B%BE%E5%83%8F%E7%94%9F%E6%88%90)为准。
349
429
 
430
+ ## MiniMax 支持
431
+
432
+ ImageForge 使用 Bearer 认证调用 `POST /v1/image_generation`,固定请求一张 Base64 图片,并根据解码后的真实图片内容返回 MIME。支持 `image-01` 和 `image-01-live`,MiniMax 密钥不会回退到 OpenAI 或智谱配置。
433
+
434
+ - `image-01`:将 `size` 转为 `width`、`height`,宽高须在 512–2048、均为 8 的倍数,且总像素不少于 `1024×1024`。
435
+ - `image-01-live`:将 `size` 约分为精确支持的宽高比;不支持的比例在请求前失败。
436
+ - `quality` 仅接受 `auto`。
437
+ - 输出仅支持 JPEG;省略 `output_format` 或传 `jpeg`,传 `png`/`webp` 会在请求前失败,不做本地转码。
438
+ - `reference_images` 最多一张 PNG/JPEG 且小于 10 MB,安全加载后以 `character` 主体 Data URL 发送。
439
+ - `watermark_enabled` 仅显式传入时映射为 `aigc_watermark`。
440
+ - 不自动重试收费请求,也不自动切换供应商。
441
+
442
+ 供应商行为以 [MiniMax 官方图片生成指南](https://platform.minimaxi.com/docs/guides/image-generation)为准。
443
+
350
444
  ## OpenAI 兼容 CPA 与网关
351
445
 
352
446
  ImageForge MCP 不仅支持 OpenAI 官方接口,也支持实现了 OpenAI Images API 兼容协议的 CPA、中转或代理服务,包括基于 **New API**、**CLI Proxy API** 等项目部署的 OpenAI 兼容网关。
@@ -363,7 +457,7 @@ ImageForge MCP 不仅支持 OpenAI 官方接口,也支持实现了 OpenAI Imag
363
457
  ## 环境要求
364
458
 
365
459
  - Node.js 22 或更高版本
366
- - OpenAI API Key,或 OpenAI 兼容 CPA/网关签发的令牌
460
+ - 所选 Provider 的凭据;完整变量名见 `.env.example` `list_image_providers`
367
461
 
368
462
  ## 安装与构建
369
463
 
@@ -393,7 +487,7 @@ npm run build
393
487
  }
394
488
  ```
395
489
 
396
- `-y` 允许 `npx` 在没有交互式安装提示的情况下下载或更新包。如果部署需要固定版本,可将包名写成 `"imageforge-mcp@0.4.0"`。
490
+ `-y` 允许 `npx` 在没有交互式安装提示的情况下下载或更新包。如果部署需要固定版本,可将包名写成 `"imageforge-mcp@0.6.0"`。
397
491
 
398
492
  如果希望 MCP 默认使用智谱,应使用独立的智谱凭据与供应商配置:
399
493
 
@@ -402,7 +496,7 @@ npm run build
402
496
  "mcpServers": {
403
497
  "imageforge-zhipu": {
404
498
  "command": "npx",
405
- "args": ["-y", "imageforge-mcp@0.4.0"],
499
+ "args": ["-y", "imageforge-mcp@0.6.0"],
406
500
  "env": {
407
501
  "IMAGEFORGE_PROVIDER": "zhipu",
408
502
  "ZHIPU_API_KEY": "你的智谱令牌",
@@ -415,6 +509,26 @@ npm run build
415
509
 
416
510
  `ZHIPU_BASE_URL` 可选,默认值为 `https://open.bigmodel.cn/api/paas/v4`;`ZHIPU_IMAGE_MODEL` 可选,默认值为 `glm-image`。智谱与 OpenAI 的环境密钥不会互相回退。单次调用传入的 `provider`、`api_key`、`base_url` 或 `model` 优先于对应环境变量。
417
511
 
512
+ MiniMax 默认配置示例:
513
+
514
+ ```json
515
+ {
516
+ "mcpServers": {
517
+ "imageforge-minimax": {
518
+ "command": "npx",
519
+ "args": ["-y", "imageforge-mcp@0.6.0"],
520
+ "env": {
521
+ "IMAGEFORGE_PROVIDER": "minimax",
522
+ "MINIMAX_API_KEY": "你的-MiniMax-令牌",
523
+ "MINIMAX_IMAGE_MODEL": "image-01"
524
+ }
525
+ }
526
+ }
527
+ }
528
+ ```
529
+
530
+ `MINIMAX_BASE_URL` 默认 `https://api.minimaxi.com/v1`,`MINIMAX_IMAGE_MODEL` 默认 `image-01`。MiniMax、OpenAI 与智谱凭据互不回退。
531
+
418
532
  `OPENAI_BASE_URL` 是可选配置。不设置时,ImageForge MCP 默认使用 OpenAI 官方接口 `https://api.openai.com/v1`。只有使用 New API、CLI Proxy API 或其他 OpenAI 兼容网关时才需要设置:
419
533
 
420
534
  ```json
@@ -425,6 +539,8 @@ npm run build
425
539
 
426
540
  `IMAGEFORGE_INPUT_CONCURRENCY` 可选,用于控制同时加载的本地或远程输入图片数量。默认值为 `4`,必须是正整数,并直接受单次最多 `16` 张输入图片的限制。单次调用的输入图片合计大小仍固定限制为 200 MB。
427
541
 
542
+ 任务型 Provider 只提交一次收费生图请求,之后仅轮询只读状态接口。`IMAGEFORGE_ASYNC_TIMEOUT_MS` 默认 `300000`、范围 30000–600000;`IMAGEFORGE_POLL_INTERVAL_MS` 默认 `2000`、范围 500–10000。轮询会在同一边界内遵循数值型 `Retry-After`。ImageForge 不使用 webhook、不重试收费创建请求,也不回退到其他 Provider。
543
+
428
544
  DNS 安全检查默认启用。只有确实需要访问私有网络地址或 DNS 代理生成的图片地址时,才应设置 `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS=true`。启用后,每次重定向都不再执行非公网地址拦截和 DNS 地址固定,可能使 MCP 进程面临 SSRF 风险。HTTP(S) 协议限制、URL 凭据限制、重定向次数、图片大小和图片魔数校验仍然有效。真值支持 `true`、`1`、`yes`、`on`,假值支持 `false`、`0`、`no`、`off`。
429
545
 
430
546
  不要把真实 API Key 写入 Git 或其他共享配置文件。
@@ -438,7 +554,7 @@ DNS 安全检查默认启用。只有确实需要访问私有网络地址或 DNS
438
554
  command = "/你的/node/绝对路径"
439
555
  args = ["/你的/ImageForgeMCP/绝对路径/dist/index.js"]
440
556
  cwd = "/你的/ImageForgeMCP/绝对路径"
441
- env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL", "ZHIPU_API_KEY", "ZHIPU_BASE_URL", "ZHIPU_IMAGE_MODEL", "IMAGEFORGE_PROVIDER", "IMAGEFORGE_INPUT_CONCURRENCY", "IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS"]
557
+ env_vars = ["OPENAI_API_KEY", "OPENAI_BASE_URL", "OPENAI_IMAGE_MODEL", "ZHIPU_API_KEY", "ZHIPU_BASE_URL", "ZHIPU_IMAGE_MODEL", "MINIMAX_API_KEY", "MINIMAX_BASE_URL", "MINIMAX_IMAGE_MODEL", "IMAGEFORGE_PROVIDER", "IMAGEFORGE_INPUT_CONCURRENCY", "IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS"]
442
558
  startup_timeout_sec = 10
443
559
  tool_timeout_sec = 300
444
560
  enabled = true
@@ -466,9 +582,12 @@ export ZHIPU_IMAGE_MODEL="glm-image"
466
582
  # 可选:export ZHIPU_BASE_URL="https://open.bigmodel.cn/api/paas/v4"
467
583
  ```
468
584
 
585
+ 使用 MiniMax 时导出 `IMAGEFORGE_PROVIDER=minimax`、`MINIMAX_API_KEY`,并按需设置 `MINIMAX_IMAGE_MODEL=image-01` 或 `image-01-live`。
586
+
469
587
  Codex 只会加载已信任项目中的 `.codex/config.toml`。新增或修改 MCP 配置后,需要重新启动 Codex 或新建任务,再使用 `/mcp verbose` 确认 `imageforge_dev` 提供以下工具:
470
588
 
471
589
  - `generate_image`
590
+ - `list_image_providers`
472
591
  - `edit_image`
473
592
 
474
593
  修改 TypeScript 源码后,需要重新构建并重启使用该 MCP 的任务:
@@ -484,18 +603,18 @@ npm run build
484
603
  | 参数 | 必填 | 默认值 | 说明 |
485
604
  | --- | --- | --- | --- |
486
605
  | `prompt` | 是 | - | 图片描述 |
487
- | `model` | 否 | 环境变量或供应商默认值 | OpenAI:`gpt-image-2`;智谱:`glm-image`、`cogview-4-250304`、`cogview-4`、`cogview-3-flash` |
488
- | `base_url` | 否 | `OPENAI_BASE_URL` 或 `ZHIPU_BASE_URL` | 单次调用覆盖对应供应商 API 地址 |
489
- | `api_key` | 否 | `OPENAI_API_KEY` 或 `ZHIPU_API_KEY` | 单次调用覆盖对应供应商密钥;推荐使用环境变量 |
490
- | `provider` | 否 | `IMAGEFORGE_PROVIDER`,再默认 `openai` | `openai` 或 `zhipu` |
606
+ | `model` | 否 | 环境变量或供应商默认值 | OpenAI:`gpt-image-2`;智谱模型见上;MiniMax:`image-01`、`image-01-live` |
607
+ | `base_url` | 否 | 供应商环境变量或官方默认值 | 单次调用覆盖对应供应商 API 地址 |
608
+ | `api_key` | 否 | 供应商独立密钥 | 单次调用覆盖对应供应商密钥;推荐使用环境变量 |
609
+ | `provider` | 否 | `IMAGEFORGE_PROVIDER`,再默认 `openai` | `openai`、`zhipu` 或 `minimax` |
491
610
  | `size` | 否 | `1024x1024` | 请求提供商输出的图片尺寸 |
492
- | `quality` | 否 | `auto` | OpenAI:`auto/low/medium/high`;`glm-image`:`auto/hd`;其他智谱模型:`auto/standard/hd` |
493
- | `output_format` | 否 | `png` | `png`、`jpeg`、`webp` |
611
+ | `quality` | 否 | `auto` | OpenAI 与智谱取值见上;MiniMax 仅接受 `auto` |
612
+ | `output_format` | 否 | `png`;MiniMax 为 `jpeg` | OpenAI:`png/jpeg/webp`;智谱忽略;MiniMax 仅接受 `jpeg` |
494
613
  | `output_path` | 否 | - | 本地保存路径;相对路径按 MCP 工作目录解析 |
495
- | `watermark_enabled` | 否 | - | 仅智谱显式传入时发送;`false` 可能需要账号去水印权限。不支持的供应商静默忽略 |
496
- | `reference_images` | 否 | - | OpenAI 参考图,支持本地绝对路径和 HTTP(S) URL;智谱会明确拒绝 |
614
+ | `watermark_enabled` | 否 | - | 显式传入时发送给智谱,或映射为 MiniMax `aigc_watermark` |
615
+ | `reference_images` | 否 | - | OpenAI:1–16 张;MiniMax:单张小于 10 MB 的 PNG/JPEG;智谱拒绝 |
497
616
 
498
- 不传 `reference_images` 时调用 `/images/generations`;OpenAI 传入参考图时,将图片作为 multipart `image[]` 文件上传到 `/images/edits`。
617
+ OpenAI 不传 `reference_images` 时调用 `/images/generations`,传入参考图时调用 multipart `/images/edits`。MiniMax 始终调用 `/image_generation`,并把单张参考图映射为 `subject_reference`。
499
618
 
500
619
  智谱首版仅支持同步文生图,不支持参考图和 `edit_image`。传入 `reference_images` 时会在读取参考文件和发起请求前明确报错;`output_format` 对智谱不生效。下载图片时不携带 Authorization,最终 MCP MIME 类型以实际图片内容为准。
501
620
 
@@ -539,6 +658,33 @@ CogView 使用供应商标准质量快速生成:
539
658
 
540
659
  智谱失败会作为 MCP 工具错误返回,包含 HTTP 状态和最多 500 个字符的供应商错误摘要。认证失败必须修正配置而不是重试;HTTP 429 且业务错误码为 `1113` 表示账户欠费,其他 429 错误也可能表示限流、模型繁忙或套餐限制。ImageForge 不会自动重试可能产生费用的生图请求。业务错误码的当前含义以[智谱官方错误码文档](https://docs.bigmodel.cn/cn/faq/api-code)为准。
541
660
 
661
+ MiniMax 文生图示例:
662
+
663
+ ```json
664
+ {
665
+ "provider": "minimax",
666
+ "model": "image-01",
667
+ "prompt": "日出时宁静的海滨村庄,电影光线,无文字",
668
+ "size": "1536x1024",
669
+ "output_format": "jpeg",
670
+ "output_path": "outputs/minimax-village.jpeg"
671
+ }
672
+ ```
673
+
674
+ MiniMax 单主体参考图示例:
675
+
676
+ ```json
677
+ {
678
+ "provider": "minimax",
679
+ "model": "image-01",
680
+ "prompt": "保持参考人物特征,将人物置于安静的图书馆,自然光",
681
+ "reference_images": ["/参考人物图片的绝对路径/character.jpg"],
682
+ "output_format": "jpeg"
683
+ }
684
+ ```
685
+
686
+ 该模式的 `reference_images` 必须恰好一张;`image-01-live` 会把 `size` 转成精确支持的宽高比,而不是发送自定义尺寸。
687
+
542
688
  ## `edit_image`
543
689
 
544
690
  `edit_image` 与 `generate_image` 使用相同的模型、API、输出和本地保存参数,但 `input_images` 必填:
@@ -556,6 +702,22 @@ CogView 使用供应商标准质量快速生成:
556
702
 
557
703
  部分 OpenAI 兼容网关可能不会严格遵循请求中的 `size`,应以实际返回文件的尺寸为准。
558
704
 
705
+ ## 维护者发布脚本
706
+
707
+ 发布流程应在本仓库的 Git checkout 中执行:
708
+
709
+ ```bash
710
+ # 只读检查;工作区不干净时会警告,但继续检查。
711
+ bash script/release.sh
712
+
713
+ # 实际发布到 npm。
714
+ bash script/release.sh --publish
715
+ ```
716
+
717
+ 默认检查模式会验证版本一致性、Git 空白、TypeScript 构建、全部测试、生产依赖审计、npm 打包文件列表、npm 发布 dry-run、可用时的 npm 登录状态,以及当前版本是否已经存在于 Registry。如果版本已存在但 Registry shasum 与本地包不一致,检查会失败并要求先升级版本号。
718
+
719
+ `--publish` 还会强制要求当前分支为 `main`、工作区干净、本地 `HEAD` 与 `origin/main` 完全一致、npm 已登录且版本尚未发布;随后以 public access 和 `latest` tag 发布,等待 Registry 可查询到准确版本和 `latest` tag,再输出 Registry shasum。脚本不会修改版本号、创建 Git 提交、推送分支、创建 Tag、自动重试失败发布或覆盖已存在的 npm 版本。
720
+
559
721
  ## 验证
560
722
 
561
723
  ```bash
@@ -0,0 +1,71 @@
1
+ import { type LoadedImage } from "./imageInput.js";
2
+ export declare const EXTERNAL_PROVIDER_IDS: readonly ["google", "xai", "stability", "ideogram", "recraft", "tencent", "baidu", "playground", "bfl", "luma", "krea", "runway", "leonardo", "bria", "freepik", "alibaba", "volcengine", "kling", "hidream"];
3
+ export type ExternalProviderId = typeof EXTERNAL_PROVIDER_IDS[number];
4
+ export type ReferenceMode = "auto" | "content" | "style" | "character";
5
+ type Quality = "auto" | "low" | "medium" | "high" | "standard" | "hd";
6
+ type OutputFormat = "png" | "jpeg" | "webp";
7
+ export interface ExternalImageConfig {
8
+ provider: ExternalProviderId;
9
+ apiKey: string;
10
+ baseUrl: string;
11
+ model: string;
12
+ }
13
+ export interface ExternalGeneratedImage {
14
+ data: Buffer;
15
+ mimeType: "image/png" | "image/jpeg" | "image/webp";
16
+ }
17
+ interface ExternalRequestInput {
18
+ prompt: string;
19
+ config: ExternalImageConfig;
20
+ size: string;
21
+ quality: Quality;
22
+ outputFormat?: OutputFormat;
23
+ watermarkEnabled?: boolean;
24
+ inputImages?: LoadedImage[];
25
+ referenceMode?: ReferenceMode;
26
+ aspectRatio?: string;
27
+ resolution?: string;
28
+ negativePrompt?: string;
29
+ seed?: number;
30
+ fetchImpl?: typeof fetch;
31
+ downloadFetchImpl?: typeof fetch;
32
+ }
33
+ interface ProviderDefinition {
34
+ id: ExternalProviderId;
35
+ name: string;
36
+ docsUrl: string;
37
+ baseUrl: string;
38
+ baseUrlEnv: string;
39
+ apiKeyEnv: string;
40
+ modelEnv: string;
41
+ defaultModel: string;
42
+ models: readonly string[];
43
+ referenceModes: readonly ReferenceMode[];
44
+ maxReferences: number;
45
+ async: boolean;
46
+ }
47
+ export declare function isExternalProvider(value: string): value is ExternalProviderId;
48
+ export declare function externalProviderDefinitions(): readonly ProviderDefinition[];
49
+ export declare function resolveExternalConfig(input: {
50
+ provider: ExternalProviderId;
51
+ apiKey?: string;
52
+ baseUrl?: string;
53
+ model?: string;
54
+ }): ExternalImageConfig;
55
+ export declare function requestExternalImage(input: ExternalRequestInput): Promise<ExternalGeneratedImage>;
56
+ export declare function externalCapabilities(): {
57
+ provider: "google" | "xai" | "stability" | "ideogram" | "recraft" | "tencent" | "baidu" | "playground" | "bfl" | "luma" | "krea" | "runway" | "leonardo" | "bria" | "freepik" | "alibaba" | "volcengine" | "kling" | "hidream";
58
+ name: string;
59
+ default_model: string;
60
+ models: string[];
61
+ reference_modes: ReferenceMode[];
62
+ max_reference_images: number;
63
+ async: boolean;
64
+ credential_environment_variables: string[];
65
+ base_url_environment_variable: string;
66
+ model_environment_variable: string;
67
+ docs_url: string;
68
+ implementation_basis: string;
69
+ live_verified: boolean;
70
+ }[];
71
+ export {};