@genart-dev/mcp-server 0.4.4 → 0.4.6

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/lib.js CHANGED
@@ -2574,7 +2574,9 @@ async function captureScreenshot(state, input) {
2574
2574
  previewPath
2575
2575
  });
2576
2576
  const previewJpegBase64 = Buffer.from(multi.inlineJpeg).toString("base64");
2577
- return { metadata, previewJpegBase64 };
2577
+ const previewDataUri = `data:image/jpeg;base64,${previewJpegBase64}`;
2578
+ metadata.previewDataUri = previewDataUri;
2579
+ return { metadata, previewJpegBase64, previewDataUri };
2578
2580
  } catch (e) {
2579
2581
  const msg = e instanceof Error ? e.message : String(e);
2580
2582
  throw new Error(`Renderer error for '${sketchId}': ${msg}`);
@@ -5185,7 +5187,7 @@ function registerSketchTools(server, state) {
5185
5187
  addToWorkspace: z2.string().optional().describe("Path to workspace to add sketch to after creation"),
5186
5188
  agent: z2.string().optional().describe("Your CLI agent name (e.g. 'claude-code', 'codex-cli', 'gemini-cli', 'opencode', 'kiro')"),
5187
5189
  model: z2.string().optional().describe("Your AI model identifier (e.g. 'claude-opus-4-6', 'gpt-4o', 'gemini-2.5-pro')"),
5188
- capture: z2.boolean().optional().describe("When true, automatically capture a screenshot after creation and return it inline (avoids a separate capture_screenshot call)")
5190
+ capture: z2.boolean().optional().describe("When true, automatically capture a screenshot after creation. The result includes previewDataUri for rendering. IMPORTANT: When capture is true, you MUST show the preview to the user by creating an HTML artifact with an <img> tag using the previewDataUri from the capture metadata. Include savedPreviewTo as caption for the full-res file.")
5189
5191
  },
5190
5192
  async (args) => {
5191
5193
  try {
@@ -5196,10 +5198,15 @@ function registerSketchTools(server, state) {
5196
5198
  target: "sketch",
5197
5199
  sketchId: args.id
5198
5200
  });
5201
+ const captureMeta = captureResult.metadata;
5199
5202
  return {
5200
5203
  content: [
5201
- { type: "text", text: JSON.stringify({ ...result, capture: captureResult.metadata }, null, 2) },
5202
- { type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" }
5204
+ { type: "text", text: JSON.stringify({
5205
+ ...result,
5206
+ capture: captureMeta
5207
+ }, null, 2) },
5208
+ { type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" },
5209
+ ...captureMeta.savedPreviewTo ? [{ type: "text", text: `![Sketch Preview](file://${captureMeta.savedPreviewTo})` }] : []
5203
5210
  ]
5204
5211
  };
5205
5212
  } catch (captureErr) {
@@ -5765,7 +5772,7 @@ function registerSnapshotTools(server, state) {
5765
5772
  function registerCaptureTools(server, state) {
5766
5773
  server.tool(
5767
5774
  "capture_screenshot",
5768
- "Capture a screenshot of a sketch. Returns metadata as text + a small inline JPEG image for visual review. In local mode, writes a full-res PNG to snapshots/<sketchId>-<seed>-preview.png next to the workspace. The savedPreviewTo path in metadata points to the file on disk.",
5775
+ "Capture a screenshot of a sketch. Returns metadata (including previewDataUri) as text + a small inline JPEG image. In local mode, writes a full-res PNG to snapshots/<sketchId>-<seed>-preview.png. IMPORTANT: After every capture, you MUST show the preview to the user by creating an HTML artifact containing an <img> tag using the previewDataUri from the metadata. Include the savedPreviewTo path as a caption so the user can find the full-res file.",
5769
5776
  {
5770
5777
  target: z2.enum(["selected", "sketch"]).optional().describe("What to capture (default: selected)"),
5771
5778
  sketchId: z2.string().optional().describe("Required when target is 'sketch'"),
@@ -5782,7 +5789,9 @@ function registerCaptureTools(server, state) {
5782
5789
  return {
5783
5790
  content: [
5784
5791
  { type: "text", text: JSON.stringify(result.metadata, null, 2) },
5785
- { type: "image", data: result.previewJpegBase64, mimeType: "image/jpeg" }
5792
+ { type: "image", data: result.previewJpegBase64, mimeType: "image/jpeg" },
5793
+ // Markdown image for hosts that render local file refs or data URIs
5794
+ ...result.metadata.savedPreviewTo ? [{ type: "text", text: `![Sketch Preview](file://${result.metadata.savedPreviewTo})` }] : []
5786
5795
  ]
5787
5796
  };
5788
5797
  } catch (e) {
@@ -5793,7 +5802,7 @@ function registerCaptureTools(server, state) {
5793
5802
  );
5794
5803
  server.tool(
5795
5804
  "capture_batch",
5796
- "Capture screenshots of multiple sketches in parallel. Returns metadata as text + inline JPEG images for visual review.",
5805
+ "Capture screenshots of multiple sketches in parallel. Returns per-sketch metadata (including previewDataUri) + inline JPEG images. IMPORTANT: After batch capture, you MUST show all previews to the user by creating an HTML artifact with <img> tags using each item's previewDataUri. Include sketch titles and savedPreviewTo paths.",
5797
5806
  {
5798
5807
  sketchIds: z2.array(z2.string()).optional().describe("IDs of sketches to capture (default: all)"),
5799
5808
  width: z2.number().optional().describe("Override width for all captures"),
@@ -5817,6 +5826,12 @@ function registerCaptureTools(server, state) {
5817
5826
  data: item.inlineJpegBase64,
5818
5827
  mimeType: "image/jpeg"
5819
5828
  });
5829
+ if (item.metadata.savedPreviewTo) {
5830
+ content.push({
5831
+ type: "text",
5832
+ text: `![${item.metadata.sketchId} Preview](file://${item.metadata.savedPreviewTo})`
5833
+ });
5834
+ }
5820
5835
  }
5821
5836
  return { content };
5822
5837
  } catch (e) {