@t2000/mcp 0.22.2 → 0.22.3

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/bin.js CHANGED
@@ -837,26 +837,24 @@ Common examples:
837
837
  const result = await mutex.run(
838
838
  () => agent.pay({ url, method, body, headers, maxPrice })
839
839
  );
840
- const content = [
841
- { type: "text", text: JSON.stringify(result) }
842
- ];
840
+ let text = JSON.stringify(result);
843
841
  try {
844
842
  const data = typeof result === "string" ? JSON.parse(result) : result;
845
843
  const imageUrls = extractImageUrls(data);
846
- for (const imgUrl of imageUrls.slice(0, 4)) {
847
- try {
848
- const imgRes = await fetch(imgUrl);
849
- if (imgRes.ok) {
850
- const buf = Buffer.from(await imgRes.arrayBuffer());
851
- const mime = imgRes.headers.get("content-type") || "image/png";
852
- content.push({ type: "image", data: buf.toString("base64"), mimeType: mime });
853
- }
854
- } catch {
855
- }
844
+ if (imageUrls.length > 0) {
845
+ const urlList = imageUrls.slice(0, 4).map((u) => `- ${u}`).join("\n");
846
+ text = `Generated images:
847
+ ${urlList}
848
+
849
+ ${text}`;
856
850
  }
857
851
  } catch {
858
852
  }
859
- return { content };
853
+ const MAX_BYTES = 8e5;
854
+ if (text.length > MAX_BYTES) {
855
+ text = text.slice(0, MAX_BYTES) + "\n\n[Response truncated \u2014 exceeded size limit]";
856
+ }
857
+ return { content: [{ type: "text", text }] };
860
858
  } catch (err) {
861
859
  return errorResult(err);
862
860
  }