bambu-printer-mcp 1.1.70 → 1.1.72

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
@@ -996,7 +996,7 @@ npx -y -p bambu-printer-mcp bambu-printer-mcp-native-setup
996
996
 
997
997
  Use the same package version as the server, for example `bambu-printer-mcp@1.2.3`; when the installation is missing or stale, the server's error names the exact command. The setup downloads the Linux plug-in that Bambu Studio itself installs, pinned to an exact version and SHA-256, and stores it with the certificates under `~/.config/bambu-printer-mcp/bambu-native` (`BAMBU_NATIVE_HOME` or `XDG_CONFIG_HOME` move it; set the same value for the server). The plug-in is not redistributed by this package, and Bambu Studio's own auto-updating copy is never used. The server finds the installation automatically and passes the plug-in and certificate paths to the helper. Rerun the setup with the server's package version after upgrading: the server refuses a helper built from another version. Only missing or changed files are downloaded again. The setup then loads the plug-in once, offline, so missing system libraries are reported during installation rather than on a stop command. `--verify` repeats these checks without network access. On Linux the server uses only this managed helper or `BAMBU_NATIVE_HELPER`; a package-local `npm run build:native` binary is not used.
998
998
 
999
- `--check-update` asks Bambu's plug-in service for the newest Linux plug-in and compares the `PrintParams` layout in the matching Bambu Studio header with the helper. It reports only: the setup never installs an unpinned plug-in, because a changed layout would send wrong print parameters. A pin is raised by a package release after the check passes and a hardware test.
999
+ `--check-update` asks Bambu's plug-in service for the newest Linux plug-in and compares the `PrintParams` layout in the matching Bambu Studio header with the helper. It reports only: the setup never installs an unpinned plug-in, because a changed layout would send wrong print parameters. A pin is raised by a package release after the check passes and the offered archive and required libraries are checksum-verified. Offline plug-in loading and physical X2D printing are separate validation steps, reported with each release.
1000
1000
 
1001
1001
  Once the helper, plug-in and certificates are installed, X2D printing, upload and controls use the same routing, safety checks and authorization handshake described for macOS above. On Linux, stop and heater-off go out over the native route and MQTT at the same time, so a stuck helper cannot delay them. MQTT is sent again once every older print or heating helper for that printer has exited and the immediate MQTT attempt has settled, so none can dispatch after it; either the native route or that later MQTT send succeeding counts, and the result lists all sends under `routes`. Each MQTT send gives up after 15 seconds (`BAMBU_EMERGENCY_MQTT_TIMEOUT_MS`), so an unreachable MQTT connection cannot hold back a stop the native route already sent. A connection completing after that deadline cannot dispatch its expired command; an already queued MQTT publish is discarded by force-closing and invalidating that client. A repeated stop or heater-off is harmless. macOS keeps its native-only route. On both systems a print goes to the printer's SD card or USB stick when the printer reports one ready, so it can be reprinted from the printer and archived by tools that read the card; otherwise it goes to internal storage (eMMC), as Bambu Studio's Print button always does. `BAMBU_NATIVE_TRY_EMMC_PRINT=1` (or `0`) forces the choice. The server accepts only the pinned plug-in checksums; `BAMBU_NATIVE_ALLOW_UNPINNED_PLUGIN=1` is a trusted override for testing another build at your own risk. Without a complete installation, Linux keeps its previous behavior: X2D status and slicing work, stop, pause and heater-off use MQTT, and native print requests name the setup command before contacting the printer. Bambu publishes the Linux plug-in for x86-64 only; other architectures keep the MQTT behavior.
1002
1002
 
@@ -1035,7 +1035,7 @@ List a designer's 3MF plates as Bambu Studio shows them when the file is opened,
1035
1035
 
1036
1036
  #### list_3mf_plate_objects
1037
1037
 
1038
- List object IDs from a sliced 3MF plate. Use this before `skip_objects` so you pass real Bambu object IDs instead of display-order guesses.
1038
+ List the objects of a sliced 3MF plate that the printer can skip, one per copy, with each copy's `identify_id` from `Metadata/slice_info.config`, as Bambu Studio's skip dialog lists them. Use this before `skip_objects` so you pass real Bambu object IDs instead of display-order guesses.
1039
1039
 
