imageforge-mcp 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -40
- package/dist/externalProviders.d.ts +71 -0
- package/dist/externalProviders.js +891 -0
- package/dist/externalProviders.js.map +1 -0
- package/dist/index.js +58 -11
- package/dist/index.js.map +1 -1
- package/dist/providers.d.ts +31 -2
- package/dist/providers.js +53 -3
- package/dist/providers.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,18 +2,16 @@
|
|
|
2
2
|
|
|
3
3
|
English | [中文](#中文说明)
|
|
4
4
|
|
|
5
|
-
A lightweight TypeScript MCP server for image generation
|
|
5
|
+
A lightweight TypeScript MCP server for image generation across 22 first-party providers, plus OpenAI image editing.
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- Provider adapters follow each vendor's documented synchronous or submit-and-poll REST contract.
|
|
8
8
|
- OpenAI image editing and reference-image generation use multipart `POST /v1/images/edits`.
|
|
9
9
|
- Generated images are returned as native MCP `image` content blocks and can optionally be saved locally.
|
|
10
10
|
|
|
11
11
|
## Features
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
- MiniMax models: `image-01`, `image-01-live`
|
|
16
|
-
- MCP tools: `generate_image` and `edit_image`
|
|
13
|
+
- 22 provider IDs: `openai`, `zhipu`, `minimax`, `google`, `xai`, `stability`, `ideogram`, `recraft`, `tencent`, `baidu`, `playground`, `bfl`, `luma`, `krea`, `runway`, `leonardo`, `bria`, `freepik`, `alibaba`, `volcengine`, `kling`, and `hidream`
|
|
14
|
+
- MCP tools: `generate_image`, `list_image_providers`, and `edit_image`
|
|
17
15
|
- Text-to-image generation
|
|
18
16
|
- Image generation guided by one or more reference images
|
|
19
17
|
- Zhipu text-to-image generation with optional server-side watermark control
|
|
@@ -29,16 +27,15 @@ A lightweight TypeScript MCP server for image generation with OpenAI, Zhipu BigM
|
|
|
29
27
|
|
|
30
28
|
## Provider capability matrix
|
|
31
29
|
|
|
32
|
-
|
|
|
33
|
-
| --- | --- | --- |
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
| Provider response | Base64 image data | Temporary image URL, downloaded immediately | Base64 image data |
|
|
30
|
+
| Group | Providers | Execution |
|
|
31
|
+
| --- | --- | --- |
|
|
32
|
+
| Existing compatibility | OpenAI, Zhipu, MiniMax | Synchronous |
|
|
33
|
+
| Additional synchronous APIs | Google Gemini, xAI, Stability AI, Ideogram, Recraft, Tencent Hunyuan, Baidu Qianfan, Playground, Volcengine Ark | Synchronous |
|
|
34
|
+
| Task APIs | Black Forest Labs, Luma, Krea, Runway, Leonardo, Bria, Freepik/Magnific, Alibaba Model Studio, Kling, HiDream | Submit once, then poll read-only status endpoints |
|
|
35
|
+
|
|
36
|
+
Call `list_image_providers` for the authoritative model list, default model, reference modes and limits, required environment-variable names, documentation URL, and contract-verification state. New 0.6.0 adapters are implemented from official documentation and covered by mocks; they are not represented as live credential verification.
|
|
37
|
+
|
|
38
|
+
`generate_image` keeps the existing common fields and adds `reference_mode` (`auto`, `content`, `style`, or `character`), `aspect_ratio`, `resolution`, `negative_prompt`, and `seed`. Unsupported combinations fail before provider access. `edit_image` remains OpenAI-only.
|
|
42
39
|
|
|
43
40
|
## Zhipu BigModel support
|
|
44
41
|
|
|
@@ -94,7 +91,7 @@ A gateway that only implements `/v1/images/generations` can be used for text-to-
|
|
|
94
91
|
## Requirements
|
|
95
92
|
|
|
96
93
|
- Node.js 22 or later
|
|
97
|
-
- A credential for the selected provider
|
|
94
|
+
- A credential for the selected provider; see `.env.example` or `list_image_providers`
|
|
98
95
|
|
|
99
96
|
## Install and build
|
|
100
97
|
|
|
@@ -124,7 +121,7 @@ For production use, start the published npm package with `npx`. No repository cl
|
|
|
124
121
|
}
|
|
125
122
|
```
|
|
126
123
|
|
|
127
|
-
`-y` allows `npx` to download or update the package without an interactive install prompt. Pin a specific version when reproducible deployments are required, for example `"imageforge-mcp@0.
|
|
124
|
+
`-y` allows `npx` to download or update the package without an interactive install prompt. Pin a specific version when reproducible deployments are required, for example `"imageforge-mcp@0.6.0"`.
|
|
128
125
|
|
|
129
126
|
For a Zhipu-default MCP server, use an independent credential and provider configuration:
|
|
130
127
|
|
|
@@ -133,7 +130,7 @@ For a Zhipu-default MCP server, use an independent credential and provider confi
|
|
|
133
130
|
"mcpServers": {
|
|
134
131
|
"imageforge-zhipu": {
|
|
135
132
|
"command": "npx",
|
|
136
|
-
"args": ["-y", "imageforge-mcp@0.
|
|
133
|
+
"args": ["-y", "imageforge-mcp@0.6.0"],
|
|
137
134
|
"env": {
|
|
138
135
|
"IMAGEFORGE_PROVIDER": "zhipu",
|
|
139
136
|
"ZHIPU_API_KEY": "your-zhipu-token",
|
|
@@ -153,7 +150,7 @@ For a MiniMax-default server:
|
|
|
153
150
|
"mcpServers": {
|
|
154
151
|
"imageforge-minimax": {
|
|
155
152
|
"command": "npx",
|
|
156
|
-
"args": ["-y", "imageforge-mcp@0.
|
|
153
|
+
"args": ["-y", "imageforge-mcp@0.6.0"],
|
|
157
154
|
"env": {
|
|
158
155
|
"IMAGEFORGE_PROVIDER": "minimax",
|
|
159
156
|
"MINIMAX_API_KEY": "your-minimax-token",
|
|
@@ -176,6 +173,8 @@ The value must point to the gateway's `/v1` root. ImageForge MCP appends `/image
|
|
|
176
173
|
|
|
177
174
|
`IMAGEFORGE_INPUT_CONCURRENCY` optionally controls how many local or remote input images are loaded at once. It defaults to `4`, must be a positive integer, and is capped at the per-call limit of `16` input images. The combined input size remains capped at 200 MB.
|
|
178
175
|
|
|
176
|
+
Task-based providers submit a paid generation request exactly once and then poll read-only status endpoints. `IMAGEFORGE_ASYNC_TIMEOUT_MS` defaults to `300000` and accepts 30000–600000; `IMAGEFORGE_POLL_INTERVAL_MS` defaults to `2000` and accepts 500–10000. Polling honors numeric `Retry-After` values within the same bounds. ImageForge does not use webhooks, retry a paid create call, or fall back to another provider.
|
|
177
|
+
|
|
179
178
|
DNS safety checks are enabled by default. Set `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS=true` only when private-network or DNS-proxy image URLs must be supported. This disables non-public address rejection and DNS pinning for every redirect hop, which can expose the MCP process to SSRF. HTTP(S)-only URLs, the credential restriction, redirect limit, size limits, and image signature validation remain enforced. Accepted true values are `true`, `1`, `yes`, and `on`; false values are `false`, `0`, `no`, and `off`.
|
|
180
179
|
|
|
181
180
|
Do not commit real API keys to Git or write them into shared configuration files.
|
|
@@ -222,6 +221,7 @@ For MiniMax, export `IMAGEFORGE_PROVIDER=minimax`, `MINIMAX_API_KEY`, and option
|
|
|
222
221
|
Codex loads project-scoped `.codex/config.toml` only for trusted projects. After adding or changing the MCP configuration, restart Codex or open a new task, then use `/mcp verbose` to confirm that `imageforge_dev` exposes:
|
|
223
222
|
|
|
224
223
|
- `generate_image`
|
|
224
|
+
- `list_image_providers`
|
|
225
225
|
- `edit_image`
|
|
226
226
|
|
|
227
227
|
After changing the TypeScript source, rebuild `dist/index.js` and restart the task using the MCP server:
|
|
@@ -369,18 +369,16 @@ Tests use a local HTTP mock. They do not call a real image API or incur generati
|
|
|
369
369
|
|
|
370
370
|
# 中文说明
|
|
371
371
|
|
|
372
|
-
ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,支持
|
|
372
|
+
ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,支持 22 个原厂生图 Provider,并保留 OpenAI 图片编辑能力。
|
|
373
373
|
|
|
374
|
-
-
|
|
374
|
+
- 各 Provider 按官方同步接口或“提交任务后轮询”REST 契约调用。
|
|
375
375
|
- OpenAI 图片编辑和参考图生图调用 multipart `POST /v1/images/edits`。
|
|
376
376
|
- 生成结果以原生 MCP `image` 内容块返回,也可以同时保存到本地。
|
|
377
377
|
|
|
378
378
|
## 功能
|
|
379
379
|
|
|
380
|
-
-
|
|
381
|
-
-
|
|
382
|
-
- MiniMax 模型:`image-01`、`image-01-live`
|
|
383
|
-
- MCP 工具:`generate_image`、`edit_image`
|
|
380
|
+
- 22 个 Provider ID:`openai`、`zhipu`、`minimax`、`google`、`xai`、`stability`、`ideogram`、`recraft`、`tencent`、`baidu`、`playground`、`bfl`、`luma`、`krea`、`runway`、`leonardo`、`bria`、`freepik`、`alibaba`、`volcengine`、`kling`、`hidream`
|
|
381
|
+
- MCP 工具:`generate_image`、`list_image_providers`、`edit_image`
|
|
384
382
|
- 支持纯文本生图
|
|
385
383
|
- 支持一张或多张参考图引导生图
|
|
386
384
|
- 支持 MiniMax 单张主体参考图生图
|
|
@@ -395,16 +393,15 @@ ImageForge MCP 是一个轻量的 TypeScript MCP 图片生成与编辑服务,
|
|
|
395
393
|
|
|
396
394
|
## 供应商能力矩阵
|
|
397
395
|
|
|
398
|
-
|
|
|
399
|
-
| --- | --- | --- |
|
|
400
|
-
|
|
|
401
|
-
|
|
|
402
|
-
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
| 供应商响应 | Base64 图片数据 | 临时图片 URL,由 ImageForge 立即下载 | Base64 图片数据 |
|
|
396
|
+
| 分组 | Provider | 执行方式 |
|
|
397
|
+
| --- | --- | --- |
|
|
398
|
+
| 现有兼容 | OpenAI、智谱、MiniMax | 同步 |
|
|
399
|
+
| 新增同步接口 | Google Gemini、xAI、Stability AI、Ideogram、Recraft、腾讯混元、百度千帆、Playground、火山方舟 | 同步 |
|
|
400
|
+
| 任务型接口 | Black Forest Labs、Luma、Krea、Runway、Leonardo、Bria、Freepik/Magnific、阿里 Model Studio、Kling、HiDream | 创建一次,随后只读轮询 |
|
|
401
|
+
|
|
402
|
+
调用 `list_image_providers` 可查询权威模型列表、默认模型、参考图模式和上限、环境变量名、官方文档地址与合约验证状态。0.6.0 新增适配器均按官方文档和 Mock 合约测试实现,不宣称已经使用真实密钥验收。
|
|
403
|
+
|
|
404
|
+
`generate_image` 在原参数上新增 `reference_mode`(`auto`、`content`、`style`、`character`)、`aspect_ratio`、`resolution`、`negative_prompt` 和 `seed`;不支持的组合会在访问供应商前失败。`edit_image` 仍仅支持 OpenAI。
|
|
408
405
|
|
|
409
406
|
## 智谱 BigModel 支持
|
|
410
407
|
|
|
@@ -460,7 +457,7 @@ ImageForge MCP 不仅支持 OpenAI 官方接口,也支持实现了 OpenAI Imag
|
|
|
460
457
|
## 环境要求
|
|
461
458
|
|
|
462
459
|
- Node.js 22 或更高版本
|
|
463
|
-
-
|
|
460
|
+
- 所选 Provider 的凭据;完整变量名见 `.env.example` 或 `list_image_providers`
|
|
464
461
|
|
|
465
462
|
## 安装与构建
|
|
466
463
|
|
|
@@ -490,7 +487,7 @@ npm run build
|
|
|
490
487
|
}
|
|
491
488
|
```
|
|
492
489
|
|
|
493
|
-
`-y` 允许 `npx` 在没有交互式安装提示的情况下下载或更新包。如果部署需要固定版本,可将包名写成 `"imageforge-mcp@0.
|
|
490
|
+
`-y` 允许 `npx` 在没有交互式安装提示的情况下下载或更新包。如果部署需要固定版本,可将包名写成 `"imageforge-mcp@0.6.0"`。
|
|
494
491
|
|
|
495
492
|
如果希望 MCP 默认使用智谱,应使用独立的智谱凭据与供应商配置:
|
|
496
493
|
|
|
@@ -499,7 +496,7 @@ npm run build
|
|
|
499
496
|
"mcpServers": {
|
|
500
497
|
"imageforge-zhipu": {
|
|
501
498
|
"command": "npx",
|
|
502
|
-
"args": ["-y", "imageforge-mcp@0.
|
|
499
|
+
"args": ["-y", "imageforge-mcp@0.6.0"],
|
|
503
500
|
"env": {
|
|
504
501
|
"IMAGEFORGE_PROVIDER": "zhipu",
|
|
505
502
|
"ZHIPU_API_KEY": "你的智谱令牌",
|
|
@@ -519,7 +516,7 @@ MiniMax 默认配置示例:
|
|
|
519
516
|
"mcpServers": {
|
|
520
517
|
"imageforge-minimax": {
|
|
521
518
|
"command": "npx",
|
|
522
|
-
"args": ["-y", "imageforge-mcp@0.
|
|
519
|
+
"args": ["-y", "imageforge-mcp@0.6.0"],
|
|
523
520
|
"env": {
|
|
524
521
|
"IMAGEFORGE_PROVIDER": "minimax",
|
|
525
522
|
"MINIMAX_API_KEY": "你的-MiniMax-令牌",
|
|
@@ -542,6 +539,8 @@ MiniMax 默认配置示例:
|
|
|
542
539
|
|
|
543
540
|
`IMAGEFORGE_INPUT_CONCURRENCY` 可选,用于控制同时加载的本地或远程输入图片数量。默认值为 `4`,必须是正整数,并直接受单次最多 `16` 张输入图片的限制。单次调用的输入图片合计大小仍固定限制为 200 MB。
|
|
544
541
|
|
|
542
|
+
任务型 Provider 只提交一次收费生图请求,之后仅轮询只读状态接口。`IMAGEFORGE_ASYNC_TIMEOUT_MS` 默认 `300000`、范围 30000–600000;`IMAGEFORGE_POLL_INTERVAL_MS` 默认 `2000`、范围 500–10000。轮询会在同一边界内遵循数值型 `Retry-After`。ImageForge 不使用 webhook、不重试收费创建请求,也不回退到其他 Provider。
|
|
543
|
+
|
|
545
544
|
DNS 安全检查默认启用。只有确实需要访问私有网络地址或 DNS 代理生成的图片地址时,才应设置 `IMAGEFORGE_SKIP_DNS_SAFETY_CHECKS=true`。启用后,每次重定向都不再执行非公网地址拦截和 DNS 地址固定,可能使 MCP 进程面临 SSRF 风险。HTTP(S) 协议限制、URL 凭据限制、重定向次数、图片大小和图片魔数校验仍然有效。真值支持 `true`、`1`、`yes`、`on`,假值支持 `false`、`0`、`no`、`off`。
|
|
546
545
|
|
|
547
546
|
不要把真实 API Key 写入 Git 或其他共享配置文件。
|
|
@@ -588,6 +587,7 @@ export ZHIPU_IMAGE_MODEL="glm-image"
|
|
|
588
587
|
Codex 只会加载已信任项目中的 `.codex/config.toml`。新增或修改 MCP 配置后,需要重新启动 Codex 或新建任务,再使用 `/mcp verbose` 确认 `imageforge_dev` 提供以下工具:
|
|
589
588
|
|
|
590
589
|
- `generate_image`
|
|
590
|
+
- `list_image_providers`
|
|
591
591
|
- `edit_image`
|
|
592
592
|
|
|
593
593
|
修改 TypeScript 源码后,需要重新构建并重启使用该 MCP 的任务:
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type LoadedImage } from "./imageInput.js";
|
|
2
|
+
export declare const EXTERNAL_PROVIDER_IDS: readonly ["google", "xai", "stability", "ideogram", "recraft", "tencent", "baidu", "playground", "bfl", "luma", "krea", "runway", "leonardo", "bria", "freepik", "alibaba", "volcengine", "kling", "hidream"];
|
|
3
|
+
export type ExternalProviderId = typeof EXTERNAL_PROVIDER_IDS[number];
|
|
4
|
+
export type ReferenceMode = "auto" | "content" | "style" | "character";
|
|
5
|
+
type Quality = "auto" | "low" | "medium" | "high" | "standard" | "hd";
|
|
6
|
+
type OutputFormat = "png" | "jpeg" | "webp";
|
|
7
|
+
export interface ExternalImageConfig {
|
|
8
|
+
provider: ExternalProviderId;
|
|
9
|
+
apiKey: string;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
model: string;
|
|
12
|
+
}
|
|
13
|
+
export interface ExternalGeneratedImage {
|
|
14
|
+
data: Buffer;
|
|
15
|
+
mimeType: "image/png" | "image/jpeg" | "image/webp";
|
|
16
|
+
}
|
|
17
|
+
interface ExternalRequestInput {
|
|
18
|
+
prompt: string;
|
|
19
|
+
config: ExternalImageConfig;
|
|
20
|
+
size: string;
|
|
21
|
+
quality: Quality;
|
|
22
|
+
outputFormat?: OutputFormat;
|
|
23
|
+
watermarkEnabled?: boolean;
|
|
24
|
+
inputImages?: LoadedImage[];
|
|
25
|
+
referenceMode?: ReferenceMode;
|
|
26
|
+
aspectRatio?: string;
|
|
27
|
+
resolution?: string;
|
|
28
|
+
negativePrompt?: string;
|
|
29
|
+
seed?: number;
|
|
30
|
+
fetchImpl?: typeof fetch;
|
|
31
|
+
downloadFetchImpl?: typeof fetch;
|
|
32
|
+
}
|
|
33
|
+
interface ProviderDefinition {
|
|
34
|
+
id: ExternalProviderId;
|
|
35
|
+
name: string;
|
|
36
|
+
docsUrl: string;
|
|
37
|
+
baseUrl: string;
|
|
38
|
+
baseUrlEnv: string;
|
|
39
|
+
apiKeyEnv: string;
|
|
40
|
+
modelEnv: string;
|
|
41
|
+
defaultModel: string;
|
|
42
|
+
models: readonly string[];
|
|
43
|
+
referenceModes: readonly ReferenceMode[];
|
|
44
|
+
maxReferences: number;
|
|
45
|
+
async: boolean;
|
|
46
|
+
}
|
|
47
|
+
export declare function isExternalProvider(value: string): value is ExternalProviderId;
|
|
48
|
+
export declare function externalProviderDefinitions(): readonly ProviderDefinition[];
|
|
49
|
+
export declare function resolveExternalConfig(input: {
|
|
50
|
+
provider: ExternalProviderId;
|
|
51
|
+
apiKey?: string;
|
|
52
|
+
baseUrl?: string;
|
|
53
|
+
model?: string;
|
|
54
|
+
}): ExternalImageConfig;
|
|
55
|
+
export declare function requestExternalImage(input: ExternalRequestInput): Promise<ExternalGeneratedImage>;
|
|
56
|
+
export declare function externalCapabilities(): {
|
|
57
|
+
provider: "google" | "xai" | "stability" | "ideogram" | "recraft" | "tencent" | "baidu" | "playground" | "bfl" | "luma" | "krea" | "runway" | "leonardo" | "bria" | "freepik" | "alibaba" | "volcengine" | "kling" | "hidream";
|
|
58
|
+
name: string;
|
|
59
|
+
default_model: string;
|
|
60
|
+
models: string[];
|
|
61
|
+
reference_modes: ReferenceMode[];
|
|
62
|
+
max_reference_images: number;
|
|
63
|
+
async: boolean;
|
|
64
|
+
credential_environment_variables: string[];
|
|
65
|
+
base_url_environment_variable: string;
|
|
66
|
+
model_environment_variable: string;
|
|
67
|
+
docs_url: string;
|
|
68
|
+
implementation_basis: string;
|
|
69
|
+
live_verified: boolean;
|
|
70
|
+
}[];
|
|
71
|
+
export {};
|