image-router-mcp 0.1.3 → 0.1.5
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/LICENSE +21 -21
- package/README.md +264 -254
- package/README.zh-TW.md +264 -0
- package/dist/providers/google.d.ts +2 -2
- package/dist/providers/google.js +33 -39
- package/dist/schemas.d.ts +2 -0
- package/dist/schemas.js +4 -1
- package/package.json +9 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 image-router-mcp contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 image-router-mcp contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,254 +1,264 @@
|
|
|
1
|
-
# image-router-mcp
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/image-router-mcp)
|
|
4
|
-
[](https://www.npmjs.com/package/image-router-mcp)
|
|
5
|
-
|
|
6
|
-
English | [繁體中文](
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
## Features
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
|
|
20
|
-
## Tools
|
|
21
|
-
|
|
22
|
-
| Tool | Provider | Supports |
|
|
23
|
-
| --- | --- | --- |
|
|
24
|
-
| `
|
|
25
|
-
| `google_generate_image` | Google Gemini/Nano Banana | Text-to-image and local reference/edit images
|
|
26
|
-
| `
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
|
148
|
-
|
|
|
149
|
-
| `
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
|
158
|
-
|
|
|
159
|
-
|
|
|
160
|
-
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
"
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
1
|
+
# image-router-mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/image-router-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/image-router-mcp)
|
|
5
|
+
|
|
6
|
+
English | [繁體中文](./README.zh-TW.md)
|
|
7
|
+
|
|
8
|
+
An open-source MCP server that routes image generation and editing to xAI/Grok, Google Gemini/Nano Banana, and OpenAI.
|
|
9
|
+
|
|
10
|
+
Run it directly from npm with `npx`. You only need an API key for the provider you want to use.
|
|
11
|
+
|
|
12
|
+
## Features
|
|
13
|
+
|
|
14
|
+
- Three focused MCP tools for xAI, Google, and OpenAI.
|
|
15
|
+
- Text-to-image plus local reference image and image-editing workflows.
|
|
16
|
+
- Flexible model IDs, so compatible new models are not blocked by a fixed allowlist.
|
|
17
|
+
- File output by default, avoiding large base64 payloads over stdio.
|
|
18
|
+
- Optional inline image content for MCP clients that can display it.
|
|
19
|
+
|
|
20
|
+
## Tools and default models
|
|
21
|
+
|
|
22
|
+
| Tool | Provider | Built-in default model | Supports |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `openai_generate_image` | OpenAI | `gpt-image-2` | Text-to-image and local reference/edit images |
|
|
25
|
+
| `google_generate_image` | Google Gemini/Nano Banana | `gemini-3.1-flash-image` | Text-to-image and local reference/edit images through the Interactions API |
|
|
26
|
+
| `xai_generate_image` | xAI/Grok | `grok-imagine-image-quality` | Text-to-image and edits with up to 3 local input images |
|
|
27
|
+
|
|
28
|
+
Model IDs are examples and defaults, not an allowlist. Other compatible model IDs can be supplied through the `model` argument.
|
|
29
|
+
|
|
30
|
+
## Prerequisites
|
|
31
|
+
|
|
32
|
+
- Node.js 20 or later, including `npm` and `npx`.
|
|
33
|
+
- An MCP client that supports local stdio servers, such as Codex, Claude Desktop, or Cursor.
|
|
34
|
+
- At least one provider API key:
|
|
35
|
+
- `OPENAI_API_KEY` for OpenAI
|
|
36
|
+
- `GOOGLE_API_KEY` or `GEMINI_API_KEY` for Google
|
|
37
|
+
- `XAI_API_KEY` for xAI
|
|
38
|
+
|
|
39
|
+
Provider API usage may incur charges. Set only the keys for providers you intend to use.
|
|
40
|
+
|
|
41
|
+
> [!WARNING]
|
|
42
|
+
> Never commit real API keys. Prefer user-level config for settings that contain secrets, or forward keys from your existing environment when the MCP client supports it.
|
|
43
|
+
|
|
44
|
+
## Quick start
|
|
45
|
+
|
|
46
|
+
The examples below configure OpenAI only. Replace or add the environment variables listed in [Configuration](#configuration) to use Google or xAI.
|
|
47
|
+
|
|
48
|
+
### Codex
|
|
49
|
+
|
|
50
|
+
Add the server from the command line:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
codex mcp add image-router-mcp --env OPENAI_API_KEY=your_openai_key -- npx -y image-router-mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Or add it to `~/.codex/config.toml` for all projects, or `.codex/config.toml` for one trusted project:
|
|
57
|
+
|
|
58
|
+
```toml
|
|
59
|
+
[mcp_servers.image-router-mcp]
|
|
60
|
+
command = "npx"
|
|
61
|
+
args = ["-y", "image-router-mcp"]
|
|
62
|
+
|
|
63
|
+
[mcp_servers.image-router-mcp.env]
|
|
64
|
+
OPENAI_API_KEY = "your_openai_key"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Restart Codex after editing the file. Use `/mcp` to confirm that `image-router-mcp` and its three tools are available.
|
|
68
|
+
|
|
69
|
+
### Claude Desktop
|
|
70
|
+
|
|
71
|
+
Open **Settings > Developer > Edit Config** and add this server to `claude_desktop_config.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"image-router-mcp": {
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["-y", "image-router-mcp"],
|
|
79
|
+
"env": {
|
|
80
|
+
"OPENAI_API_KEY": "your_openai_key"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Default config locations:
|
|
88
|
+
|
|
89
|
+
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
90
|
+
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
91
|
+
|
|
92
|
+
Completely quit and reopen Claude Desktop after saving the file.
|
|
93
|
+
|
|
94
|
+
### Cursor
|
|
95
|
+
|
|
96
|
+
Add the same JSON configuration shown above to one of these locations:
|
|
97
|
+
|
|
98
|
+
- Global: `~/.cursor/mcp.json`
|
|
99
|
+
- Project only: `.cursor/mcp.json`
|
|
100
|
+
|
|
101
|
+
Open **Cursor Settings > Tools & MCP** to confirm that the server and tools are enabled.
|
|
102
|
+
|
|
103
|
+
## Generate your first image
|
|
104
|
+
|
|
105
|
+
After the server is connected, ask your MCP client:
|
|
106
|
+
|
|
107
|
+
> Use `openai_generate_image` to create a 1024x1024 cinematic product photo of a transparent mechanical keyboard on a marble desk. Save it to `/absolute/path/to/generated-images` and return the saved file path.
|
|
108
|
+
|
|
109
|
+
To edit an existing image:
|
|
110
|
+
|
|
111
|
+
> Use `google_generate_image` with `/absolute/path/to/sketch.png` as the input image. Turn it into a polished 16:9 mobile app hero illustration and save the result to `/absolute/path/to/generated-images`.
|
|
112
|
+
|
|
113
|
+
Use absolute paths in prompts and tool calls. Relative paths depend on the working directory chosen by the MCP client.
|
|
114
|
+
|
|
115
|
+
## Paths and image output
|
|
116
|
+
|
|
117
|
+
- `input_images` paths are resolved from the MCP server process working directory.
|
|
118
|
+
- `output_path` can be either a file path or a directory.
|
|
119
|
+
- An existing directory, or a new path without a file extension, is treated as a directory.
|
|
120
|
+
- A path with a file extension is treated as the requested output filename. Multiple results receive numbered suffixes.
|
|
121
|
+
- When `output_path` is omitted, files are saved under `DEFAULT_OUTPUT_DIR`, or `./generated-images` relative to the MCP server working directory.
|
|
122
|
+
- Use absolute input and output paths for predictable behavior across clients.
|
|
123
|
+
- For portable local-image use across providers, use PNG, JPG/JPEG, or WebP files. The Google and xAI loaders accept these extensions.
|
|
124
|
+
- xAI accepts at most 3 `input_images`.
|
|
125
|
+
|
|
126
|
+
### Return modes
|
|
127
|
+
|
|
128
|
+
| Mode | Behavior |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `file` | Default. Saves images to disk and returns their paths. |
|
|
131
|
+
| `inline` | Returns MCP `image` content without saving it. Each image is limited by `inline_max_bytes`. |
|
|
132
|
+
| `both` | Saves images and also returns inline MCP image content. |
|
|
133
|
+
|
|
134
|
+
Use `file` for large images. Use `inline` or `both` only when the MCP client can display image content and the result fits its payload limits.
|
|
135
|
+
|
|
136
|
+
## Tool parameters
|
|
137
|
+
|
|
138
|
+
### Common parameters
|
|
139
|
+
|
|
140
|
+
| Parameter | Required | Default | Description |
|
|
141
|
+
| --- | --- | --- | --- |
|
|
142
|
+
| `prompt` | Yes | — | Image generation or editing instructions. |
|
|
143
|
+
| `model` | No | Provider default | Compatible provider model ID. |
|
|
144
|
+
| `input_images` | No | `[]` | Local reference/edit image paths. |
|
|
145
|
+
| `output_path` | No | `DEFAULT_OUTPUT_DIR` or `./generated-images` | Saved output file or directory. |
|
|
146
|
+
| `return_mode` | No | `file` | `file`, `inline`, or `both`. |
|
|
147
|
+
| `inline_max_bytes` | No | `4194304` (4 MiB) | Maximum size of each inline image. |
|
|
148
|
+
| `n` | No | Provider default | Number of results, from 1 to 10, when supported. Google currently returns one image. |
|
|
149
|
+
| `user` | No | — | Optional end-user identifier for provider abuse monitoring. |
|
|
150
|
+
|
|
151
|
+
### OpenAI parameters
|
|
152
|
+
|
|
153
|
+
| Parameter | Values or examples | Default |
|
|
154
|
+
| --- | --- | --- |
|
|
155
|
+
| `size` | `auto`, `1024x1024`, `1536x1024`, or another supported `WIDTHxHEIGHT` | Provider default |
|
|
156
|
+
| `quality` | `auto`, `low`, `medium`, `high`, `standard`, `hd` | Provider default |
|
|
157
|
+
| `background` | `transparent`, `opaque`, `auto` | Provider default |
|
|
158
|
+
| `output_format` | `png`, `jpeg`, `webp` | `png` |
|
|
159
|
+
| `moderation` | `low`, `auto` | Provider default |
|
|
160
|
+
| `style` | `vivid`, `natural`; used with DALL-E 3 | Provider default |
|
|
161
|
+
|
|
162
|
+
### Google parameters
|
|
163
|
+
|
|
164
|
+
| Parameter | Values or examples | Default |
|
|
165
|
+
| --- | --- | --- |
|
|
166
|
+
| `aspect_ratio` | For example `1:1`, `16:9`, `9:16`, `4:3`, or `3:2` | Provider default |
|
|
167
|
+
| `image_size` | `512`, `0.5K`, `1K`, `2K`, `4K`; availability depends on the model | Provider default |
|
|
168
|
+
|
|
169
|
+
`0.5K` is accepted as a legacy alias and normalized to `512`.
|
|
170
|
+
|
|
171
|
+
### xAI parameters
|
|
172
|
+
|
|
173
|
+
| Parameter | Values or examples | Default |
|
|
174
|
+
| --- | --- | --- |
|
|
175
|
+
| `aspect_ratio` | For example `1:1`, `16:9`, `9:16`, `3:2`, or `auto` | Provider default |
|
|
176
|
+
| `resolution` | `1k`, `2k` | Provider default |
|
|
177
|
+
|
|
178
|
+
## Configuration
|
|
179
|
+
|
|
180
|
+
| Variable | Required | Behavior |
|
|
181
|
+
| --- | --- | --- |
|
|
182
|
+
| `OPENAI_API_KEY` | For the OpenAI tool | OpenAI API key. |
|
|
183
|
+
| `GOOGLE_API_KEY` or `GEMINI_API_KEY` | For the Google tool | Google Gemini API key. |
|
|
184
|
+
| `XAI_API_KEY` | For the xAI tool | xAI API key. |
|
|
185
|
+
| `DEFAULT_OPENAI_IMAGE_MODEL` | No | Default OpenAI model when `model` is omitted. An explicit `model` argument can override it. |
|
|
186
|
+
| `DEFAULT_GOOGLE_IMAGE_MODEL` | No | Pins Google requests to this model and takes precedence over the per-call `model` argument. |
|
|
187
|
+
| `DEFAULT_XAI_IMAGE_MODEL` | No | Pins xAI requests to this model and takes precedence over the per-call `model` argument. |
|
|
188
|
+
| `DEFAULT_OUTPUT_DIR` | No | Default saved-image directory. Defaults to `./generated-images` from the MCP server working directory. |
|
|
189
|
+
|
|
190
|
+
Keys are checked only when their corresponding tool is called, so one provider key is enough to start.
|
|
191
|
+
|
|
192
|
+
## Advanced direct tool calls
|
|
193
|
+
|
|
194
|
+
Most users can ask their MCP client in natural language. If your client supports direct tool invocation, the equivalent OpenAI request is:
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"tool": "openai_generate_image",
|
|
199
|
+
"arguments": {
|
|
200
|
+
"prompt": "A cinematic product photo of a transparent mechanical keyboard on a marble desk",
|
|
201
|
+
"model": "gpt-image-2",
|
|
202
|
+
"size": "1024x1024",
|
|
203
|
+
"return_mode": "file",
|
|
204
|
+
"output_path": "/absolute/path/to/generated-images"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Google reference-image example:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"tool": "google_generate_image",
|
|
214
|
+
"arguments": {
|
|
215
|
+
"prompt": "Turn this sketch into a polished mobile app hero illustration",
|
|
216
|
+
"model": "gemini-3.1-flash-image",
|
|
217
|
+
"input_images": ["/absolute/path/to/sketch.png"],
|
|
218
|
+
"aspect_ratio": "16:9",
|
|
219
|
+
"image_size": "512",
|
|
220
|
+
"return_mode": "file",
|
|
221
|
+
"output_path": "/absolute/path/to/generated-images"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Troubleshooting
|
|
227
|
+
|
|
228
|
+
### `npx` is not found
|
|
229
|
+
|
|
230
|
+
Install Node.js 20 or later and confirm that both `node --version` and `npx --version` work in a new terminal.
|
|
231
|
+
|
|
232
|
+
### The MCP tools do not appear
|
|
233
|
+
|
|
234
|
+
- Check the JSON or TOML syntax and the config file location.
|
|
235
|
+
- Completely restart the MCP client after editing its configuration.
|
|
236
|
+
- In Codex, use `/mcp`; in Cursor, check **Settings > Tools & MCP**.
|
|
237
|
+
|
|
238
|
+
### Authentication or billing errors
|
|
239
|
+
|
|
240
|
+
Confirm that the key matches the selected tool and that the provider account has access, billing, or credits enabled. Only the provider whose tool is called checks its key.
|
|
241
|
+
|
|
242
|
+
### An input image cannot be found
|
|
243
|
+
|
|
244
|
+
Replace relative paths with absolute paths that are readable by the local MCP server process.
|
|
245
|
+
|
|
246
|
+
### An inline image exceeds 4 MiB
|
|
247
|
+
|
|
248
|
+
Use `return_mode: "file"`, or raise `inline_max_bytes` only if the client can accept the larger payload.
|
|
249
|
+
|
|
250
|
+
## Development
|
|
251
|
+
|
|
252
|
+
For contributors working from the source repository:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install
|
|
256
|
+
npm run dev
|
|
257
|
+
npm run ci
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
`npm run ci` runs type checking, tests, and a production build.
|
|
261
|
+
|
|
262
|
+
## License
|
|
263
|
+
|
|
264
|
+
[MIT](./LICENSE)
|
package/README.zh-TW.md
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
# image-router-mcp
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/image-router-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/image-router-mcp)
|
|
5
|
+
|
|
6
|
+
[English](./README.md) | 繁體中文
|
|
7
|
+
|
|
8
|
+
開源 MCP 伺服器,可將圖片生成與編輯請求路由到 xAI/Grok、Google Gemini/Nano Banana 與 OpenAI。
|
|
9
|
+
|
|
10
|
+
可直接透過 npm 的 `npx` 執行。只需準備實際要使用之供應商的 API Key。
|
|
11
|
+
|
|
12
|
+
## 功能
|
|
13
|
+
|
|
14
|
+
- 分別提供 xAI、Google 與 OpenAI 三個明確的 MCP 工具。
|
|
15
|
+
- 支援文字生成圖片、本機參考圖及圖片編輯流程。
|
|
16
|
+
- 接受彈性的模型 ID,不會因固定允許清單而阻擋相容的新模型。
|
|
17
|
+
- 預設將圖片儲存成檔案,避免透過 stdio 傳送大型 base64 payload。
|
|
18
|
+
- 可選擇回傳 inline 圖片內容,讓支援的 MCP 客戶端直接顯示。
|
|
19
|
+
|
|
20
|
+
## 工具與預設模型
|
|
21
|
+
|
|
22
|
+
| 工具 | 供應商 | 內建預設模型 | 支援內容 |
|
|
23
|
+
| --- | --- | --- | --- |
|
|
24
|
+
| `openai_generate_image` | OpenAI | `gpt-image-2` | 文字生成圖片及本機參考圖/編輯圖 |
|
|
25
|
+
| `google_generate_image` | Google Gemini/Nano Banana | `gemini-3.1-flash-image` | 透過 Interactions API 進行文字生成圖片及本機參考圖/編輯圖 |
|
|
26
|
+
| `xai_generate_image` | xAI/Grok | `grok-imagine-image-quality` | 文字生成圖片,以及最多 3 張本機輸入圖的編輯 |
|
|
27
|
+
|
|
28
|
+
以上模型是範例與預設值,不是允許清單。可透過 `model` 參數傳入其他相容的模型 ID。
|
|
29
|
+
|
|
30
|
+
## 前置需求
|
|
31
|
+
|
|
32
|
+
- Node.js 20 以上版本,並包含 `npm` 與 `npx`。
|
|
33
|
+
- 支援本機 stdio server 的 MCP 客戶端,例如 Codex、Claude Desktop 或 Cursor。
|
|
34
|
+
- 至少一組供應商 API Key:
|
|
35
|
+
- OpenAI 使用 `OPENAI_API_KEY`
|
|
36
|
+
- Google 使用 `GOOGLE_API_KEY` 或 `GEMINI_API_KEY`
|
|
37
|
+
- xAI 使用 `XAI_API_KEY`
|
|
38
|
+
|
|
39
|
+
呼叫供應商 API 可能產生費用。只需設定實際要使用的供應商 Key。
|
|
40
|
+
|
|
41
|
+
> [!WARNING]
|
|
42
|
+
> 請勿將真實 API Key 提交到版本控制。含有密鑰的設定建議放在使用者層級;若 MCP 客戶端支援,也可從既有環境變數轉送 Key。
|
|
43
|
+
|
|
44
|
+
## 快速開始
|
|
45
|
+
|
|
46
|
+
以下範例只設定 OpenAI。若要使用 Google 或 xAI,請依照[環境設定](#環境設定)取代或加入對應的環境變數。
|
|
47
|
+
|
|
48
|
+
### Codex
|
|
49
|
+
|
|
50
|
+
透過命令列加入 server:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
codex mcp add image-router-mcp --env OPENAI_API_KEY=your_openai_key -- npx -y image-router-mcp
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
也可以加入所有專案共用的 `~/.codex/config.toml`,或單一受信任專案中的 `.codex/config.toml`:
|
|
57
|
+
|
|
58
|
+
```toml
|
|
59
|
+
[mcp_servers.image-router-mcp]
|
|
60
|
+
command = "npx"
|
|
61
|
+
args = ["-y", "image-router-mcp"]
|
|
62
|
+
|
|
63
|
+
[mcp_servers.image-router-mcp.env]
|
|
64
|
+
OPENAI_API_KEY = "your_openai_key"
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
編輯檔案後重新啟動 Codex,再使用 `/mcp` 確認 `image-router-mcp` 與三個工具已出現。
|
|
68
|
+
|
|
69
|
+
### Claude Desktop
|
|
70
|
+
|
|
71
|
+
開啟 **Settings > Developer > Edit Config**,將以下 server 加入 `claude_desktop_config.json`:
|
|
72
|
+
|
|
73
|
+
```json
|
|
74
|
+
{
|
|
75
|
+
"mcpServers": {
|
|
76
|
+
"image-router-mcp": {
|
|
77
|
+
"command": "npx",
|
|
78
|
+
"args": ["-y", "image-router-mcp"],
|
|
79
|
+
"env": {
|
|
80
|
+
"OPENAI_API_KEY": "your_openai_key"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
預設設定檔位置:
|
|
88
|
+
|
|
89
|
+
- macOS:`~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
90
|
+
- Windows:`%APPDATA%\Claude\claude_desktop_config.json`
|
|
91
|
+
|
|
92
|
+
儲存後請完整結束並重新開啟 Claude Desktop。
|
|
93
|
+
|
|
94
|
+
### Cursor
|
|
95
|
+
|
|
96
|
+
將上方相同的 JSON 設定加入下列其中一個位置:
|
|
97
|
+
|
|
98
|
+
- 全域:`~/.cursor/mcp.json`
|
|
99
|
+
- 僅限單一專案:`.cursor/mcp.json`
|
|
100
|
+
|
|
101
|
+
開啟 **Cursor Settings > Tools & MCP**,確認 server 與工具已啟用。
|
|
102
|
+
|
|
103
|
+
## 生成第一張圖片
|
|
104
|
+
|
|
105
|
+
連線完成後,直接向 MCP 客戶端提出:
|
|
106
|
+
|
|
107
|
+
> 使用 `openai_generate_image` 生成一張 1024x1024 的電影感產品照,內容是放在大理石桌面上的透明機械鍵盤。將圖片儲存到 `/absolute/path/to/generated-images`,並回傳儲存路徑。
|
|
108
|
+
|
|
109
|
+
若要編輯既有圖片:
|
|
110
|
+
|
|
111
|
+
> 使用 `google_generate_image`,以 `/absolute/path/to/sketch.png` 作為輸入圖片。將它轉換成精緻的 16:9 行動 App 主視覺插圖,並儲存到 `/absolute/path/to/generated-images`。
|
|
112
|
+
|
|
113
|
+
請在提示詞與工具呼叫中使用絕對路徑。相對路徑會受到 MCP 客戶端所選工作目錄影響。
|
|
114
|
+
|
|
115
|
+
## 路徑與圖片輸出
|
|
116
|
+
|
|
117
|
+
- `input_images` 路徑會從 MCP server process 的工作目錄開始解析。
|
|
118
|
+
- `output_path` 可以是檔案路徑或資料夾。
|
|
119
|
+
- 已存在的資料夾,或沒有副檔名的新路徑,會被視為資料夾。
|
|
120
|
+
- 帶有副檔名的路徑會被視為指定輸出檔名;若有多張結果,檔名會加入編號。
|
|
121
|
+
- 未傳入 `output_path` 時,圖片會儲存在 `DEFAULT_OUTPUT_DIR`;若未設定該變數,則使用 MCP server 工作目錄下的 `./generated-images`。
|
|
122
|
+
- 建議輸入與輸出都使用絕對路徑,確保不同客戶端有一致結果。
|
|
123
|
+
- 若要跨供應商使用本機圖片,建議採用 PNG、JPG/JPEG 或 WebP。Google 與 xAI 的載入器接受這些副檔名。
|
|
124
|
+
- xAI 最多接受 3 張 `input_images`。
|
|
125
|
+
|
|
126
|
+
### 回傳模式
|
|
127
|
+
|
|
128
|
+
| 模式 | 行為 |
|
|
129
|
+
| --- | --- |
|
|
130
|
+
| `file` | 預設。將圖片儲存到磁碟並回傳路徑。 |
|
|
131
|
+
| `inline` | 不儲存檔案,直接回傳 MCP `image` content;每張圖片受 `inline_max_bytes` 限制。 |
|
|
132
|
+
| `both` | 同時儲存圖片並回傳 inline MCP 圖片內容。 |
|
|
133
|
+
|
|
134
|
+
大型圖片建議使用 `file`。只有在 MCP 客戶端可以顯示圖片、且結果符合 payload 限制時,才使用 `inline` 或 `both`。
|
|
135
|
+
|
|
136
|
+
## 工具參數
|
|
137
|
+
|
|
138
|
+
### 共用參數
|
|
139
|
+
|
|
140
|
+
| 參數 | 必填 | 預設值 | 說明 |
|
|
141
|
+
| --- | --- | --- | --- |
|
|
142
|
+
| `prompt` | 是 | — | 圖片生成或編輯指示。 |
|
|
143
|
+
| `model` | 否 | 供應商預設值 | 相容的供應商模型 ID。 |
|
|
144
|
+
| `input_images` | 否 | `[]` | 本機參考圖/編輯圖路徑。 |
|
|
145
|
+
| `output_path` | 否 | `DEFAULT_OUTPUT_DIR` 或 `./generated-images` | 儲存結果的檔案或資料夾。 |
|
|
146
|
+
| `return_mode` | 否 | `file` | `file`、`inline` 或 `both`。 |
|
|
147
|
+
| `inline_max_bytes` | 否 | `4194304`(4 MiB) | 每張 inline 圖片允許的最大大小。 |
|
|
148
|
+
| `n` | 否 | 供應商預設值 | 供應商支援時的結果數量,範圍為 1 到 10;Google 目前回傳一張。 |
|
|
149
|
+
| `user` | 否 | — | 選用的終端使用者識別碼,供供應商進行濫用監控。 |
|
|
150
|
+
|
|
151
|
+
### OpenAI 參數
|
|
152
|
+
|
|
153
|
+
| 參數 | 值或範例 | 預設值 |
|
|
154
|
+
| --- | --- | --- |
|
|
155
|
+
| `size` | `auto`、`1024x1024`、`1536x1024` 或其他支援的 `WIDTHxHEIGHT` | 供應商預設值 |
|
|
156
|
+
| `quality` | `auto`、`low`、`medium`、`high`、`standard`、`hd` | 供應商預設值 |
|
|
157
|
+
| `background` | `transparent`、`opaque`、`auto` | 供應商預設值 |
|
|
158
|
+
| `output_format` | `png`、`jpeg`、`webp` | `png` |
|
|
159
|
+
| `moderation` | `low`、`auto` | 供應商預設值 |
|
|
160
|
+
| `style` | `vivid`、`natural`;供 DALL-E 3 使用 | 供應商預設值 |
|
|
161
|
+
|
|
162
|
+
### Google 參數
|
|
163
|
+
|
|
164
|
+
| 參數 | 值或範例 | 預設值 |
|
|
165
|
+
| --- | --- | --- |
|
|
166
|
+
| `aspect_ratio` | 例如 `1:1`、`16:9`、`9:16`、`4:3` 或 `3:2` | 供應商預設值 |
|
|
167
|
+
| `image_size` | `512`、`0.5K`、`1K`、`2K`、`4K`;實際可用值依模型而定 | 供應商預設值 |
|
|
168
|
+
|
|
169
|
+
`0.5K` 是相容舊版的別名,送出前會正規化為 `512`。
|
|
170
|
+
|
|
171
|
+
### xAI 參數
|
|
172
|
+
|
|
173
|
+
| 參數 | 值或範例 | 預設值 |
|
|
174
|
+
| --- | --- | --- |
|
|
175
|
+
| `aspect_ratio` | 例如 `1:1`、`16:9`、`9:16`、`3:2` 或 `auto` | 供應商預設值 |
|
|
176
|
+
| `resolution` | `1k`、`2k` | 供應商預設值 |
|
|
177
|
+
|
|
178
|
+
## 環境設定
|
|
179
|
+
|
|
180
|
+
| 變數 | 必要性 | 行為 |
|
|
181
|
+
| --- | --- | --- |
|
|
182
|
+
| `OPENAI_API_KEY` | 使用 OpenAI 工具時需要 | OpenAI API Key。 |
|
|
183
|
+
| `GOOGLE_API_KEY` 或 `GEMINI_API_KEY` | 使用 Google 工具時需要 | Google Gemini API Key。 |
|
|
184
|
+
| `XAI_API_KEY` | 使用 xAI 工具時需要 | xAI API Key。 |
|
|
185
|
+
| `DEFAULT_OPENAI_IMAGE_MODEL` | 否 | 未傳入 `model` 時使用的 OpenAI 預設模型;明確傳入的 `model` 可以覆寫。 |
|
|
186
|
+
| `DEFAULT_GOOGLE_IMAGE_MODEL` | 否 | 將 Google 請求固定到此模型,優先於每次呼叫的 `model` 參數。 |
|
|
187
|
+
| `DEFAULT_XAI_IMAGE_MODEL` | 否 | 將 xAI 請求固定到此模型,優先於每次呼叫的 `model` 參數。 |
|
|
188
|
+
| `DEFAULT_OUTPUT_DIR` | 否 | 預設圖片儲存資料夾;預設為 MCP server 工作目錄下的 `./generated-images`。 |
|
|
189
|
+
|
|
190
|
+
Key 只會在呼叫對應工具時檢查,因此只設定一個供應商 Key 即可開始使用。
|
|
191
|
+
|
|
192
|
+
## 進階直接工具呼叫
|
|
193
|
+
|
|
194
|
+
多數使用者直接用自然語言要求 MCP 客戶端即可。若客戶端支援直接呼叫工具,對等的 OpenAI 請求如下:
|
|
195
|
+
|
|
196
|
+
```json
|
|
197
|
+
{
|
|
198
|
+
"tool": "openai_generate_image",
|
|
199
|
+
"arguments": {
|
|
200
|
+
"prompt": "A cinematic product photo of a transparent mechanical keyboard on a marble desk",
|
|
201
|
+
"model": "gpt-image-2",
|
|
202
|
+
"size": "1024x1024",
|
|
203
|
+
"return_mode": "file",
|
|
204
|
+
"output_path": "/absolute/path/to/generated-images"
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Google 參考圖範例:
|
|
210
|
+
|
|
211
|
+
```json
|
|
212
|
+
{
|
|
213
|
+
"tool": "google_generate_image",
|
|
214
|
+
"arguments": {
|
|
215
|
+
"prompt": "Turn this sketch into a polished mobile app hero illustration",
|
|
216
|
+
"model": "gemini-3.1-flash-image",
|
|
217
|
+
"input_images": ["/absolute/path/to/sketch.png"],
|
|
218
|
+
"aspect_ratio": "16:9",
|
|
219
|
+
"image_size": "512",
|
|
220
|
+
"return_mode": "file",
|
|
221
|
+
"output_path": "/absolute/path/to/generated-images"
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 疑難排解
|
|
227
|
+
|
|
228
|
+
### 找不到 `npx`
|
|
229
|
+
|
|
230
|
+
安裝 Node.js 20 以上版本,並在新的終端機中確認 `node --version` 與 `npx --version` 都能執行。
|
|
231
|
+
|
|
232
|
+
### MCP 工具沒有出現
|
|
233
|
+
|
|
234
|
+
- 檢查 JSON 或 TOML 語法,以及設定檔位置。
|
|
235
|
+
- 編輯設定後,完整重新啟動 MCP 客戶端。
|
|
236
|
+
- Codex 使用 `/mcp` 檢查;Cursor 前往 **Settings > Tools & MCP**。
|
|
237
|
+
|
|
238
|
+
### API 驗證或帳務錯誤
|
|
239
|
+
|
|
240
|
+
確認 Key 與選擇的工具相符,且供應商帳戶已取得存取權限並啟用帳務或額度。只有被呼叫工具所屬的供應商會檢查 Key。
|
|
241
|
+
|
|
242
|
+
### 找不到輸入圖片
|
|
243
|
+
|
|
244
|
+
將相對路徑改為本機 MCP server process 可以讀取的絕對路徑。
|
|
245
|
+
|
|
246
|
+
### Inline 圖片超過 4 MiB
|
|
247
|
+
|
|
248
|
+
改用 `return_mode: "file"`;只有在客戶端能接受較大 payload 時,才提高 `inline_max_bytes`。
|
|
249
|
+
|
|
250
|
+
## 開發
|
|
251
|
+
|
|
252
|
+
若要從原始碼進行開發:
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
npm install
|
|
256
|
+
npm run dev
|
|
257
|
+
npm run ci
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
`npm run ci` 會執行型別檢查、測試與正式建置。
|
|
261
|
+
|
|
262
|
+
## 授權
|
|
263
|
+
|
|
264
|
+
[MIT](./LICENSE)
|
|
@@ -2,8 +2,8 @@ import { GoogleGenAI } from "@google/genai";
|
|
|
2
2
|
import type { GoogleParams } from "../schemas.js";
|
|
3
3
|
import type { ProviderResult } from "../types.js";
|
|
4
4
|
export type GoogleImageClient = {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
interactions: {
|
|
6
|
+
create: GoogleGenAI["interactions"]["create"];
|
|
7
7
|
};
|
|
8
8
|
};
|
|
9
9
|
export declare function setGoogleClientForTests(client: GoogleImageClient | undefined): void;
|
package/dist/providers/google.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GoogleGenAI
|
|
2
|
-
import { bytesFromBase64, loadInputImages } from "../files.js";
|
|
1
|
+
import { GoogleGenAI } from "@google/genai";
|
|
2
|
+
import { base64FromUrl, bytesFromBase64, loadInputImages } from "../files.js";
|
|
3
3
|
import { requireEnv } from "../errors.js";
|
|
4
4
|
let googleClient;
|
|
5
5
|
function getGoogleClient() {
|
|
@@ -14,54 +14,48 @@ export function setGoogleClientForTests(client) {
|
|
|
14
14
|
export async function generateGoogleImage(params, client = getGoogleClient()) {
|
|
15
15
|
const model = process.env.DEFAULT_GOOGLE_IMAGE_MODEL ?? params.model;
|
|
16
16
|
const inputImages = await loadInputImages(params.input_images);
|
|
17
|
-
const
|
|
18
|
-
{ text: params.prompt },
|
|
17
|
+
const input = [
|
|
19
18
|
...inputImages.map((image) => ({
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
19
|
+
type: "image",
|
|
20
|
+
data: image.data,
|
|
21
|
+
mime_type: image.mimeType,
|
|
24
22
|
})),
|
|
23
|
+
{ type: "text", text: params.prompt },
|
|
25
24
|
];
|
|
26
|
-
const response = await client.
|
|
25
|
+
const response = await client.interactions.create({
|
|
27
26
|
model,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
...(params.aspect_ratio ? { aspectRatio: params.aspect_ratio } : {}),
|
|
35
|
-
...(params.image_size ? { imageSize: params.image_size } : {}),
|
|
36
|
-
},
|
|
37
|
-
}
|
|
38
|
-
: {}),
|
|
27
|
+
input,
|
|
28
|
+
response_format: {
|
|
29
|
+
type: "image",
|
|
30
|
+
delivery: "inline",
|
|
31
|
+
...(params.aspect_ratio ? { aspect_ratio: params.aspect_ratio } : {}),
|
|
32
|
+
...(params.image_size ? { image_size: params.image_size === "0.5K" ? "512" : params.image_size } : {}),
|
|
39
33
|
},
|
|
40
34
|
});
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (
|
|
54
|
-
throw new Error(
|
|
35
|
+
const outputImage = response.output_image;
|
|
36
|
+
let image;
|
|
37
|
+
if (outputImage?.data) {
|
|
38
|
+
image = {
|
|
39
|
+
data: outputImage.data,
|
|
40
|
+
mimeType: outputImage.mime_type ?? "image/png",
|
|
41
|
+
bytes: bytesFromBase64(outputImage.data),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
else if (outputImage?.uri) {
|
|
45
|
+
image = { ...(await base64FromUrl(outputImage.uri)), url: outputImage.uri };
|
|
46
|
+
}
|
|
47
|
+
if (!image) {
|
|
48
|
+
throw new Error(response.output_text || `Google interaction ${response.status} did not include generated image data.`);
|
|
55
49
|
}
|
|
56
50
|
return {
|
|
57
51
|
provider: "google",
|
|
58
52
|
model,
|
|
59
|
-
images,
|
|
60
|
-
text:
|
|
53
|
+
images: [image],
|
|
54
|
+
text: response.output_text || undefined,
|
|
61
55
|
metadata: {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
56
|
+
interactionId: response.id,
|
|
57
|
+
status: response.status,
|
|
58
|
+
usage: response.usage,
|
|
65
59
|
},
|
|
66
60
|
};
|
|
67
61
|
}
|
package/dist/schemas.d.ts
CHANGED
|
@@ -50,6 +50,7 @@ export declare const googleInputShape: {
|
|
|
50
50
|
readonly model: z.ZodDefault<z.ZodString>;
|
|
51
51
|
readonly aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
52
52
|
readonly image_size: z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
512: "512";
|
|
53
54
|
"0.5K": "0.5K";
|
|
54
55
|
"1K": "1K";
|
|
55
56
|
"2K": "2K";
|
|
@@ -131,6 +132,7 @@ export declare const googleParamsSchema: z.ZodObject<{
|
|
|
131
132
|
model: z.ZodDefault<z.ZodString>;
|
|
132
133
|
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
133
134
|
image_size: z.ZodOptional<z.ZodEnum<{
|
|
135
|
+
512: "512";
|
|
134
136
|
"0.5K": "0.5K";
|
|
135
137
|
"1K": "1K";
|
|
136
138
|
"2K": "2K";
|
package/dist/schemas.js
CHANGED
|
@@ -35,7 +35,10 @@ export const googleInputShape = {
|
|
|
35
35
|
...commonImageShape,
|
|
36
36
|
model: nonEmptyString.default("gemini-3.1-flash-image").describe("Google image model ID. Defaults to Nano Banana 2."),
|
|
37
37
|
aspect_ratio: nonEmptyString.optional().describe("Aspect ratio, for example 1:1, 16:9, 9:16, 4:3, or 3:2."),
|
|
38
|
-
image_size: z
|
|
38
|
+
image_size: z
|
|
39
|
+
.enum(["512", "0.5K", "1K", "2K", "4K"])
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('Google image size where supported. Use "512" for 512px; legacy "0.5K" is accepted and normalized to "512".'),
|
|
39
42
|
};
|
|
40
43
|
export const xaiInputShape = {
|
|
41
44
|
...commonImageShape,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "image-router-mcp",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
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": {
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
13
|
"README.md",
|
|
14
|
+
"README.zh-TW.md",
|
|
14
15
|
"LICENSE"
|
|
15
16
|
],
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=20.0.0"
|
|
19
|
+
},
|
|
16
20
|
"scripts": {
|
|
17
21
|
"build": "tsc -p tsconfig.json",
|
|
18
22
|
"dev": "tsx src/index.ts",
|
|
@@ -33,16 +37,16 @@
|
|
|
33
37
|
"author": "",
|
|
34
38
|
"license": "MIT",
|
|
35
39
|
"dependencies": {
|
|
36
|
-
"@google/genai": "2.
|
|
40
|
+
"@google/genai": "2.13.0",
|
|
37
41
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
38
|
-
"openai": "6.
|
|
42
|
+
"openai": "6.49.0",
|
|
39
43
|
"zod": "4.4.3"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
42
46
|
"@types/node": "25.9.1",
|
|
43
|
-
"tsx": "4.
|
|
47
|
+
"tsx": "4.23.1",
|
|
44
48
|
"typescript": "6.0.3",
|
|
45
|
-
"vitest": "4.1.
|
|
49
|
+
"vitest": "4.1.10"
|
|
46
50
|
},
|
|
47
51
|
"repository": {
|
|
48
52
|
"type": "git",
|