1040
1040
  ```json
1041
1041
  {
@@ -1202,7 +1202,7 @@ When `slicer_type` is `bambustudio` (the default), these additional parameters a
1202
1202
  | `arrange` | boolean | Auto-arrange objects on the build plate |
1203
1203
  | `ensure_on_bed` | boolean | Lift floating models onto the bed |
1204
1204
  | `clone_objects` | string | Clone counts per object, comma-separated (e.g. `"1,3,1,10"`) |
1205
- | `skip_objects` | string | Object indices to skip, comma-separated (e.g. `"3,5,10"`) |
1205
+ | `skip_objects` | string | `identify_id`s of the object copies to skip, comma-separated (e.g. `"78,92"`); `list_3mf_plates` gives them per plate as `instances` |
1206
1206
  | `load_filaments` | string | Filament profile paths, semicolon-separated |
1207
1207
  | `load_filament_ids` | string | Filament-to-object mapping, comma-separated. STL input only: Bambu Studio's CLI refuses it for a 3MF, where each object or part names its own filament (see `counterpart_make_3mf`) |
1208
1208
  | `nozzle_volume_type` | string | Installed nozzle flow type: `standard` or `high_flow` (default: `BAMBU_NOZZLE_VOLUME_TYPE`, else the preset's Standard default). `high_flow` uses the presets' High Flow values, such as the filament's High Flow max volumetric speed, and is refused if the machine preset declares no High Flow variant. Also on `slice_with_template`. |
@@ -27,4 +27,12 @@ export declare function getCollarCharmRolePolicy(): {
27
27
  };
28
28
  };
29
29
  export declare function analyze3MFAmsRequirements(filePath: string, plateIndex?: number): Promise<ThreeMFAmsRequirements>;
30
+ /**
31
+ * The objects of one sliced plate that the printer can skip, as Bambu Studio lists them in its skip dialog
32
+ * (02.08.02.61 slic3r/GUI/PartSkipDialog.cpp:734-741, SkipPartCanvas.cpp:690-730): one entry per instance
33
+ * from Metadata/slice_info.config's plate whose `index` matches (written per instance at bbs_3mf.cpp:8718-8750),
34
+ * with its identify_id. plate_N.json's bbox_objects are not paired by position: their `id` is an internal
35
+ * object id the printer doesn't know (BambuStudio.cpp:7374-7382), and copies share a name. The wipe tower
36
+ * is never a slice_info object.
37
+ */
30
38
  export declare function analyze3MFPlateObjects(filePath: string, plateIndex?: number): Promise<ThreeMFPlateObjects>;
@@ -453,68 +453,66 @@ export async function analyze3MFAmsRequirements(filePath, plateIndex = 0) {
453
453
  }),
454
454
  };
455
455
  }
456
+ /**
457
+ * The objects of one sliced plate that the printer can skip, as Bambu Studio lists them in its skip dialog
458
+ * (02.08.02.61 slic3r/GUI/PartSkipDialog.cpp:734-741, SkipPartCanvas.cpp:690-730): one entry per instance
459
+ * from Metadata/slice_info.config's plate whose `index` matches (written per instance at bbs_3mf.cpp:8718-8750),
460
+ * with its identify_id. plate_N.json's bbox_objects are not paired by position: their `id` is an internal
461
+ * object id the printer doesn't know (BambuStudio.cpp:7374-7382), and copies share a name. The wipe tower
462
+ * is never a slice_info object.
463
+ */
456
464
  export async function analyze3MFPlateObjects(filePath, plateIndex = 0) {
457
465
  const data = await fs.readFile(filePath);
458
466
  const zip = await JSZip.loadAsync(data);
459
- const plateName = `Metadata/plate_${plateIndex + 1}.json`;
460
- const plateFile = zip.file(plateName);
461
- if (!plateFile) {
462
- throw new Error(`3MF is missing ${plateName}; cannot list plate objects.`);
463
- }
464
- const plateJson = JSON.parse(await plateFile.async('string'));
465
- const bboxObjects = Array.isArray(plateJson?.bbox_objects) ? plateJson.bbox_objects : [];
466
- const sliceInfoObjects = [];
467
+ const plateNumber = plateIndex + 1;
467
468
  const sliceInfo = zip.file('Metadata/slice_info.config');
468
- if (sliceInfo) {
469
+ if (!sliceInfo) {
470
+ throw new Error('This 3MF has no Metadata/slice_info.config, so it was not sliced by Bambu Studio or OrcaSlicer and has no skip-object ids. Slice it first.');
471
+ }
472
+ const parsed = await parseStringPromise(await sliceInfo.async('string'), { explicitArray: true });
473
+ const plates = parsed?.config?.plate ?? [];
474
+ const selected = plates.find(plate => (plate?.metadata ?? [])
475
+ .some((item) => item?.$?.key === 'index' && Number(item?.$?.value) === plateNumber));
476
+ if (!selected) {
477
+ throw new Error(`Plate ${plateNumber} was not sliced in this 3MF, so it has no skip-object ids.`);
478
+ }
479
+ const labelObjectEnabled = (selected.metadata ?? [])
480
+ .some((item) => item?.$?.key === 'label_object_enabled' && item?.$?.value === 'true');
481
+ const instances = (selected.object ?? []).flatMap((object) => {
482
+ const id = Number(object?.$?.identify_id);
483
+ if (!Number.isSafeInteger(id) || id <= 0)
484
+ return [];
485
+ return [{ id, name: typeof object.$.name === 'string' ? object.$.name : `object_${id}`, skipped: object.$.skipped === 'true' }];
486
+ });
487
+ // First-layer area and box, attached by name only where one instance and one box carry it.
488
+ const boxes = new Map();
489
+ const plateFile = zip.file(`Metadata/plate_${plateNumber}.json`);
490
+ if (plateFile) {
469
491
  try {
470
- const parsed = await parseStringPromise(await sliceInfo.async('string'), {
471
- explicitArray: false,
472
- mergeAttrs: true,
473
- });
474
- const plateNodes = parsed?.config?.plate
475
- ? Array.isArray(parsed.config.plate) ? parsed.config.plate : [parsed.config.plate]
476
- : [];
477
- const plateNumber = plateIndex + 1;
478
- const selectedPlate = plateNodes.find((plate) => {
479
- const metadata = Array.isArray(plate?.metadata)
480
- ? plate.metadata
481
- : plate?.metadata
482
- ? [plate.metadata]
483
- : [];
484
- return metadata.some((item) => item?.key === 'index' && Number(item?.value) === plateNumber);
485
- }) || plateNodes[plateIndex] || plateNodes[0];
486
- const objectNodes = selectedPlate?.object
487
- ? Array.isArray(selectedPlate.object) ? selectedPlate.object : [selectedPlate.object]
488
- : [];
489
- for (const object of objectNodes) {
490
- const id = Number.parseInt(String(object?.identify_id ?? ''), 10);
491
- if (!Number.isInteger(id))
492
+ const plateJson = JSON.parse(await plateFile.async('string'));
493
+ for (const box of Array.isArray(plateJson?.bbox_objects) ? plateJson.bbox_objects : []) {
494
+ if (typeof box?.name !== 'string' || box.name === 'wipe_tower')
492
495
  continue;
493
- sliceInfoObjects.push({
494
- id,
495
- name: typeof object?.name === 'string' ? object.name : null,
496
- });
496
+ boxes.set(box.name, [...(boxes.get(box.name) ?? []), box]);
497
497
  }
498
498
  }
499
499
  catch {
500
- // Fall back to bbox IDs for older or malformed 3MFs.
500
+ // The ids above still stand without the boxes.
501
501
  }
502
502
  }
503
+ const nameCount = new Map();
504
+ for (const instance of instances)
505
+ nameCount.set(instance.name, (nameCount.get(instance.name) ?? 0) + 1);
503
506
  return {
504
507
  plateIndex,
505
- objects: bboxObjects
506
- .map((object, index) => {
507
- const sliceObject = sliceInfoObjects[index];
508
- const id = sliceObject?.id ?? Number(object?.id);
509
- if (!Number.isInteger(id))
510
- return null;
508
+ labelObjectEnabled,
509
+ objects: instances.map((instance) => {
510
+ const box = nameCount.get(instance.name) === 1 && boxes.get(instance.name)?.length === 1 ? boxes.get(instance.name)[0] : undefined;
511
511
  return {
512
- id,
513
- name: sliceObject?.name || (typeof object?.name === 'string' ? object.name : `object_${id}`),
514
- area: Number.isFinite(Number(object?.area)) ? Number(object.area) : null,
515
- bbox: object?.bbox ?? null,
512
+ ...instance,
513
+ area: box && Number.isFinite(Number(box.area)) ? Number(box.area) : null,
514
+ bbox: box?.bbox ?? null,
516
515
  };
517
- })
518
- .filter((object) => object !== null),
516
+ }),
519
517
  };
520
518
  }
@@ -70,8 +70,10 @@ export function bridgeAmsMapping2Entry(value, dualNozzle = false) {
70
70
  return dualNozzle ? { ams_id: 255, slot_id: 0 } : { ams_id: 255, slot_id: 255 };
71
71
  if (value === 254)
72
72
  return { ams_id: 254, slot_id: dualNozzle ? 0 : 254 };
73
+ // An AMS-HT has one slot; its absolute tray index is its own unit id (Bambu Studio 02.08.02.61
74
+ // DevFilaSystem.cpp:367-368), sent as that unit's ams_id with slot 0 (SelectMachine.cpp:1489-1497).
73
75
  if (value >= 128)
74
- return { ams_id: 128, slot_id: value - 128 };
76
+ return { ams_id: value, slot_id: 0 };
75
77
  return { ams_id: Math.floor(value / 4), slot_id: value % 4 };
76
78
  }
77
79
  /** Read every project filament (not just the plate's used ones) from project_settings.config. */
@@ -73,12 +73,12 @@ export declare const BAMBU_NATIVE_CERTIFICATES: readonly ["slicer_base64.cer", "
73
73
  */
74
74
  export declare const BAMBU_NATIVE_PLUGIN_LIBRARIES: readonly ["libbambu_networking.so", "libBambuSource.so"];
75
75
  /**
76
- * The only Linux plug-in build whose PrintParams layout matches the helper
77
- * (Bambu Studio v02.08.02.61, network agent 02.08.02.54). The setup installs
76
+ * The pinned Linux plug-in build whose PrintParams layout matches the helper
77
+ * (Bambu Studio v02.09.01.70, network agent 02.09.01.54). The setup installs
78
78
  * exactly these files and the server refuses anything else.
79
79
  */
80
80
  export declare const BAMBU_NATIVE_PINNED_PLUGIN: Readonly<{
81
- version: "02.08.02.54";
81
+ version: "02.09.01.54";
82
82
  sha256: Readonly<Record<"libbambu_networking.so" | "libBambuSource.so", string>>;
83
83
  }>;
84
84
  /** Layout shared by the Linux setup script, the server and the helper's environment. */
@@ -39,14 +39,14 @@ export const BAMBU_NATIVE_CERTIFICATES = ["slicer_base64.cer", "printer.cer"];
39
39
  */
40
40
  export const BAMBU_NATIVE_PLUGIN_LIBRARIES = ["libbambu_networking.so", "libBambuSource.so"];
41
41
  /**
42
- * The only Linux plug-in build whose PrintParams layout matches the helper
43
- * (Bambu Studio v02.08.02.61, network agent 02.08.02.54). The setup installs
42
+ * The pinned Linux plug-in build whose PrintParams layout matches the helper
43
+ * (Bambu Studio v02.09.01.70, network agent 02.09.01.54). The setup installs
44
44
  * exactly these files and the server refuses anything else.
45
45
  */
46
46
  export const BAMBU_NATIVE_PINNED_PLUGIN = Object.freeze({
47
- version: "02.08.02.54",
47
+ version: "02.09.01.54",
48
48
  sha256: Object.freeze({
49
- "libbambu_networking.so": "bba49709c8dea14ba70251b43965646c0a5e2cde8fd133c64f764d425691bdf2",
49
+ "libbambu_networking.so": "a3d3fb6e6568cbf62a81c88248f4ddfee90ecaa47685d5156ada411271aa5ad3",
50
50
  "libBambuSource.so": "4e05f16fa02740fd12f0040b9efc3e70d43446c7a1a877c6a3926ef0758ca7db",
51
51
  }),
52
52
  });
@@ -3,6 +3,15 @@ export interface ModelPlate {
3
3
  index: number;
4
4
  name: string;
5
5
  objects: string[];
6
+ /**
7
+ * Each object copy on the plate with its identify_id, from model_settings.config's <model_instance> entries
8
+ * (Bambu Studio 02.08.02.61 bbs_3mf.cpp:8448-8482). These are the ids slice_stl's skip_objects takes: the
9
+ * CLI matches them against each instance's loaded id (BambuStudio.cpp:1785-1789, 6530-6545).
10
+ */
11
+ instances: {
12
+ identify_id: number;
13
+ name: string;
14
+ }[];
6
15
  /** The file already holds this plate's G-code. */
7
16
  sliced: boolean;
8
17
  /** The plate's own preview from the file (Metadata/plate_N.png), when asked for and present. */
@@ -12,6 +12,7 @@ import { readSafe3mfArchive } from "../safety/archive.js";
12
12
  const MAX_METADATA_BYTES = 8 * 1024 * 1024;
13
13
  const MAX_THUMBNAIL_BYTES = 2 * 1024 * 1024;
14
14
  const MAX_PLATES = 1000;
15
+ const MAX_INSTANCES_PER_PLATE = 1000;
15
16
  const words = (value) => value
16
17
  .replace(/&(?:amp|lt|gt|quot|apos);/g, entity => ({ "&amp;": "&", "&lt;": "<", "&gt;": ">", "&quot;": "\"", "&apos;": "'" }[entity]))
17
18
  .replace(/[\u0000-\u001f\u007f]/g, " ").trim().slice(0, 256);
@@ -57,7 +58,13 @@ export async function listModelPlates(filePath, options = {}) {
57
58
  if (!valid(number))
58
59
  continue;
59
60
  const name = /<metadata\s+key="plater_name"\s+value="([^"]*)"/.exec(match[1]);
60
- plates.set(number, { index: number - 1, name: words(name?.[1] ?? "") || `Plate ${number}`, sliced: false,
61
+ const instances = [...match[1].matchAll(/<model_instance>([\s\S]*?)<\/model_instance>/g)].flatMap(instance => {
62
+ const object = /<metadata\s+key="object_id"\s+value="(\d+)"/.exec(instance[1])?.[1];
63
+ const identify = Number(/<metadata\s+key="identify_id"\s+value="(\d+)"/.exec(instance[1])?.[1]);
64
+ return object !== undefined && Number.isSafeInteger(identify) && identify > 0
65
+ ? [{ identify_id: identify, name: objects.get(object) ?? "" }] : [];
66
+ }).slice(0, MAX_INSTANCES_PER_PLATE);
67
+ plates.set(number, { index: number - 1, name: words(name?.[1] ?? "") || `Plate ${number}`, sliced: false, instances,
61
68
  objects: [...match[1].matchAll(/<metadata\s+key="object_id"\s+value="(\d+)"/g)].flatMap(item => objects.get(item[1]) ? [objects.get(item[1])] : []) });
62
69
  }
63
70
  for (const name of Object.keys(zip.files)) {
@@ -67,7 +74,7 @@ export async function listModelPlates(filePath, options = {}) {
67
74
  const number = Number(match[1]);
68
75
  if (!valid(number))
69
76
  continue;
70
- const plate = plates.get(number) ?? { index: number - 1, name: `Plate ${number}`, objects: [], sliced: false };
77
+ const plate = plates.get(number) ?? { index: number - 1, name: `Plate ${number}`, objects: [], instances: [], sliced: false };
71
78
  if (match[2] === "gcode")
72
79
  plate.sliced = true;
73
80
  else {
@@ -84,7 +91,7 @@ export async function listModelPlates(filePath, options = {}) {
84
91
  result.plates = [...plates.values()].sort((a, b) => a.index - b.index);
85
92
  // A standard single-build 3MF has no Bambu plate metadata: it is one plate.
86
93
  if (!result.plates.length)
87
- result.plates.push({ index: 0, name: "Plate 1", objects: [], sliced: false });
94
+ result.plates.push({ index: 0, name: "Plate 1", objects: [], instances: [], sliced: false });
88
95
  const geometry = has("item") && (has("mesh") || has("component"));
89
96
  if (!geometry) {
90
97
  // A sliced-only file (previews and G-code, no model): only its sliced plates can print.
package/dist/index.js CHANGED
@@ -225,7 +225,7 @@ function resolveNozzleVolumeType(value) {
225
225
  }
226
226
  return NOZZLE_VOLUME_TYPES[normalized];
227
227
  }
228
- const VALID_BAMBUSTUDIO_CLI_BED_TYPES = ["textured_plate", "cool_plate", "engineering_plate", "hot_plate"];
228
+ const VALID_BAMBUSTUDIO_CLI_BED_TYPES = ["textured_plate", "cool_plate", "engineering_plate", "hot_plate", "supertack_plate"];
229
229
  // Map model IDs to BambuStudio --load-machine preset names
230
230
  const BAMBU_MODEL_PRESETS = {
231
231
  p1s: (n) => `Bambu Lab P1S ${n} nozzle`,
@@ -653,7 +653,7 @@ function resolveBedType(argsBedType) {
653
653
  function resolveBambuStudioCliBedType(argsBedType) {
654
654
  const bedType = resolveBedType(argsBedType);
655
655
  if (!VALID_BAMBUSTUDIO_CLI_BED_TYPES.includes(bedType)) {
656
- throw new Error(`BambuStudio CLI bed_type "${bedType}" is not verified. Use a pre-sliced 3MF for SuperTack, or choose one of: ${VALID_BAMBUSTUDIO_CLI_BED_TYPES.join(", ")}`);
656
+ throw new Error(`BambuStudio CLI bed_type "${bedType}" is not one of: ${VALID_BAMBUSTUDIO_CLI_BED_TYPES.join(", ")}`);
657
657
  }
658
658
  return bedType;
659
659
  }
@@ -1292,9 +1292,6 @@ class BambuPrinterMCPServer {
1292
1292
  return { threeMFPath, autoSliced: false };
1293
1293
  }
1294
1294
  assertUniformCliNozzles(args);
1295
- if (bedType === "supertack_plate") {
1296
- throw new Error('BambuStudio CLI SuperTack bed type is not verified; use a pre-sliced 3MF for SuperTack or choose textured_plate, cool_plate, engineering_plate, or hot_plate.');
1297
- }
1298
1295
  console.error(`3MF has no gcode - auto-slicing with ${slicerType} for ${printModel}`);
1299
1296
  const autoSliceOptions = {
1300
1297
  ...(slicerType === "orca-slicer-api" ? {} : {
@@ -1771,9 +1768,6 @@ class BambuPrinterMCPServer {
1771
1768
  throw new Error(`Failed to inspect collar charm 3MF before slicing: ${error.message}`);
1772
1769
  }
1773
1770
  const printPreset = BAMBU_MODEL_PRESETS[printModel]?.(printNozzle);
1774
- if (bedType === "supertack_plate") {
1775
- throw new Error('BambuStudio CLI SuperTack bed type is not verified; use a pre-sliced 3MF for SuperTack or choose textured_plate, cool_plate, engineering_plate, or hot_plate.');
1776
- }
1777
1771
  const autoSliceOptions = {
1778
1772
  ...(slicerType === "orca-slicer-api" ? {} : {
1779
1773
  uptodate: true, ensureOnBed: true, minSave: true, skipModifiedGcodes: true,
@@ -2063,7 +2057,7 @@ class BambuPrinterMCPServer {
2063
2057
  },
2064
2058
  {
2065
2059
  name: "list_3mf_plates",
2066
- description: "List a Bambu Studio or OrcaSlicer 3MF's plates as its designer laid them out, before slicing: plate_count, and for each plate its index (from 0; slice_stl's slice_plate is index + 1, inspect_print_file's plate_index is index), name, the objects on it and whether the file already holds its G-code (sliced). A plain 3MF without plate metadata is one plate. include_thumbnails adds each plate's own preview from the file (thumbnail_png_base64). Read-only.",
2060
+ description: "List a Bambu Studio or OrcaSlicer 3MF's plates as its designer laid them out, before slicing: plate_count, and for each plate its index (from 0; slice_stl's slice_plate is index + 1, inspect_print_file's plate_index is index), name, the objects on it, each object copy's identify_id (instances: the ids slice_stl's skip_objects takes) and whether the file already holds its G-code (sliced). A plain 3MF without plate metadata is one plate. include_thumbnails adds each plate's own preview from the file (thumbnail_png_base64). Read-only.",
2067
2061
  inputSchema: {
2068
2062
  type: "object",
2069
2063
  properties: {
@@ -2075,7 +2069,7 @@ class BambuPrinterMCPServer {
2075
2069
  },
2076
2070
  {
2077
2071
  name: "list_3mf_plate_objects",
2078
- description: "List object IDs from a sliced 3MF plate. Use these IDs with skip_objects during a running print.",
2072
+ description: "List the objects of a sliced 3MF plate that the printer can skip, one per copy, as Bambu Studio's skip dialog lists them: identify_id (id), name, whether it is already skipped, and labelObjectEnabled (the plate was sliced with object labels, which skipping needs). Use these ids with skip_objects during a running print.",
2079
2073
  inputSchema: {
2080
2074
  type: "object",
2081
2075
  properties: {
@@ -2226,7 +2220,7 @@ class BambuPrinterMCPServer {
2226
2220
  bed_type: {
2227
2221
  type: "string",
2228
2222
  enum: ["textured_plate", "cool_plate", "engineering_plate", "hot_plate", "supertack_plate"],
2229
- description: "Bed plate type for slicing (default: textured_plate). SuperTack is accepted only for pre-sliced print jobs until the BambuStudio CLI identifier is verified."
2223
+ description: "Bed plate type for slicing (default: textured_plate)."
2230
2224
  },
2231
2225
  nozzle_type: {
2232
2226
  type: "string",
@@ -2287,7 +2281,7 @@ class BambuPrinterMCPServer {
2287
2281
  bed_type: {
2288
2282
  type: "string",
2289
2283
  enum: ["textured_plate", "cool_plate", "engineering_plate", "hot_plate", "supertack_plate"],
2290
- description: "Bed plate type for slicing (default: textured_plate). SuperTack is accepted only for pre-sliced print jobs until the BambuStudio CLI identifier is verified."
2284
+ description: "Bed plate type for slicing (default: textured_plate)."
2291
2285
  },
2292
2286
  nozzle_type: {
2293
2287
  type: "string",
@@ -2306,7 +2300,7 @@ class BambuPrinterMCPServer {
2306
2300
  arrange: { type: "boolean", description: "Auto-arrange all objects on the build plate with optimal spacing; STL input is arranged by default. Set false only to keep a 3MF's existing layout: an STL that is not already on the plate then fails to slice." },
2307
2301
  ensure_on_bed: { type: "boolean", description: "Detect models floating above the bed and lower them onto the build surface. Safety net for imported models with incorrect Z origins." },
2308
2302
  clone_objects: { type: "string", description: "Clone the loaded model: total copies as a single integer, e.g. '3'. The Bambu-style CLIs count copies per input file and this tool loads one file, so a comma-separated list is rejected by the slicer." },
2309
- skip_objects: { type: "string", description: "Skip specific objects during slicing by index. Comma-separated, e.g. '3,5,10'. Useful for multi-object 3MFs where you only want to print some parts." },
2303
+ skip_objects: { type: "string", description: "Skip these object copies when slicing, by identify_id, comma-separated (e.g. '78,92'). The ids are the instances list_3mf_plates gives for each plate; they are not positions. Useful for multi-object 3MFs where you only want to print some parts." },
2310
2304
  load_filaments: { type: "string", description: "Override filament profiles. Semicolon-separated paths to filament JSON configs, e.g. 'pla_basic.json;petg_cf.json'." },
2311
2305
  filament_profile: { type: "string", description: "Compatibility alias for load_filaments. Semicolon-separated Orca/Bambu filament profile JSON paths." },
2312
2306
  load_filament_ids: { type: "string", description: "Map filaments to objects/parts. Comma-separated IDs matching load_filaments order, e.g. '1,2,3,1' assigns filament 1 to objects 0 and 3." },
@@ -2764,7 +2758,7 @@ class BambuPrinterMCPServer {
2764
2758
  properties: {
2765
2759
  object_ids: {
2766
2760
  type: "array",
2767
- description: "Object IDs to skip. Use list_3mf_plate_objects on the sliced 3MF to find IDs.",
2761
+ description: "identify_id values of the object copies to skip. Use list_3mf_plate_objects on the sliced 3MF to find them.",
2768
2762
  items: { type: "number" }
2769
2763
  },
2770
2764
  host: { type: "string", description: "Hostname or IP of the printer (default: value from env)" },
@@ -4089,9 +4083,6 @@ class BambuPrinterMCPServer {
4089
4083
  }
4090
4084
  if (!hasGcode) {
4091
4085
  assertUniformCliNozzles(args);
4092
- if (printBedType === "supertack_plate") {
4093
- throw new Error('BambuStudio CLI SuperTack bed type is not verified; use a pre-sliced 3MF for SuperTack or choose textured_plate, cool_plate, engineering_plate, or hot_plate.');
4094
- }
4095
4086
  console.error(`3MF has no gcode — auto-slicing with ${slicerType} for ${printModel}`);
4096
4087
  const autoSliceOptions = {
4097
4088
  ...(slicerType === "orca-slicer-api" ? { slicePlate: plateIndex + 1 } : {
@@ -4100,7 +4091,8 @@ class BambuPrinterMCPServer {
4100
4091
  bedType: printBedType,
4101
4092
  nozzleType: resolveNozzleType(args?.nozzle_type),
4102
4093
  nozzleVolumeType: resolveNozzleVolumeType(args?.nozzle_volume_type),
4103
- ...(pauseLayers ? { pauseAtLayers: pauseLayers } : {}),
4094
+ // A pause belongs to the plate being printed; the CLI carries custom G-code for one plate only.
4095
+ ...(pauseLayers ? { pauseAtLayers: pauseLayers, slicePlate: plateIndex + 1 } : {}),
4104
4096
  };
4105
4097
  if (!explicitSlicerProfile) {
4106
4098
  try {
@@ -11,17 +11,26 @@ function list(value) {
11
11
  return value.split(/[;,]/).map(s => s.trim().replace(/^"|"$/g, ''));
12
12
  return [];
13
13
  }
14
+ /**
15
+ * Every name a Bambu plate goes by, to the plate_N.json bed_type token Bambu Studio writes for it
16
+ * (02.08.02.61 PrintConfig.hpp:437-456 bed_type_to_gcode_string). project_settings and the G-code header
17
+ * carry curr_bed_type's enum key instead (PrintConfig.cpp:437-445); the GUI labels (:1307-1311) and this
18
+ * server's own bed_type values name the same plates. Other names (another slicer's plates) stay as written,
19
+ * so two copies of the same name still agree.
20
+ */
21
+ const BED_NAMES = {
22
+ cool_plate: ['cool plate'],
23
+ eng_plate: ['engineering plate'],
24
+ hot_plate: ['high temp plate', 'smooth pei plate', 'smooth pei plate / high temp plate', 'high temperature plate'],
25
+ textured_plate: ['textured pei plate'],
26
+ supertack_plate: ['supertack plate', 'bambu cool plate supertack', 'cool plate supertack'],
27
+ };
28
+ const BED_TOKENS = new Map(Object.entries(BED_NAMES).flatMap(([token, names]) => [token, ...names].map(name => [name.replace(/[_-]/g, ' '), token])));
14
29
  function normalizeBed(value) {
15
30
  if (typeof value !== 'string' || !value.trim())
16
31
  return undefined;
17
32
  const text = value.trim().toLowerCase().replace(/[_-]/g, ' ').replace(/\s+/g, ' ');
18
- if (['textured pei plate', 'textured plate'].includes(text))
19
- return 'textured pei plate';
20
- if (['supertack plate', 'cool plate supertack'].includes(text))
21
- return 'cool plate supertack';
22
- if (['smooth pei plate', 'high temp plate', 'high temperature plate', 'hot plate'].includes(text))
23
- return 'smooth pei plate';
24
- return text;
33
+ return BED_TOKENS.get(text) ?? text;
25
34
  }
26
35
  function metadataValues(metadata, keys) {
27
36
  return metadata.flatMap(data => keys.filter(key => data[key] !== undefined).map(key => data[key]));
@@ -376,8 +376,9 @@ function externalTray(raw, trayIndex, model) {
376
376
  return object(raw.vt_tray) ? raw.vt_tray : undefined;
377
377
  }
378
378
  function mappedTray(raw, index) {
379
- const unit = index >= 128 ? 128 : Math.floor(index / 4);
380
- const slot = index >= 128 ? index - 128 : index % 4;
379
+ // An AMS-HT tray index is the unit's own id, with its single slot 0 (Bambu Studio DevFilaSystem.cpp:367-368).
380
+ const unit = index >= 128 ? index : Math.floor(index / 4);
381
+ const slot = index >= 128 ? 0 : index % 4;
381
382
  const units = raw.ams?.ams;
382
383
  const ams = Array.isArray(units) ? units.find((value) => Number(value?.id) === unit) : undefined;
383
384
  const tray = Array.isArray(ams?.tray) ? ams.tray.find((value) => Number(value?.id) === slot) : undefined;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Every error code the Bambu Studio CLI can exit with, from libslic3r/Utils.hpp:21-75 of Bambu Studio
3
+ * 02.08.02.61 (OrcaSlicer's CLI shares them). The names and numbers are Studio's; the sentences are ours.
4
+ * The process exits with the code's low byte (-50 exits as 206). The CLI's own result.json, when present and
5
+ * fresh, is still the better reason; this table is for when it is missing or stale.
6
+ *
7
+ * tests/slicer/cli-exit-codes.test.mjs checks the names and numbers against Utils.hpp's list.
8
+ */
9
+ export declare const BAMBU_CLI_EXIT_CODES: Record<number, {
10
+ name: string;
11
+ sentence: string;
12
+ }>;
13
+ /** The table's entry for a process exit status (the code's low byte) or a full negative code. */
14
+ export declare function bambuCliExitCode(exitCode: unknown): {
15
+ code: number;
16
+ name: string;
17
+ sentence: string;
18
+ } | undefined;
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Every error code the Bambu Studio CLI can exit with, from libslic3r/Utils.hpp:21-75 of Bambu Studio
3
+ * 02.08.02.61 (OrcaSlicer's CLI shares them). The names and numbers are Studio's; the sentences are ours.
4
+ * The process exits with the code's low byte (-50 exits as 206). The CLI's own result.json, when present and
5
+ * fresh, is still the better reason; this table is for when it is missing or stale.
6
+ *
7
+ * tests/slicer/cli-exit-codes.test.mjs checks the names and numbers against Utils.hpp's list.
8
+ */
9
+ export const BAMBU_CLI_EXIT_CODES = {
10
+ [-1]: { name: "CLI_ENVIRONMENT_ERROR", sentence: "the slicer could not set up its working environment" },
11
+ [-2]: { name: "CLI_INVALID_PARAMS", sentence: "the slicer was given options it does not accept" },
12
+ [-3]: { name: "CLI_FILE_NOTFOUND", sentence: "an input file was not found" },
13
+ [-4]: { name: "CLI_FILELIST_INVALID_ORDER", sentence: "the input files were in the wrong order (a 3MF has to come first)" },
14
+ [-5]: { name: "CLI_CONFIG_FILE_ERROR", sentence: "a settings file could not be read" },
15
+ [-6]: { name: "CLI_DATA_FILE_ERROR", sentence: "the model file could not be read" },
16
+ [-7]: { name: "CLI_INVALID_PRINTER_TECH", sentence: "the printer settings are not for a filament (FDM) printer" },
17
+ [-8]: { name: "CLI_UNSUPPORTED_OPERATION", sentence: "the slicer does not support that operation" },
18
+ [-9]: { name: "CLI_COPY_OBJECTS_ERROR", sentence: "making copies of the objects failed" },
19
+ [-10]: { name: "CLI_SCALE_TO_FIT_ERROR", sentence: "scaling the model to fit the bed failed" },
20
+ [-11]: { name: "CLI_EXPORT_STL_ERROR", sentence: "writing the STL file failed" },
21
+ [-12]: { name: "CLI_EXPORT_OBJ_ERROR", sentence: "writing the OBJ file failed" },
22
+ [-13]: { name: "CLI_EXPORT_3MF_ERROR", sentence: "writing the 3MF file failed" },
23
+ [-14]: { name: "CLI_OUT_OF_MEMORY", sentence: "the slicer ran out of memory" },
24
+ [-15]: { name: "CLI_3MF_NOT_SUPPORT_MACHINE_CHANGE", sentence: "this 3MF can't be moved to the chosen printer" },
25
+ [-16]: { name: "CLI_3MF_NEW_MACHINE_NOT_SUPPORTED", sentence: "the chosen printer can't be used with this 3MF" },
26
+ [-17]: { name: "CLI_PROCESS_NOT_COMPATIBLE", sentence: "the process settings don't fit the chosen printer" },
27
+ [-18]: { name: "CLI_INVALID_VALUES_IN_3MF", sentence: "the 3MF holds settings values the slicer rejects" },
28
+ [-19]: { name: "CLI_POSTPROCESS_NOT_SUPPORTED", sentence: "the settings use post-processing scripts, which the slicer CLI doesn't run" },
29
+ [-20]: { name: "CLI_PRINTABLE_SIZE_REDUCED", sentence: "the chosen printer's bed is smaller than the one the settings were made for" },
30
+ [-21]: { name: "CLI_OBJECT_ARRANGE_FAILED", sentence: "arranging the objects on the plate failed" },
31
+ [-22]: { name: "CLI_OBJECT_ORIENT_FAILED", sentence: "turning the objects to print well failed" },
32
+ [-23]: { name: "CLI_MODIFIED_PARAMS_TO_PRINTER", sentence: "the printer settings change its bed area, height or excluded area, which isn't allowed" },
33
+ [-24]: { name: "CLI_FILE_VERSION_NOT_SUPPORTED", sentence: "the 3MF was saved by a slicer version this one can't read (often a beta)" },
34
+ [-25]: { name: "CLI_3MF_FEATURE_NOT_SUPPORTED", sentence: "the 3MF uses an experimental feature this slicer doesn't support yet" },
35
+ [-50]: { name: "CLI_NO_SUITABLE_OBJECTS", sentence: "a plate is empty or has no object fully inside it; arrange the model or place it on the plate" },
36
+ [-51]: { name: "CLI_VALIDATE_ERROR", sentence: "the slicing settings failed the slicer's own checks" },
37
+ [-52]: { name: "CLI_OBJECTS_PARTLY_INSIDE", sentence: "objects extend over the bed boundary" },
38
+ [-53]: { name: "CLI_EXPORT_CACHE_DIRECTORY_CREATE_FAILED", sentence: "the slicer couldn't create its cache folder" },
39
+ [-54]: { name: "CLI_EXPORT_CACHE_WRITE_FAILED", sentence: "the slicer couldn't write its cache" },
40
+ [-55]: { name: "CLI_IMPORT_CACHE_NOT_FOUND", sentence: "the slicer's cache wasn't found" },
41
+ [-56]: { name: "CLI_IMPORT_CACHE_DATA_CAN_NOT_USE", sentence: "the slicer's cache couldn't be read" },
42
+ [-57]: { name: "CLI_IMPORT_CACHE_LOAD_FAILED", sentence: "loading the slicer's cache failed" },
43
+ [-58]: { name: "CLI_SLICING_TIME_EXCEEDS_LIMIT", sentence: "slicing a plate took longer than the time limit; simplify the model or use a taller layer height" },
44
+ [-59]: { name: "CLI_TRIANGLE_COUNT_EXCEEDS_LIMIT", sentence: "a plate has more triangles than the limit; simplify the model" },
45
+ [-60]: { name: "CLI_NO_SUITABLE_OBJECTS_AFTER_SKIP", sentence: "no printable objects remain after skipping" },
46
+ [-61]: { name: "CLI_FILAMENT_NOT_MATCH_BED_TYPE", sentence: "a filament can't be printed on the chosen plate type" },
47
+ [-62]: { name: "CLI_FILAMENTS_DIFFERENT_TEMP", sentence: "the filaments' temperatures differ too much" },
48
+ [-63]: { name: "CLI_OBJECT_COLLISION_IN_SEQ_PRINT", sentence: "objects collide in print-by-object mode" },
49
+ [-64]: { name: "CLI_OBJECT_COLLISION_IN_LAYER_PRINT", sentence: "objects collide" },
50
+ [-65]: { name: "CLI_SPIRAL_MODE_INVALID_PARAMS", sentence: "some settings can't be used in spiral vase mode" },
51
+ [-66]: { name: "CLI_FILAMENT_CAN_NOT_MAP", sentence: "some filaments can't be assigned to the printer's nozzles" },
52
+ [-67]: { name: "CLI_ONLY_ONE_TPU_SUPPORTED", sentence: "only one TPU filament can be used in a print" },
53
+ [-68]: { name: "CLI_FILAMENTS_NOT_SUPPORTED_BY_EXTRUDER", sentence: "a filament can't be printed by the nozzle it is assigned to" },
54
+ [-100]: { name: "CLI_SLICING_ERROR", sentence: "slicing the model failed" },
55
+ [-101]: { name: "CLI_GCODE_PATH_CONFLICTS", sentence: "the print paths of two objects overlap; move them apart, or move the wipe tower away from the models" },
56
+ [-102]: { name: "CLI_GCODE_PATH_IN_UNPRINTABLE_AREA", sentence: "the print reaches an area one of the printer's nozzles can't print" },
57
+ [-103]: { name: "CLI_FILAMENT_UNPRINTABLE_ON_FIRST_LAYER", sentence: "a filament can't be printed on the first layer of this plate type" },
58
+ [-104]: { name: "CLI_GCODE_PATH_OUTSIDE", sentence: "the print goes outside the printable area, usually through a support, brim, skirt or the wipe tower" },
59
+ [-105]: { name: "CLI_GCODE_IN_WRAPPING_DETECT_AREA", sentence: "the print goes into the bed area the printer keeps clear for its clumping (wrapping) check" },
60
+ };
61
+ /** The table's entry for a process exit status (the code's low byte) or a full negative code. */
62
+ export function bambuCliExitCode(exitCode) {
63
+ if (typeof exitCode !== "number" || !Number.isInteger(exitCode) || exitCode === 0)
64
+ return undefined;
65
+ const code = Object.keys(BAMBU_CLI_EXIT_CODES).map(Number)
66
+ .find(value => value === exitCode || (value & 0xff) === exitCode);
67
+ return code === undefined ? undefined : { code, ...BAMBU_CLI_EXIT_CODES[code] };
68
+ }
@@ -4,11 +4,13 @@
4
4
  * (M400 U1 on Bambu printers) before the chosen layer, so the printer pauses
5
5
  * by itself there and waits for Resume; no remote command is involved.
6
6
  *
7
- * The CLI takes these as --load-custom-gcodes <json> (CustomGCode::Info). It
8
- * does not apply the pauses a project 3MF already carries in
9
- * Metadata/custom_gcode_per_print_z.xml, so those are read here and passed the
10
- * same way. A pause's print_z must be the exact top of its layer: a height
11
- * between layers lands on the layer below.
7
+ * The CLI takes these as --load-custom-gcodes <json> (CustomGCode::Info). A
8
+ * project 3MF keeps its own pauses and colour changes in
9
+ * Metadata/custom_gcode_per_layer.xml (Bambu Studio 02.08.02.61 bbs_3mf.cpp:184,
10
+ * written at :8943-8990), which the CLI loads with the project. The JSON
11
+ * replaces that whole map (BambuStudio.cpp:4005-4008), so the plate's own
12
+ * entries are read here and merged in. A pause's print_z must be the exact top
13
+ * of its layer: a height between layers lands on the layer below.
12
14
  */
13
15
  /** CustomGCode::Type, in the order bbs_3mf.cpp writes it as an integer. */
14
16
  declare const CUSTOM_GCODE_TYPES: readonly ["ColorChange", "PausePrint", "ToolChange", "Template", "Custom", "Unknown"];
@@ -6,11 +6,13 @@ import JSZip from "jszip";
6
6
  * (M400 U1 on Bambu printers) before the chosen layer, so the printer pauses
7
7
  * by itself there and waits for Resume; no remote command is involved.
8
8
  *
9
- * The CLI takes these as --load-custom-gcodes <json> (CustomGCode::Info). It
10
- * does not apply the pauses a project 3MF already carries in
11
- * Metadata/custom_gcode_per_print_z.xml, so those are read here and passed the
12
- * same way. A pause's print_z must be the exact top of its layer: a height
13
- * between layers lands on the layer below.
9
+ * The CLI takes these as --load-custom-gcodes <json> (CustomGCode::Info). A
10
+ * project 3MF keeps its own pauses and colour changes in
11
+ * Metadata/custom_gcode_per_layer.xml (Bambu Studio 02.08.02.61 bbs_3mf.cpp:184,
12
+ * written at :8943-8990), which the CLI loads with the project. The JSON
13
+ * replaces that whole map (BambuStudio.cpp:4005-4008), so the plate's own
14
+ * entries are read here and merged in. A pause's print_z must be the exact top
15
+ * of its layer: a height between layers lands on the layer below.
14
16
  */
15
17
  /** CustomGCode::Type, in the order bbs_3mf.cpp writes it as an integer. */
16
18
  const CUSTOM_GCODE_TYPES = ["ColorChange", "PausePrint", "ToolChange", "Template", "Custom", "Unknown"];
@@ -44,7 +46,7 @@ export async function readProjectCustomGcodes(threeMfPath, plate = 1) {
44
46
  catch {
45
47
  return undefined;
46
48
  }
47
- const file = zip.file(/^Metadata\/custom_gcode_per_print_z\.xml$/i)[0];
49
+ const file = zip.file(/^Metadata\/custom_gcode_per_layer\.xml$/i)[0];
48
50
  if (!file)
49
51
  return undefined;
50
52
  const xml = await file.async("string");