mcp-duojie-image 0.5.7 → 0.5.8
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 +1 -5
- package/dist/config.js +0 -5
- package/dist/index.js +1 -5
- package/dist/provider.js +2 -7
- package/package.json +46 -46
package/README.md
CHANGED
|
@@ -18,7 +18,6 @@ Required:
|
|
|
18
18
|
|---|---|---|
|
|
19
19
|
| `DUOJIE_API_KEY` | required | duojie.games API key |
|
|
20
20
|
| `DUOJIE_BASE_URL` | `https://api.duojie.games` | API base URL |
|
|
21
|
-
| `DUOJIE_IMAGE_MODEL` | `gpt-image-2` | Optional; only `gpt-image-2` is supported |
|
|
22
21
|
|
|
23
22
|
## Tool: `generate_image`
|
|
24
23
|
|
|
@@ -31,7 +30,6 @@ Required parameters:
|
|
|
31
30
|
| `prompt` | string | Image prompt |
|
|
32
31
|
| `output_dir` | string | Absolute output directory |
|
|
33
32
|
| `output_filename` | string | Filename without extension |
|
|
34
|
-
| `model` | `gpt-image-2` | Only supported model |
|
|
35
33
|
|
|
36
34
|
Optional parameters:
|
|
37
35
|
|
|
@@ -71,8 +69,7 @@ Done response:
|
|
|
71
69
|
"success": true,
|
|
72
70
|
"task_id": "uuid",
|
|
73
71
|
"status": "done",
|
|
74
|
-
"saved_path": "D:/images/output.png"
|
|
75
|
-
"model": "gpt-image-2"
|
|
72
|
+
"saved_path": "D:/images/output.png"
|
|
76
73
|
}
|
|
77
74
|
```
|
|
78
75
|
|
|
@@ -105,7 +102,6 @@ These templates were tested directly against `/v1/images/generations`; all retur
|
|
|
105
102
|
```text
|
|
106
103
|
generate_image(
|
|
107
104
|
prompt="A futuristic city at sunset",
|
|
108
|
-
model="gpt-image-2",
|
|
109
105
|
size="2K",
|
|
110
106
|
aspect_ratio="16:9",
|
|
111
107
|
output_dir="D:/ai-images",
|
package/dist/config.js
CHANGED
|
@@ -9,14 +9,9 @@ export function loadConfig(overrides) {
|
|
|
9
9
|
if (!apiKey) {
|
|
10
10
|
throw new AppError("E_CONFIG_MISSING_KEY", "DUOJIE_API_KEY is not set");
|
|
11
11
|
}
|
|
12
|
-
const model = overrides?.model ?? process.env.DUOJIE_IMAGE_MODEL ?? "gpt-image-2";
|
|
13
|
-
if (model !== "gpt-image-2") {
|
|
14
|
-
throw new AppError("E_INPUT_INVALID", "Only gpt-image-2 is supported");
|
|
15
|
-
}
|
|
16
12
|
return {
|
|
17
13
|
apiKey,
|
|
18
14
|
baseUrl: overrides?.baseUrl ?? process.env.DUOJIE_BASE_URL ?? "https://api.duojie.games",
|
|
19
|
-
model,
|
|
20
15
|
timeoutMs: 300_000,
|
|
21
16
|
};
|
|
22
17
|
}
|
package/dist/index.js
CHANGED
|
@@ -32,7 +32,7 @@ const server = new McpServer({
|
|
|
32
32
|
version: "0.1.0",
|
|
33
33
|
});
|
|
34
34
|
server.registerTool("generate_image", {
|
|
35
|
-
description: "Generate image async
|
|
35
|
+
description: "Generate image async with gpt-image-2. Return after tool call; don't wait/check.",
|
|
36
36
|
inputSchema: z.object({
|
|
37
37
|
prompt: z.string().min(1).describe("Prompt"),
|
|
38
38
|
output_dir: z.string().describe("Absolute output dir"),
|
|
@@ -41,7 +41,6 @@ server.registerTool("generate_image", {
|
|
|
41
41
|
size: z.enum(IMAGE_SIZES).optional().describe("Default 1K. Supported: 1K, 2K, 4K"),
|
|
42
42
|
aspect_ratio: z.enum(ASPECT_RATIOS).optional().describe("Supported: 1:1, 3:2, 2:3, 16:9, 9:16"),
|
|
43
43
|
format: z.string().optional().describe("Default png"),
|
|
44
|
-
model: z.enum(["gpt-image-2"]).describe("Required; only gpt-image-2 is supported"),
|
|
45
44
|
overwrite: z.boolean().optional().describe("Default false"),
|
|
46
45
|
negative_prompt: z.string().optional().describe("Avoid"),
|
|
47
46
|
silent: z.boolean().optional().describe("No notification"),
|
|
@@ -64,7 +63,6 @@ server.registerTool("generate_image", {
|
|
|
64
63
|
const imageBuffer = await generateImage(config, {
|
|
65
64
|
prompt: args.prompt,
|
|
66
65
|
referenceImages: args.reference_images,
|
|
67
|
-
model: args.model,
|
|
68
66
|
negativePrompt: args.negative_prompt,
|
|
69
67
|
size: args.size ?? "1K",
|
|
70
68
|
aspectRatio: args.aspect_ratio,
|
|
@@ -79,7 +77,6 @@ server.registerTool("generate_image", {
|
|
|
79
77
|
status: "done",
|
|
80
78
|
completedAt: Date.now(),
|
|
81
79
|
savedPath,
|
|
82
|
-
model: args.model,
|
|
83
80
|
});
|
|
84
81
|
await server.sendLoggingMessage({
|
|
85
82
|
level: "info",
|
|
@@ -147,7 +144,6 @@ server.registerTool("check_image_task", {
|
|
|
147
144
|
};
|
|
148
145
|
if (task.status === "done") {
|
|
149
146
|
response.saved_path = task.savedPath;
|
|
150
|
-
response.model = task.model;
|
|
151
147
|
}
|
|
152
148
|
if (task.status === "failed") {
|
|
153
149
|
response.error = task.errorCode;
|
package/dist/provider.js
CHANGED
|
@@ -81,7 +81,6 @@ async function handleProviderError(res) {
|
|
|
81
81
|
throw new AppError("E_PROVIDER_BAD_REQUEST", `Upstream error ${res.status}: ${text.slice(0, 200)}`);
|
|
82
82
|
}
|
|
83
83
|
async function generateOpenAIImage(config, opts) {
|
|
84
|
-
const model = opts.model ?? config.model;
|
|
85
84
|
const prompt = opts.negativePrompt ? `${opts.prompt}\n\nAvoid: ${opts.negativePrompt}` : opts.prompt;
|
|
86
85
|
const size = mapOpenAISize(opts.size, opts.aspectRatio);
|
|
87
86
|
const hasReferenceImages = Boolean(opts.referenceImages?.length);
|
|
@@ -92,7 +91,7 @@ async function generateOpenAIImage(config, opts) {
|
|
|
92
91
|
};
|
|
93
92
|
if (hasReferenceImages) {
|
|
94
93
|
const form = new FormData();
|
|
95
|
-
form.set("model",
|
|
94
|
+
form.set("model", GPT_IMAGE_MODEL);
|
|
96
95
|
form.set("prompt", prompt);
|
|
97
96
|
form.set("size", size);
|
|
98
97
|
if (opts.aspectRatio) {
|
|
@@ -108,7 +107,7 @@ async function generateOpenAIImage(config, opts) {
|
|
|
108
107
|
else {
|
|
109
108
|
headers = { ...headers, "Content-Type": "application/json" };
|
|
110
109
|
body = JSON.stringify({
|
|
111
|
-
model,
|
|
110
|
+
model: GPT_IMAGE_MODEL,
|
|
112
111
|
prompt,
|
|
113
112
|
size,
|
|
114
113
|
...(opts.aspectRatio ? { aspect_ratio: opts.aspectRatio } : {}),
|
|
@@ -125,9 +124,5 @@ async function generateOpenAIImage(config, opts) {
|
|
|
125
124
|
return imageFromOpenAIResponse(res);
|
|
126
125
|
}
|
|
127
126
|
export async function generateImage(config, opts) {
|
|
128
|
-
const model = opts.model ?? config.model;
|
|
129
|
-
if (model !== GPT_IMAGE_MODEL) {
|
|
130
|
-
throw new AppError("E_PROVIDER_BAD_REQUEST", `Unsupported model: ${model}`);
|
|
131
|
-
}
|
|
132
127
|
return generateOpenAIImage(config, opts);
|
|
133
128
|
}
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "mcp-duojie-image",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "MCP server for image generation via duojie.games",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"bin": {
|
|
8
|
-
"mcp-duojie-image": "dist/index.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"dev": "tsx src/index.ts",
|
|
12
|
-
"build": "tsc",
|
|
13
|
-
"start": "node dist/index.js",
|
|
14
|
-
"test": "vitest run",
|
|
15
|
-
"lint": "tsc --noEmit",
|
|
16
|
-
"prepublishOnly": "npm run build"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"mcp",
|
|
20
|
-
"image-generation",
|
|
21
|
-
"gpt",
|
|
22
|
-
"openai",
|
|
23
|
-
"ai"
|
|
24
|
-
],
|
|
25
|
-
"author": "",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
29
|
-
"jimp": "^1.6.0",
|
|
30
|
-
"node-notifier": "^10.0.1",
|
|
31
|
-
"zod": "^3.23.8"
|
|
32
|
-
},
|
|
33
|
-
"devDependencies": {
|
|
34
|
-
"@types/node": "^22.0.0",
|
|
35
|
-
"@types/node-notifier": "^8.0.5",
|
|
36
|
-
"tsx": "^4.19.0",
|
|
37
|
-
"typescript": "^5.5.0",
|
|
38
|
-
"vitest": "^2.0.0"
|
|
39
|
-
},
|
|
40
|
-
"engines": {
|
|
41
|
-
"node": ">=18.0.0"
|
|
42
|
-
},
|
|
43
|
-
"files": [
|
|
44
|
-
"dist"
|
|
45
|
-
]
|
|
46
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-duojie-image",
|
|
3
|
+
"version": "0.5.8",
|
|
4
|
+
"description": "MCP server for image generation via duojie.games",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"bin": {
|
|
8
|
+
"mcp-duojie-image": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "tsx src/index.ts",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"start": "node dist/index.js",
|
|
14
|
+
"test": "vitest run",
|
|
15
|
+
"lint": "tsc --noEmit",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"mcp",
|
|
20
|
+
"image-generation",
|
|
21
|
+
"gpt",
|
|
22
|
+
"openai",
|
|
23
|
+
"ai"
|
|
24
|
+
],
|
|
25
|
+
"author": "",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
29
|
+
"jimp": "^1.6.0",
|
|
30
|
+
"node-notifier": "^10.0.1",
|
|
31
|
+
"zod": "^3.23.8"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@types/node": "^22.0.0",
|
|
35
|
+
"@types/node-notifier": "^8.0.5",
|
|
36
|
+
"tsx": "^4.19.0",
|
|
37
|
+
"typescript": "^5.5.0",
|
|
38
|
+
"vitest": "^2.0.0"
|
|
39
|
+
},
|
|
40
|
+
"engines": {
|
|
41
|
+
"node": ">=18.0.0"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
|
+
}
|