bambu-printer-mcp 1.1.43 → 1.1.45

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/CONTRIBUTORS.md CHANGED
@@ -6,6 +6,7 @@ Thank you to everyone who builds, tests, reports problems, and shares real print
6
6
 
7
7
  | Contributor | Contribution |
8
8
  | --- | --- |
9
+ | [billh-hub](https://github.com/billh-hub) | Reports and isolates three official H2C time-lapse and filament-change command rejections in [#84](https://github.com/DMontgomery40/bambu-printer-mcp/issues/84), supplies emitted commands and multi-colour reproduction evidence, and distinguishes the unknown cooling parameter for source-backed investigation. The correction preserves independent safety checks; no maintainer physical printing is claimed. |
9
10
  | [Steve Pritchard (sjpritchard)](https://github.com/sjpritchard) | Reports and diagnoses H2C per-variant first-layer temperature rejection in [#81](https://github.com/DMontgomery40/bambu-printer-mcp/issues/81), supplies the exact official preset metadata and reproduction, and identifies the upstream variant-mapping contract. Verification uses synthetic slicing and offline regressions, not physical printing. |
10
11
  | [JackCA](https://github.com/JackCA) | Reports an X2D retaining `FAILED` with no active print/HMS error after cancellation, supplies read-only printer evidence for `fail_reason: 0300400C`, and contributes narrow canceled-task recovery, job-bound physical confirmation, a recheck of the job and error codes after connecting and before clearing hardware errors on any model, and regression coverage in [#76](https://github.com/DMontgomery40/bambu-printer-mcp/pull/76). Physical print delivery after the fix remains unverified. |
11
12
  | [ZombieLurker](https://github.com/ZombieLurker) | Reports and diagnoses the unused-nozzle preheat rejection for OrcaSlicer 2.4.2 single-filament H2D jobs in [#73](https://github.com/DMontgomery40/bambu-printer-mcp/issues/73), supplies the exact startup commands and environment, and verifies a local inspection fix. H2D Pro coverage is independently supported by its official profile; no physical printing is claimed by this release. |
package/dist/index.js CHANGED
@@ -32,7 +32,10 @@ const DEFAULT_BAMBU_DEV_ID = process.env.BAMBU_DEV_ID || DEFAULT_BAMBU_SERIAL;
32
32
  // cwd-relative default here can throw at module load via the mkdirSync
33
33
  // below and kill the server before it ever opens the stdio transport.
34
34
  const AUTOMATIC_TEMP_DIR = process.env.TEMP_DIR ? undefined : fs.mkdtempSync(path.join(os.tmpdir(), "bambu-printer-mcp-"));
35
- const TEMP_DIR = process.env.TEMP_DIR || AUTOMATIC_TEMP_DIR;
35
+ // Resolve an explicit TEMP_DIR (e.g. ./temp) against the server's working
36
+ // directory, as dotenv's own .env lookup is. Slicer CLIs receive paths under
37
+ // it, and BambuStudio fails every 3MF export to a relative --outputdir.
38
+ const TEMP_DIR = process.env.TEMP_DIR ? path.resolve(process.env.TEMP_DIR) : AUTOMATIC_TEMP_DIR;
36
39
  if (AUTOMATIC_TEMP_DIR) {
37
40
  // The exit event also covers startup failures and normal event-loop exit.
38
41
  // Only the directory created above belongs to us; explicit TEMP_DIR is retained.
@@ -482,12 +482,12 @@ export async function inspectPrintFile(filePath, options) {
482
482
  const argumentsText = line.slice(command[0].length).trim();
483
483
  commandCount++;
484
484
  if (code === 'M9711') {
485
- // Official X2D and H2D time-lapse capture (Bambu Studio and OrcaSlicer
485
+ // Official X2D, H2D and H2C time-lapse capture (Bambu Studio and OrcaSlicer
486
486
  // templates), emitted on every layer: M is the time-lapse mode and E the
487
487
  // physical extruder, not a second command; T is a duration, not a heater.
488
488
  // It sets no temperature. Positions stay inside the machine volume.
489
489
  const invalid = () => fail('unsupported M9711 time-lapse parameters');
490
- if (!['x2d', 'h2d'].includes(model))
490
+ if (!['x2d', 'h2d', 'h2c'].includes(model))
491
491
  invalid();
492
492
  let args;
493
493
  try {
@@ -500,7 +500,7 @@ export async function inspectPrintFile(filePath, options) {
500
500
  const position = ['X', 'Y', 'U', 'V'].filter(key => args.has(key)).join('');
501
501
  const limit = { X: width, U: width, Y: depth, V: depth };
502
502
  if ([...args.keys()].some(key => !'MEXYUVZSCOT'.includes(key)) ||
503
- // X2D and H2D have two physical extruders, whatever the file declares.
503
+ // These models have two physical extruders, whatever the file declares.
504
504
  ![0, 1].includes(args.get('M')) || !Number.isInteger(args.get('E')) || !inRange(args, 'E', 0, Math.min(nozzleDiameters.length, 2) - 1) ||
505
505
  args.get('S') !== 11 || args.get('C') !== 10 || args.get('O') !== 0 || !inRange(args, 'T', 0, 600000) ||
506
506
  !inRange(args, 'Z', 0, height) ||
@@ -643,9 +643,10 @@ export async function inspectPrintFile(filePath, options) {
643
643
  }
644
644
  else if (code === 'M620.14') {
645
645
  const args = parameters(argumentsText);
646
- // H2C tower coordinates include the rear wipe area outside object bounds.
647
- if (!h2cStartup(index) || args.size !== 2 || !['X', 'Y'].every(key => args.has(key) && Number.isFinite(args.get(key)) && args.get(key) >= 0 && args.get(key) <= 350))
648
- fail('unsupported H2C startup tower parameters');
646
+ // H2C uses these coordinates during startup and a selected filament change.
647
+ // The rear wipe area extends outside object bounds (official fallback Y336).
648
+ if (!(h2cStartup(index) || (model === 'h2c' && pending !== undefined)) || args.size !== 2 || !['X', 'Y'].every(key => args.has(key) && Number.isFinite(args.get(key)) && args.get(key) >= 0 && args.get(key) <= 350))
649
+ fail('unsupported H2C tower parameters');
649
650
  }
650
651
  else if (model === 'h2c' && ['G383', 'G383.3', 'G383.7'].includes(code) && /U/i.test(argumentsText)) {
651
652
  const args = parameters(argumentsText);
@@ -687,9 +688,12 @@ export async function inspectPrintFile(filePath, options) {
687
688
  // H2D change_filament_gcode supplies the incoming filament's cooling
688
689
  // temperature as C{new_filament_temp - filament_cooling_before_tower}.
689
690
  const args = parameters(argumentsText);
690
- if (args.size !== 1 || !args.has('C'))
691
+ // H2C also supplies P{filament_pre_cooling_temperature_nc[next_filament_id]}
692
+ // before switching hotends. P and C both constrain the incoming material.
693
+ const target = model === 'h2c' && args.has('P') ? 'P' : 'C';
694
+ if (args.size !== 1 || !args.has(target))
691
695
  fail('unsupported M620.15 cooling temperature parameters');
692
- heat('nozzle', args.get('C'), pending ?? active);
696
+ heat('nozzle', args.get(target), pending ?? active);
693
697
  }
694
698
  else if (code === 'M620.17') {
695
699
  const args = parameters(argumentsText);
@@ -644,7 +644,7 @@ async function writeTemp(tempDir, kind, leafName, data) {
644
644
  */
645
645
  export function detectProfilesRoot(slicerPath, slicerType = 'bambustudio') {
646
646
  if (process.env["BAMBU_PROFILES_ROOT"]) {
647
- return process.env["BAMBU_PROFILES_ROOT"];
647
+ return path.resolve(process.env["BAMBU_PROFILES_ROOT"]);
648
648
  }
649
649
  if (slicerPath) {
650
650
  let executable = slicerPath;
@@ -84,7 +84,7 @@ function isPathLikeExecutable(slicerPath) {
84
84
  function configuredBambuProfileDirs() {
85
85
  const override = process.env.BAMBU_SLICER_PROFILE_DIRS;
86
86
  if (override !== undefined) {
87
- return override.split(path.delimiter).filter(Boolean);
87
+ return override.split(path.delimiter).filter(Boolean).map((dir) => path.resolve(dir));
88
88
  }
89
89
  const home = os.homedir();
90
90
  const macAppSupport = path.join(home, 'Library', 'Application Support');
@@ -164,7 +164,8 @@ export class STLManipulator extends EventEmitter {
164
164
  constructor(tempDir = path.join(process.cwd(), 'temp')) {
165
165
  super();
166
166
  this.activeOperations = new Map();
167
- this.tempDir = tempDir;
167
+ // Every slicer output and generated profile lives here; keep it absolute.
168
+ this.tempDir = path.resolve(tempDir);
168
169
  // Ensure temp directory exists
169
170
  if (!fs.existsSync(this.tempDir)) {
170
171
  fs.mkdirSync(this.tempDir, { recursive: true });
@@ -179,7 +180,7 @@ export class STLManipulator extends EventEmitter {
179
180
  getAvailableProfileRoots() {
180
181
  const selectedRoot = process.env.BAMBU_PROFILES_ROOT;
181
182
  return [
182
- ...(selectedRoot ? [path.join(selectedRoot, 'BBL')] : []),
183
+ ...(selectedRoot ? [path.resolve(selectedRoot, 'BBL')] : []),
183
184
  ...configuredBambuProfileDirs(),
184
185
  ...BAMBU_PROFILE_ROOTS,
185
186
  ].filter((root) => fs.existsSync(root));
@@ -1442,6 +1443,9 @@ export class STLManipulator extends EventEmitter {
1442
1443
  cliResult = { resultPath: path.join(outputDir, 'result.json'), startedAt: Date.now() };
1443
1444
  // A result.json left by an earlier run must not explain this one.
1444
1445
  await fs.promises.rm(cliResult.resultPath, { force: true });
1446
+ // BambuStudio fails exports to a relative --outputdir; give the CLI an
1447
+ // absolute path for every file it reads, whichever setting supplied it.
1448
+ const absoluteCliPathList = (paths) => paths.map((entry) => entry && path.resolve(entry)).join(';');
1445
1449
  args = [
1446
1450
  ...orcaExtraArgs,
1447
1451
  '--slice', String(bambuOptions?.slicePlate ?? 0),
@@ -1449,7 +1453,7 @@ export class STLManipulator extends EventEmitter {
1449
1453
  '--export-3mf', path.basename(bambuOutputPath),
1450
1454
  ];
1451
1455
  if (cliBundle.settingsArg) {
1452
- args.push('--load-settings', cliBundle.settingsArg);
1456
+ args.push('--load-settings', absoluteCliPathList(cliBundle.settingsArg.split(';')));
1453
1457
  }
1454
1458
  // Always allow newer-version 3MF files (the CLI rejects them by default)
1455
1459
  args.push('--allow-newer-file');
@@ -1492,12 +1496,12 @@ export class STLManipulator extends EventEmitter {
1492
1496
  if (bambuOptions?.skipObjects)
1493
1497
  args.push('--skip-objects', bambuOptions.skipObjects);
1494
1498
  if (cliBundle.filamentPaths.length > 0) {
1495
- args.push('--load-filaments', cliBundle.filamentPaths.join(';'));
1499
+ args.push('--load-filaments', absoluteCliPathList(cliBundle.filamentPaths));
1496
1500
  args.push('--load-defaultfila');
1497
1501
  }
1498
1502
  if (bambuOptions?.loadFilamentIds)
1499
1503
  args.push('--load-filament-ids', bambuOptions.loadFilamentIds);
1500
- args.push(inputPath);
1504
+ args.push(path.resolve(inputPath));
1501
1505
  // Override outputFilePath for bambustudio since it produces 3MF, not gcode
1502
1506
  outputFilePath = bambuOutputPath;
1503
1507
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bambu-printer-mcp",
3
- "version": "1.1.43",
3
+ "version": "1.1.45",
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
@@ -62,7 +62,10 @@ const DEFAULT_BAMBU_DEV_ID = process.env.BAMBU_DEV_ID || DEFAULT_BAMBU_SERIAL;
62
62
  // cwd-relative default here can throw at module load via the mkdirSync
63
63
  // below and kill the server before it ever opens the stdio transport.
64
64
  const AUTOMATIC_TEMP_DIR = process.env.TEMP_DIR ? undefined : fs.mkdtempSync(path.join(os.tmpdir(), "bambu-printer-mcp-"));
65
- const TEMP_DIR = process.env.TEMP_DIR || AUTOMATIC_TEMP_DIR!;
65
+ // Resolve an explicit TEMP_DIR (e.g. ./temp) against the server's working
66
+ // directory, as dotenv's own .env lookup is. Slicer CLIs receive paths under
67
+ // it, and BambuStudio fails every 3MF export to a relative --outputdir.
68
+ const TEMP_DIR = process.env.TEMP_DIR ? path.resolve(process.env.TEMP_DIR) : AUTOMATIC_TEMP_DIR!;
66
69
  if (AUTOMATIC_TEMP_DIR) {
67
70
  // The exit event also covers startup failures and normal event-loop exit.
68
71
  // Only the directory created above belongs to us; explicit TEMP_DIR is retained.
@@ -374,19 +374,19 @@ export async function inspectPrintFile(filePath: string, options: {model:string;
374
374
  const [base,subcode]=command![2].split('.');
375
375
  const code=command![1].toUpperCase()+String(Number(base))+(subcode===undefined?'':'.'+subcode);const argumentsText=line.slice(command![0].length).trim();commandCount++;
376
376
  if(code==='M9711') {
377
- // Official X2D and H2D time-lapse capture (Bambu Studio and OrcaSlicer
377
+ // Official X2D, H2D and H2C time-lapse capture (Bambu Studio and OrcaSlicer
378
378
  // templates), emitted on every layer: M is the time-lapse mode and E the
379
379
  // physical extruder, not a second command; T is a duration, not a heater.
380
380
  // It sets no temperature. Positions stay inside the machine volume.
381
381
  const invalid=()=>fail('unsupported M9711 time-lapse parameters');
382
- if(!['x2d','h2d'].includes(model)) invalid();
382
+ if(!['x2d','h2d','h2c'].includes(model)) invalid();
383
383
  let args:Map<string,number>;
384
384
  try {args=parameters(argumentsText);} catch {return invalid();}
385
385
  const [width,depth,height]=MACHINE_LIMITS[model].volume;
386
386
  const position=['X','Y','U','V'].filter(key=>args.has(key)).join('');
387
387
  const limit:Record<string,number>={X:width,U:width,Y:depth,V:depth};
388
388
  if([...args.keys()].some(key=>!'MEXYUVZSCOT'.includes(key)) ||
389
- // X2D and H2D have two physical extruders, whatever the file declares.
389
+ // These models have two physical extruders, whatever the file declares.
390
390
  ![0,1].includes(args.get('M')!) || !Number.isInteger(args.get('E')) || !inRange(args,'E',0,Math.min(nozzleDiameters.length,2)-1) ||
391
391
  args.get('S')!==11 || args.get('C')!==10 || args.get('O')!==0 || !inRange(args,'T',0,600000) ||
392
392
  !inRange(args,'Z',0,height) ||
@@ -476,8 +476,9 @@ export async function inspectPrintFile(filePath: string, options: {model:string;
476
476
  fail(`unsupported thermal-affecting wipe command ${code}`);
477
477
  } else if(code==='M620.14') {
478
478
  const args=parameters(argumentsText);
479
- // H2C tower coordinates include the rear wipe area outside object bounds.
480
- if(!h2cStartup(index) || args.size!==2 || !['X','Y'].every(key=>args.has(key) && Number.isFinite(args.get(key)) && args.get(key)!>=0 && args.get(key)!<=350)) fail('unsupported H2C startup tower parameters');
479
+ // H2C uses these coordinates during startup and a selected filament change.
480
+ // The rear wipe area extends outside object bounds (official fallback Y336).
481
+ if(!(h2cStartup(index) || (model==='h2c' && pending!==undefined)) || args.size!==2 || !['X','Y'].every(key=>args.has(key) && Number.isFinite(args.get(key)) && args.get(key)!>=0 && args.get(key)!<=350)) fail('unsupported H2C tower parameters');
481
482
  } else if(model==='h2c' && ['G383','G383.3','G383.7'].includes(code) && /U/i.test(argumentsText)) {
482
483
  const args=parameters(argumentsText);
483
484
  const expected=code==='G383.7'?'UJ':code==='G383.3'?'UL':'OUL';
@@ -508,8 +509,11 @@ export async function inspectPrintFile(filePath: string, options: {model:string;
508
509
  // H2D change_filament_gcode supplies the incoming filament's cooling
509
510
  // temperature as C{new_filament_temp - filament_cooling_before_tower}.
510
511
  const args=parameters(argumentsText);
511
- if(args.size!==1 || !args.has('C')) fail('unsupported M620.15 cooling temperature parameters');
512
- heat('nozzle',args.get('C')!,pending ?? active);
512
+ // H2C also supplies P{filament_pre_cooling_temperature_nc[next_filament_id]}
513
+ // before switching hotends. P and C both constrain the incoming material.
514
+ const target=model==='h2c' && args.has('P')?'P':'C';
515
+ if(args.size!==1 || !args.has(target)) fail('unsupported M620.15 cooling temperature parameters');
516
+ heat('nozzle',args.get(target)!,pending ?? active);
513
517
  } else if(code==='M620.17') {
514
518
  const args=parameters(argumentsText);
515
519
  if(!args.has('S') || !args.has('L') || !args.has('T') || !Number.isInteger(args.get('T')) || args.get('T')!<0 || args.get('T')!>=nozzleDiameters.length) fail('unsupported M620.17 nozzle/material temperature mapping');
@@ -809,7 +809,7 @@ async function writeTemp(
809
809
  */
810
810
  export function detectProfilesRoot(slicerPath?: string, slicerType = 'bambustudio'): string {
811
811
  if (process.env["BAMBU_PROFILES_ROOT"]) {
812
- return process.env["BAMBU_PROFILES_ROOT"];
812
+ return path.resolve(process.env["BAMBU_PROFILES_ROOT"]);
813
813
  }
814
814
 
815
815
  if (slicerPath) {
@@ -129,7 +129,7 @@ function isPathLikeExecutable(slicerPath: string): boolean {
129
129
  function configuredBambuProfileDirs(): string[] {
130
130
  const override = process.env.BAMBU_SLICER_PROFILE_DIRS;
131
131
  if (override !== undefined) {
132
- return override.split(path.delimiter).filter(Boolean);
132
+ return override.split(path.delimiter).filter(Boolean).map((dir) => path.resolve(dir));
133
133
  }
134
134
 
135
135
  const home = os.homedir();
@@ -270,7 +270,8 @@ export class STLManipulator extends EventEmitter {
270
270
 
271
271
  constructor(tempDir: string = path.join(process.cwd(), 'temp')) {
272
272
  super();
273
- this.tempDir = tempDir;
273
+ // Every slicer output and generated profile lives here; keep it absolute.
274
+ this.tempDir = path.resolve(tempDir);
274
275
  // Ensure temp directory exists
275
276
  if (!fs.existsSync(this.tempDir)) {
276
277
  fs.mkdirSync(this.tempDir, { recursive: true });
@@ -287,7 +288,7 @@ export class STLManipulator extends EventEmitter {
287
288
  private getAvailableProfileRoots(): string[] {
288
289
  const selectedRoot = process.env.BAMBU_PROFILES_ROOT;
289
290
  return [
290
- ...(selectedRoot ? [path.join(selectedRoot, 'BBL')] : []),
291
+ ...(selectedRoot ? [path.resolve(selectedRoot, 'BBL')] : []),
291
292
  ...configuredBambuProfileDirs(),
292
293
  ...BAMBU_PROFILE_ROOTS,
293
294
  ].filter((root) => fs.existsSync(root));
@@ -1834,6 +1835,9 @@ export class STLManipulator extends EventEmitter {
1834
1835
  cliResult = { resultPath: path.join(outputDir, 'result.json'), startedAt: Date.now() };
1835
1836
  // A result.json left by an earlier run must not explain this one.
1836
1837
  await fs.promises.rm(cliResult.resultPath, { force: true });
1838
+ // BambuStudio fails exports to a relative --outputdir; give the CLI an
1839
+ // absolute path for every file it reads, whichever setting supplied it.
1840
+ const absoluteCliPathList = (paths: string[]) => paths.map((entry) => entry && path.resolve(entry)).join(';');
1837
1841
  args = [
1838
1842
  ...orcaExtraArgs,
1839
1843
  '--slice', String(bambuOptions?.slicePlate ?? 0),
@@ -1841,7 +1845,7 @@ export class STLManipulator extends EventEmitter {
1841
1845
  '--export-3mf', path.basename(bambuOutputPath),
1842
1846
  ];
1843
1847
  if (cliBundle.settingsArg) {
1844
- args.push('--load-settings', cliBundle.settingsArg);
1848
+ args.push('--load-settings', absoluteCliPathList(cliBundle.settingsArg.split(';')));
1845
1849
  }
1846
1850
  // Always allow newer-version 3MF files (the CLI rejects them by default)
1847
1851
  args.push('--allow-newer-file');
@@ -1869,12 +1873,12 @@ export class STLManipulator extends EventEmitter {
1869
1873
  if (bambuOptions?.cloneObjects) args.push('--clone-objects', bambuOptions.cloneObjects);
1870
1874
  if (bambuOptions?.skipObjects) args.push('--skip-objects', bambuOptions.skipObjects);
1871
1875
  if (cliBundle.filamentPaths.length > 0) {
1872
- args.push('--load-filaments', cliBundle.filamentPaths.join(';'));
1876
+ args.push('--load-filaments', absoluteCliPathList(cliBundle.filamentPaths));
1873
1877
  args.push('--load-defaultfila');
1874
1878
  }
1875
1879
  if (bambuOptions?.loadFilamentIds) args.push('--load-filament-ids', bambuOptions.loadFilamentIds);
1876
1880
 
1877
- args.push(inputPath);
1881
+ args.push(path.resolve(inputPath));
1878
1882
  // Override outputFilePath for bambustudio since it produces 3MF, not gcode
1879
1883
  outputFilePath = bambuOutputPath;
1880
1884
  }