@jordyvd/openrouter-imagegen-mcp 1.0.1 → 1.0.2

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/dist/index.cjs CHANGED
@@ -62198,6 +62198,8 @@ Only make the specific change requested above. The output should be identical to
62198
62198
  }
62199
62199
  };
62200
62200
  const responseContent = [];
62201
+ console.error(`[edit_image] Making API request to OpenRouter...`);
62202
+ const apiStartTime = Date.now();
62201
62203
  const response = await fetch("https://openrouter.ai/api/v1/chat/completions", {
62202
62204
  method: "POST",
62203
62205
  headers: {
@@ -62206,11 +62208,13 @@ Only make the specific change requested above. The output should be identical to
62206
62208
  },
62207
62209
  body: JSON.stringify(requestBody)
62208
62210
  });
62211
+ console.error(`[edit_image] API response status: ${response.status} (took ${Date.now() - apiStartTime}ms)`);
62209
62212
  if (!response.ok) {
62210
62213
  const errorText = await response.text();
62211
62214
  throw new Error(`API error: ${response.status} ${errorText}`);
62212
62215
  }
62213
62216
  const result = await response.json();
62217
+ console.error(`[edit_image] API response parsed successfully`);
62214
62218
  const assistantMessage = result.choices[0]?.message;
62215
62219
  if (!assistantMessage) {
62216
62220
  throw new Error("No response from model");
@@ -62278,7 +62282,12 @@ Only make the specific change requested above. The output should be identical to
62278
62282
  if (textContent) {
62279
62283
  assistantContent.push({ type: "text", text: textContent });
62280
62284
  }
62285
+ let processedImageCount = 0;
62281
62286
  for (const image of images) {
62287
+ processedImageCount++;
62288
+ console.error(`[edit_image] Processing image ${processedImageCount}/${images.length}`);
62289
+ console.error(`[edit_image] Image object keys: ${Object.keys(image).join(", ")}`);
62290
+ console.error(`[edit_image] Image object sample: ${JSON.stringify(image).substring(0, 300)}`);
62282
62291
  let imageData2 = null;
62283
62292
  if (image.imageUrl?.url) {
62284
62293
  imageData2 = await fetchImageAsBuffer(image.imageUrl.url);
@@ -62295,8 +62304,9 @@ Only make the specific change requested above. The output should be identical to
62295
62304
  if (imageData2) {
62296
62305
  const extension = imageData2.mimeType.split("/")[1] || "png";
62297
62306
  const filename = `${Date.now()}.${extension}`;
62307
+ console.error(`[edit_image] Uploading image ${processedImageCount} to S3 (${(imageData2.buffer.length / 1024).toFixed(1)}KB)...`);
62298
62308
  const s3Url = await uploadImageToS3(imageData2.buffer, filename, imageData2.mimeType, convId);
62299
- console.error(`Uploaded edited image to S3: ${s3Url} (${(imageData2.buffer.length / 1024).toFixed(1)}KB)`);
62309
+ console.error(`[edit_image] Image ${processedImageCount} uploaded to S3: ${s3Url}`);
62300
62310
  responseContent.push({
62301
62311
  type: "text",
62302
62312
  text: `IMAGE_URL: ${s3Url}`
@@ -62305,8 +62315,12 @@ Only make the specific change requested above. The output should be identical to
62305
62315
  type: "image_url",
62306
62316
  image_url: { url: s3Url }
62307
62317
  });
62318
+ console.error(`[edit_image] Image ${processedImageCount} added to response and conversation history`);
62319
+ } else {
62320
+ console.error(`[edit_image] WARNING: Image ${processedImageCount} could not be processed - imageData is null`);
62308
62321
  }
62309
62322
  }
62323
+ console.error(`[edit_image] Finished processing ${images.length} images, responseContent has ${responseContent.length} items`);
62310
62324
  messages.push({
62311
62325
  role: "assistant",
62312
62326
  content: assistantContent.length > 0 ? assistantContent : textContent || ""
@@ -62317,8 +62331,14 @@ Only make the specific change requested above. The output should be identical to
62317
62331
  content: textContent || ""
62318
62332
  });
62319
62333
  }
62334
+ console.error(`[edit_image] Saving conversation with ${messages.length} messages`);
62320
62335
  conversations.set(convId, messages);
62321
- await saveConversationToS3(convId, messages);
62336
+ try {
62337
+ await saveConversationToS3(convId, messages);
62338
+ console.error(`[edit_image] Conversation saved to S3 successfully`);
62339
+ } catch (saveError) {
62340
+ console.error(`[edit_image] Warning: Failed to save conversation to S3: ${saveError}`);
62341
+ }
62322
62342
  responseContent.push({
62323
62343
  type: "text",
62324
62344
  text: `
@@ -62327,10 +62347,16 @@ Only make the specific change requested above. The output should be identical to
62327
62347
  Conversation ID: ${convId}
62328
62348
  Use edit_image with this ID to make more changes.`
62329
62349
  });
62330
- return {
62350
+ console.error(`[edit_image] Returning response with ${responseContent.length} content items`);
62351
+ console.error(`[edit_image] Response content types: ${responseContent.map((c4) => c4.type).join(", ")}`);
62352
+ const finalResponse = {
62331
62353
  content: responseContent
62332
62354
  };
62355
+ console.error(`[edit_image] Final response: ${JSON.stringify(finalResponse).substring(0, 500)}`);
62356
+ return finalResponse;
62333
62357
  } catch (error47) {
62358
+ console.error(`[edit_image] CAUGHT ERROR: ${error47}`);
62359
+ console.error(`[edit_image] Error stack: ${error47 instanceof Error ? error47.stack : "N/A"}`);
62334
62360
  const errorMessage = error47 instanceof Error ? error47.message : String(error47);
62335
62361
  return {
62336
62362
  content: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jordyvd/openrouter-imagegen-mcp",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server for AI image generation via OpenRouter with S3 storage",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {