bambu-printer-mcp 1.1.64 → 1.1.65

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/README.md CHANGED
@@ -1139,7 +1139,7 @@ Inspect the slicer settings embedded in a saved 3MF template or in an extracted
1139
1139
  }
1140
1140
  ```
1141
1141
 
1142
- This returns a compact summary of the high-signal settings such as printer preset, default print profile, filament profiles, layer height, infill density, shell counts, support mode, and bed type. It accepts either `source_path` or `template_name`. For 3MF inputs it also writes the extracted settings blob to a temp path so the result can be reused directly, and returns `own_process`: true when the 3MF carries its own process (a designer's project), so `slice_stl` and `print_3mf`'s auto-slice slice it with that process unless the call names `slicer_profile`, `template_name` or `template_3mf_path`.
1142
+ This returns a compact summary of the high-signal settings such as printer preset, default print profile, filament profiles, layer height, infill density, shell counts, support mode, and bed type. It accepts either `source_path` or `template_name`. For 3MF inputs it also writes the extracted settings blob to a temp path so the result can be reused directly, and returns `own_process`. With `source_path`, pass the slice's other arguments too (`slicer_profile`, `template_name`, `template_3mf_path`, `layer_height`, `wall_loops`, `sparse_infill_density`, `quality`, `strength`). `own_process` is then true when that `slice_stl` call prints the process the 3MF carries (a designer's project) unchanged.
1143
1143
 
1144
1144
  #### slice_with_template
1145
1145
 
package/dist/index.js CHANGED
@@ -805,6 +805,17 @@ async function previewOfSnapshot(snapshot, plateIndex, sha256) {
805
805
  const preview = await previewPrintFile({ gcode, ...(projectColours ? { projectColours } : {}) });
806
806
  return preview ? { ...preview, artifact_sha256: sha256, plate_index: plateIndex } : undefined;
807
807
  }
808
+ /**
809
+ * The slice's arguments change a resolved process: an explicit value (layer height, walls, infill, supports), or a
810
+ * quality or strength other than standard. Invalid values throw, as slice_stl's own parsing does.
811
+ */
812
+ function changesProcess(args) {
813
+ // slice_stl's own validation of these values (quality, strength, layer height, walls, infill, supports).
814
+ const nozzle = Number(args.nozzle_diameter || DEFAULT_NOZZLE_DIAMETER);
815
+ parseProcessOverrides(withPrintQuality(args, nozzle), nozzle);
816
+ return ["layer_height", "wall_loops", "sparse_infill_density", "enable_support", "support_type", "support_threshold_angle"].some(key => args[key] !== undefined)
817
+ || (args.quality !== undefined && args.quality !== "standard") || (args.strength !== undefined && args.strength !== "standard");
818
+ }
808
819
  function hasExplicitSlicerProfile(args) {
809
820
  return typeof args?.slicer_profile === "string" && args.slicer_profile.trim().length > 0;
810
821
  }
@@ -1683,7 +1694,12 @@ class BambuPrinterMCPServer {
1683
1694
  }
1684
1695
  return inventory;
1685
1696
  }
1686
- async inspectSliceSettings(sourcePath) {
1697
+ /**
1698
+ * `sliceArgs`: the slice_stl arguments a client would send with this file (slicer_profile, template_name,
1699
+ * template_3mf_path, layer_height, wall_loops, sparse_infill_density, quality, strength). `requestedTemplatePath`:
1700
+ * their template, resolved. own_process says whether that slice prints the process the 3MF carries, unchanged.
1701
+ */
1702
+ async inspectSliceSettings(sourcePath, sliceArgs = {}, requestedTemplatePath) {
1687
1703
  if (!fs.existsSync(sourcePath)) {
1688
1704
  throw new Error(`Slice settings source not found: ${sourcePath}`);
1689
1705
  }
@@ -1703,8 +1719,10 @@ class BambuPrinterMCPServer {
1703
1719
  metadata_keys: Object.keys(parsed.metadata),
1704
1720
  summary: summarizeSliceSettings(config),
1705
1721
  raw_key_count: Object.keys(config).length,
1706
- // ownProcessTemplate itself, for a call that names no profile or template, so this can't drift from slicing.
1707
- own_process: (await ownProcessTemplate({}, sourcePath, undefined)) !== undefined,
1722
+ // ownProcessTemplate itself, with the slice's own arguments, so this can't drift from slicing; an explicit
1723
+ // value or a quality or strength other than standard changes the process the file carries.
1724
+ // Validated first, so an invalid value is refused even when a named profile or template decides the answer.
1725
+ own_process: !changesProcess(sliceArgs) && (await ownProcessTemplate(sliceArgs, sourcePath, requestedTemplatePath)) !== undefined,
1708
1726
  };
1709
1727
  }
1710
1728
  const content = fs.readFileSync(sourcePath, "utf8");
@@ -2116,7 +2134,7 @@ class BambuPrinterMCPServer {
2116
2134
  },
2117
2135
  {
2118
2136
  name: "get_slice_settings",
2119
- description: "Inspect slicer settings from a saved 3MF template or a JSON/config slicer profile without slicing anything. For a 3MF, own_process is true when the file carries its own process (a designer's Bambu Studio or Orca project), so slice_stl and print_3mf's auto-slice slice it with that process unless the call names slicer_profile, template_name or template_3mf_path.",
2137
+ description: "Inspect slicer settings from a saved 3MF template or a JSON/config slicer profile without slicing anything. For a 3MF given as source_path, own_process is true when slice_stl, given this call's other arguments as it would take them (slicer_profile, template_name, template_3mf_path, layer_height, wall_loops, sparse_infill_density, quality, strength), prints the process the file carries (a designer's Bambu Studio or Orca project) unchanged.",
2120
2138
  inputSchema: {
2121
2139
  type: "object",
2122
2140
  properties: {
@@ -2126,12 +2144,21 @@ class BambuPrinterMCPServer {
2126
2144
  },
2127
2145
  template_name: {
2128
2146
  type: "string",
2129
- description: "Optional named template from the local registry. If provided, resolves source_path automatically."
2147
+ description: "Optional named template from the local registry. Without source_path it is the source read; with source_path it is the slice's template, for own_process."
2130
2148
  },
2131
2149
  template_dir: {
2132
2150
  type: "string",
2133
2151
  description: "Optional template directory override when resolving template_name."
2134
- }
2152
+ },
2153
+ slicer_profile: { type: "string", description: "For own_process: the slicer_profile slice_stl would be given." },
2154
+ template_3mf_path: { type: "string", description: "For own_process: the template_3mf_path slice_stl would be given." },
2155
+ layer_height: { type: "number", description: "For own_process: the layer_height slice_stl would be given." },
2156
+ nozzle_diameter: { type: "string", description: "For own_process: the nozzle_diameter slice_stl would be given; layer heights are checked against it." },
2157
+ wall_loops: { type: "number", description: "For own_process: the wall_loops slice_stl would be given." },
2158
+ sparse_infill_density: { type: "string", description: "For own_process: the sparse_infill_density slice_stl would be given." },
2159
+ enable_support: { type: "boolean", description: "For own_process: the enable_support slice_stl would be given." },
2160
+ support_type: { type: "string", description: "For own_process: the support_type slice_stl would be given." },
2161
+ ...PRINT_QUALITY_PROPERTIES
2135
2162
  }
2136
2163
  }
2137
2164
  },
@@ -3729,7 +3756,10 @@ class BambuPrinterMCPServer {
3729
3756
  if (!args?.source_path && !args?.template_name) {
3730
3757
  throw new Error("Missing required parameter: source_path or template_name");
3731
3758
  }
3732
- result = await this.inspectSliceSettings(String(args?.source_path || resolveTemplatePathFromName(["3mf", "json", "config"])));
3759
+ // With source_path, the other arguments are the slice's (template_name is its template), as slice_stl takes them.
3760
+ result = args?.source_path
3761
+ ? await this.inspectSliceSettings(String(args.source_path), args, namedTemplatePath(args, typeof args?.template_name === "string" && args.template_name.trim() ? resolveTemplatePathFromName(["json", "config", "3mf"]) : undefined))
3762
+ : await this.inspectSliceSettings(String(resolveTemplatePathFromName(["3mf", "json", "config"])));
3733
3763
  break;
3734
3764
  case "slice_with_template": {
3735
3765
  if (!args?.stl_path) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bambu-printer-mcp",
3
- "version": "1.1.64",
3
+ "version": "1.1.65",
4
4
  "description": "MCP server for Bambu Lab 3D printers with STL manipulation, slicing, and print management",
5
5
  "main": "dist/index.js",
6
6
  "repository": {
package/src/index.ts CHANGED
@@ -997,6 +997,18 @@ async function previewOfSnapshot(snapshot: string, plateIndex: number, sha256: s
997
997
  return preview ? { ...preview, artifact_sha256: sha256, plate_index: plateIndex } : undefined;
998
998
  }
999
999
 
1000
+ /**
1001
+ * The slice's arguments change a resolved process: an explicit value (layer height, walls, infill, supports), or a
1002
+ * quality or strength other than standard. Invalid values throw, as slice_stl's own parsing does.
1003
+ */
1004
+ function changesProcess(args: Record<string, unknown>): boolean {
1005
+ // slice_stl's own validation of these values (quality, strength, layer height, walls, infill, supports).
1006
+ const nozzle = Number(args.nozzle_diameter || DEFAULT_NOZZLE_DIAMETER);
1007
+ parseProcessOverrides(withPrintQuality(args, nozzle), nozzle);
1008
+ return ["layer_height", "wall_loops", "sparse_infill_density", "enable_support", "support_type", "support_threshold_angle"].some(key => args[key] !== undefined)
1009
+ || (args.quality !== undefined && args.quality !== "standard") || (args.strength !== undefined && args.strength !== "standard");
1010
+ }
1011
+
1000
1012
  function hasExplicitSlicerProfile(args: any): boolean {
1001
1013
  return typeof args?.slicer_profile === "string" && args.slicer_profile.trim().length > 0;
1002
1014
  }
@@ -2120,7 +2132,12 @@ class BambuPrinterMCPServer {
2120
2132
  return inventory;
2121
2133
  }
2122
2134
 
2123
- private async inspectSliceSettings(sourcePath: string) {
2135
+ /**
2136
+ * `sliceArgs`: the slice_stl arguments a client would send with this file (slicer_profile, template_name,
2137
+ * template_3mf_path, layer_height, wall_loops, sparse_infill_density, quality, strength). `requestedTemplatePath`:
2138
+ * their template, resolved. own_process says whether that slice prints the process the 3MF carries, unchanged.
2139
+ */
2140
+ private async inspectSliceSettings(sourcePath: string, sliceArgs: Record<string, unknown> = {}, requestedTemplatePath?: string) {
2124
2141
  if (!fs.existsSync(sourcePath)) {
2125
2142
  throw new Error(`Slice settings source not found: ${sourcePath}`);
2126
2143
  }
@@ -2142,8 +2159,10 @@ class BambuPrinterMCPServer {
2142
2159
  metadata_keys: Object.keys(parsed.metadata),
2143
2160
  summary: summarizeSliceSettings(config),
2144
2161
  raw_key_count: Object.keys(config).length,
2145
- // ownProcessTemplate itself, for a call that names no profile or template, so this can't drift from slicing.
2146
- own_process: (await ownProcessTemplate({}, sourcePath, undefined)) !== undefined,
2162
+ // ownProcessTemplate itself, with the slice's own arguments, so this can't drift from slicing; an explicit
2163
+ // value or a quality or strength other than standard changes the process the file carries.
2164
+ // Validated first, so an invalid value is refused even when a named profile or template decides the answer.
2165
+ own_process: !changesProcess(sliceArgs) && (await ownProcessTemplate(sliceArgs, sourcePath, requestedTemplatePath)) !== undefined,
2147
2166
  };
2148
2167
  }
2149
2168
 
@@ -2632,7 +2651,7 @@ class BambuPrinterMCPServer {
2632
2651
  },
2633
2652
  {
2634
2653
  name: "get_slice_settings",
2635
- description: "Inspect slicer settings from a saved 3MF template or a JSON/config slicer profile without slicing anything. For a 3MF, own_process is true when the file carries its own process (a designer's Bambu Studio or Orca project), so slice_stl and print_3mf's auto-slice slice it with that process unless the call names slicer_profile, template_name or template_3mf_path.",
2654
+ description: "Inspect slicer settings from a saved 3MF template or a JSON/config slicer profile without slicing anything. For a 3MF given as source_path, own_process is true when slice_stl, given this call's other arguments as it would take them (slicer_profile, template_name, template_3mf_path, layer_height, wall_loops, sparse_infill_density, quality, strength), prints the process the file carries (a designer's Bambu Studio or Orca project) unchanged.",
2636
2655
  inputSchema: {
2637
2656
  type: "object",
2638
2657
  properties: {
@@ -2642,12 +2661,21 @@ class BambuPrinterMCPServer {
2642
2661
  },
2643
2662
  template_name: {
2644
2663
  type: "string",
2645
- description: "Optional named template from the local registry. If provided, resolves source_path automatically."
2664
+ description: "Optional named template from the local registry. Without source_path it is the source read; with source_path it is the slice's template, for own_process."
2646
2665
  },
2647
2666
  template_dir: {
2648
2667
  type: "string",
2649
2668
  description: "Optional template directory override when resolving template_name."
2650
- }
2669
+ },
2670
+ slicer_profile: { type: "string", description: "For own_process: the slicer_profile slice_stl would be given." },
2671
+ template_3mf_path: { type: "string", description: "For own_process: the template_3mf_path slice_stl would be given." },
2672
+ layer_height: { type: "number", description: "For own_process: the layer_height slice_stl would be given." },
2673
+ nozzle_diameter: { type: "string", description: "For own_process: the nozzle_diameter slice_stl would be given; layer heights are checked against it." },
2674
+ wall_loops: { type: "number", description: "For own_process: the wall_loops slice_stl would be given." },
2675
+ sparse_infill_density: { type: "string", description: "For own_process: the sparse_infill_density slice_stl would be given." },
2676
+ enable_support: { type: "boolean", description: "For own_process: the enable_support slice_stl would be given." },
2677
+ support_type: { type: "string", description: "For own_process: the support_type slice_stl would be given." },
2678
+ ...PRINT_QUALITY_PROPERTIES
2651
2679
  }
2652
2680
  }
2653
2681
  },
@@ -4358,9 +4386,11 @@ class BambuPrinterMCPServer {
4358
4386
  if (!args?.source_path && !args?.template_name) {
4359
4387
  throw new Error("Missing required parameter: source_path or template_name");
4360
4388
  }
4361
- result = await this.inspectSliceSettings(
4362
- String(args?.source_path || resolveTemplatePathFromName(["3mf", "json", "config"]))
4363
- );
4389
+ // With source_path, the other arguments are the slice's (template_name is its template), as slice_stl takes them.
4390
+ result = args?.source_path
4391
+ ? await this.inspectSliceSettings(String(args.source_path), args as Record<string, unknown>,
4392
+ namedTemplatePath(args, typeof args?.template_name === "string" && args.template_name.trim() ? resolveTemplatePathFromName(["json", "config", "3mf"]) : undefined))
4393
+ : await this.inspectSliceSettings(String(resolveTemplatePathFromName(["3mf", "json", "config"])));
4364
4394
  break;
4365
4395
 
4366
4396
  case "slice_with_template": {