@constructorfleet/sketchforge3d 1.26.0 → 1.28.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.
Files changed (78) hide show
  1. package/README.md +28 -5
  2. package/dist/cli.d.ts +5 -1
  3. package/dist/cli.d.ts.map +1 -1
  4. package/dist/cli.js +111 -1
  5. package/dist/cli.js.map +1 -1
  6. package/dist/client.d.ts +3 -1
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +2 -2
  9. package/dist/client.js.map +1 -1
  10. package/dist/environment.d.ts.map +1 -1
  11. package/dist/environment.js.map +1 -1
  12. package/dist/errors.d.ts +6 -1
  13. package/dist/errors.d.ts.map +1 -1
  14. package/dist/errors.js +14 -0
  15. package/dist/errors.js.map +1 -1
  16. package/dist/http.d.ts +3 -0
  17. package/dist/http.d.ts.map +1 -1
  18. package/dist/http.js +11 -0
  19. package/dist/http.js.map +1 -1
  20. package/dist/index.d.ts +1 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js.map +1 -1
  23. package/dist/layout.js.map +1 -1
  24. package/dist/macro.js.map +1 -1
  25. package/dist/resources/arrange.d.ts.map +1 -1
  26. package/dist/resources/arrange.js.map +1 -1
  27. package/dist/resources/booleans.d.ts.map +1 -1
  28. package/dist/resources/booleans.js.map +1 -1
  29. package/dist/resources/draft-prism.d.ts.map +1 -1
  30. package/dist/resources/draft-prism.js.map +1 -1
  31. package/dist/resources/drawings.d.ts.map +1 -1
  32. package/dist/resources/drawings.js.map +1 -1
  33. package/dist/resources/edges.d.ts.map +1 -1
  34. package/dist/resources/edges.js.map +1 -1
  35. package/dist/resources/explosions.d.ts.map +1 -1
  36. package/dist/resources/explosions.js.map +1 -1
  37. package/dist/resources/exports.d.ts.map +1 -1
  38. package/dist/resources/exports.js.map +1 -1
  39. package/dist/resources/faces.d.ts +3 -1
  40. package/dist/resources/faces.d.ts.map +1 -1
  41. package/dist/resources/faces.js +2 -2
  42. package/dist/resources/faces.js.map +1 -1
  43. package/dist/resources/groups.d.ts.map +1 -1
  44. package/dist/resources/groups.js.map +1 -1
  45. package/dist/resources/imports.d.ts.map +1 -1
  46. package/dist/resources/imports.js.map +1 -1
  47. package/dist/resources/interference.d.ts.map +1 -1
  48. package/dist/resources/interference.js.map +1 -1
  49. package/dist/resources/measurements.d.ts.map +1 -1
  50. package/dist/resources/measurements.js.map +1 -1
  51. package/dist/resources/mirrors.d.ts.map +1 -1
  52. package/dist/resources/mirrors.js.map +1 -1
  53. package/dist/resources/parts.d.ts.map +1 -1
  54. package/dist/resources/parts.js.map +1 -1
  55. package/dist/resources/projects.d.ts +2 -1
  56. package/dist/resources/projects.d.ts.map +1 -1
  57. package/dist/resources/projects.js +8 -0
  58. package/dist/resources/projects.js.map +1 -1
  59. package/dist/resources/properties.d.ts.map +1 -1
  60. package/dist/resources/properties.js.map +1 -1
  61. package/dist/resources/shapes.d.ts +2 -1
  62. package/dist/resources/shapes.d.ts.map +1 -1
  63. package/dist/resources/shapes.js +8 -0
  64. package/dist/resources/shapes.js.map +1 -1
  65. package/dist/resources/shell.d.ts.map +1 -1
  66. package/dist/resources/shell.js.map +1 -1
  67. package/dist/resources/thickness.d.ts.map +1 -1
  68. package/dist/resources/thickness.js.map +1 -1
  69. package/dist/resources/treatments.d.ts.map +1 -1
  70. package/dist/resources/treatments.js.map +1 -1
  71. package/dist/types.d.ts +33 -0
  72. package/dist/types.d.ts.map +1 -1
  73. package/dist/types.js.map +1 -1
  74. package/mcp/createShapeKinds.mjs +62 -0
  75. package/mcp/filesystemPaths.mjs +66 -0
  76. package/mcp/localEngine.mjs +35 -16
  77. package/mcp/server.mjs +115 -31
  78. package/package.json +2 -2
