@constructorfleet/sketchforge3d 1.21.0 → 1.22.0
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/mcp/localEngine.mjs +13 -0
- package/mcp/server.mjs +21 -0
- package/package.json +2 -2
package/mcp/localEngine.mjs
CHANGED
|
@@ -67,6 +67,7 @@ function compactMutationValue(value) {
|
|
|
67
67
|
const MUTATION_TOOLS = new Set([
|
|
68
68
|
"sketchforge_create_shape",
|
|
69
69
|
"sketchforge_import_mesh",
|
|
70
|
+
"sketchforge_import_stl",
|
|
70
71
|
"sketchforge_update_object",
|
|
71
72
|
"sketchforge_delete_objects",
|
|
72
73
|
"sketchforge_align_objects",
|
|
@@ -370,6 +371,18 @@ async function callLocalEngineToolRaw(name, args = {}) {
|
|
|
370
371
|
const changes = Object.fromEntries(["name", "color", "x", "z", "elevation"].filter((key) => args[key] !== undefined).map((key) => [key, args[key]]));
|
|
371
372
|
return Object.keys(changes).length ? unwrap(await engine.changeShape(id, imported.shape.id, changes)) : imported;
|
|
372
373
|
}
|
|
374
|
+
case "sketchforge_import_stl": {
|
|
375
|
+
const sourcePath = path.resolve(String(args.filePath ?? ""));
|
|
376
|
+
if (path.extname(sourcePath).toLowerCase() !== ".stl") throw new Error("filePath must point to an .stl file.");
|
|
377
|
+
const bytes = await readFile(sourcePath);
|
|
378
|
+
const imported = await unwrap(await engine.importMesh(id, {
|
|
379
|
+
fileName: path.basename(sourcePath),
|
|
380
|
+
bytes,
|
|
381
|
+
mediaType: "model/stl",
|
|
382
|
+
}));
|
|
383
|
+
const changes = Object.fromEntries(["name", "color", "x", "z", "elevation"].filter((key) => args[key] !== undefined).map((key) => [key, args[key]]));
|
|
384
|
+
return Object.keys(changes).length ? unwrap(await engine.changeShape(id, imported.shape.id, changes)) : imported;
|
|
385
|
+
}
|
|
373
386
|
case "sketchforge_update_object": {
|
|
374
387
|
const { id: shapeId, projectId, ...changes } = args;
|
|
375
388
|
return unwrap(await engine.changeShape(id, shapeId, changes));
|
package/mcp/server.mjs
CHANGED
|
@@ -182,6 +182,24 @@ const tools = [
|
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
184
|
},
|
|
185
|
+
{
|
|
186
|
+
name: "sketchforge_import_stl",
|
|
187
|
+
description: "Import an STL file from the MCP host filesystem into a local project. Available in local mode; provide projectId and filePath.",
|
|
188
|
+
inputSchema: {
|
|
189
|
+
...editorTargetSchema,
|
|
190
|
+
required: ["projectId", "filePath"],
|
|
191
|
+
properties: {
|
|
192
|
+
...editorTargetSchema.properties,
|
|
193
|
+
projectId: { type: "string" },
|
|
194
|
+
filePath: { type: "string", description: "Path to an STL file readable by the MCP host." },
|
|
195
|
+
name: { type: "string" },
|
|
196
|
+
color: { type: "string" },
|
|
197
|
+
x: { type: "number" },
|
|
198
|
+
z: { type: "number" },
|
|
199
|
+
elevation: { type: "number" },
|
|
200
|
+
},
|
|
201
|
+
},
|
|
202
|
+
},
|
|
185
203
|
{
|
|
186
204
|
name: "sketchforge_update_object",
|
|
187
205
|
description: "Update one object's exact dimensions, position, color, name, hole state, or rotations.",
|
|
@@ -766,6 +784,9 @@ function normalizedServerUrl(value) {
|
|
|
766
784
|
|
|
767
785
|
async function callTool(name, args = {}) {
|
|
768
786
|
const { url, ...toolArgs } = args || {};
|
|
787
|
+
if (name === "sketchforge_import_stl" && typeof url === "string" && url.trim()) {
|
|
788
|
+
throw new Error("sketchforge_import_stl is only available in local mode; omit url.");
|
|
789
|
+
}
|
|
769
790
|
if (["sketchforge_list_projects", "sketchforge_create_project", "sketchforge_import_project"].includes(name) && typeof url === "string" && url.trim()) {
|
|
770
791
|
throw new Error(`${name} is only available in local mode; omit url.`);
|
|
771
792
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructorfleet/sketchforge3d",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.22.0",
|
|
4
4
|
"description": "Typed client and macro runner for the SketchForge REST API.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"author": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"client"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@constructorfleet/sketchforge-engine": "1.
|
|
22
|
+
"@constructorfleet/sketchforge-engine": "1.22.0",
|
|
23
23
|
"fflate": "^0.8.3",
|
|
24
24
|
"sharp": "^0.35.5"
|
|
25
25
|
},
|