image-router-mcp 0.2.1 → 0.4.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 +15 -11
- package/README.zh-TW.md +15 -11
- package/dist/files.js +2 -0
- package/dist/index.js +2 -2
- package/dist/providers/google.js +9 -0
- package/dist/providers/openai.js +31 -4
- package/dist/providers/xai.js +2 -1
- package/dist/schemas.d.ts +24 -0
- package/dist/schemas.js +10 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -27,17 +27,17 @@ 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 (checked 2026-
|
|
30
|
+
### Model update notes (checked 2026-12-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 output on both generation and raster edits (`input_images` with PNG, JPG/JPEG, or WebP). For example, pass `model: "gpt-image-2.6-flare", output_format: "svg", n: 1` with your prompt. Use `safety_identifier` instead of the deprecated `user` field. 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, `1K`/`2K`/`4K` sizes, and medium thinking. The compatibility default `gemini-3.1-flash-image` (which also supports `512`/`0.5K`) is deprecated with no shutdown date announced. `gemini-2.5-flash-image` is scheduled to shut down on March 15, 2027. [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.grok.com/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
|
-
|
|
38
|
+
No configuration change is required. See the [December audit](https://github.com/JiaDians/image-router-mcp/blob/main/docs/provider-audits/2026-12-05.md) for API limits and dependency decisions.
|
|
39
39
|
|
|
40
|
-
If you pin an older OpenAI model,
|
|
40
|
+
If you pin an older OpenAI model, note that `gpt-image-1` (October 23, 2026) and `gpt-image-1-mini`, `gpt-image-1.5`, `chatgpt-image-latest` (December 1, 2026) have shut down, and `gpt-image-2` / `gpt-image-2-2026-04-21` are scheduled to shut down on February 10, 2027 (migrate to `gpt-image-2.6-sunburst` or `gpt-image-2.6-flare`). Explicit pins are not silently migrated. [Official deprecations](https://developers.openai.com/api/docs/deprecations)
|
|
41
41
|
|
|
42
42
|
## Prerequisites
|
|
43
43
|
|
|
@@ -133,7 +133,7 @@ Use absolute paths in prompts and tool calls. Relative paths depend on the worki
|
|
|
133
133
|
- When `output_path` is omitted, files are saved under `DEFAULT_OUTPUT_DIR`, or `./generated-images` relative to the MCP server working directory.
|
|
134
134
|
- Use absolute input and output paths for predictable behavior across clients.
|
|
135
135
|
- For portable local-image use across providers, use PNG, JPG/JPEG, or WebP files. The Google and xAI loaders accept these extensions.
|
|
136
|
-
- 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.
|
|
137
137
|
|
|
138
138
|
### Return modes
|
|
139
139
|
|
|
@@ -158,7 +158,7 @@ Use `file` for large images. Use `inline` or `both` only when the MCP client can
|
|
|
158
158
|
| `return_mode` | No | `file` | `file`, `inline`, or `both`. |
|
|
159
159
|
| `inline_max_bytes` | No | `4194304` (4 MiB) | Maximum size of each inline image. |
|
|
160
160
|
| `n` | No | Provider default | Number of results, from 1 to 10, when supported. Google currently returns one image. |
|
|
161
|
-
| `user` | No | — | Optional end-user identifier for provider abuse monitoring. |
|
|
161
|
+
| `user` | No | — | Optional end-user identifier for provider abuse monitoring (for OpenAI, prefer `safety_identifier`). |
|
|
162
162
|
|
|
163
163
|
### OpenAI parameters
|
|
164
164
|
|
|
@@ -167,9 +167,13 @@ Use `file` for large images. Use `inline` or `both` only when the MCP client can
|
|
|
167
167
|
| `size` | `auto`, `1024x1024`, `1536x1024`, or another supported `WIDTHxHEIGHT` | Provider default |
|
|
168
168
|
| `quality` | `auto`, `low`, `medium`, `high`, `xhigh`, `max`, `standard`, `hd` (model-dependent) | Provider default |
|
|
169
169
|
| `background` | `transparent`, `opaque`, `auto` | Provider default |
|
|
170
|
-
| `output_format` | `png`, `jpeg`, `webp` | `png` |
|
|
170
|
+
| `output_format` | `png`, `jpeg`, `webp`, or 2.6 generation/raster-edit `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 generation or edits 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 |
|
|
171
174
|
| `output_compression` | Integer `0`–`100`, GPT Image JPEG/WebP output only | Provider default |
|
|
172
175
|
| `moderation` | `low`, `auto`, for GPT Image generation and editing (not sent to DALL-E) | Provider default |
|
|
176
|
+
| `safety_identifier` | Privacy-preserving end-user identifier (up to 128 chars), preferred over deprecated `user` | None |
|
|
173
177
|
| `style` | `vivid`, `natural`; used with DALL-E 3 | Provider default |
|
|
174
178
|
|
|
175
179
|
### Google parameters
|
|
@@ -177,9 +181,9 @@ Use `file` for large images. Use `inline` or `both` only when the MCP client can
|
|
|
177
181
|
| Parameter | Values or examples | Default |
|
|
178
182
|
| --- | --- | --- |
|
|
179
183
|
| `aspect_ratio` | For example `1:1`, `16:9`, `9:16`, `4:3`, or `3:2` | Provider default |
|
|
180
|
-
| `image_size` | `512`, `0.5K`, `1K`, `2K`, `4K`;
|
|
184
|
+
| `image_size` | `512`, `0.5K`, `1K`, `2K`, `4K`; `512`/`0.5K` is for `gemini-3.1-flash-image` only, Nano Banana 2.1 supports `1K`/`2K`/`4K`, Lite supports `1K` | Provider default |
|
|
181
185
|
| `output_format` | `png`, `jpeg` | Provider default |
|
|
182
|
-
| `thinking_level` | `minimal`, `high`,
|
|
186
|
+
| `thinking_level` | `minimal`, `high`, plus `medium` on Nano Banana 2.1 | Provider default |
|
|
183
187
|
| `previous_interaction_id` | `metadata.interactionId` from a previous Google result | None |
|
|
184
188
|
|
|
185
189
|
`0.5K` is accepted as a legacy alias and normalized to `512`.
|
package/README.zh-TW.md
CHANGED
|
@@ -27,17 +27,17 @@
|
|
|
27
27
|
|
|
28
28
|
以上模型是範例與預設值,不是允許清單。可透過 `model` 參數傳入其他相容的模型 ID。
|
|
29
29
|
|
|
30
|
-
### 模型更新說明(2026-
|
|
30
|
+
### 模型更新說明(2026-12-05 查核)
|
|
31
31
|
|
|
32
|
-
- OpenAI
|
|
33
|
-
- Google
|
|
34
|
-
- xAI
|
|
32
|
+
- OpenAI:指定 `gpt-image-2.6-sunburst` 或 `gpt-image-2.6-flare` 即可控制構圖複雜度,並在生成與點陣圖片編輯(PNG、JPG/JPEG、WebP 輸入)輸出 SVG 或動態 GIF。例如在提示詞之外傳入 `model: "gpt-image-2.6-flare", output_format: "svg", n: 1`。建議改用 `safety_identifier` 取代棄用的 `user`。預設仍為 2.5 Sunburst。[影像指南](https://developers.openai.com/api/docs/guides/image-generation)
|
|
33
|
+
- Google:新專案建議選用 `gemini-nano-banana-2.1`,可接續編輯、使用最多 14 張參考圖、`1K`/`2K`/`4K` 尺寸及中等思考等級。為相容舊設定(包含 `512`/`0.5K` 尺寸),本工具仍預設使用 `gemini-3.1-flash-image`。Google 已將其列為棄用,但尚未公告停用日;`gemini-2.5-flash-image` 停用日為 2027 年 3 月 15 日。[模型文件](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.grok.com/developers/migration/imagine-image-quality-nov-2)
|
|
35
35
|
|
|
36
36
|
模型存取權依供應商帳戶而定。無法使用時,不會自動改呼叫其他付費模型。
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
升級不需修改原有設定。官方來源、限制及依賴選擇見[十二月查核紀錄](https://github.com/JiaDians/image-router-mcp/blob/main/docs/provider-audits/2026-12-05.md)。
|
|
39
39
|
|
|
40
|
-
若固定使用舊 OpenAI
|
|
40
|
+
若固定使用舊 OpenAI 模型,請留意:`gpt-image-1`(2026 年 10 月 23 日)以及 `gpt-image-1-mini`、`gpt-image-1.5`、`chatgpt-image-latest`(2026 年 12 月 1 日)均已停用,`gpt-image-2` 與 `gpt-image-2-2026-04-21` 預計於 2027 年 2 月 10 日停用,建議改用 `gpt-image-2.6-sunburst` 或 `gpt-image-2.6-flare`。本工具不會暗中替換指定模型。[官方棄用公告](https://developers.openai.com/api/docs/deprecations)
|
|
41
41
|
|
|
42
42
|
## 前置需求
|
|
43
43
|
|
|
@@ -133,7 +133,7 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
133
133
|
- 未傳入 `output_path` 時,圖片會儲存在 `DEFAULT_OUTPUT_DIR`,若未設定該變數,則使用 MCP server 工作目錄下的 `./generated-images`。
|
|
134
134
|
- 建議輸入與輸出都使用絕對路徑,確保不同客戶端有一致結果。
|
|
135
135
|
- 若要跨供應商使用本機圖片,建議採用 PNG、JPG/JPEG 或 WebP。Google 與 xAI 的載入器接受這些副檔名。
|
|
136
|
-
- xAI Imagine Image 2.0
|
|
136
|
+
- xAI Imagine Image 2.0 與已轉向的 quality/pro 別名最多接受 5 張 `input_images`,舊版 1.0 仍限 3 張。
|
|
137
137
|
|
|
138
138
|
### 回傳模式
|
|
139
139
|
|
|
@@ -158,7 +158,7 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
158
158
|
| `return_mode` | 否 | `file` | `file`、`inline` 或 `both`。 |
|
|
159
159
|
| `inline_max_bytes` | 否 | `4194304`(4 MiB) | 每張 inline 圖片允許的最大大小。 |
|
|
160
160
|
| `n` | 否 | 供應商預設值 | 供應商支援時的結果數量,範圍為 1 到 10,Google 目前回傳一張。 |
|
|
161
|
-
| `user` | 否 | — |
|
|
161
|
+
| `user` | 否 | — | 選用的終端使用者識別碼,供供應商進行濫用監控(OpenAI 建議改用 `safety_identifier`)。 |
|
|
162
162
|
|
|
163
163
|
### OpenAI 參數
|
|
164
164
|
|
|
@@ -167,9 +167,13 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
167
167
|
| `size` | `auto`、`1024x1024`、`1536x1024` 或其他支援的 `WIDTHxHEIGHT` | 供應商預設值 |
|
|
168
168
|
| `quality` | `auto`、`low`、`medium`、`high`、`xhigh`、`max`、`standard`、`hd`,依模型支援 | 供應商預設值 |
|
|
169
169
|
| `background` | `transparent`、`opaque`、`auto` | 供應商預設值 |
|
|
170
|
-
| `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 標註圖路徑,尺寸須符合第一張輸入圖校正方向後的尺寸 | 無 |
|
|
171
174
|
| `output_compression` | 整數 `0`–`100`,僅供 GPT Image 的 JPEG/WebP 輸出使用 | 供應商預設值 |
|
|
172
175
|
| `moderation` | `low`、`auto`,適用 GPT Image 生成與編輯,不傳給 DALL-E | 供應商預設值 |
|
|
176
|
+
| `safety_identifier` | 隱私保護的終端使用者識別碼(最多 128 字元),建議優先取代已棄用的 `user` | 無 |
|
|
173
177
|
| `style` | `vivid`、`natural`,供 DALL-E 3 使用 | 供應商預設值 |
|
|
174
178
|
|
|
175
179
|
### Google 參數
|
|
@@ -177,9 +181,9 @@ OPENAI_API_KEY = "your_openai_key"
|
|
|
177
181
|
| 參數 | 值或範例 | 預設值 |
|
|
178
182
|
| --- | --- | --- |
|
|
179
183
|
| `aspect_ratio` | 例如 `1:1`、`16:9`、`9:16`、`4:3` 或 `3:2` | 供應商預設值 |
|
|
180
|
-
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K
|
|
184
|
+
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K`,`512`/`0.5K` 僅限 `gemini-3.1-flash-image`,Nano Banana 2.1 支援 `1K`/`2K`/`4K`,Lite 限 `1K` | 供應商預設值 |
|
|
181
185
|
| `output_format` | `png`、`jpeg` | 供應商預設值 |
|
|
182
|
-
| `thinking_level` | `minimal`、`high
|
|
186
|
+
| `thinking_level` | `minimal`、`high`,Nano Banana 2.1 另支援 `medium` | 供應商預設值 |
|
|
183
187
|
| `previous_interaction_id` | 前次 Google 結果的 `metadata.interactionId` | 無 |
|
|
184
188
|
|
|
185
189
|
`0.5K` 是相容舊版的別名,送出前會正規化為 `512`。
|
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 or raster edits. 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,15 @@ 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
|
+
}
|
|
22
|
+
if (/^gemini-nano-banana-2\.1(?:-|$)/.test(model) && (params.image_size === "512" || params.image_size === "0.5K")) {
|
|
23
|
+
throw new UserInputError("Nano Banana 2.1 supports image_size 1K, 2K, or 4K. Use gemini-3.1-flash-image for 512px (0.5K).");
|
|
24
|
+
}
|
|
16
25
|
if (/^gemini-3\.1-flash-lite-image(?:-|$)/.test(model) && params.image_size && params.image_size !== "1K") {
|
|
17
26
|
throw new UserInputError("Gemini 3.1 Flash Lite Image supports only image_size 1K.");
|
|
18
27
|
}
|
package/dist/providers/openai.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createReadStream } from "node:fs";
|
|
2
2
|
import OpenAI from "openai";
|
|
3
|
-
import { bytesFromBase64, base64FromUrl } from "../files.js";
|
|
3
|
+
import { bytesFromBase64, base64FromUrl, mimeFromPath } from "../files.js";
|
|
4
4
|
import { requireEnv, UserInputError } from "../errors.js";
|
|
5
5
|
let openAIClient;
|
|
6
6
|
function getOpenAIClient() {
|
|
@@ -34,16 +34,37 @@ 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 svgOrGif = outputFormat === "svg" || outputFormat === "gif";
|
|
38
|
+
const pre25 = dallEModel || /^gpt-image-(?:1(?:[.-]|$)|2(?:-|$))/.test(model);
|
|
39
|
+
if ((svgOrGif || 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 (svgOrGif && inputImages.length > 0) {
|
|
43
|
+
for (const imagePath of inputImages) {
|
|
44
|
+
mimeFromPath(imagePath);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (outputFormat === "svg" && (params.n ?? 1) !== 1)
|
|
48
|
+
throw new UserInputError("SVG output requires n=1.");
|
|
49
|
+
if (outputFormat !== "gif" && (params.frame_count !== undefined || params.frame_duration_ms !== undefined)) {
|
|
50
|
+
throw new UserInputError("Animation frame options require GIF output.");
|
|
51
|
+
}
|
|
52
|
+
if (params.markup && (pre25 || !inputImages.length || !/\.png$/i.test(params.markup))) {
|
|
53
|
+
throw new UserInputError("Markup requires a GPT Image 2.5 or newer edit with an input image and a transparent PNG overlay.");
|
|
54
|
+
}
|
|
55
|
+
if (params.output_compression !== undefined && (dallEModel || !["jpeg", "webp"].includes(outputFormat))) {
|
|
38
56
|
throw new UserInputError("output_compression requires a GPT Image model with output_format jpeg or webp.");
|
|
39
57
|
}
|
|
40
58
|
if ((params.quality === "xhigh" || params.quality === "max") &&
|
|
41
|
-
|
|
59
|
+
pre25) {
|
|
42
60
|
throw new UserInputError("Quality xhigh and max require GPT Image 2.5 or a compatible newer model.");
|
|
43
61
|
}
|
|
44
62
|
// SDK 6 keeps Node.js 20 support. It forwards the API's new quality values unchanged,
|
|
45
63
|
// but its type declarations predate GPT Image 2.5. Wire-format tests cover both endpoints.
|
|
46
64
|
const quality = params.quality;
|
|
65
|
+
const gifOptions = outputFormat === "gif"
|
|
66
|
+
? { frame_count: params.frame_count, frame_duration_ms: params.frame_duration_ms }
|
|
67
|
+
: {};
|
|
47
68
|
const common = {
|
|
48
69
|
model,
|
|
49
70
|
prompt: params.prompt,
|
|
@@ -54,9 +75,12 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
54
75
|
? { response_format: "b64_json" }
|
|
55
76
|
: {
|
|
56
77
|
background: params.background,
|
|
78
|
+
// SDK 6 serializes these newer formats and fields (including safety_identifier) at runtime.
|
|
57
79
|
output_format: outputFormat,
|
|
80
|
+
complexity: params.complexity,
|
|
58
81
|
output_compression: params.output_compression,
|
|
59
82
|
moderation: params.moderation,
|
|
83
|
+
...(params.safety_identifier !== undefined && { safety_identifier: params.safety_identifier }),
|
|
60
84
|
}),
|
|
61
85
|
};
|
|
62
86
|
const response = inputImages.length > 0
|
|
@@ -66,6 +90,8 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
66
90
|
}
|
|
67
91
|
return client.images.edit({
|
|
68
92
|
...common,
|
|
93
|
+
...gifOptions,
|
|
94
|
+
...(params.markup && { markup: createReadStream(params.markup) }),
|
|
69
95
|
quality: quality,
|
|
70
96
|
image: inputImages.length === 1
|
|
71
97
|
? createReadStream(inputImages[0])
|
|
@@ -75,13 +101,14 @@ export async function generateOpenAIImage(params, client = getOpenAIClient()) {
|
|
|
75
101
|
: await client.images.generate({
|
|
76
102
|
...common,
|
|
77
103
|
quality,
|
|
104
|
+
...gifOptions,
|
|
78
105
|
...(dallEModel ? { style: params.style } : {}),
|
|
79
106
|
});
|
|
80
107
|
const data = "data" in response ? response.data ?? [] : [];
|
|
81
108
|
if (data.length === 0) {
|
|
82
109
|
throw new Error("OpenAI response did not include generated images.");
|
|
83
110
|
}
|
|
84
|
-
const mimeType =
|
|
111
|
+
const mimeType = outputFormat === "svg" ? "image/svg+xml" : `image/${outputFormat}`;
|
|
85
112
|
return {
|
|
86
113
|
provider: "openai",
|
|
87
114
|
model,
|
package/dist/providers/xai.js
CHANGED
|
@@ -18,7 +18,8 @@ async function imageFromXAIItem(item) {
|
|
|
18
18
|
export async function generateXAIImage(params, fetchImpl = fetch) {
|
|
19
19
|
const model = process.env.DEFAULT_XAI_IMAGE_MODEL ?? params.model;
|
|
20
20
|
const legacyModel = /^grok-imagine-image(?:-quality|-pro)?(?:-latest|-\d{8}|-\d{4}-\d{2}-\d{2})?$/.test(model);
|
|
21
|
-
|
|
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,12 +27,23 @@ 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";
|
|
34
44
|
low: "low";
|
|
35
45
|
}>>;
|
|
46
|
+
readonly safety_identifier: z.ZodOptional<z.ZodString>;
|
|
36
47
|
readonly style: z.ZodOptional<z.ZodEnum<{
|
|
37
48
|
vivid: "vivid";
|
|
38
49
|
natural: "natural";
|
|
@@ -57,6 +68,7 @@ export declare const googleInputShape: {
|
|
|
57
68
|
}>>;
|
|
58
69
|
readonly previous_interaction_id: z.ZodOptional<z.ZodString>;
|
|
59
70
|
readonly thinking_level: z.ZodOptional<z.ZodEnum<{
|
|
71
|
+
medium: "medium";
|
|
60
72
|
high: "high";
|
|
61
73
|
minimal: "minimal";
|
|
62
74
|
}>>;
|
|
@@ -126,12 +138,23 @@ export declare const openAIParamsSchema: z.ZodObject<{
|
|
|
126
138
|
png: "png";
|
|
127
139
|
jpeg: "jpeg";
|
|
128
140
|
webp: "webp";
|
|
141
|
+
svg: "svg";
|
|
142
|
+
gif: "gif";
|
|
129
143
|
}>>;
|
|
144
|
+
complexity: z.ZodOptional<z.ZodEnum<{
|
|
145
|
+
low: "low";
|
|
146
|
+
medium: "medium";
|
|
147
|
+
high: "high";
|
|
148
|
+
}>>;
|
|
149
|
+
frame_count: z.ZodOptional<z.ZodNumber>;
|
|
150
|
+
frame_duration_ms: z.ZodOptional<z.ZodNumber>;
|
|
151
|
+
markup: z.ZodOptional<z.ZodString>;
|
|
130
152
|
output_compression: z.ZodOptional<z.ZodNumber>;
|
|
131
153
|
moderation: z.ZodOptional<z.ZodEnum<{
|
|
132
154
|
auto: "auto";
|
|
133
155
|
low: "low";
|
|
134
156
|
}>>;
|
|
157
|
+
safety_identifier: z.ZodOptional<z.ZodString>;
|
|
135
158
|
style: z.ZodOptional<z.ZodEnum<{
|
|
136
159
|
vivid: "vivid";
|
|
137
160
|
natural: "natural";
|
|
@@ -156,6 +179,7 @@ export declare const googleParamsSchema: z.ZodObject<{
|
|
|
156
179
|
}>>;
|
|
157
180
|
previous_interaction_id: z.ZodOptional<z.ZodString>;
|
|
158
181
|
thinking_level: z.ZodOptional<z.ZodEnum<{
|
|
182
|
+
medium: "medium";
|
|
159
183
|
high: "high";
|
|
160
184
|
minimal: "minimal";
|
|
161
185
|
}>>;
|
package/dist/schemas.js
CHANGED
|
@@ -19,7 +19,7 @@ const commonImageShape = {
|
|
|
19
19
|
.default(DEFAULT_INLINE_MAX_BYTES)
|
|
20
20
|
.describe("Maximum bytes allowed for each inline image response."),
|
|
21
21
|
n: z.number().int().min(1).max(10).optional().describe("Number of images to generate when the provider supports it."),
|
|
22
|
-
user: nonEmptyString.optional().describe("Optional end-user identifier for provider abuse monitoring."),
|
|
22
|
+
user: nonEmptyString.optional().describe("Optional end-user identifier for provider abuse monitoring. For OpenAI, prefer safety_identifier."),
|
|
23
23
|
};
|
|
24
24
|
export const openAIInputShape = {
|
|
25
25
|
...commonImageShape,
|
|
@@ -27,9 +27,14 @@ 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("PNG, JPEG, or WebP, plus SVG and animated GIF on GPT Image 2.6 generation or raster edits. 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 or edit 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 or edit 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
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."),
|
|
37
|
+
safety_identifier: nonEmptyString.max(128).optional().describe("Optional privacy-preserving end-user identifier (up to 128 chars) for OpenAI safety monitoring. Preferred over deprecated user."),
|
|
33
38
|
style: z.enum(["vivid", "natural"]).optional().describe("DALL-E 3 style option."),
|
|
34
39
|
};
|
|
35
40
|
export const googleInputShape = {
|
|
@@ -37,16 +42,16 @@ export const googleInputShape = {
|
|
|
37
42
|
model: nonEmptyString.default("gemini-3.1-flash-image").describe("Google image model ID. Defaults to Nano Banana 2."),
|
|
38
43
|
output_format: z.enum(["png", "jpeg"]).optional().describe("Requested Google image output format. Omit to use the provider default."),
|
|
39
44
|
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("
|
|
45
|
+
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
46
|
aspect_ratio: nonEmptyString.optional().describe("Aspect ratio, for example 1:1, 16:9, 9:16, 4:3, or 3:2."),
|
|
42
47
|
image_size: z
|
|
43
48
|
.enum(["512", "0.5K", "1K", "2K", "4K"])
|
|
44
49
|
.optional()
|
|
45
|
-
.describe('Google image size where supported.
|
|
50
|
+
.describe('Google image size where supported. Nano Banana 2.1 supports 1K, 2K, and 4K; 512 (legacy 0.5K) is only supported on Gemini 3.1 Flash Image, and Lite supports 1K.'),
|
|
46
51
|
};
|
|
47
52
|
export const xaiInputShape = {
|
|
48
53
|
...commonImageShape,
|
|
49
|
-
input_images: z.array(nonEmptyString).max(5).optional().describe("
|
|
54
|
+
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
55
|
model: nonEmptyString.default("grok-imagine-image-2.0").describe("xAI/Grok image model ID. Defaults to Imagine Image 2.0."),
|
|
51
56
|
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
57
|
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.4.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.32.
|
|
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",
|