package/mcp/server.mjs CHANGED
@@ -3,8 +3,18 @@
3
3
  import { readFileSync, writeFileSync } from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
+ import { resolveMcpReadPath, resolveMcpWritePath } from "./filesystemPaths.mjs";
6
7
  import { listMacros, macroTools, runMacroByName } from "./macroTools.mjs";
7
8
  import { callLocalEngineTool } from "./localEngine.mjs";
9
+ import {
10
+ CREATE_SHAPE_KINDS,
11
+ EDITOR_SHAPE_KINDS,
12
+ LOCAL_SHAPE_KINDS,
13
+ LOCAL_SOLID_KINDS,
14
+ LOCAL_STORED_KINDS,
15
+ STEP_KINDS,
16
+ TAPER_KINDS,
17
+ } from "./createShapeKinds.mjs";
8
18
 
9
19
 
10
20
  /**
@@ -27,6 +37,7 @@ const MCP_ROUTE = "/api/sketchforge-mcp";
27
37
  const PROJECTION_LAYOUTS = ["multiview", "front", "back", "top", "bottom", "left", "right", "iso"];
28
38
  const SECTION_PLANES = ["xy", "xz", "yz"];
29
39
 
40
+
30
41
  const editorTargetSchema = {
31
42
  type: "object",
32
43
  properties: {
@@ -37,22 +48,28 @@ const editorTargetSchema = {
37
48
  timeoutMs: { type: "number", description: "Command timeout in milliseconds. Defaults to 15000." },
38
49
  },
39
50
  };
51
+ const localProjectSchema = { type: "object", properties: {} };
52
+ /** What group_objects and boolean_cut may name and colour the shape they leave behind. */
53
+ const resultAttributeProperties = {
54
+ name: { type: "string", description: "Name for the result (default \"Group\")." },
55
+ color: { type: "string", description: "Color for the result, stored as given as create_shape stores its color, such as #2a9d8f (default the first solid's color)." },
56
+ };
40
57
 
