image-router-mcp 0.2.0 → 0.2.1
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 +8 -2
- package/README.zh-TW.md +19 -13
- package/dist/index.js +1 -1
- package/dist/providers/openai.js +2 -1
- package/dist/providers/xai.js +1 -1
- package/dist/schemas.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Run it directly from npm with `npx`. You only need an API key for the provider y
|
|
|
27
27
|
|
|
28
28
|
Model IDs are examples and defaults, not an allowlist. Other compatible model IDs can be supplied through the `model` argument.
|
|
29
29
|
|
|
30
|
-
### Model update notes (2026-
|
|
30
|
+
### Model update notes (checked 2026-10-05)
|
|
31
31
|
|
|
32
32
|
- OpenAI: Sunburst is the default for editing precision. Choose `gpt-image-2.5-flare` for everyday generation, or explicitly set `gpt-image-2` to retain the previous model. `xhigh` and `max` require GPT Image 2.5 or a compatible newer model. [Official guide](https://developers.openai.com/api/docs/guides/image-generation)
|
|
33
33
|
- Google: `gemini-3.1-flash-lite-image` (Nano Banana 2 Lite) is an optional faster, lower-cost model, limited to `1K` output. The default remains `gemini-3.1-flash-image`. [Official guide](https://ai.google.dev/gemini-api/docs/image-generation)
|
|
@@ -35,6 +35,10 @@ Model IDs are examples and defaults, not an allowlist. Other compatible model ID
|
|
|
35
35
|
|
|
36
36
|
Model access depends on your provider account. No automatic fallback to another paid model is performed.
|
|
37
37
|
|
|
38
|
+
Version 0.2.1 keeps these defaults and Node.js 20 support. It fixes `moderation` forwarding for GPT Image edits, validates legacy xAI dated aliases, and updates MCP SDK 1.32.0 plus two vulnerable transitive dependencies. See the [October audit](https://github.com/JiaDians/image-router-mcp/blob/main/docs/provider-audits/2026-10-05.md) for sources, deferred changes and verification limits.
|
|
39
|
+
|
|
40
|
+
If you pin an older OpenAI model, review its retirement date: `gpt-image-1` on October 23, 2026, and `gpt-image-1-mini`, `gpt-image-1.5`, `chatgpt-image-latest` on December 1, 2026. Explicit pins are not silently migrated. [Official deprecations](https://developers.openai.com/api/docs/deprecations)
|
|
41
|
+
|
|
38
42
|
## Prerequisites
|
|
39
43
|
|
|
40
44
|
- Node.js 20 or later, including `npm` and `npx`.
|
|
@@ -165,7 +169,7 @@ Use `file` for large images. Use `inline` or `both` only when the MCP client can
|
|
|
165
169
|
| `background` | `transparent`, `opaque`, `auto` | Provider default |
|
|
166
170
|
| `output_format` | `png`, `jpeg`, `webp` | `png` |
|
|
167
171
|
| `output_compression` | Integer `0`–`100`, GPT Image JPEG/WebP output only | Provider default |
|
|
168
|
-
| `moderation` | `low`, `auto
|
|
172
|
+
| `moderation` | `low`, `auto`, for GPT Image generation and editing (not sent to DALL-E) | Provider default |
|
|
169
173
|
| `style` | `vivid`, `natural`; used with DALL-E 3 | Provider default |
|
|
170
174
|
|
|
171
175
|
### Google parameters
|
|
@@ -192,6 +196,8 @@ For a follow-up edit, pass the previous result's `metadata.interactionId` as `pr
|
|
|
192
196
|
|
|
193
197
|
Aspect ratios also accept `21:9` and `5:2`. When xAI returns its serving model ID, it is included as `metadata.servedModel`. The top-level `model` continues to identify the requested model.
|
|
194
198
|
|
|
199
|
+
Legacy dated aliases such as `grok-imagine-image-2026-03-02` retain the three-reference limit and reject the 2.0-only `quality` parameter, including when selected through `DEFAULT_XAI_IMAGE_MODEL`.
|
|
200
|
+
|
|
195
201
|
## Configuration
|
|
196
202
|
|
|
197
203
|
| Variable | Required | Behavior |
|
package/README.zh-TW.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
以上模型是範例與預設值,不是允許清單。可透過 `model` 參數傳入其他相容的模型 ID。
|
|
29
29
|
|
|
30
|
-
### 模型更新說明(2026-
|
|
30
|
+
### 模型更新說明(2026-10-05 查核)
|
|
31
31
|
|
|
32
32
|
- OpenAI:預設使用偏重精準編輯的 Sunburst,日常生成可選 `gpt-image-2.5-flare`。若要維持先前模型,可明確指定 `gpt-image-2`。`xhigh`、`max` 需使用 GPT Image 2.5 或相容的新模型。[官方指南](https://developers.openai.com/api/docs/guides/image-generation)
|
|
33
33
|
- Google:可選速度更快、成本較低的 `gemini-3.1-flash-lite-image`(Nano Banana 2 Lite),僅支援 `1K` 輸出。預設仍為 `gemini-3.1-flash-image`。[官方指南](https://ai.google.dev/gemini-api/docs/image-generation)
|
|
@@ -35,6 +35,10 @@
|
|
|
35
35
|
|
|
36
36
|
模型存取權依供應商帳戶而定。無法使用時,不會自動改呼叫其他付費模型。
|
|
37
37
|
|
|
38
|
+
0.2.1 維持以上預設值及 Node.js 20 支援,修正 GPT Image 編輯時的 `moderation` 傳遞與 xAI 舊日期版模型的限制檢查,更新 MCP SDK 至 1.32.0 並修補兩項間接依賴漏洞。官方來源、暫緩項目及驗證範圍見[十月查核紀錄](https://github.com/JiaDians/image-router-mcp/blob/main/docs/provider-audits/2026-10-05.md)。
|
|
39
|
+
|
|
40
|
+
若固定使用舊 OpenAI 模型,請留意停用日期:`gpt-image-1` 為 2026 年 10 月 23 日,`gpt-image-1-mini`、`gpt-image-1.5`、`chatgpt-image-latest` 為 2026 年 12 月 1 日。本工具不會暗中替換指定模型。[官方棄用公告](https://developers.openai.com/api/docs/deprecations)
|
|
41
|
+
|
|
38
42
|
## 前置需求
|
|
39
43
|
|
|
40
44
|
- Node.js 20 以上版本,並包含 `npm` 與 `npx`。
|
|
@@ -47,7 +51,7 @@
|
|
|
47
51
|
呼叫供應商 API 可能產生費用。只需設定實際要使用的供應商 Key。
|
|
48
52
|
|
|
49
53
|
> [!WARNING]
|
|
50
|
-
> 請勿將真實 API Key
|
|
54
|
+
> 請勿將真實 API Key 提交到版本控制。含有密鑰的設定建議放在使用者層級,若 MCP 客戶端支援,也可從既有環境變數轉送 Key。
|
|
51
55
|
|
|
52
56
|
## 快速開始
|
|
53
57
|
|
|
@@ -125,8 +129,8 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
125
129
|
- `input_images` 路徑會從 MCP server process 的工作目錄開始解析。
|
|
126
130
|
- `output_path` 可以是檔案路徑或資料夾。
|
|
127
131
|
- 已存在的資料夾,或沒有副檔名的新路徑,會被視為資料夾。
|
|
128
|
-
-
|
|
129
|
-
- 未傳入 `output_path` 時,圖片會儲存在 `DEFAULT_OUTPUT_DIR
|
|
132
|
+
- 帶有副檔名的路徑會被視為指定輸出檔名,若有多張結果,檔名會加入編號。
|
|
133
|
+
- 未傳入 `output_path` 時,圖片會儲存在 `DEFAULT_OUTPUT_DIR`,若未設定該變數,則使用 MCP server 工作目錄下的 `./generated-images`。
|
|
130
134
|
- 建議輸入與輸出都使用絕對路徑,確保不同客戶端有一致結果。
|
|
131
135
|
- 若要跨供應商使用本機圖片,建議採用 PNG、JPG/JPEG 或 WebP。Google 與 xAI 的載入器接受這些副檔名。
|
|
132
136
|
- xAI Imagine Image 2.0 最多接受 5 張 `input_images`,舊模型維持 3 張限制。
|
|
@@ -136,7 +140,7 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
136
140
|
| 模式 | 行為 |
|
|
137
141
|
| --- | --- |
|
|
138
142
|
| `file` | 預設。將圖片儲存到磁碟並回傳路徑。 |
|
|
139
|
-
| `inline` | 不儲存檔案,直接回傳 MCP `image` content
|
|
143
|
+
| `inline` | 不儲存檔案,直接回傳 MCP `image` content,每張圖片受 `inline_max_bytes` 限制。 |
|
|
140
144
|
| `both` | 同時儲存圖片並回傳 inline MCP 圖片內容。 |
|
|
141
145
|
|
|
142
146
|
大型圖片建議使用 `file`。只有在 MCP 客戶端可以顯示圖片、且結果符合 payload 限制時,才使用 `inline` 或 `both`。
|
|
@@ -153,7 +157,7 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
153
157
|
| `output_path` | 否 | `DEFAULT_OUTPUT_DIR` 或 `./generated-images` | 儲存結果的檔案或資料夾。 |
|
|
154
158
|
| `return_mode` | 否 | `file` | `file`、`inline` 或 `both`。 |
|
|
155
159
|
| `inline_max_bytes` | 否 | `4194304`(4 MiB) | 每張 inline 圖片允許的最大大小。 |
|
|
156
|
-
| `n` | 否 | 供應商預設值 | 供應商支援時的結果數量,範圍為 1 到 10
|
|
160
|
+
| `n` | 否 | 供應商預設值 | 供應商支援時的結果數量,範圍為 1 到 10,Google 目前回傳一張。 |
|
|
157
161
|
| `user` | 否 | — | 選用的終端使用者識別碼,供供應商進行濫用監控。 |
|
|
158
162
|
|
|
159
163
|
### OpenAI 參數
|
|
@@ -165,15 +169,15 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
165
169
|
| `background` | `transparent`、`opaque`、`auto` | 供應商預設值 |
|
|
166
170
|
| `output_format` | `png`、`jpeg`、`webp` | `png` |
|
|
167
171
|
| `output_compression` | 整數 `0`–`100`,僅供 GPT Image 的 JPEG/WebP 輸出使用 | 供應商預設值 |
|
|
168
|
-
| `moderation` | `low`、`auto
|
|
169
|
-
| `style` | `vivid`、`natural
|
|
172
|
+
| `moderation` | `low`、`auto`,適用 GPT Image 生成與編輯,不傳給 DALL-E | 供應商預設值 |
|
|
173
|
+
| `style` | `vivid`、`natural`,供 DALL-E 3 使用 | 供應商預設值 |
|
|
170
174
|
|
|
171
175
|
### Google 參數
|
|
172
176
|
|
|
173
177
|
| 參數 | 值或範例 | 預設值 |
|
|
174
178
|
| --- | --- | --- |
|
|
175
179
|
| `aspect_ratio` | 例如 `1:1`、`16:9`、`9:16`、`4:3` 或 `3:2` | 供應商預設值 |
|
|
176
|
-
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K
|
|
180
|
+
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K`,實際可用值依模型而定 | 供應商預設值 |
|
|
177
181
|
| `output_format` | `png`、`jpeg` | 供應商預設值 |
|
|
178
182
|
| `thinking_level` | `minimal`、`high`,供 Gemini 3.1 Flash Image/Flash Lite Image 使用 | 供應商預設值 |
|
|
179
183
|
| `previous_interaction_id` | 前次 Google 結果的 `metadata.interactionId` | 無 |
|
|
@@ -192,6 +196,8 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
192
196
|
|
|
193
197
|
長寬比亦可指定 `21:9`、`5:2`。xAI 回傳實際服務模型時,會記錄於 `metadata.servedModel`。最外層的 `model` 仍表示請求指定的模型。
|
|
194
198
|
|
|
199
|
+
`grok-imagine-image-2026-03-02` 等舊日期版別名維持三張參考圖限制,不接受 2.0 才支援的 `quality` 參數。透過 `DEFAULT_XAI_IMAGE_MODEL` 固定模型時亦會檢查。
|
|
200
|
+
|
|
195
201
|
## 環境設定
|
|
196
202
|
|
|
197
203
|
| 變數 | 必要性 | 行為 |
|
|
@@ -199,10 +205,10 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
199
205
|
| `OPENAI_API_KEY` | 使用 OpenAI 工具時需要 | OpenAI API Key。 |
|
|
200
206
|
| `GOOGLE_API_KEY` 或 `GEMINI_API_KEY` | 使用 Google 工具時需要 | Google Gemini API Key。 |
|
|
201
207
|
| `XAI_API_KEY` | 使用 xAI 工具時需要 | xAI API Key。 |
|
|
202
|
-
| `DEFAULT_OPENAI_IMAGE_MODEL` | 否 | 未傳入 `model` 時使用的 OpenAI
|
|
208
|
+
| `DEFAULT_OPENAI_IMAGE_MODEL` | 否 | 未傳入 `model` 時使用的 OpenAI 預設模型,明確傳入的 `model` 可以覆寫。 |
|
|
203
209
|
| `DEFAULT_GOOGLE_IMAGE_MODEL` | 否 | 將 Google 請求固定到此模型,優先於每次呼叫的 `model` 參數。 |
|
|
204
210
|
| `DEFAULT_XAI_IMAGE_MODEL` | 否 | 將 xAI 請求固定到此模型,優先於每次呼叫的 `model` 參數。 |
|
|
205
|
-
| `DEFAULT_OUTPUT_DIR` | 否 |
|
|
211
|
+
| `DEFAULT_OUTPUT_DIR` | 否 | 預設圖片儲存資料夾,預設為 MCP server 工作目錄下的 `./generated-images`。 |
|
|
206
212
|
|
|
207
213
|
Key 只會在呼叫對應工具時檢查,因此只設定一個供應商 Key 即可開始使用。
|
|
208
214
|
|
|
@@ -250,7 +256,7 @@ Google 參考圖範例:
|
|
|
250
256
|
|
|
251
257
|
- 檢查 JSON 或 TOML 語法,以及設定檔位置。
|
|
252
258
|
- 編輯設定後,完整重新啟動 MCP 客戶端。
|
|
253
|
-
- Codex 使用 `/mcp`
|
|
259
|
+
- Codex 使用 `/mcp` 檢查,Cursor 前往 **Settings > Tools & MCP**。
|
|
254
260
|
|
|
255
261
|
### API 驗證或帳務錯誤
|
|
256
262
|
|
|
@@ -262,7 +268,7 @@ Google 參考圖範例:
|
|
|
262
268
|
|
|
263
269
|
### Inline 圖片超過 4 MiB
|
|
264
270
|
|
|
265
|
-
改用 `return_mode: "file"
|
|
271
|
+
改用 `return_mode: "file"`,只有在客戶端能接受較大 payload 時,才提高 `inline_max_bytes`。
|
|
266
272
|
|
|
267
273
|
## 開發
|
|
268
274
|
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ export function createServer() {
|
|
|
35
35
|
});
|
|
36
36
|
server.registerTool("openai_generate_image", {
|
|
37
37
|
title: "OpenAI image generation and editing",
|
|
38
|
-
description: "Generate or edit images with OpenAI GPT Image 2.5 Sunburst and Flare, including xhigh/max quality
|
|
38
|
+
description: "Generate or edit images with OpenAI GPT Image 2.5 Sunburst and Flare, including xhigh/max quality, JPEG/WebP compression and optional moderation on both endpoints. Compatible model IDs remain flexible.",
|
|
39
39
|
inputSchema: openAIInputShape,
|
|
40
40
|
}, async (rawParams) => {
|
|
41
41
|
try {
|
package/dist/providers/openai.js
CHANGED
|
@@ -56,6 +56,7 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
56
56
|
background: params.background,
|
|
57
57
|
output_format: outputFormat,
|
|
58
58
|
output_compression: params.output_compression,
|
|
59
|
+
moderation: params.moderation,
|
|
59
60
|
}),
|
|
60
61
|
};
|
|
61
62
|
const response = inputImages.length > 0
|
|
@@ -74,7 +75,7 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
74
75
|
: await client.images.generate({
|
|
75
76
|
...common,
|
|
76
77
|
quality,
|
|
77
|
-
...(dallEModel ? { style: params.style } : {
|
|
78
|
+
...(dallEModel ? { style: params.style } : {}),
|
|
78
79
|
});
|
|
79
80
|
const data = "data" in response ? response.data ?? [] : [];
|
|
80
81
|
if (data.length === 0) {
|
package/dist/providers/xai.js
CHANGED
|
@@ -17,7 +17,7 @@ async function imageFromXAIItem(item) {
|
|
|
17
17
|
}
|
|
18
18
|
export async function generateXAIImage(params, fetchImpl = fetch) {
|
|
19
19
|
const model = process.env.DEFAULT_XAI_IMAGE_MODEL ?? params.model;
|
|
20
|
-
const legacyModel = /^grok-imagine-image(?:-quality|-pro)?(?:-latest|-\d{8})?$/.test(model);
|
|
20
|
+
const legacyModel = /^grok-imagine-image(?:-quality|-pro)?(?:-latest|-\d{8}|-\d{4}-\d{2}-\d{2})?$/.test(model);
|
|
21
21
|
if (legacyModel && (params.input_images?.length ?? 0) > 3) {
|
|
22
22
|
throw new UserInputError("This older xAI model supports up to 3 input images. Use grok-imagine-image-2.0 for up to 5.");
|
|
23
23
|
}
|
package/dist/schemas.js
CHANGED
|
@@ -29,7 +29,7 @@ export const openAIInputShape = {
|
|
|
29
29
|
background: z.enum(["transparent", "opaque", "auto"]).optional().describe("OpenAI background option."),
|
|
30
30
|
output_format: z.enum(["png", "jpeg", "webp"]).default("png").describe("Output image format."),
|
|
31
31
|
output_compression: z.number().int().min(0).max(100).optional().describe("Output compression from 0 to 100 for JPEG or WebP GPT Image output."),
|
|
32
|
-
moderation: z.enum(["low", "auto"]).optional().describe("
|
|
32
|
+
moderation: z.enum(["low", "auto"]).optional().describe("Moderation for GPT Image generation and editing. Omit to use the provider default. Not sent to DALL-E models."),
|
|
33
33
|
style: z.enum(["vivid", "natural"]).optional().describe("DALL-E 3 style option."),
|
|
34
34
|
};
|
|
35
35
|
export const googleInputShape = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-router-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "MCP server for routing image generation and editing across xAI, Google Gemini/Nano Banana, and OpenAI.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@google/genai": "2.21.0",
|
|
41
|
-
"@modelcontextprotocol/sdk": "1.
|
|
41
|
+
"@modelcontextprotocol/sdk": "1.32.0",
|
|
42
42
|
"openai": "6.49.0",
|
|
43
43
|
"zod": "4.4.3"
|
|
44
44
|
},
|