image-router-mcp 0.2.0 → 0.3.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 +17 -8
- package/README.zh-TW.md +28 -19
- package/dist/files.js +2 -0
- package/dist/index.js +2 -2
- package/dist/providers/google.js +6 -0
- package/dist/providers/openai.js +24 -4
- package/dist/providers/xai.js +3 -2
- package/dist/schemas.d.ts +22 -0
- package/dist/schemas.js +8 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -27,14 +27,18 @@ 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-11-05)
|
|
31
31
|
|
|
32
|
-
- OpenAI:
|
|
33
|
-
- Google: `gemini-
|
|
34
|
-
- xAI:
|
|
32
|
+
- OpenAI: Select `gpt-image-2.6-sunburst` or `gpt-image-2.6-flare` for complexity control and SVG/GIF generation. For example, pass `model: "gpt-image-2.6-flare", output_format: "svg", n: 1` with your prompt. The default stays on 2.5 Sunburst. [Image guide](https://developers.openai.com/api/docs/guides/image-generation)
|
|
33
|
+
- Google: For new projects, select `gemini-nano-banana-2.1` for conversational edits, up to 14 references and medium thinking. The compatibility default `gemini-3.1-flash-image` is deprecated with no shutdown date announced. [Model card](https://aistudio.google.com/docs/models/gemini-nano-banana-2.1)
|
|
34
|
+
- xAI: Since November 2 the exact `grok-imagine-image-quality` and `grok-imagine-image-pro` slugs route to Imagine Image 2.0 at low quality. Use `grok-imagine-image-2.0` explicitly to select quality. [Migration guide](https://docs.x.ai/developers/migration/imagine-image-quality-nov-2)
|
|
35
35
|
|
|
36
36
|
Model access depends on your provider account. No automatic fallback to another paid model is performed.
|
|
37
37
|
|
|
38
|
+
No configuration change is required. See the [November audit](https://github.com/JiaDians/image-router-mcp/blob/main/docs/provider-audits/2026-11-05.md) for API limits and dependency decisions.
|
|
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`.
|
|
@@ -129,7 +133,7 @@ Use absolute paths in prompts and tool calls. Relative paths depend on the worki
|
|
|
129
133
|
- When `output_path` is omitted, files are saved under `DEFAULT_OUTPUT_DIR`, or `./generated-images` relative to the MCP server working directory.
|
|
130
134
|
- Use absolute input and output paths for predictable behavior across clients.
|
|
131
135
|
- For portable local-image use across providers, use PNG, JPG/JPEG, or WebP files. The Google and xAI loaders accept these extensions.
|
|
132
|
-
- xAI Imagine Image 2.0
|
|
136
|
+
- xAI Imagine Image 2.0 and the redirected quality/pro slugs accept at most 5 `input_images`. Legacy 1.0 models retain the 3-image limit.
|
|
133
137
|
|
|
134
138
|
### Return modes
|
|
135
139
|
|
|
@@ -163,9 +167,12 @@ Use `file` for large images. Use `inline` or `both` only when the MCP client can
|
|
|
163
167
|
| `size` | `auto`, `1024x1024`, `1536x1024`, or another supported `WIDTHxHEIGHT` | Provider default |
|
|
164
168
|
| `quality` | `auto`, `low`, `medium`, `high`, `xhigh`, `max`, `standard`, `hd` (model-dependent) | Provider default |
|
|
165
169
|
| `background` | `transparent`, `opaque`, `auto` | Provider default |
|
|
166
|
-
| `output_format` | `png`, `jpeg`, `webp` | `png` |
|
|
170
|
+
| `output_format` | `png`, `jpeg`, `webp`, or 2.6 generation-only `svg` / `gif`. SVG requires `n: 1`. | `png` |
|
|
171
|
+
| `complexity` | `low`, `medium`, `high` on 2.6, independently of `quality` | Provider default |
|
|
172
|
+
| `frame_count` / `frame_duration_ms` | GIF only: 2–16 frames, 20–2000 ms per frame | Provider default |
|
|
173
|
+
| `markup` | Path to a transparent PNG overlay matching the first input image's dimensions after orientation, for GPT Image 2.5/2.6 edits | None |
|
|
167
174
|
| `output_compression` | Integer `0`–`100`, GPT Image JPEG/WebP output only | Provider default |
|
|
168
|
-
| `moderation` | `low`, `auto
|
|
175
|
+
| `moderation` | `low`, `auto`, for GPT Image generation and editing (not sent to DALL-E) | Provider default |
|
|
169
176
|
| `style` | `vivid`, `natural`; used with DALL-E 3 | Provider default |
|
|
170
177
|
|
|
171
178
|
### Google parameters
|
|
@@ -175,7 +182,7 @@ Use `file` for large images. Use `inline` or `both` only when the MCP client can
|
|
|
175
182
|
| `aspect_ratio` | For example `1:1`, `16:9`, `9:16`, `4:3`, or `3:2` | Provider default |
|
|
176
183
|
| `image_size` | `512`, `0.5K`, `1K`, `2K`, `4K`; availability depends on the model | Provider default |
|
|
177
184
|
| `output_format` | `png`, `jpeg` | Provider default |
|
|
178
|
-
| `thinking_level` | `minimal`, `high`,
|
|
185
|
+
| `thinking_level` | `minimal`, `high`, plus `medium` on Nano Banana 2.1 | Provider default |
|
|
179
186
|
| `previous_interaction_id` | `metadata.interactionId` from a previous Google result | None |
|
|
180
187
|
|
|
181
188
|
`0.5K` is accepted as a legacy alias and normalized to `512`.
|
|
@@ -192,6 +199,8 @@ For a follow-up edit, pass the previous result's `metadata.interactionId` as `pr
|
|
|
192
199
|
|
|
193
200
|
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
201
|
|
|
202
|
+
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`.
|
|
203
|
+
|
|
195
204
|
## Configuration
|
|
196
205
|
|
|
197
206
|
| Variable | Required | Behavior |
|
package/README.zh-TW.md
CHANGED
|
@@ -27,14 +27,18 @@
|
|
|
27
27
|
|
|
28
28
|
以上模型是範例與預設值,不是允許清單。可透過 `model` 參數傳入其他相容的模型 ID。
|
|
29
29
|
|
|
30
|
-
### 模型更新說明(2026-
|
|
30
|
+
### 模型更新說明(2026-11-05 查核)
|
|
31
31
|
|
|
32
|
-
- OpenAI
|
|
33
|
-
- Google
|
|
34
|
-
- xAI
|
|
32
|
+
- OpenAI:指定 `gpt-image-2.6-sunburst` 或 `gpt-image-2.6-flare` 即可控制構圖複雜度、生成 SVG 或動態 GIF。例如在提示詞之外傳入 `model: "gpt-image-2.6-flare", output_format: "svg", n: 1`。預設仍為 2.5 Sunburst。[影像指南](https://developers.openai.com/api/docs/guides/image-generation)
|
|
33
|
+
- Google:新專案建議選用 `gemini-nano-banana-2.1`,可接續編輯、使用最多 14 張參考圖及中等思考等級。為相容舊設定,本工具仍預設使用 `gemini-3.1-flash-image`。Google 已將其列為棄用,但尚未公告停用日。[模型文件](https://aistudio.google.com/docs/models/gemini-nano-banana-2.1)
|
|
34
|
+
- xAI:自 11 月 2 日起,`grok-imagine-image-quality` 與 `grok-imagine-image-pro` 兩個別名由供應商轉向 Imagine Image 2.0 的低品質。若要自行選擇品質,請指定 `grok-imagine-image-2.0`。[遷移指南](https://docs.x.ai/developers/migration/imagine-image-quality-nov-2)
|
|
35
35
|
|
|
36
36
|
模型存取權依供應商帳戶而定。無法使用時,不會自動改呼叫其他付費模型。
|
|
37
37
|
|
|
38
|
+
升級不需修改原有設定。官方來源、限制及依賴選擇見[十一月查核紀錄](https://github.com/JiaDians/image-router-mcp/blob/main/docs/provider-audits/2026-11-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,18 +129,18 @@ 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
|
-
- xAI Imagine Image 2.0
|
|
136
|
+
- xAI Imagine Image 2.0 與已轉向的 quality/pro 別名最多接受 5 張 `input_images`,舊版 1.0 仍限 3 張。
|
|
133
137
|
|
|
134
138
|
### 回傳模式
|
|
135
139
|
|
|
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 參數
|
|
@@ -163,19 +167,22 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
163
167
|
| `size` | `auto`、`1024x1024`、`1536x1024` 或其他支援的 `WIDTHxHEIGHT` | 供應商預設值 |
|
|
164
168
|
| `quality` | `auto`、`low`、`medium`、`high`、`xhigh`、`max`、`standard`、`hd`,依模型支援 | 供應商預設值 |
|
|
165
169
|
| `background` | `transparent`、`opaque`、`auto` | 供應商預設值 |
|
|
166
|
-
| `output_format` | `png`、`jpeg`、`webp` | `png` |
|
|
170
|
+
| `output_format` | `png`、`jpeg`、`webp`,或 2.6 僅供生成的 `svg`、`gif`。SVG 限 `n: 1`。 | `png` |
|
|
171
|
+
| `complexity` | 2.6 支援 `low`、`medium`、`high`,與 `quality` 分開控制 | 供應商預設值 |
|
|
172
|
+
| `frame_count`/`frame_duration_ms` | 僅限 GIF:2–16 幀,每幀 20–2000 毫秒 | 供應商預設值 |
|
|
173
|
+
| `markup` | 2.5/2.6 編輯用的透明 PNG 標註圖路徑,尺寸須符合第一張輸入圖校正方向後的尺寸 | 無 |
|
|
167
174
|
| `output_compression` | 整數 `0`–`100`,僅供 GPT Image 的 JPEG/WebP 輸出使用 | 供應商預設值 |
|
|
168
|
-
| `moderation` | `low`、`auto
|
|
169
|
-
| `style` | `vivid`、`natural
|
|
175
|
+
| `moderation` | `low`、`auto`,適用 GPT Image 生成與編輯,不傳給 DALL-E | 供應商預設值 |
|
|
176
|
+
| `style` | `vivid`、`natural`,供 DALL-E 3 使用 | 供應商預設值 |
|
|
170
177
|
|
|
171
178
|
### Google 參數
|
|
172
179
|
|
|
173
180
|
| 參數 | 值或範例 | 預設值 |
|
|
174
181
|
| --- | --- | --- |
|
|
175
182
|
| `aspect_ratio` | 例如 `1:1`、`16:9`、`9:16`、`4:3` 或 `3:2` | 供應商預設值 |
|
|
176
|
-
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K
|
|
183
|
+
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K`,實際可用值依模型而定 | 供應商預設值 |
|
|
177
184
|
| `output_format` | `png`、`jpeg` | 供應商預設值 |
|
|
178
|
-
| `thinking_level` | `minimal`、`high
|
|
185
|
+
| `thinking_level` | `minimal`、`high`,Nano Banana 2.1 另支援 `medium` | 供應商預設值 |
|
|
179
186
|
| `previous_interaction_id` | 前次 Google 結果的 `metadata.interactionId` | 無 |
|
|
180
187
|
|
|
181
188
|
`0.5K` 是相容舊版的別名,送出前會正規化為 `512`。
|
|
@@ -192,6 +199,8 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
192
199
|
|
|
193
200
|
長寬比亦可指定 `21:9`、`5:2`。xAI 回傳實際服務模型時,會記錄於 `metadata.servedModel`。最外層的 `model` 仍表示請求指定的模型。
|
|
194
201
|
|
|
202
|
+
`grok-imagine-image-2026-03-02` 等舊日期版別名維持三張參考圖限制,不接受 2.0 才支援的 `quality` 參數。透過 `DEFAULT_XAI_IMAGE_MODEL` 固定模型時亦會檢查。
|
|
203
|
+
|
|
195
204
|
## 環境設定
|
|
196
205
|
|
|
197
206
|
| 變數 | 必要性 | 行為 |
|
|
@@ -199,10 +208,10 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
199
208
|
| `OPENAI_API_KEY` | 使用 OpenAI 工具時需要 | OpenAI API Key。 |
|
|
200
209
|
| `GOOGLE_API_KEY` 或 `GEMINI_API_KEY` | 使用 Google 工具時需要 | Google Gemini API Key。 |
|
|
201
210
|
| `XAI_API_KEY` | 使用 xAI 工具時需要 | xAI API Key。 |
|
|
202
|
-
| `DEFAULT_OPENAI_IMAGE_MODEL` | 否 | 未傳入 `model` 時使用的 OpenAI
|
|
211
|
+
| `DEFAULT_OPENAI_IMAGE_MODEL` | 否 | 未傳入 `model` 時使用的 OpenAI 預設模型,明確傳入的 `model` 可以覆寫。 |
|
|
203
212
|
| `DEFAULT_GOOGLE_IMAGE_MODEL` | 否 | 將 Google 請求固定到此模型,優先於每次呼叫的 `model` 參數。 |
|
|
204
213
|
| `DEFAULT_XAI_IMAGE_MODEL` | 否 | 將 xAI 請求固定到此模型,優先於每次呼叫的 `model` 參數。 |
|
|
205
|
-
| `DEFAULT_OUTPUT_DIR` | 否 |
|
|
214
|
+
| `DEFAULT_OUTPUT_DIR` | 否 | 預設圖片儲存資料夾,預設為 MCP server 工作目錄下的 `./generated-images`。 |
|
|
206
215
|
|
|
207
216
|
Key 只會在呼叫對應工具時檢查,因此只設定一個供應商 Key 即可開始使用。
|
|
208
217
|
|
|
@@ -250,7 +259,7 @@ Google 參考圖範例:
|
|
|
250
259
|
|
|
251
260
|
- 檢查 JSON 或 TOML 語法,以及設定檔位置。
|
|
252
261
|
- 編輯設定後,完整重新啟動 MCP 客戶端。
|
|
253
|
-
- Codex 使用 `/mcp`
|
|
262
|
+
- Codex 使用 `/mcp` 檢查,Cursor 前往 **Settings > Tools & MCP**。
|
|
254
263
|
|
|
255
264
|
### API 驗證或帳務錯誤
|
|
256
265
|
|
|
@@ -262,7 +271,7 @@ Google 參考圖範例:
|
|
|
262
271
|
|
|
263
272
|
### Inline 圖片超過 4 MiB
|
|
264
273
|
|
|
265
|
-
改用 `return_mode: "file"
|
|
274
|
+
改用 `return_mode: "file"`,只有在客戶端能接受較大 payload 時,才提高 `inline_max_bytes`。
|
|
266
275
|
|
|
267
276
|
## 開發
|
|
268
277
|
|
package/dist/files.js
CHANGED
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
|
|
38
|
+
description: "Generate or edit GPT Images. Select gpt-image-2.6-sunburst or gpt-image-2.6-flare for complexity control and SVG/GIF generation. Use a local PNG markup overlay for GPT Image 2.5/2.6 edits. The default remains 2.5 Sunburst.",
|
|
39
39
|
inputSchema: openAIInputShape,
|
|
40
40
|
}, async (rawParams) => {
|
|
41
41
|
try {
|
|
@@ -49,7 +49,7 @@ export function createServer() {
|
|
|
49
49
|
});
|
|
50
50
|
server.registerTool("google_generate_image", {
|
|
51
51
|
title: "Google Gemini/Nano Banana image generation and editing",
|
|
52
|
-
description: "Generate or edit
|
|
52
|
+
description: "Generate or edit Gemini images. Select gemini-nano-banana-2.1 for up to 14 references and optional medium thinking. Continue edits with previous_interaction_id and choose PNG/JPEG output.",
|
|
53
53
|
inputSchema: googleInputShape,
|
|
54
54
|
}, async (rawParams) => {
|
|
55
55
|
try {
|
package/dist/providers/google.js
CHANGED
|
@@ -13,6 +13,12 @@ export function setGoogleClientForTests(client) {
|
|
|
13
13
|
}
|
|
14
14
|
export async function generateGoogleImage(params, client = getGoogleClient()) {
|
|
15
15
|
const model = process.env.DEFAULT_GOOGLE_IMAGE_MODEL ?? params.model;
|
|
16
|
+
if (params.thinking_level === "medium" && /^gemini-3\.1-flash(?:-lite)?-image(?:-|$)/.test(model)) {
|
|
17
|
+
throw new UserInputError("Use gemini-nano-banana-2.1 for medium thinking, or choose minimal/high on Flash Image.");
|
|
18
|
+
}
|
|
19
|
+
if (/^gemini-nano-banana-2\.1(?:-|$)/.test(model) && (params.input_images?.length ?? 0) > 14) {
|
|
20
|
+
throw new UserInputError("Nano Banana 2.1 supports up to 14 reference images.");
|
|
21
|
+
}
|
|
16
22
|
if (/^gemini-3\.1-flash-lite-image(?:-|$)/.test(model) && params.image_size && params.image_size !== "1K") {
|
|
17
23
|
throw new UserInputError("Gemini 3.1 Flash Lite Image supports only image_size 1K.");
|
|
18
24
|
}
|
package/dist/providers/openai.js
CHANGED
|
@@ -34,11 +34,26 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
34
34
|
const outputFormat = params.output_format ?? "png";
|
|
35
35
|
const inputImages = params.input_images ?? [];
|
|
36
36
|
const dallEModel = isDallEModel(model);
|
|
37
|
-
|
|
37
|
+
const generationOnly = outputFormat === "svg" || outputFormat === "gif";
|
|
38
|
+
const pre25 = dallEModel || /^gpt-image-(?:1(?:[.-]|$)|2(?:-|$))/.test(model);
|
|
39
|
+
if ((generationOnly || params.complexity) && (pre25 || /^gpt-image-2\.5(?:-|$)/.test(model))) {
|
|
40
|
+
throw new UserInputError("SVG, GIF and complexity require GPT Image 2.6 or a compatible newer model.");
|
|
41
|
+
}
|
|
42
|
+
if (generationOnly && inputImages.length)
|
|
43
|
+
throw new UserInputError("SVG and GIF output are for generation, not edits.");
|
|
44
|
+
if (outputFormat === "svg" && (params.n ?? 1) !== 1)
|
|
45
|
+
throw new UserInputError("SVG output requires n=1.");
|
|
46
|
+
if (outputFormat !== "gif" && (params.frame_count !== undefined || params.frame_duration_ms !== undefined)) {
|
|
47
|
+
throw new UserInputError("Animation frame options require GIF output.");
|
|
48
|
+
}
|
|
49
|
+
if (params.markup && (pre25 || !inputImages.length || !/\.png$/i.test(params.markup))) {
|
|
50
|
+
throw new UserInputError("Markup requires a GPT Image 2.5 or newer edit with an input image and a transparent PNG overlay.");
|
|
51
|
+
}
|
|
52
|
+
if (params.output_compression !== undefined && (dallEModel || !["jpeg", "webp"].includes(outputFormat))) {
|
|
38
53
|
throw new UserInputError("output_compression requires a GPT Image model with output_format jpeg or webp.");
|
|
39
54
|
}
|
|
40
55
|
if ((params.quality === "xhigh" || params.quality === "max") &&
|
|
41
|
-
|
|
56
|
+
pre25) {
|
|
42
57
|
throw new UserInputError("Quality xhigh and max require GPT Image 2.5 or a compatible newer model.");
|
|
43
58
|
}
|
|
44
59
|
// SDK 6 keeps Node.js 20 support. It forwards the API's new quality values unchanged,
|
|
@@ -54,8 +69,11 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
54
69
|
? { response_format: "b64_json" }
|
|
55
70
|
: {
|
|
56
71
|
background: params.background,
|
|
72
|
+
// SDK 6 serializes these newer formats but types only the raster subset.
|
|
57
73
|
output_format: outputFormat,
|
|
74
|
+
complexity: params.complexity,
|
|
58
75
|
output_compression: params.output_compression,
|
|
76
|
+
moderation: params.moderation,
|
|
59
77
|
}),
|
|
60
78
|
};
|
|
61
79
|
const response = inputImages.length > 0
|
|
@@ -65,6 +83,7 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
65
83
|
}
|
|
66
84
|
return client.images.edit({
|
|
67
85
|
...common,
|
|
86
|
+
...(params.markup && { markup: createReadStream(params.markup) }),
|
|
68
87
|
quality: quality,
|
|
69
88
|
image: inputImages.length === 1
|
|
70
89
|
? createReadStream(inputImages[0])
|
|
@@ -74,13 +93,14 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
74
93
|
: await client.images.generate({
|
|
75
94
|
...common,
|
|
76
95
|
quality,
|
|
77
|
-
...(
|
|
96
|
+
...(outputFormat === "gif" && { frame_count: params.frame_count, frame_duration_ms: params.frame_duration_ms }),
|
|
97
|
+
...(dallEModel ? { style: params.style } : {}),
|
|
78
98
|
});
|
|
79
99
|
const data = "data" in response ? response.data ?? [] : [];
|
|
80
100
|
if (data.length === 0) {
|
|
81
101
|
throw new Error("OpenAI response did not include generated images.");
|
|
82
102
|
}
|
|
83
|
-
const mimeType =
|
|
103
|
+
const mimeType = outputFormat === "svg" ? "image/svg+xml" : `image/${outputFormat}`;
|
|
84
104
|
return {
|
|
85
105
|
provider: "openai",
|
|
86
106
|
model,
|
package/dist/providers/xai.js
CHANGED
|
@@ -17,8 +17,9 @@ 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);
|
|
21
|
-
|
|
20
|
+
const legacyModel = /^grok-imagine-image(?:-quality|-pro)?(?:-latest|-\d{8}|-\d{4}-\d{2}-\d{2})?$/.test(model);
|
|
21
|
+
const redirectedToLow = model === "grok-imagine-image-quality" || model === "grok-imagine-image-pro";
|
|
22
|
+
if (legacyModel && !redirectedToLow && (params.input_images?.length ?? 0) > 3) {
|
|
22
23
|
throw new UserInputError("This older xAI model supports up to 3 input images. Use grok-imagine-image-2.0 for up to 5.");
|
|
23
24
|
}
|
|
24
25
|
if (legacyModel && params.quality !== undefined) {
|
package/dist/schemas.d.ts
CHANGED
|
@@ -27,7 +27,17 @@ export declare const openAIInputShape: {
|
|
|
27
27
|
png: "png";
|
|
28
28
|
jpeg: "jpeg";
|
|
29
29
|
webp: "webp";
|
|
30
|
+
svg: "svg";
|
|
31
|
+
gif: "gif";
|
|
30
32
|
}>>;
|
|
33
|
+
readonly complexity: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
low: "low";
|
|
35
|
+
medium: "medium";
|
|
36
|
+
high: "high";
|
|
37
|
+
}>>;
|
|
38
|
+
readonly frame_count: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
readonly frame_duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
40
|
+
readonly markup: z.ZodOptional<z.ZodString>;
|
|
31
41
|
readonly output_compression: z.ZodOptional<z.ZodNumber>;
|
|
32
42
|
readonly moderation: z.ZodOptional<z.ZodEnum<{
|
|
33
43
|
auto: "auto";
|
|
@@ -57,6 +67,7 @@ export declare const googleInputShape: {
|
|
|
57
67
|
}>>;
|
|
58
68
|
readonly previous_interaction_id: z.ZodOptional<z.ZodString>;
|
|
59
69
|
readonly thinking_level: z.ZodOptional<z.ZodEnum<{
|
|
70
|
+
medium: "medium";
|
|
60
71
|
high: "high";
|
|
61
72
|
minimal: "minimal";
|
|
62
73
|
}>>;
|
|
@@ -126,7 +137,17 @@ export declare const openAIParamsSchema: z.ZodObject<{
|
|
|
126
137
|
png: "png";
|
|
127
138
|
jpeg: "jpeg";
|
|
128
139
|
webp: "webp";
|
|
140
|
+
svg: "svg";
|
|
141
|
+
gif: "gif";
|
|
129
142
|
}>>;
|
|
143
|
+
complexity: z.ZodOptional<z.ZodEnum<{
|
|
144
|
+
low: "low";
|
|
145
|
+
medium: "medium";
|
|
146
|
+
high: "high";
|
|
147
|
+
}>>;
|
|
148
|
+
frame_count: z.ZodOptional<z.ZodNumber>;
|
|
149
|
+
frame_duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
markup: z.ZodOptional<z.ZodString>;
|
|
130
151
|
output_compression: z.ZodOptional<z.ZodNumber>;
|
|
131
152
|
moderation: z.ZodOptional<z.ZodEnum<{
|
|
132
153
|
auto: "auto";
|
|
@@ -156,6 +177,7 @@ export declare const googleParamsSchema: z.ZodObject<{
|
|
|
156
177
|
}>>;
|
|
157
178
|
previous_interaction_id: z.ZodOptional<z.ZodString>;
|
|
158
179
|
thinking_level: z.ZodOptional<z.ZodEnum<{
|
|
180
|
+
medium: "medium";
|
|
159
181
|
high: "high";
|
|
160
182
|
minimal: "minimal";
|
|
161
183
|
}>>;
|
package/dist/schemas.js
CHANGED
|
@@ -27,9 +27,13 @@ export const openAIInputShape = {
|
|
|
27
27
|
size: nonEmptyString.optional().describe("OpenAI size, such as auto, 1024x1024, 1536x1024, or any supported WIDTHxHEIGHT."),
|
|
28
28
|
quality: z.enum(["auto", "low", "medium", "high", "xhigh", "max", "standard", "hd"]).optional().describe("OpenAI quality. xhigh and max require GPT Image 2.5 or a compatible newer model. Higher quality can increase cost and latency."),
|
|
29
29
|
background: z.enum(["transparent", "opaque", "auto"]).optional().describe("OpenAI background option."),
|
|
30
|
-
output_format: z.enum(["png", "jpeg", "webp"]).default("png").describe("
|
|
30
|
+
output_format: z.enum(["png", "jpeg", "webp", "svg", "gif"]).default("png").describe("SVG and animated GIF are generation-only on GPT Image 2.6. SVG requires n=1."),
|
|
31
|
+
complexity: z.enum(["low", "medium", "high"]).optional().describe("GPT Image 2.6 planning complexity, independent of rendering quality."),
|
|
32
|
+
frame_count: z.number().int().min(2).max(16).optional().describe("GIF generation only. 2–16 frames (portable range across the guide and API reference)."),
|
|
33
|
+
frame_duration_ms: z.number().int().min(20).max(2000).optional().describe("GIF generation only. Frame delay in milliseconds, rounded by the provider to 10 ms."),
|
|
34
|
+
markup: nonEmptyString.optional().describe("Local transparent PNG annotation overlay for a GPT Image 2.5/2.6 edit. Match the first input image's oriented dimensions."),
|
|
31
35
|
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("
|
|
36
|
+
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
37
|
style: z.enum(["vivid", "natural"]).optional().describe("DALL-E 3 style option."),
|
|
34
38
|
};
|
|
35
39
|
export const googleInputShape = {
|
|
@@ -37,7 +41,7 @@ export const googleInputShape = {
|
|
|
37
41
|
model: nonEmptyString.default("gemini-3.1-flash-image").describe("Google image model ID. Defaults to Nano Banana 2."),
|
|
38
42
|
output_format: z.enum(["png", "jpeg"]).optional().describe("Requested Google image output format. Omit to use the provider default."),
|
|
39
43
|
previous_interaction_id: nonEmptyString.optional().describe("Continue a Google image editing conversation using metadata.interactionId from a previous result. Requires that interaction to remain available in the same provider account."),
|
|
40
|
-
thinking_level: z.enum(["minimal", "high"]).optional().describe("
|
|
44
|
+
thinking_level: z.enum(["minimal", "medium", "high"]).optional().describe("Nano Banana 2.1 supports minimal, medium and high. Older Flash Image and Lite accept minimal or high."),
|
|
41
45
|
aspect_ratio: nonEmptyString.optional().describe("Aspect ratio, for example 1:1, 16:9, 9:16, 4:3, or 3:2."),
|
|
42
46
|
image_size: z
|
|
43
47
|
.enum(["512", "0.5K", "1K", "2K", "4K"])
|
|
@@ -46,7 +50,7 @@ export const googleInputShape = {
|
|
|
46
50
|
};
|
|
47
51
|
export const xaiInputShape = {
|
|
48
52
|
...commonImageShape,
|
|
49
|
-
input_images: z.array(nonEmptyString).max(5).optional().describe("
|
|
53
|
+
input_images: z.array(nonEmptyString).max(5).optional().describe("Up to 5 local references for Imagine Image 2.0 and its redirected quality/pro slugs. Up to 3 for legacy 1.0."),
|
|
50
54
|
model: nonEmptyString.default("grok-imagine-image-2.0").describe("xAI/Grok image model ID. Defaults to Imagine Image 2.0."),
|
|
51
55
|
quality: z.enum(["low", "medium", "auto"]).optional().describe("Imagine Image 2.0 quality. Provider auto currently uses low for generation and medium for editing, with different costs. Set low or medium to pin quality."),
|
|
52
56
|
aspect_ratio: nonEmptyString.optional().describe("Aspect ratio, for example 1:1, 16:9, 9:16, 3:2, or auto."),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-router-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
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,15 +38,15 @@
|
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@google/genai": "2.21.0",
|
|
41
|
-
"@modelcontextprotocol/sdk": "1.
|
|
41
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
42
42
|
"openai": "6.49.0",
|
|
43
|
-
"zod": "4.
|
|
43
|
+
"zod": "4.6.7"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "25.9.1",
|
|
47
47
|
"tsx": "4.23.1",
|
|
48
48
|
"typescript": "6.0.3",
|
|
49
|
-
"vitest": "4.1.
|
|
49
|
+
"vitest": "4.1.12"
|
|
50
50
|
},
|
|
51
51
|
"repository": {
|
|
52
52
|
"type": "git",
|