@genart-dev/mcp-server 0.4.3 → 0.4.5
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 +29 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -4
- package/dist/index.js.map +1 -1
- package/dist/lib.cjs +29 -4
- package/dist/lib.cjs.map +1 -1
- package/dist/lib.js +29 -4
- package/dist/lib.js.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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}`);
|
|
@@ -5184,11 +5186,34 @@ function registerSketchTools(server, state) {
|
|
|
5184
5186
|
).optional().describe('Component dependencies. Use list_components to see available. Keys are component names, values are semver ranges (e.g. "^1.0.0") or objects with version/code/exports.'),
|
|
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
|
-
model: z2.string().optional().describe("Your AI model identifier (e.g. 'claude-opus-4-6', 'gpt-4o', 'gemini-2.5-pro')")
|
|
5189
|
+
model: z2.string().optional().describe("Your AI model identifier (e.g. 'claude-opus-4-6', 'gpt-4o', 'gemini-2.5-pro')"),
|
|
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.")
|
|
5188
5191
|
},
|
|
5189
5192
|
async (args) => {
|
|
5190
5193
|
try {
|
|
5191
5194
|
const result = await createSketch(state, args);
|
|
5195
|
+
if (args.capture && !state.remoteMode) {
|
|
5196
|
+
try {
|
|
5197
|
+
const captureResult = await captureScreenshot(state, {
|
|
5198
|
+
target: "sketch",
|
|
5199
|
+
sketchId: args.id
|
|
5200
|
+
});
|
|
5201
|
+
return {
|
|
5202
|
+
content: [
|
|
5203
|
+
{ type: "text", text: JSON.stringify({
|
|
5204
|
+
...result,
|
|
5205
|
+
capture: captureResult.metadata
|
|
5206
|
+
}, null, 2) },
|
|
5207
|
+
{ type: "image", data: captureResult.previewJpegBase64, mimeType: "image/jpeg" }
|
|
5208
|
+
]
|
|
5209
|
+
};
|
|
5210
|
+
} catch (captureErr) {
|
|
5211
|
+
return jsonResult({
|
|
5212
|
+
...result,
|
|
5213
|
+
captureError: captureErr instanceof Error ? captureErr.message : String(captureErr)
|
|
5214
|
+
});
|
|
5215
|
+
}
|
|
5216
|
+
}
|
|
5192
5217
|
return jsonResult(result);
|
|
5193
5218
|
} catch (e) {
|
|
5194
5219
|
return toolError(e instanceof Error ? e.message : String(e));
|
|
@@ -5745,7 +5770,7 @@ function registerSnapshotTools(server, state) {
|
|
|
5745
5770
|
function registerCaptureTools(server, state) {
|
|
5746
5771
|
server.tool(
|
|
5747
5772
|
"capture_screenshot",
|
|
5748
|
-
"Capture a screenshot of a sketch. Returns metadata as text + a small inline JPEG image
|
|
5773
|
+
"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.",
|
|
5749
5774
|
{
|
|
5750
5775
|
target: z2.enum(["selected", "sketch"]).optional().describe("What to capture (default: selected)"),
|
|
5751
5776
|
sketchId: z2.string().optional().describe("Required when target is 'sketch'"),
|
|
@@ -5773,7 +5798,7 @@ function registerCaptureTools(server, state) {
|
|
|
5773
5798
|
);
|
|
5774
5799
|
server.tool(
|
|
5775
5800
|
"capture_batch",
|
|
5776
|
-
"Capture screenshots of multiple sketches in parallel. Returns metadata
|
|
5801
|
+
"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.",
|
|
5777
5802
|
{
|
|
5778
5803
|
sketchIds: z2.array(z2.string()).optional().describe("IDs of sketches to capture (default: all)"),
|
|
5779
5804
|
width: z2.number().optional().describe("Override width for all captures"),
|