grok-imagine-image-mcp-server 1.0.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/.env.example +15 -0
- package/LICENSE +21 -0
- package/README.ja.md +225 -0
- package/README.md +225 -0
- package/dist/cli/batch.d.ts +19 -0
- package/dist/cli/batch.d.ts.map +1 -0
- package/dist/cli/batch.js +288 -0
- package/dist/cli/batch.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +203 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/edit.d.ts +14 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +236 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/generate.d.ts +13 -0
- package/dist/tools/generate.d.ts.map +1 -0
- package/dist/tools/generate.js +183 -0
- package/dist/tools/generate.js.map +1 -0
- package/dist/types/batch.d.ts +137 -0
- package/dist/types/batch.d.ts.map +1 -0
- package/dist/types/batch.js +5 -0
- package/dist/types/batch.js.map +1 -0
- package/dist/types/tools.d.ts +52 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +20 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/batch-config.d.ts +31 -0
- package/dist/utils/batch-config.d.ts.map +1 -0
- package/dist/utils/batch-config.js +236 -0
- package/dist/utils/batch-config.js.map +1 -0
- package/dist/utils/batch-manager.d.ts +24 -0
- package/dist/utils/batch-manager.d.ts.map +1 -0
- package/dist/utils/batch-manager.js +301 -0
- package/dist/utils/batch-manager.js.map +1 -0
- package/dist/utils/debug.d.ts +5 -0
- package/dist/utils/debug.d.ts.map +1 -0
- package/dist/utils/debug.js +16 -0
- package/dist/utils/debug.js.map +1 -0
- package/dist/utils/image.d.ts +36 -0
- package/dist/utils/image.d.ts.map +1 -0
- package/dist/utils/image.js +85 -0
- package/dist/utils/image.js.map +1 -0
- package/dist/utils/path.d.ts +16 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +70 -0
- package/dist/utils/path.js.map +1 -0
- package/examples/batch-detailed.json +41 -0
- package/examples/batch-simple.json +14 -0
- package/examples/batch-variants.json +23 -0
- package/examples/batch-with-edits.json +26 -0
- package/package.json +66 -0
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Edit image tool - Edit images using xAI Grok Imagine
|
|
3
|
+
* Uses /v1/images/edits endpoint
|
|
4
|
+
*/
|
|
5
|
+
import * as fs from 'fs/promises';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
8
|
+
import { saveBase64Image, downloadAndSaveImage, generateThumbnailData, isThumbnailEnabled, createThumbnailContent, } from '../utils/image.js';
|
|
9
|
+
import { normalizeAndValidatePath, getDisplayPath, generateUniqueFilePath, } from '../utils/path.js';
|
|
10
|
+
import { debugLog } from '../utils/debug.js';
|
|
11
|
+
import { RESOLUTIONS, MODELS } from '../types/tools.js';
|
|
12
|
+
// Edit endpoint is different from generation endpoint
|
|
13
|
+
const XAI_EDIT_ENDPOINT = 'https://api.x.ai/v1/images/edits';
|
|
14
|
+
export async function editImage(apiKey, params) {
|
|
15
|
+
debugLog('Edit image called with params:', {
|
|
16
|
+
...params,
|
|
17
|
+
image_base64: params.image_base64 ? '[REDACTED]' : undefined,
|
|
18
|
+
});
|
|
19
|
+
const { prompt, image_path, image_base64, image_url, output_path = 'edited_image.jpg', model = 'grok-imagine-image', n = 1, resolution = '1k', response_format = 'b64_json', return_base64 = false, include_thumbnail, } = params;
|
|
20
|
+
// Validate that at least one image source is provided
|
|
21
|
+
if (!image_path && !image_base64 && !image_url) {
|
|
22
|
+
throw new McpError(ErrorCode.InvalidParams, 'One of image_path, image_base64, or image_url is required');
|
|
23
|
+
}
|
|
24
|
+
// Normalize and validate output path
|
|
25
|
+
let normalizedPath = await normalizeAndValidatePath(output_path);
|
|
26
|
+
normalizedPath = await generateUniqueFilePath(normalizedPath);
|
|
27
|
+
// Validation
|
|
28
|
+
if (!prompt || prompt.trim().length === 0) {
|
|
29
|
+
throw new McpError(ErrorCode.InvalidParams, 'Prompt is required and cannot be empty');
|
|
30
|
+
}
|
|
31
|
+
if (!MODELS.includes(model)) {
|
|
32
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid model: ${model}. Must be one of: ${MODELS.join(', ')}`);
|
|
33
|
+
}
|
|
34
|
+
// Only grok-imagine-image supports image editing
|
|
35
|
+
if (model !== 'grok-imagine-image') {
|
|
36
|
+
throw new McpError(ErrorCode.InvalidParams, `Image editing is only supported by grok-imagine-image model. Got: ${model}`);
|
|
37
|
+
}
|
|
38
|
+
if (n < 1 || n > 10) {
|
|
39
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid n: ${n}. Must be between 1 and 10`);
|
|
40
|
+
}
|
|
41
|
+
if (!RESOLUTIONS.includes(resolution)) {
|
|
42
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid resolution: ${resolution}. Must be one of: ${RESOLUTIONS.join(', ')}`);
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
// Prepare image URL
|
|
46
|
+
let imageDataUrl;
|
|
47
|
+
if (image_base64) {
|
|
48
|
+
imageDataUrl = `data:image/jpeg;base64,${image_base64}`;
|
|
49
|
+
debugLog('Using provided base64 image');
|
|
50
|
+
}
|
|
51
|
+
else if (image_path) {
|
|
52
|
+
// Read image from file and convert to data URL
|
|
53
|
+
const absolutePath = path.isAbsolute(image_path)
|
|
54
|
+
? image_path
|
|
55
|
+
: path.join(process.cwd(), image_path);
|
|
56
|
+
debugLog(`Reading image from: ${absolutePath}`);
|
|
57
|
+
try {
|
|
58
|
+
const imageBuffer = await fs.readFile(absolutePath);
|
|
59
|
+
const base64 = imageBuffer.toString('base64');
|
|
60
|
+
imageDataUrl = `data:image/jpeg;base64,${base64}`;
|
|
61
|
+
debugLog(`Image loaded: ${imageBuffer.length} bytes`);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to read image file: ${error.message}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (image_url) {
|
|
68
|
+
// Use URL directly or download and convert
|
|
69
|
+
if (image_url.startsWith('data:')) {
|
|
70
|
+
imageDataUrl = image_url;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
// Download image from URL and convert to data URL
|
|
74
|
+
debugLog(`Downloading image from: ${image_url}`);
|
|
75
|
+
try {
|
|
76
|
+
const response = await fetch(image_url);
|
|
77
|
+
if (!response.ok) {
|
|
78
|
+
throw new Error(`HTTP ${response.status}`);
|
|
79
|
+
}
|
|
80
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
81
|
+
const base64 = Buffer.from(arrayBuffer).toString('base64');
|
|
82
|
+
imageDataUrl = `data:image/jpeg;base64,${base64}`;
|
|
83
|
+
debugLog(`Image downloaded: ${arrayBuffer.byteLength} bytes`);
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
throw new McpError(ErrorCode.InvalidParams, `Failed to download image from URL: ${error.message}`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new McpError(ErrorCode.InvalidParams, 'No image source provided');
|
|
92
|
+
}
|
|
93
|
+
debugLog('Calling xAI Edit API...');
|
|
94
|
+
// Build request body according to /v1/images/edits spec
|
|
95
|
+
const requestBody = {
|
|
96
|
+
model,
|
|
97
|
+
prompt,
|
|
98
|
+
image: {
|
|
99
|
+
url: imageDataUrl,
|
|
100
|
+
},
|
|
101
|
+
n,
|
|
102
|
+
resolution,
|
|
103
|
+
response_format,
|
|
104
|
+
};
|
|
105
|
+
debugLog('Request body:', {
|
|
106
|
+
...requestBody,
|
|
107
|
+
image: { url: '[DATA_URL]' },
|
|
108
|
+
});
|
|
109
|
+
// Call xAI Edit API
|
|
110
|
+
const response = await fetch(XAI_EDIT_ENDPOINT, {
|
|
111
|
+
method: 'POST',
|
|
112
|
+
headers: {
|
|
113
|
+
'Content-Type': 'application/json',
|
|
114
|
+
Authorization: `Bearer ${apiKey}`,
|
|
115
|
+
},
|
|
116
|
+
body: JSON.stringify(requestBody),
|
|
117
|
+
});
|
|
118
|
+
if (!response.ok) {
|
|
119
|
+
const errorData = await response.json().catch(() => ({}));
|
|
120
|
+
const errorMessage = errorData.error?.message || `HTTP ${response.status}: ${response.statusText}`;
|
|
121
|
+
debugLog('API error:', errorData);
|
|
122
|
+
if (response.status === 401) {
|
|
123
|
+
throw new McpError(ErrorCode.InvalidRequest, 'Authentication failed. Please check your XAI_API_KEY environment variable.');
|
|
124
|
+
}
|
|
125
|
+
else if (response.status === 403) {
|
|
126
|
+
throw new McpError(ErrorCode.InvalidRequest, 'Access denied. Please check your API key permissions.');
|
|
127
|
+
}
|
|
128
|
+
else if (response.status === 400) {
|
|
129
|
+
throw new McpError(ErrorCode.InvalidRequest, `Bad request: ${errorMessage}`);
|
|
130
|
+
}
|
|
131
|
+
else if (response.status === 429) {
|
|
132
|
+
throw new McpError(ErrorCode.InvalidRequest, 'Rate limit exceeded. Please wait and try again.');
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw new McpError(ErrorCode.InternalError, `API error (${response.status}): ${errorMessage}`);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const data = (await response.json());
|
|
139
|
+
debugLog('API response received');
|
|
140
|
+
if (!data.data || data.data.length === 0) {
|
|
141
|
+
throw new McpError(ErrorCode.InternalError, 'No image data returned from API');
|
|
142
|
+
}
|
|
143
|
+
debugLog(`Received ${data.data.length} image(s) from API`);
|
|
144
|
+
// Process and save all generated images
|
|
145
|
+
const savedPaths = [];
|
|
146
|
+
const base64Results = [];
|
|
147
|
+
const revisedPrompts = [];
|
|
148
|
+
for (let i = 0; i < data.data.length; i++) {
|
|
149
|
+
const imgData = data.data[i];
|
|
150
|
+
// Collect revised prompts
|
|
151
|
+
if (imgData.revised_prompt) {
|
|
152
|
+
revisedPrompts.push(imgData.revised_prompt);
|
|
153
|
+
}
|
|
154
|
+
// Generate numbered filename for multiple images
|
|
155
|
+
let imagePath = normalizedPath;
|
|
156
|
+
if (n > 1) {
|
|
157
|
+
const pathParts = normalizedPath.split('.');
|
|
158
|
+
const ext = pathParts.pop();
|
|
159
|
+
const basePath = pathParts.join('.');
|
|
160
|
+
imagePath = `${basePath}_${i + 1}.${ext}`;
|
|
161
|
+
}
|
|
162
|
+
if (imgData.b64_json) {
|
|
163
|
+
// Save base64 image
|
|
164
|
+
await saveBase64Image(imgData.b64_json, imagePath);
|
|
165
|
+
savedPaths.push(imagePath);
|
|
166
|
+
if (return_base64) {
|
|
167
|
+
base64Results.push(imgData.b64_json);
|
|
168
|
+
}
|
|
169
|
+
debugLog(`Image ${i + 1}: Saved from b64_json to ${imagePath}`);
|
|
170
|
+
}
|
|
171
|
+
else if (imgData.url) {
|
|
172
|
+
// Download and save URL image
|
|
173
|
+
await downloadAndSaveImage(imgData.url, imagePath);
|
|
174
|
+
savedPaths.push(imagePath);
|
|
175
|
+
debugLog(`Image ${i + 1}: Downloaded from URL to ${imagePath}`);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
throw new McpError(ErrorCode.InternalError, `No image data (url or b64_json) in response for image ${i + 1}`);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
// Determine if thumbnails should be included
|
|
182
|
+
const shouldIncludeThumbnail = include_thumbnail !== undefined ? include_thumbnail : isThumbnailEnabled();
|
|
183
|
+
// Build result message
|
|
184
|
+
let resultText;
|
|
185
|
+
if (n === 1) {
|
|
186
|
+
const displayPath = getDisplayPath(savedPaths[0]);
|
|
187
|
+
resultText = `Image edited successfully: ${displayPath}`;
|
|
188
|
+
}
|
|
189
|
+
else {
|
|
190
|
+
resultText = `${n} images edited successfully:\n`;
|
|
191
|
+
savedPaths.forEach((filePath, idx) => {
|
|
192
|
+
resultText += ` ${idx + 1}. ${getDisplayPath(filePath)}\n`;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
// Add parameters info
|
|
196
|
+
resultText += `\nParameters:`;
|
|
197
|
+
resultText += `\n - Model: ${model}`;
|
|
198
|
+
resultText += `\n - Resolution: ${resolution}`;
|
|
199
|
+
// Add revised prompt if available
|
|
200
|
+
if (revisedPrompts.length > 0) {
|
|
201
|
+
resultText += `\n\nRevised prompt: ${revisedPrompts[0]}`;
|
|
202
|
+
}
|
|
203
|
+
// Add base64 data if requested
|
|
204
|
+
if (return_base64 && base64Results.length > 0) {
|
|
205
|
+
resultText += '\n\nBase64 data included in response.';
|
|
206
|
+
}
|
|
207
|
+
// Return with thumbnails if enabled
|
|
208
|
+
if (shouldIncludeThumbnail) {
|
|
209
|
+
debugLog('[Thumbnail] Including thumbnails in response');
|
|
210
|
+
const content = [{ type: 'text', text: resultText }];
|
|
211
|
+
// Generate and add thumbnails for each image
|
|
212
|
+
for (const imagePath of savedPaths) {
|
|
213
|
+
try {
|
|
214
|
+
const thumbnailData = await generateThumbnailData(imagePath);
|
|
215
|
+
const thumbnailContent = createThumbnailContent(thumbnailData);
|
|
216
|
+
content.push(thumbnailContent);
|
|
217
|
+
debugLog(`[Thumbnail] Added thumbnail for: ${imagePath}`);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
debugLog(`[WARNING] Failed to generate thumbnail for ${imagePath}:`, error.message);
|
|
221
|
+
// Continue without thumbnail for this image
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return { content };
|
|
225
|
+
}
|
|
226
|
+
return resultText;
|
|
227
|
+
}
|
|
228
|
+
catch (error) {
|
|
229
|
+
debugLog('Error editing image:', error);
|
|
230
|
+
if (error instanceof McpError) {
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
throw new McpError(ErrorCode.InternalError, `Failed to edit image: ${error.message}`);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//# sourceMappingUR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EAAE,CACzC,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate image tool - Create images from text prompts using xAI Grok Imagine
|
|
3
|
+
*/
|
|
4
|
+
import type { GenerateImageParams } from '../types/tools.js';
|
|
5
|
+
export declare function generateImage(apiKey: string, params: GenerateImageParams): Promise<string | {
|
|
6
|
+
content: Array<{
|
|
7
|
+
type: string;
|
|
8
|
+
text?: string;
|
|
9
|
+
data?: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/tools/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,OAAO,KAAK,EAAE,mBAAmB,EAAoB,MAAM,mBAAmB,CAAC;AAU/E,wBAAsB,aAAa,CACjC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CACN,MAAM,GACN;IACE,OAAO,EAAE,KAAK,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ,CACJ,CAgQA"}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generate image tool - Create images from text prompts using xAI Grok Imagine
|
|
3
|
+
*/
|
|
4
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
5
|
+
import { saveBase64Image, downloadAndSaveImage, generateThumbnailData, isThumbnailEnabled, createThumbnailContent, } from '../utils/image.js';
|
|
6
|
+
import { normalizeAndValidatePath, getDisplayPath, generateUniqueFilePath, } from '../utils/path.js';
|
|
7
|
+
import { debugLog } from '../utils/debug.js';
|
|
8
|
+
import { ASPECT_RATIOS, RESOLUTIONS, QUALITIES, MODELS, } from '../types/tools.js';
|
|
9
|
+
const XAI_API_ENDPOINT = 'https://api.x.ai/v1/images/generations';
|
|
10
|
+
export async function generateImage(apiKey, params) {
|
|
11
|
+
debugLog('Generate image called with params:', params);
|
|
12
|
+
const { prompt, output_path = 'generated_image.jpg', model = 'grok-imagine-image', n = 1, aspect_ratio = '1:1', resolution = '1k', quality, response_format = 'b64_json', return_base64 = false, include_thumbnail, } = params;
|
|
13
|
+
// Normalize and validate output path
|
|
14
|
+
let normalizedPath = await normalizeAndValidatePath(output_path);
|
|
15
|
+
normalizedPath = await generateUniqueFilePath(normalizedPath);
|
|
16
|
+
// Validation
|
|
17
|
+
if (!prompt || prompt.trim().length === 0) {
|
|
18
|
+
throw new McpError(ErrorCode.InvalidParams, 'Prompt is required and cannot be empty');
|
|
19
|
+
}
|
|
20
|
+
if (!MODELS.includes(model)) {
|
|
21
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid model: ${model}. Must be one of: ${MODELS.join(', ')}`);
|
|
22
|
+
}
|
|
23
|
+
if (n < 1 || n > 10) {
|
|
24
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid n: ${n}. Must be between 1 and 10`);
|
|
25
|
+
}
|
|
26
|
+
// Validate aspect ratio
|
|
27
|
+
if (!ASPECT_RATIOS.includes(aspect_ratio)) {
|
|
28
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid aspect_ratio: ${aspect_ratio}. Must be one of: ${ASPECT_RATIOS.join(', ')}`);
|
|
29
|
+
}
|
|
30
|
+
if (!RESOLUTIONS.includes(resolution)) {
|
|
31
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid resolution: ${resolution}. Must be one of: ${RESOLUTIONS.join(', ')}`);
|
|
32
|
+
}
|
|
33
|
+
if (quality && !QUALITIES.includes(quality)) {
|
|
34
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid quality: ${quality}. Must be one of: ${QUALITIES.join(', ')}`);
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
debugLog('Calling xAI API...');
|
|
38
|
+
// Build request body
|
|
39
|
+
const requestBody = {
|
|
40
|
+
model,
|
|
41
|
+
prompt,
|
|
42
|
+
n,
|
|
43
|
+
aspect_ratio,
|
|
44
|
+
resolution,
|
|
45
|
+
response_format,
|
|
46
|
+
};
|
|
47
|
+
// Quality is currently no-op but include if specified
|
|
48
|
+
if (quality) {
|
|
49
|
+
requestBody.quality = quality;
|
|
50
|
+
}
|
|
51
|
+
debugLog('Request body:', requestBody);
|
|
52
|
+
// Call xAI API
|
|
53
|
+
const response = await fetch(XAI_API_ENDPOINT, {
|
|
54
|
+
method: 'POST',
|
|
55
|
+
headers: {
|
|
56
|
+
'Content-Type': 'application/json',
|
|
57
|
+
Authorization: `Bearer ${apiKey}`,
|
|
58
|
+
},
|
|
59
|
+
body: JSON.stringify(requestBody),
|
|
60
|
+
});
|
|
61
|
+
if (!response.ok) {
|
|
62
|
+
const errorData = await response.json().catch(() => ({}));
|
|
63
|
+
const errorMessage = errorData.error?.message || `HTTP ${response.status}: ${response.statusText}`;
|
|
64
|
+
debugLog('API error:', errorData);
|
|
65
|
+
if (response.status === 401) {
|
|
66
|
+
throw new McpError(ErrorCode.InvalidRequest, 'Authentication failed. Please check your XAI_API_KEY environment variable.');
|
|
67
|
+
}
|
|
68
|
+
else if (response.status === 403) {
|
|
69
|
+
throw new McpError(ErrorCode.InvalidRequest, 'Access denied. Please check your API key permissions.');
|
|
70
|
+
}
|
|
71
|
+
else if (response.status === 400) {
|
|
72
|
+
throw new McpError(ErrorCode.InvalidRequest, `Bad request: ${errorMessage}`);
|
|
73
|
+
}
|
|
74
|
+
else if (response.status === 429) {
|
|
75
|
+
throw new McpError(ErrorCode.InvalidRequest, 'Rate limit exceeded. Please wait and try again.');
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
throw new McpError(ErrorCode.InternalError, `API error (${response.status}): ${errorMessage}`);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const data = (await response.json());
|
|
82
|
+
debugLog('API response received');
|
|
83
|
+
if (!data.data || data.data.length === 0) {
|
|
84
|
+
throw new McpError(ErrorCode.InternalError, 'No image data returned from API');
|
|
85
|
+
}
|
|
86
|
+
debugLog(`Received ${data.data.length} image(s) from API`);
|
|
87
|
+
// Process and save all generated images
|
|
88
|
+
const savedPaths = [];
|
|
89
|
+
const base64Results = [];
|
|
90
|
+
const revisedPrompts = [];
|
|
91
|
+
for (let i = 0; i < data.data.length; i++) {
|
|
92
|
+
const imageData = data.data[i];
|
|
93
|
+
// Collect revised prompts
|
|
94
|
+
if (imageData.revised_prompt) {
|
|
95
|
+
revisedPrompts.push(imageData.revised_prompt);
|
|
96
|
+
}
|
|
97
|
+
// Generate numbered filename for multiple images
|
|
98
|
+
let imagePath = normalizedPath;
|
|
99
|
+
if (n > 1) {
|
|
100
|
+
const pathParts = normalizedPath.split('.');
|
|
101
|
+
const ext = pathParts.pop();
|
|
102
|
+
const basePath = pathParts.join('.');
|
|
103
|
+
imagePath = `${basePath}_${i + 1}.${ext}`;
|
|
104
|
+
}
|
|
105
|
+
if (imageData.b64_json) {
|
|
106
|
+
// Save base64 image
|
|
107
|
+
await saveBase64Image(imageData.b64_json, imagePath);
|
|
108
|
+
savedPaths.push(imagePath);
|
|
109
|
+
if (return_base64) {
|
|
110
|
+
base64Results.push(imageData.b64_json);
|
|
111
|
+
}
|
|
112
|
+
debugLog(`Image ${i + 1}: Saved from b64_json to ${imagePath}`);
|
|
113
|
+
}
|
|
114
|
+
else if (imageData.url) {
|
|
115
|
+
// Download and save URL image
|
|
116
|
+
await downloadAndSaveImage(imageData.url, imagePath);
|
|
117
|
+
savedPaths.push(imagePath);
|
|
118
|
+
debugLog(`Image ${i + 1}: Downloaded from URL to ${imagePath}`);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
throw new McpError(ErrorCode.InternalError, `No image data (url or b64_json) in response for image ${i + 1}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
// Determine if thumbnails should be included
|
|
125
|
+
const shouldIncludeThumbnail = include_thumbnail !== undefined ? include_thumbnail : isThumbnailEnabled();
|
|
126
|
+
// Build result message
|
|
127
|
+
let resultText;
|
|
128
|
+
if (n === 1) {
|
|
129
|
+
const displayPath = getDisplayPath(savedPaths[0]);
|
|
130
|
+
resultText = `Image generated successfully: ${displayPath}`;
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
resultText = `${n} images generated successfully:\n`;
|
|
134
|
+
savedPaths.forEach((filePath, idx) => {
|
|
135
|
+
resultText += ` ${idx + 1}. ${getDisplayPath(filePath)}\n`;
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
// Add parameters info
|
|
139
|
+
resultText += `\nParameters:`;
|
|
140
|
+
resultText += `\n - Model: ${model}`;
|
|
141
|
+
resultText += `\n - Aspect ratio: ${aspect_ratio}`;
|
|
142
|
+
resultText += `\n - Resolution: ${resolution}`;
|
|
143
|
+
if (quality) {
|
|
144
|
+
resultText += `\n - Quality: ${quality}`;
|
|
145
|
+
}
|
|
146
|
+
// Add revised prompt if available
|
|
147
|
+
if (revisedPrompts.length > 0) {
|
|
148
|
+
resultText += `\n\nRevised prompt: ${revisedPrompts[0]}`;
|
|
149
|
+
}
|
|
150
|
+
// Add base64 data if requested
|
|
151
|
+
if (return_base64 && base64Results.length > 0) {
|
|
152
|
+
resultText += '\n\nBase64 data included in response.';
|
|
153
|
+
}
|
|
154
|
+
// Return with thumbnails if enabled
|
|
155
|
+
if (shouldIncludeThumbnail) {
|
|
156
|
+
debugLog('[Thumbnail] Including thumbnails in response');
|
|
157
|
+
const content = [{ type: 'text', text: resultText }];
|
|
158
|
+
// Generate and add thumbnails for each image
|
|
159
|
+
for (const imagePath of savedPaths) {
|
|
160
|
+
try {
|
|
161
|
+
const thumbnailData = await generateThumbnailData(imagePath);
|
|
162
|
+
const thumbnailContent = createThumbnailContent(thumbnailData);
|
|
163
|
+
content.push(thumbnailContent);
|
|
164
|
+
debugLog(`[Thumbnail] Added thumbnail for: ${imagePath}`);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
debugLog(`[WARNING] Failed to generate thumbnail for ${imagePath}:`, error.message);
|
|
168
|
+
// Continue without thumbnail for this image
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return { content };
|
|
172
|
+
}
|
|
173
|
+
return resultText;
|
|
174
|
+
}
|
|
175
|
+
catch (error) {
|
|
176
|
+
debugLog('Error generating image:', error);
|
|
177
|
+
if (error instanceof McpError) {
|
|
178
|
+
throw error;
|
|
179
|
+
}
|
|
180
|
+
throw new McpError(ErrorCode.InternalError, `Failed to generate image: ${error.message}`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=generate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.js","sourceRoot":"","sources":["../../src/tools/generate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,sBAAsB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,EACL,aAAa,EACb,WAAW,EACX,SAAS,EACT,MAAM,GACP,MAAM,mBAAmB,CAAC;AAE3B,MAAM,gBAAgB,GAAG,wCAAwC,CAAC;AAElE,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAc,EACd,MAA2B;IAY3B,QAAQ,CAAC,oCAAoC,EAAE,MAAM,CAAC,CAAC;IAEvD,MAAM,EACJ,MAAM,EACN,WAAW,GAAG,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+
/**
|
|
2
|
+
* Batch processing type definitions
|
|
3
|
+
*/
|
|
4
|
+
import type { AspectRatio, Resolution, Model } from './tools.js';
|
|
5
|
+
/**
|
|
6
|
+
* Individual job configuration in batch
|
|
7
|
+
*/
|
|
8
|
+
export interface BatchJobConfig {
|
|
9
|
+
/** Text prompt describing the image to generate */
|
|
10
|
+
prompt: string;
|
|
11
|
+
/** Output file path (optional, auto-generated if not specified) */
|
|
12
|
+
output_path?: string;
|
|
13
|
+
/** Model to use (default: grok-imagine-image) */
|
|
14
|
+
model?: Model;
|
|
15
|
+
/** Aspect ratio (model-dependent, default: 1:1) */
|
|
16
|
+
aspect_ratio?: AspectRatio;
|
|
17
|
+
/** Resolution (default: 1k) */
|
|
18
|
+
resolution?: Resolution;
|
|
19
|
+
/** Number of images to generate for this prompt (1-10, default: 1) */
|
|
20
|
+
n?: number;
|
|
21
|
+
/** Path to source image for editing */
|
|
22
|
+
image_path?: string;
|
|
23
|
+
/** Base64 encoded source image for editing */
|
|
24
|
+
image_base64?: string;
|
|
25
|
+
/** URL of source image for editing */
|
|
26
|
+
image_url?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Retry policy configuration
|
|
30
|
+
*/
|
|
31
|
+
export interface RetryPolicy {
|
|
32
|
+
/** Maximum number of retry attempts (0-5, default: 2) */
|
|
33
|
+
max_retries?: number;
|
|
34
|
+
/** Delay between retries in milliseconds (100-60000, default: 1000) */
|
|
35
|
+
retry_delay_ms?: number;
|
|
36
|
+
/** Error patterns to trigger retry (case-insensitive) */
|
|
37
|
+
retry_on_errors?: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Batch configuration file structure
|
|
41
|
+
*/
|
|
42
|
+
export interface BatchConfig {
|
|
43
|
+
/** Array of job configurations (required, 1-100 jobs) */
|
|
44
|
+
jobs: BatchJobConfig[];
|
|
45
|
+
/** Default output directory for generated images */
|
|
46
|
+
output_dir?: string;
|
|
47
|
+
/** Maximum concurrent jobs (1-10, default: 2) */
|
|
48
|
+
max_concurrent?: number;
|
|
49
|
+
/** Timeout in milliseconds (default: 600000 = 10 minutes) */
|
|
50
|
+
timeout?: number;
|
|
51
|
+
/** Retry policy for failed jobs */
|
|
52
|
+
retry_policy?: RetryPolicy;
|
|
53
|
+
/** Default model for all jobs */
|
|
54
|
+
default_model?: Model;
|
|
55
|
+
/** Default resolution for all jobs */
|
|
56
|
+
default_resolution?: Resolution;
|
|
57
|
+
/** Default aspect ratio for all jobs */
|
|
58
|
+
default_aspect_ratio?: AspectRatio;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Result of a single batch job
|
|
62
|
+
*/
|
|
63
|
+
export interface BatchJobResult {
|
|
64
|
+
/** Job index (1-based) */
|
|
65
|
+
index: number;
|
|
66
|
+
/** Original prompt */
|
|
67
|
+
prompt: string;
|
|
68
|
+
/** Job status */
|
|
69
|
+
status: 'completed' | 'failed' | 'cancelled';
|
|
70
|
+
/** Output file path(s) */
|
|
71
|
+
output_paths?: string[];
|
|
72
|
+
/** Error message if failed */
|
|
73
|
+
error?: string;
|
|
74
|
+
/** Job duration in milliseconds */
|
|
75
|
+
duration_ms?: number;
|
|
76
|
+
/** Revised prompt from API */
|
|
77
|
+
revised_prompt?: string;
|
|
78
|
+
/** Whether this was an edit job */
|
|
79
|
+
is_edit?: boolean;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Overall batch execution result
|
|
83
|
+
*/
|
|
84
|
+
export interface BatchResult {
|
|
85
|
+
/** Total number of jobs */
|
|
86
|
+
total: number;
|
|
87
|
+
/** Number of successful jobs */
|
|
88
|
+
succeeded: number;
|
|
89
|
+
/** Number of failed jobs */
|
|
90
|
+
failed: number;
|
|
91
|
+
/** Number of cancelled jobs (timeout) */
|
|
92
|
+
cancelled: number;
|
|
93
|
+
/** Individual job results */
|
|
94
|
+
results: BatchJobResult[];
|
|
95
|
+
/** Batch start timestamp (ISO) */
|
|
96
|
+
started_at: string;
|
|
97
|
+
/** Batch finish timestamp (ISO) */
|
|
98
|
+
finished_at: string;
|
|
99
|
+
/** Total batch duration in milliseconds */
|
|
100
|
+
total_duration_ms: number;
|
|
101
|
+
/** Estimated total cost in USD */
|
|
102
|
+
estimated_cost?: number;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Batch execution options (from CLI)
|
|
106
|
+
*/
|
|
107
|
+
export interface BatchExecutionOptions {
|
|
108
|
+
/** Override output directory */
|
|
109
|
+
outputDir?: string;
|
|
110
|
+
/** Output format */
|
|
111
|
+
format?: 'text' | 'json';
|
|
112
|
+
/** Timeout in milliseconds */
|
|
113
|
+
timeout?: number;
|
|
114
|
+
/** Maximum concurrent jobs */
|
|
115
|
+
maxConcurrent?: number;
|
|
116
|
+
/** Estimate cost only without executing */
|
|
117
|
+
estimateOnly?: boolean;
|
|
118
|
+
/** Allow any output path (for CI/CD) */
|
|
119
|
+
allowAnyPath?: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Cost estimation result
|
|
123
|
+
*/
|
|
124
|
+
export interface CostEstimate {
|
|
125
|
+
totalJobs: number;
|
|
126
|
+
totalImages: number;
|
|
127
|
+
estimatedCostMin: number;
|
|
128
|
+
estimatedCostMax: number;
|
|
129
|
+
breakdown: {
|
|
130
|
+
model: string;
|
|
131
|
+
count: number;
|
|
132
|
+
images: number;
|
|
133
|
+
costMin: number;
|
|
134
|
+
costMax: number;
|
|
135
|
+
}[];
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/types/batch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,MAAM,EAAE,MAAM,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