41
58
  const tools = [
42
59
  {
43
60
  name: "sketchforge_list_projects",
44
61
  description: "List projects stored in SKETCHFORGE_PROJECTS_DIR for offline MCP use.",
45
- inputSchema: { ...editorTargetSchema, properties: { url: editorTargetSchema.properties.url } },
62
+ inputSchema: localProjectSchema,
46
63
  },
47
64
  {
48
65
  name: "sketchforge_create_project",
49
66
  description: "Create an empty project in the local SKETCHFORGE_PROJECTS_DIR.",
50
- inputSchema: { ...editorTargetSchema, required: ["name"], properties: { ...editorTargetSchema.properties, name: { type: "string" } } },
67
+ inputSchema: { ...localProjectSchema, required: ["name"], properties: { name: { type: "string" } } },
51
68
  },
52
69
  {
53
70
  name: "sketchforge_import_project",
54
- description: "Import a local .skf file as a new project in SKETCHFORGE_PROJECTS_DIR.",
55
- inputSchema: { ...editorTargetSchema, required: ["filePath"], properties: { ...editorTargetSchema.properties, filePath: { type: "string" }, name: { type: "string" } } },
71
+ description: "Import a local .skf file as a new project in SKETCHFORGE_PROJECTS_DIR. File reads are confined to SKETCHFORGE_MCP_FILES_DIR, or SKETCHFORGE_PROJECTS_DIR when unset; if both are unset, paths are unrestricted.",
72
+ inputSchema: { ...localProjectSchema, required: ["filePath"], properties: { filePath: { type: "string", description: "Path to a .skf under SKETCHFORGE_MCP_FILES_DIR (or SKETCHFORGE_PROJECTS_DIR when unset); unrestricted if neither is set." }, name: { type: "string" } } },
56
73
  },
57
74
  {
58
75
  name: "sketchforge_list_editors",
@@ -114,13 +131,25 @@ const tools = [
114
131
  },
115
132
  {
116
133
  name: "sketchforge_create_shape",
117
- description: "Create a box/cube, cylinder, loft, simple extruded sketch, revolve, or standard screw thread in SketchForge.",
134
+ description: `Create a parameterized shape, extruded sketch, revolve, or standard screw thread in SketchForge. Local mode (no url) accepts ${LOCAL_SHAPE_KINDS.join(", ")}; the kind description says which of those it can measure and export. An editor (url) builds ${EDITOR_SHAPE_KINDS.join(", ")}. sketch is editor-only. Each parameter's description names the kinds it applies to.`,
118
135
  inputSchema: {
119
136
  ...editorTargetSchema,
120
137
  required: ["kind"],
121
138
  properties: {
122
139
  ...editorTargetSchema.properties,
123
- kind: { type: "string", enum: ["box", "cube", "cylinder", "sketch", "loft", "revolve", "thread"] },
140
+ kind: {
141
+ type: "string",
142
+ enum: CREATE_SHAPE_KINDS,
143
+ description: [
144
+ `Local mode builds ${LOCAL_SOLID_KINDS.join(", ")} as solids that measure and export as STL.`,
145
+ "A roundRoof's height may be at most half its width; a taller one fails to build.",
146
+ `${LOCAL_STORED_KINDS.join(", ")} are stored only: local mode records the parameters but cannot measure or export them; open the project in an editor for those.`,
147
+ `STEP export holds only ${STEP_KINDS.join(", ")}; export the other solids as STL.`,
148
+ "revolve there means a plain revolve: no pitch, no coreRadius, one closed profile region with straight edges, and not resized unevenly across its axis; any other revolve, like a thread, exports as STL only. A plain revolve is in STEP only when exported by the server or local mode, from its exact solid; an open editor's own STEP export skips it.",
149
+ "sketch is editor-only: it needs an open editor (url), and local mode refuses it.",
150
+ `An editor builds only ${EDITOR_SHAPE_KINDS.join(", ")}.`,
151
+ ].join(" "),
152
+ },
124
153
  profile: {
125
154
  type: "array",
126
155
  description: "For kind sketch: a closed 2D outline to extrude, as [x, z] pairs. For kind revolve: the closed outline to revolve, where x is distance from axis and z runs along it.",
@@ -130,10 +159,13 @@ const tools = [
130
159
  turns: { type: "number", description: "For kind revolve/thread: how many full turns to sweep (default 8 for a thread)." },
131
160
  diameter: { type: "number", description: "For kind thread: outside diameter in mm, for a size the catalog does not list. The 60-degree ISO profile follows from this and the pitch." },
132
161
  length: { type: "number", description: "For kind thread: how long the thread should be in mm, instead of giving turns." },
133
- hole: { type: "boolean", description: "For kind thread: cut the form wider by a clearance so a bolt of that size fits, and mark the shape as a hole so grouping it with a solid taps that solid." },
162
+ hole: {
163
+ type: "boolean",
164
+ description: "Any kind: create the shape as a hole (a cutter), so grouping it with a solid cuts it out of that solid without a separate update_object call. For kind thread it also cuts the form wider by a clearance so a bolt of that size fits, which taps the solid.",
165
+ },
134
166
  clearance: { type: "number", description: "For kind thread with hole: how much wider to cut, per side, in mm (default 0.2 for printed parts)." },
135
167
  startAngle: { type: "number", description: "For kind revolve: rotation the sweep starts at, in degrees." },
136
- sweepAngle: { type: "number", description: "For kind revolve with no pitch: how far round to revolve, in degrees (±360)." },
168
+ sweepAngle: { type: "number", description: "For kind revolve with no pitch: how far round to revolve, in degrees (±360). x/z place the axis of revolution, so a partial sweep lies to one side of them; the result's x/z is its box centre, and local mode reports the axis as revolveAxis." },
137
169
  name: { type: "string" },
138
170
  color: { type: "string" },
139
171
  x: { type: "number" },
@@ -149,7 +181,28 @@ const tools = [
149
181
  rotation: { type: "number" },
150
182
  rotationX: { type: "number" },
151
183
  rotationZ: { type: "number" },
152
- sides: { type: "number" },
184
+ sides: { type: "number", description: "Number of flat sides around the axis, at least 3. For cylinder: default 96, which builds a true round cylinder; fewer builds a prism. For pyramid: default 4, a rectangular base; any other count is a regular polygon base. A cone and roundRoof are always round, whatever sides says. For kind revolve/thread: facets per full turn of the sweep, 3-512 (default 64). On a 150 mm ring 64 facets are about 7.4 mm wide and 256 about 1.8 mm; the triangle count grows with it." },
185
+ quality: { type: "number", description: "For kind revolve/thread: how finely curved segments of the profile are sampled, 1-10 (default 6). An outline of [x, z] points is all straight segments, so it changes nothing there; raise sides to smooth the turn." },
186
+ steps: { type: "number", description: "For sphere and halfSphere: display mesh segments around and over the surface (at least 4, default 32). The measured and exported solid is a true curved surface whatever steps says." },
187
+ bevel: {
188
+ type: "number",
189
+ description: "For tube and ring: wall thickness in mm, measured inward from the outer radius (default 4). It is clamped to at least 0.1 and at most the smaller outer radius less 0.1, so the bore never closes: on a 20 mm wide tube, any bevel above 9.9 builds a 9.9 mm wall. A 20x20x10 tube with bevel 4 has a 6 mm inner radius. For text: edge rounding in mm (default 0).",
190
+ },
191
+ segments: { type: "number", description: "For text: curve segments per glyph outline (at least 1, default 2)." },
192
+ topRadius: { type: "number", description: "For cone: radius of the top in mm (default 0, a point)." },
193
+ baseRadius: { type: "number", description: "For cone: recorded base radius in mm (default half the width). It does not change the solid: a cone stands on half its width, so set width and depth to size the base." },
194
+ taperTopWidth: { type: "number", description: `For ${TAPER_KINDS.join(", ")} in local mode: footprint width at the top of the extrusion in mm (default width). Other kinds store it, but measuring or exporting a tapered one is refused. An editor ignores it.` },
195
+ taperTopDepth: { type: "number", description: `For ${TAPER_KINDS.join(", ")} in local mode: footprint depth at the top of the extrusion in mm (default depth). Other kinds store it, but measuring or exporting a tapered one is refused. An editor ignores it.` },
196
+ taperBottomWidth: { type: "number", description: `For ${TAPER_KINDS.join(", ")} in local mode: footprint width at the bottom of the extrusion in mm (default width). Other kinds store it, but measuring or exporting a tapered one is refused. An editor ignores it.` },
197
+ taperBottomDepth: { type: "number", description: `For ${TAPER_KINDS.join(", ")} in local mode: footprint depth at the bottom of the extrusion in mm (default depth). Other kinds store it, but measuring or exporting a tapered one is refused. An editor ignores it.` },
198
+ teeth: { type: "number", description: "For gear: tooth count (default 12)." },
199
+ toothSize: { type: "number", description: "For gear: radial tooth height in mm (default 2.5)." },
200
+ toothWidth: { type: "number", description: "For gear: tooth width in mm (default 0.54 of the tooth pitch, clamped between 0.12 and 0.82 of it)." },
201
+ centerHoleSize: { type: "number", description: "For gear: centre hole size in mm (default 6, clamped so it stays inside the tooth roots; 0 for none)." },
202
+ gearType: { type: "string", enum: ["spur", "helical", "bevel"], description: "For gear: tooth form (default spur)." },
203
+ helixAngle: { type: "number", description: "For gear with gearType helical: helix angle in degrees (default 22.5)." },
204
+ text: { type: "string", description: "For text: the characters to extrude (default TEXT)." },
205
+ font: { type: "string", description: "For text: font name (default Multilanguage)." },
153
206
  loftBottomShape: { type: "string", enum: ["Oval", "Rectangle", "Triangle", "Pentagon", "Hexagon"], description: "loft only. Defaults to Rectangle." },
154
207
  loftTopShape: { type: "string", enum: ["Oval", "Rectangle", "Triangle", "Pentagon", "Hexagon"], description: "loft only. Defaults to Oval." },
155
208
  loftTopWidth: { type: "number", description: "loft only. Independent of the bottom's width, like a cone's top radius. Defaults to matching width." },
@@ -182,16 +235,28 @@ const tools = [
182
235
  },
183
236
  },
184
237
  },
238
+ {
239
+ name: "sketchforge_import_file",
240
+ description: "Import an STL, OBJ, or SVG file from the MCP host filesystem into SketchForge. The source filename supplies the shape name; color and placement use importer defaults. In local mode provide projectId and filePath; with url, the file is sent to POST /api/v1/imports. File reads are confined to SKETCHFORGE_MCP_FILES_DIR, or SKETCHFORGE_PROJECTS_DIR when unset; if both are unset, paths are unrestricted.",
241
+ inputSchema: {
242
+ type: "object",
243
+ required: ["projectId", "filePath"],
244
+ properties: {
245
+ url: editorTargetSchema.properties.url,
246
+ projectId: { type: "string" },
247
+ filePath: { type: "string", description: "Path to an .stl, .obj, or .svg file under the configured MCP files root; unrestricted when no root is set." },
248
+ },
249
+ },
250
+ },
185
251
  {
186
252
  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.",
253
+ description: "Local-only compatibility alias for sketchforge_import_file. Accepts STL, OBJ, or SVG files. Optional name, color, and placement fields override the imported shape. A remote url is not supported.",
188
254
  inputSchema: {
189
- ...editorTargetSchema,
255
+ type: "object",
190
256
  required: ["projectId", "filePath"],
191
257
  properties: {
192
- ...editorTargetSchema.properties,
193
258
  projectId: { type: "string" },
194
- filePath: { type: "string", description: "Path to an STL file readable by the MCP host." },
259
+ filePath: { type: "string", description: "Path to an .stl, .obj, or .svg file under the configured MCP files root; unrestricted when no root is set." },
195
260
  name: { type: "string" },
196
261
  color: { type: "string" },
197
262
  x: { type: "number" },
@@ -275,13 +340,14 @@ const tools = [
275
340
  },
276
341
  {
277
342
  name: "sketchforge_group_objects",
278
- description: "Group objects by id using SketchForge's normal grouping/boolean pipeline.",
343
+ description: "Group objects by id using SketchForge's normal grouping/boolean pipeline. A selection holding a hole comes back cut. Optional name and color are set on the result.",
279
344
  inputSchema: {
280
345
  ...editorTargetSchema,
281
346
  required: ["ids"],
282
347
  properties: {
283
348
  ...editorTargetSchema.properties,
284
349
  ids: { type: "array", items: { type: "string" } },
350
+ ...resultAttributeProperties,
285
351
  },
286
352
  },
287
353
  },
@@ -299,7 +365,7 @@ const tools = [
299
365
  },
300
366
  {
301
367
  name: "sketchforge_boolean_cut",
302
- description: "Cut solids with hole objects. Provide solidIds and holeIds; the result replaces the operands.",
368
+ description: "Cut solids with hole objects. Provide solidIds and holeIds; the result replaces the operands. Optional name and color are set on the result.",
303
369
  inputSchema: {
304
370
  ...editorTargetSchema,
305
371
  required: ["solidIds", "holeIds"],
@@ -307,6 +373,7 @@ const tools = [
307
373
  ...editorTargetSchema.properties,
308
374
  solidIds: { type: "array", items: { type: "string" } },
309
375
  holeIds: { type: "array", items: { type: "string" } },
376
+ ...resultAttributeProperties,
310
377
  },
311
378
  },
312
379
  },
@@ -377,17 +444,18 @@ const tools = [
377
444
  properties: {
378
445
  ...editorTargetSchema.properties,
379
446
  face: { type: "string", enum: ["current", "home", "top", "bottom", "front", "back", "right", "left"] },
447
+ featureAngle: { type: "number", minimum: 0, maximum: 180, description: "Crease angle in degrees for mesh shapes (imported, mesh-derived, boolean results): an edge between two triangles is drawn only where they meet at more than this, besides boundaries and silhouettes. Default 30; 0 draws every edge that is not flat. Exact solids ignore it. Local project mode only; the live editor viewport ignores it." },
380
448
  },
381
449
  },
382
450
  },
383
451
  {
384
452
  name: "sketchforge_export_scene",
385
- description: "Export selected objects or the whole scene as STL, OBJ, 3MF, STEP, SKF, a ZIP kit, SVG drawings, or section DXF. DXF needs section {plane, offset}. Set outputPath to save directly on the MCP host.",
386
- inputSchema: { ...editorTargetSchema, required: ["format"], properties: { ...editorTargetSchema.properties, format: { type: "string", enum: ["stl", "obj", "3mf", "step", "skf", "zip", "svg", "dxf"] }, view: { type: "string", enum: PROJECTION_LAYOUTS, description: "For svg only: one named view, or the multiview grid (default)." }, section: { type: "object", description: "For svg or dxf section export.", properties: { plane: { type: "string", enum: ["xy", "xz", "yz"] }, offset: { type: "number" } }, required: ["plane", "offset"] }, shapeIds: { type: "array", items: { type: "string" }, description: "Optional object ids." }, name: { type: "string" }, outputPath: { type: "string", description: "Optional destination path on the computer running the SketchForge MCP server." } } },
453
+ description: "Export selected objects or the whole scene as STL, OBJ, 3MF, STEP, SKF, a ZIP kit, SVG drawings, or section DXF. DXF needs section {plane, offset}. Set outputPath to save on the MCP host; writes are confined to SKETCHFORGE_MCP_FILES_DIR, or SKETCHFORGE_PROJECTS_DIR when unset. If both are unset, paths are unrestricted. Existing files require overwrite: true.",
454
+ inputSchema: { ...editorTargetSchema, required: ["format"], properties: { ...editorTargetSchema.properties, format: { type: "string", enum: ["stl", "obj", "3mf", "step", "skf", "zip", "svg", "dxf"] }, view: { type: "string", enum: PROJECTION_LAYOUTS, description: "For svg only: one named view, or the multiview grid (default)." }, section: { type: "object", description: "For svg or dxf section export.", properties: { plane: { type: "string", enum: ["xy", "xz", "yz"] }, offset: { type: "number" } }, required: ["plane", "offset"] }, shapeIds: { type: "array", items: { type: "string" }, description: "Optional object ids." }, name: { type: "string" }, outputPath: { type: "string", description: "Destination path under SKETCHFORGE_MCP_FILES_DIR (or SKETCHFORGE_PROJECTS_DIR when unset); unrestricted if neither is set." }, overwrite: { type: "boolean", description: "Set true to replace an existing output file." } } },
387
455
  },
388
456
  {
389
457
  name: "sketchforge_project_view",
390
- description: "Draw a stored project as an SVG by the CAD kernel's hidden-line removal: true curves, hidden edges dashed, a gnomon per view and the overall size. The multiview grid (front, top, right, iso) is the readable picture of the geometry; a single view is a 2D drawing of that face. Works offline or against a server when url is supplied.",
458
+ description: "Draw a stored project as an SVG by the CAD kernel's hidden-line removal: true curves, hidden edges dashed, a gnomon per view and the overall size. Mesh shapes are drawn by feature edges (see featureAngle), silhouettes and boundaries rather than every triangle. The multiview grid (front, top, right, iso) is the readable picture of the geometry; a single view is a 2D drawing of that face. Works offline or against a server when url is supplied.",
391
459
  inputSchema: {
392
460
  type: "object",
393
461
  required: ["projectId"],
@@ -395,15 +463,17 @@ const tools = [
395
463
  url: { type: "string", description: "Optional SketchForge server URL. Omit to work offline with local project files." },
396
464
  projectId: { type: "string", description: "The server-side project id." },
397
465
  view: { type: "string", enum: PROJECTION_LAYOUTS, description: "One named view, or the multiview grid (default)." },
466
+ featureAngle: { type: "number", minimum: 0, maximum: 180, description: "Crease angle in degrees for mesh shapes (imported, mesh-derived, boolean results): an edge between two triangles is drawn only where they meet at more than this, besides boundaries and silhouettes. Default 30; 0 draws every edge that is not flat. Exact solids ignore it." },
398
467
  shapeIds: { type: "array", items: { type: "string" }, description: "Optional object ids; defaults to the current selection, or the whole scene when nothing is selected." },
399
468
  name: { type: "string", description: "Optional base name for the file." },
400
- outputPath: { type: "string", description: "Optional destination path on the computer running the SketchForge MCP server; the SVG text is returned inline otherwise." },
469
+ outputPath: { type: "string", description: "Optional destination path under SKETCHFORGE_MCP_FILES_DIR (or SKETCHFORGE_PROJECTS_DIR when unset); unrestricted if neither is set. SVG text is returned inline otherwise." },
470
+ overwrite: { type: "boolean", description: "Set true to replace an existing output file." },
401
471
  },
402
472
  },
403
473
  },
404
474
  {
405
475
  name: "sketchforge_section_view",
406
- description: "Return an exact CAD section drawing as SVG by cutting the stored solids with one axis-aligned plane in drawing coordinates. offset is the coordinate of the omitted axis, in millimetres. Works offline or against a server when url is supplied.",
476
+ description: "Return a CAD section drawing as SVG by cutting the stored solids with one axis-aligned plane in drawing coordinates. offset is the coordinate of the omitted axis, in millimetres. Exact shapes are cut by the OCCT kernel; mesh shapes (imported STL/OBJ and other mesh-backed shapes) are sliced directly, up to 2,000,000 triangles across the selection -- pass shapeIds to section fewer shapes when over that. Works offline or against a server when url is supplied.",
407
477
  inputSchema: {
408
478
  type: "object",
409
479
  required: ["projectId", "plane", "offset"],
@@ -414,7 +484,8 @@ const tools = [
414
484
  offset: { type: "number", description: "Coordinate of the omitted axis in millimetres; must intersect the selected scene." },
415
485
  shapeIds: { type: "array", items: { type: "string" }, description: "Optional object ids; defaults to the current selection, or the whole scene when nothing is selected." },
416
486
  name: { type: "string", description: "Optional base name for the file." },
417
- outputPath: { type: "string", description: "Optional destination path on the computer running the SketchForge MCP server; the SVG text is returned inline otherwise." },
487
+ outputPath: { type: "string", description: "Optional destination path under SKETCHFORGE_MCP_FILES_DIR (or SKETCHFORGE_PROJECTS_DIR when unset); unrestricted if neither is set. SVG text is returned inline otherwise." },
488
+ overwrite: { type: "boolean", description: "Set true to replace an existing output file." },
418
489
  },
419
490
  },
420
491
  },
@@ -492,7 +563,7 @@ const tools = [
492
563
  },
493
564
  {
494
565
  name: "sketchforge_shape_properties",
495
- description: "Read one stored shape's volume, surface area, center of mass, bounds and validity, with provenance identifying the geometry source and whether precision is exact or tessellated. Works offline or against a server when url is supplied.",
566
+ description: "Read one stored shape's volume, surface area, center of mass, bounds and validity, with provenance identifying the geometry source and whether precision is exact or tessellated. A group of solids is measured as the union of its children. Exact shapes are measured by the CAD kernel; closed mesh-sourced shapes are measured directly from their triangles, counting every shell and subtracting enclosed voids, and a mesh that does not close is left to the kernel, which refuses it. Works offline or against a server when url is supplied.",
496
567
  inputSchema: {
497
568
  type: "object",
498
569
  required: ["projectId", "shapeId"],
@@ -640,6 +711,18 @@ async function callRemoteTool(name, args, baseUrl) {
640
711
  return bridgeCommand("create_shape", args, 15000, baseUrl);
641
712
  case "sketchforge_import_mesh":
642
713
  return bridgeCommand("import_mesh", args, 60000, baseUrl);
714
+ case "sketchforge_import_file": {
715
+ const sourcePath = await resolveMcpReadPath(args.filePath);
716
+ const extension = path.extname(sourcePath).toLowerCase();
717
+ const mediaType = extension === ".stl" ? "model/stl" : extension === ".obj" ? "model/obj" : extension === ".svg" ? "image/svg+xml" : undefined;
718
+ if (!mediaType) throw new Error("filePath must point to an .stl, .obj, or .svg file.");
719
+ const bytes = readFileSync(sourcePath);
720
+ return restRequest("POST", "/imports", {
721
+ query: { projectId: args.projectId },
722
+ body: { fileName: path.basename(sourcePath), data: bytes.toString("base64"), mediaType },
723
+ baseUrl,
724
+ });
725
+ }
643
726
  case "sketchforge_update_object":
644
727
  return bridgeCommand("update_object", args, 15000, baseUrl);
645
728
  case "sketchforge_align_objects":
@@ -695,6 +778,7 @@ async function callRemoteTool(name, args, baseUrl) {
695
778
  body: {
696
779
  format: "svg",
697
780
  ...(args.view === undefined ? {} : { view: args.view }),
781
+ ...(args.featureAngle === undefined ? {} : { featureAngle: args.featureAngle }),
698
782
  ...(args.shapeIds === undefined ? {} : { shapeIds: args.shapeIds }),
699
783
  ...(args.name === undefined ? {} : { name: args.name }),
700
784
  },
@@ -703,9 +787,9 @@ async function callRemoteTool(name, args, baseUrl) {
703
787
  const bytes = Buffer.from(artifact.base64, "base64");
704
788
  const response = { view: args.view ?? "multiview", filename: artifact.filename, mimeType: artifact.mimeType, bytes: artifact.bytes, shapeCount: artifact.shapeCount };
705
789
  if (typeof args.outputPath === "string" && args.outputPath.trim()) {
706
- const destination = path.resolve(args.outputPath);
707
- writeFileSync(destination, bytes);
708
- return { ...response, savedTo: destination };
790
+ const destination = await resolveMcpWritePath(args.outputPath, { overwrite: args.overwrite === true });
791
+ writeFileSync(destination, bytes, { flag: args.overwrite === true ? "w" : "wx" });
792
+ return { ...response, savedTo: path.resolve(args.outputPath) };
709
793
  }
710
794
  return { ...response, svg: bytes.toString("utf8") };
711
795
  }
@@ -723,9 +807,9 @@ async function callRemoteTool(name, args, baseUrl) {
723
807
  const bytes = Buffer.from(artifact.base64, "base64");
724
808
  const response = { plane: args.plane, offset: args.offset, filename: artifact.filename, mimeType: artifact.mimeType, bytes: artifact.bytes, shapeCount: artifact.shapeCount };
725
809
  if (typeof args.outputPath === "string" && args.outputPath.trim()) {
726
- const destination = path.resolve(args.outputPath);
727
- writeFileSync(destination, bytes);
728
- return { ...response, savedTo: destination };
810
+ const destination = await resolveMcpWritePath(args.outputPath, { overwrite: args.overwrite === true });
811
+ writeFileSync(destination, bytes, { flag: args.overwrite === true ? "w" : "wx" });
812
+ return { ...response, savedTo: path.resolve(args.outputPath) };
729
813
  }
730
814
  return { ...response, svg: bytes.toString("utf8") };
731
815
  }
@@ -746,9 +830,9 @@ async function callRemoteTool(name, args, baseUrl) {
746
830
  })
747
831
  : await bridgeCommand("export_scene", args, 60000, baseUrl);
748
832
  if (typeof args.outputPath === "string" && args.outputPath.trim()) {
749
- const destination = path.resolve(args.outputPath);
750
- writeFileSync(destination, Buffer.from(artifact.base64, "base64"));
751
- return { filename: artifact.filename, mimeType: artifact.mimeType, bytes: artifact.bytes, shapeCount: artifact.shapeCount, savedTo: destination };
833
+ const destination = await resolveMcpWritePath(args.outputPath, { overwrite: args.overwrite === true });
834
+ writeFileSync(destination, Buffer.from(artifact.base64, "base64"), { flag: args.overwrite === true ? "w" : "wx" });
835
+ return { filename: artifact.filename, mimeType: artifact.mimeType, bytes: artifact.bytes, shapeCount: artifact.shapeCount, savedTo: path.resolve(args.outputPath) };
752
836
  }
753
837
  return artifact;
754
838
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructorfleet/sketchforge3d",
3
- "version": "1.26.0",
3
+ "version": "1.28.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.26.0",
22
+ "@constructorfleet/sketchforge-engine": "1.28.0",
23
23
  "fflate": "^0.8.3",
24
24
  "sharp": "^0.35.5"
25
25
  },