@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/index.js CHANGED
@@ -2893,7 +2893,9 @@ async function captureScreenshot(state, input) {
2893
2893
  previewPath
2894
2894
  });
2895
2895
  const previewJpegBase64 = Buffer.from(multi.inlineJpeg).toString("base64");
2896
- return { metadata, previewJpegBase64 };
2896
+ const previewDataUri = `data:image/jpeg;base64,${previewJpegBase64}`;
2897
+ metadata.previewDataUri = previewDataUri;
2898
+ return { metadata, previewJpegBase64, previewDataUri };
2897
2899
  } catch (e) {
2898
2900
  const msg = e instanceof Error ? e.message : String(e);
2899
2901
  throw new Error(`Renderer error for '${sketchId}': ${msg}`);
@@ -5504,7 +5506,7 @@ function registerSketchTools(server, state) {
5504
5506
  addToWorkspace: z2.string().optional().describe("Path to workspace to add sketch to after creation"),
5505
5507
  agent: z2.string().optional().describe("Your CLI agent name (e.g. 'claude-code', 'codex-cli', 'gemini-cli', 'opencode', 'kiro')"),
5506
5508
  model: z2.string().optional().describe("Your AI model identifier (e.g. 'claude-opus-4-6', 'gpt-4o', 'gemini-2.5-pro')"),
5507
- capture: z2.boolean().optional().describe("When true, automatically capture a screenshot after creation and return it inline (avoids a separate capture_screenshot call)")
5509
+ 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.")
5508
5510
  },
5509
5511
  async (args) => {
5510
5512
  try {
@@ -5515,10 +5517,15 @@ function registerSketchTools(server, state) {
5515
5517
  target: "sketch",
5516
5518
  sketchId: args.id
5517
5519
  });
5520
+ const captureMeta = captureResult.metadata;
5518
5521
  return {
5519
5522
  content: [
5520
- { type: "text", text: JSON.stringify({ ...result, capture: captureResult.metadata }, null, 2) },
5521
- { type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" }
5523
+ { type: "text", text: JSON.stringify({
5524
+ ...result,
5525
+ capture: captureMeta
5526
+ }, null, 2) },
5527
+ { type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" },
5528
+ ...captureMeta.savedPreviewTo ? [{ type: "text", text: `![Sketch Preview](file://${captureMeta.savedPreviewTo})` }] : []
5522
5529
  ]
5523
5530
  };
5524
5531
  } catch (captureErr) {
@@ -6084,7 +6091,7 @@ function registerSnapshotTools(server, state) {
6084
6091
  function registerCaptureTools(server, state) {
6085
6092
  server.tool(
6086
6093
  "capture_screenshot",
6087
- "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.",
6094
+ "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.",
6088
6095
  {
6089
6096
  target: z2.enum(["selected", "sketch"]).optional().describe("What to capture (default: selected)"),
6090
6097
  sketchId: z2.string().optional().describe("Required when target is 'sketch'"),
@@ -6101,7 +6108,9 @@ function registerCaptureTools(server, state) {
6101
6108
  return {
6102
6109
  content: [
6103
6110
  { type: "text", text: JSON.stringify(result.metadata, null, 2) },
6104
- { type: "image", data: result.previewJpegBase64, mimeType: "image/jpeg" }
6111
+ { type: "image", data: result.previewJpegBase64, mimeType: "image/jpeg" },
6112
+ // Markdown image for hosts that render local file refs or data URIs
6113
+ ...result.metadata.savedPreviewTo ? [{ type: "text", text: `![Sketch Preview](file://${result.metadata.savedPreviewTo})` }] : []
6105
6114
  ]
6106
6115
  };
6107
6116
  } catch (e) {
@@ -6112,7 +6121,7 @@ function registerCaptureTools(server, state) {
6112
6121
  );
6113
6122
  server.tool(
6114
6123
  "capture_batch",
6115
- "Capture screenshots of multiple sketches in parallel. Returns metadata as text + inline JPEG images for visual review.",
6124
+ "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.",
6116
6125
  {
6117
6126
  sketchIds: z2.array(z2.string()).optional().describe("IDs of sketches to capture (default: all)"),
6118
6127
  width: z2.number().optional().describe("Override width for all captures"),
@@ -6136,6 +6145,12 @@ function registerCaptureTools(server, state) {
6136
6145
  data: item.inlineJpegBase64,
6137
6146
  mimeType: "image/jpeg"
6138
6147
  });
6148
+ if (item.metadata.savedPreviewTo) {
6149
+ content.push({
6150
+ type: "text",
6151
+ text: `![${item.metadata.sketchId} Preview](file://${item.metadata.savedPreviewTo})`
6152
+ });
6153
+ }
6139
6154
  }
6140
6155
  return { content };
6141
6156
  } catch (e) {