bambu-printer-mcp 1.1.47 → 1.1.48

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 (45) hide show
  1. package/README.md +116 -2
  2. package/dist/blender-mcp-bridge.d.ts +15 -0
  3. package/dist/blender-mcp-bridge.js +21 -3
  4. package/dist/counterpart/info.d.ts +10 -0
  5. package/dist/counterpart/info.js +34 -0
  6. package/dist/counterpart/make-3mf.d.ts +16 -0
  7. package/dist/counterpart/make-3mf.js +219 -0
  8. package/dist/counterpart/progress.d.ts +28 -0
  9. package/dist/counterpart/progress.js +254 -0
  10. package/dist/counterpart/schemas.d.ts +322 -0
  11. package/dist/counterpart/schemas.js +124 -0
  12. package/dist/fusion-mcp-bridge.d.ts +182 -0
  13. package/dist/fusion-mcp-bridge.js +557 -0
  14. package/dist/index.js +192 -12
  15. package/dist/printers/bambu-stages.d.ts +7 -0
  16. package/dist/printers/bambu-stages.js +89 -0
  17. package/dist/printers/bambu.d.ts +76 -4
  18. package/dist/printers/bambu.js +297 -37
  19. package/dist/printers/camera-models.d.ts +7 -0
  20. package/dist/printers/camera-models.js +18 -0
  21. package/dist/safety/hms-messages.d.ts +42 -0
  22. package/dist/safety/hms-messages.js +6194 -0
  23. package/dist/safety/printer-state.d.ts +18 -0
  24. package/dist/safety/printer-state.js +3 -3
  25. package/dist/slicer/process-overrides.d.ts +12 -0
  26. package/dist/slicer/process-overrides.js +33 -0
  27. package/dist/slicer/remote-slicer.js +2 -0
  28. package/dist/stl/stl-manipulator.d.ts +2 -0
  29. package/dist/stl/stl-manipulator.js +19 -0
  30. package/package.json +1 -1
  31. package/src/blender-mcp-bridge.ts +22 -3
  32. package/src/counterpart/info.ts +36 -0
  33. package/src/counterpart/make-3mf.ts +220 -0
  34. package/src/counterpart/progress.ts +254 -0
  35. package/src/counterpart/schemas.ts +154 -0
  36. package/src/fusion-mcp-bridge.ts +545 -0
  37. package/src/index.ts +199 -12
  38. package/src/printers/bambu-stages.ts +90 -0
  39. package/src/printers/bambu.ts +315 -37
  40. package/src/printers/camera-models.ts +18 -0
  41. package/src/safety/hms-messages.ts +6198 -0
  42. package/src/safety/printer-state.ts +4 -4
  43. package/src/slicer/process-overrides.ts +42 -0
  44. package/src/slicer/remote-slicer.ts +2 -0
  45. package/src/stl/stl-manipulator.ts +22 -0
package/src/index.ts CHANGED
@@ -40,15 +40,21 @@ import {
40
40
  } from "./bambu-native.js";
41
41
  import { importFileViaBambuConnect } from "./bambu-connect.js";
42
42
  import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
43
+ import { FUSION_CALL_OUTPUT_SCHEMA, FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFAULT_ARGS, FUSION_NEW_DESIGN_OUTPUT_SCHEMA, FUSION_STATUS_OUTPUT_SCHEMA, FusionMcpBridge } from "./fusion-mcp-bridge.js";
43
44
  import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, hasAmsMappingInput, normalizeAmsMappingObject, normalizeBridgeAmsTrayValue } from "./ams-mapping.js";
44
45
  import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, parse3MF } from './3mf_parser.js';
45
46
  import type { ThreeMFAmsRequirements } from "./types.js";
46
- import { BambuImplementation, assertDirectPrintSupported } from "./printers/bambu.js";
47
+ import { BambuImplementation, assertDirectPrintSupported, checkedFile } from "./printers/bambu.js";
47
48
  import { inspectPrintFile } from "./safety/print-file.js";
48
- import { externalStorageState, validatePrinterState } from "./safety/printer-state.js";
49
+ import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
49
50
  import { isDualNozzleModel } from "./safety/limits.js";
50
51
  import { withPrinterOperation, withPrintSnapshot, uniquePrintName } from "./safety/artifact.js";
51
52
  import { detectProfilesRoot } from "./slicer/profile-flatten.js";
53
+ import { bambuPrinterInfo } from "./counterpart/info.js";
54
+ import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
55
+ import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
56
+ import { MAKE_3MF_OUTPUT_SCHEMA, PRINT_PROGRESS_OUTPUT_SCHEMA, PRINTER_INFO_OUTPUT_SCHEMA } from "./counterpart/schemas.js";
57
+ import { parseProcessOverrides } from "./slicer/process-overrides.js";
52
58
 
53
59
  dotenv.config();
54
60
 
@@ -87,6 +93,16 @@ const DEFAULT_BAMBU_CONNECTION_MODE =
87
93
  process.env.BAMBU_DEFAULT_CONNECTION_MODE?.trim().toLowerCase() || "";
88
94
  const DEFAULT_BED_TYPE = process.env.BED_TYPE?.trim().toLowerCase() || "textured_plate";
89
95
  const DEFAULT_NOZZLE_DIAMETER = process.env.NOZZLE_DIAMETER?.trim() || "0.4";
96
+ /** MCP initialize name/version; counterpart_printer_info reports the same values. */
97
+ const SERVER_INFO = {
98
+ name: "bambu-printer-mcp",
99
+ version: String(JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version),
100
+ };
101
+ /** Tools that declare an outputSchema: they always return structuredContent, and errors carry none. */
102
+ const OUTPUT_SCHEMA_TOOLS = new Set([
103
+ "counterpart_printer_info", "counterpart_print_progress", "counterpart_make_3mf",
104
+ "fusion_mcp_status", "fusion_mcp_call", "fusion_mcp_new_design", "fusion_mcp_export",
105
+ ]);
90
106
 
91
107
  /** Bound for each Linux X2D emergency MQTT send (BAMBU_EMERGENCY_MQTT_TIMEOUT_MS, 1–60000 ms). */
92
108
  function withEmergencyMqttTimeout<T>(send: (signal: AbortSignal) => Promise<T>): Promise<T> {
@@ -1202,6 +1218,7 @@ class BambuPrinterMCPServer {
1202
1218
  private bambu: BambuImplementation;
1203
1219
  private bambuNetwork: BambuNetworkBridge;
1204
1220
  private readonly blender = new BlenderMcpBridge();
1221
+ private readonly fusion = new FusionMcpBridge();
1205
1222
  private stlManipulator: STLManipulator;
1206
1223
  private readonly runtimeConfig: RuntimeConfig;
1207
1224
  private httpRuntime?: { transport: StreamableHTTPServerTransport; httpServer: HttpServer };
@@ -1211,10 +1228,7 @@ class BambuPrinterMCPServer {
1211
1228
  constructor() {
1212
1229
  this.runtimeConfig = readRuntimeConfig();
1213
1230
  this.server = new Server(
1214
- {
1215
- name: "bambu-printer-mcp",
1216
- version: JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version
1217
- },
1231
+ SERVER_INFO,
1218
1232
  {
1219
1233
  capabilities: {
1220
1234
  resources: {},
@@ -1266,6 +1280,16 @@ class BambuPrinterMCPServer {
1266
1280
  this.setupToolHandlers();
1267
1281
  }
1268
1282
 
1283
+ /**
1284
+ * The model for display-only counterpart tools: the argument, then the
1285
+ * configured model, then the serial prefix. Never a safety decision and
1286
+ * never elicited; print routes use resolveBambuModel and fresh identity.
1287
+ */
1288
+ private displayModel(args: Record<string, unknown> | undefined, serial: string): string | undefined {
1289
+ const requested = typeof args?.bambu_model === "string" ? args.bambu_model.trim() : "";
1290
+ return requested || DEFAULT_BAMBU_MODEL || SERIAL_MODELS[serial.trim().toUpperCase().slice(0, 3)] || undefined;
1291
+ }
1292
+
1269
1293
  /**
1270
1294
  * Resolve the Bambu printer model from args, env, or by asking the user via elicitation.
1271
1295
  * This is critical for safety: the wrong model can cause physical damage to the printer.
@@ -1621,6 +1645,7 @@ class BambuPrinterMCPServer {
1621
1645
 
1622
1646
  return withPrinterOperation(devIp, devId, assertActive => withPrintSnapshot(threeMFPath, async (snapshot, retainForDispatchedUpload) => {
1623
1647
  const inspection = await inspectPrintFile(snapshot, { model: printModel, nozzleDiameters: printNozzles, plateIndex, bedType: printBedType });
1648
+ const resumeFile = await checkedFile(inspection, snapshot);
1624
1649
  let mapping = finalAmsMapping?.slice();
1625
1650
  if (finalAmsSlots) {
1626
1651
  if (finalAmsSlots.length !== inspection.usedFilamentPositions.length) throw new Error("ams_slots must supply exactly one physical tray per used filament.");
@@ -1731,7 +1756,7 @@ class BambuPrinterMCPServer {
1731
1756
  assertActive();
1732
1757
  } });
1733
1758
  assertActive();
1734
- this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements);
1759
+ this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements, resumeFile, false);
1735
1760
  return { ...nativeResult, autoSliced, projectName, plateIndex, useAMS, amsMapping: mapping };
1736
1761
  }
1737
1762
  const bridgeOptions: BambuNetworkBridgeOptions = {
@@ -1777,7 +1802,7 @@ class BambuPrinterMCPServer {
1777
1802
  }
1778
1803
 
1779
1804
  assertActive();
1780
- this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements);
1805
+ this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements, resumeFile, false);
1781
1806
 
1782
1807
  return {
1783
1808
  status: "success",
@@ -2542,7 +2567,10 @@ class BambuPrinterMCPServer {
2542
2567
  rotate_y: { type: "number", description: "Rotate the model around the Y-axis by this many degrees before slicing. Useful for reorienting prints for better layer adhesion." },
2543
2568
  min_save: { type: "boolean", description: "Write a smaller output 3MF by omitting non-essential metadata. Reduces file size for faster FTP upload to the printer." },
2544
2569
  skip_modified_gcodes: { type: "boolean", description: "Strip custom start/end gcodes embedded in the 3MF. Recommended for downloaded 3MFs since custom gcodes from other users' profiles may be unsafe for your printer." },
2545
- slice_plate: { type: "number", description: "Which plate index to slice. 0 = all plates for local slicers; remote slicing defaults to plate 1 and rejects 0. Use 1, 2, etc. to slice only a specific plate in multi-plate 3MF projects." }
2570
+ slice_plate: { type: "number", description: "Which plate index to slice. 0 = all plates for local slicers; remote slicing defaults to plate 1 and rejects 0. Use 1, 2, etc. to slice only a specific plate in multi-plate 3MF projects." },
2571
+ layer_height: { type: "number", exclusiveMinimum: 0, description: "Layer height in mm, such as 0.28 (draft), 0.2 (standard) or 0.12 (fine). Written as the process preset's layer_height over the machine and process preset this tool resolves; at most the nozzle diameter. Bambu-compatible slicers only." },
2572
+ wall_loops: { type: "integer", minimum: 0, maximum: 1000, description: "Number of walls (perimeters), written as the process preset's wall_loops. Bambu-compatible slicers only." },
2573
+ sparse_infill_density: { type: "string", pattern: "^\\s*\\d+(\\.\\d+)?\\s*%\\s*$", description: "Sparse infill density as a percentage, such as \"15%\", written as the process preset's sparse_infill_density. Bambu-compatible slicers only." }
2546
2574
  },
2547
2575
  required: ["stl_path", "bambu_model"]
2548
2576
  }
@@ -2816,7 +2844,7 @@ class BambuPrinterMCPServer {
2816
2844
  },
2817
2845
  {
2818
2846
  name: "resume_print",
2819
- description: "Resume a paused print job on the Bambu Lab printer",
2847
+ description: "Resume a paused job that this server inspected and started. It re-downloads the job's file over FTPS and compares its SHA-256, asks a person to confirm (unless BAMBU_REQUIRE_CONFIRMATION=0), and reads the printer again before sending. A job that was cancelled, ended or replaced is never resumed. Returns jobName and bytesVerified.",
2820
2848
  inputSchema: {
2821
2849
  type: "object",
2822
2850
  properties: {
@@ -3218,6 +3246,121 @@ class BambuPrinterMCPServer {
3218
3246
  : ["stl_path", "operations"],
3219
3247
  additionalProperties: false
3220
3248
  }
3249
+ },
3250
+ {
3251
+ name: "counterpart_printer_info",
3252
+ description: "Counterpart contract (counterpart/1): this server's name and version, the configured Bambu printer, and which progress, layer, camera, filament, pause/resume/cancel and print features it has. Sends nothing to the printer.",
3253
+ inputSchema: {
3254
+ type: "object",
3255
+ properties: {
3256
+ bambu_model: { type: "string", description: "Printer model; defaults to BAMBU_MODEL. Selects the camera transport." },
3257
+ host: { type: "string", description: "Hostname or IP of the printer (default: value from env)" },
3258
+ bambu_serial: { type: "string", description: "Serial number (default: value from env)" },
3259
+ bambu_token: { type: "string", description: "Access token (default: value from env); never returned." }
3260
+ }
3261
+ },
3262
+ outputSchema: PRINTER_INFO_OUTPUT_SCHEMA,
3263
+ annotations: { readOnlyHint: true }
3264
+ },
3265
+ {
3266
+ name: "counterpart_print_progress",
3267
+ description: "Counterpart contract (counterpart/1): the printer's state, current job (name, task id, percent, time left, layers, stage words), temperatures, active filament and problems with Bambu's HMS messages and links. Read from the MQTT report this server keeps, so a held session asks the printer nothing; observedAt is when the printer sent it. An unreachable printer reports state offline. Read-only; not a safety check.",
3268
+ inputSchema: {
3269
+ type: "object",
3270
+ properties: {
3271
+ bambu_model: { type: "string", description: "Printer model; defaults to BAMBU_MODEL. Used for the chamber sensor and Bambu's per-model messages." },
3272
+ host: { type: "string", description: "Hostname or IP of the printer (default: value from env)" },
3273
+ bambu_serial: { type: "string", description: "Serial number (default: value from env)" },
3274
+ bambu_token: { type: "string", description: "Access token (default: value from env)" }
3275
+ }
3276
+ },
3277
+ outputSchema: PRINT_PROGRESS_OUTPUT_SCHEMA,
3278
+ annotations: { readOnlyHint: true }
3279
+ },
3280
+ {
3281
+ name: "counterpart_make_3mf",
3282
+ description: "Counterpart contract (counterpart/1): combine STL parts exported separately (for example each body of a design) into one new 3MF for multi-colour printing. The parts keep their relative positions as one assembly, and each part prints with its filament number (default: part 1 uses filament 1, part 2 filament 2, and so on). Slice it with slice_stl, passing one load_filaments profile per filament number, then print it with print_3mf and ams_mapping or ams_slots. Never overwrites a file.",
3283
+ inputSchema: {
3284
+ type: "object",
3285
+ properties: {
3286
+ parts: {
3287
+ type: "array",
3288
+ minItems: 1,
3289
+ maxItems: 64,
3290
+ description: "The parts, in filament order.",
3291
+ items: {
3292
+ type: "object",
3293
+ properties: {
3294
+ stl_path: { type: "string", description: "Path to the part's STL file." },
3295
+ name: { type: "string", description: "The part's name, shown in the slicer." },
3296
+ filament: { type: "integer", minimum: 1, maximum: 64, description: "1-based project filament for this part; defaults to the part's position (1, 2, ...)." }
3297
+ },
3298
+ required: ["stl_path", "name"],
3299
+ additionalProperties: false
3300
+ }
3301
+ },
3302
+ out_path: { type: "string", description: "New .3mf path whose parent directory exists. Existing files are never overwritten." }
3303
+ },
3304
+ required: ["parts", "out_path"],
3305
+ additionalProperties: false
3306
+ },
3307
+ outputSchema: MAKE_3MF_OUTPUT_SCHEMA
3308
+ },
3309
+ {
3310
+ name: "fusion_mcp_status",
3311
+ description: `Check Autodesk Fusion through the configured Fusion MCP server (faust-machines/fusion360-mcp-server): whether it is configured, Fusion is running, the Fusion360MCP add-in answers on its port, and the server's tools and schemas. connected is true only when the add-in answers. With launch: true, starts Fusion on macOS when it is not running and waits up to 90 s for the add-in. Configure FUSION_MCP_COMMAND (uvx) and FUSION_MCP_ARGS (${JSON.stringify(FUSION_MCP_DEFAULT_ARGS)}).`,
3312
+ inputSchema: {
3313
+ type: "object",
3314
+ properties: {
3315
+ launch: { type: "boolean", description: "Start Autodesk Fusion (open -a \"Autodesk Fusion\") when it is not running, then wait up to 90 s for the add-in." },
3316
+ timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Connection and discovery deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
3317
+ },
3318
+ additionalProperties: false
3319
+ },
3320
+ outputSchema: FUSION_STATUS_OUTPUT_SCHEMA
3321
+ },
3322
+ {
3323
+ name: "fusion_mcp_call",
3324
+ description: "Call a discovered tool on the configured Fusion MCP server, such as create_sketch, extrude, fillet, create_parameter, set_parameter, check_interference or execute_code, preserving its full MCP content and errors. Discover tool schemas with fusion_mcp_status first. Calls change the open Fusion design and are never automatically retried. Most tools need an open design: call fusion_mcp_new_design first.",
3325
+ inputSchema: {
3326
+ type: "object",
3327
+ properties: {
3328
+ tool_name: { type: "string", description: "Exact tool name advertised by the Fusion MCP server." },
3329
+ arguments: { type: "object", description: "Arguments matching the remote tool's discovered input schema." },
3330
+ timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Total deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
3331
+ },
3332
+ required: ["tool_name"],
3333
+ additionalProperties: false
3334
+ },
3335
+ outputSchema: FUSION_CALL_OUTPUT_SCHEMA
3336
+ },
3337
+ {
3338
+ name: "fusion_mcp_new_design",
3339
+ description: "Open a new parametric design document in Fusion (execute_code with app.documents.add(FusionDesignDocumentType)). The Fusion MCP tools work on the open design, so a design pass calls this first.",
3340
+ inputSchema: {
3341
+ type: "object",
3342
+ properties: {
3343
+ timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Total deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
3344
+ },
3345
+ additionalProperties: false
3346
+ },
3347
+ outputSchema: FUSION_NEW_DESIGN_OUTPUT_SCHEMA
3348
+ },
3349
+ {
3350
+ name: "fusion_mcp_export",
3351
+ description: "Export the open Fusion design into an existing directory as <name>.stl (export_stl of one body), <name>.f3d (export_f3d) and <name>.parameters.json (its user parameters), and return their absolute paths. The STL is checked as a finite triangle mesh; slice it like any other model. Fusion must run on this computer, and existing files are never overwritten.",
3352
+ inputSchema: {
3353
+ type: "object",
3354
+ properties: {
3355
+ output_dir: { type: "string", description: "Existing directory for the three files." },
3356
+ name: { type: "string", description: "File name without extension, such as bracket." },
3357
+ body_name: { type: "string", description: "The body to export as STL. Optional when the design has exactly one body." },
3358
+ timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Total deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
3359
+ },
3360
+ required: ["output_dir", "name"],
3361
+ additionalProperties: false
3362
+ },
3363
+ outputSchema: FUSION_EXPORT_OUTPUT_SCHEMA
3221
3364
  }
3222
3365
  ]
3223
3366
  };
@@ -4066,6 +4209,12 @@ class BambuPrinterMCPServer {
4066
4209
  if (args?.min_save !== undefined) sliceBambuOptions.minSave = Boolean(args.min_save);
4067
4210
  if (args?.skip_modified_gcodes !== undefined) sliceBambuOptions.skipModifiedGcodes = Boolean(args.skip_modified_gcodes);
4068
4211
  if (args?.slice_plate !== undefined) sliceBambuOptions.slicePlate = Number(args.slice_plate);
4212
+ const processOverrides = parseProcessOverrides(args as Record<string, unknown>, Number(nozzleDiam));
4213
+ if (processOverrides) sliceBambuOptions.processOverrides = processOverrides;
4214
+ if (sliceBambuOptions.loadFilamentIds && String(args.stl_path).toLowerCase().endsWith(".3mf")) {
4215
+ // Bambu Studio's CLI refuses --load-filament-ids for 3MF input and counts it per input file.
4216
+ throw new Error("load_filament_ids applies only to STL input. In a 3MF, each object or part names its own filament; counterpart_make_3mf writes it from parts[].filament.");
4217
+ }
4069
4218
  const usePrinterFilaments =
4070
4219
  args?.use_printer_filaments !== undefined ? Boolean(args.use_printer_filaments) : true;
4071
4220
  if (
@@ -4450,6 +4599,40 @@ class BambuPrinterMCPServer {
4450
4599
  );
4451
4600
  break;
4452
4601
 
4602
+ case "counterpart_printer_info":
4603
+ result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial) });
4604
+ break;
4605
+
4606
+ case "counterpart_print_progress": {
4607
+ const report = await this.bambu.readProgressReport(host, bambuSerial, bambuToken);
4608
+ result = report
4609
+ ? bambuProgress(report.raw, { receivedAt: report.receivedAt, serial: bambuSerial, model: this.displayModel(args, bambuSerial) })
4610
+ : offlineProgress(Date.now());
4611
+ break;
4612
+ }
4613
+
4614
+ case "counterpart_make_3mf":
4615
+ result = await makeCounterpart3mf(args ?? {});
4616
+ break;
4617
+
4618
+ case "fusion_mcp_status":
4619
+ result = await this.fusion.status(args ?? {}, extra.signal);
4620
+ break;
4621
+
4622
+ case "fusion_mcp_call": {
4623
+ // The remote result passes through unchanged; its structuredContent satisfies the open schema.
4624
+ const remote = await this.fusion.call(args ?? {}, extra.signal);
4625
+ return { ...remote, structuredContent: remote.structuredContent ?? {} };
4626
+ }
4627
+
4628
+ case "fusion_mcp_new_design":
4629
+ result = await this.fusion.newDesign(args ?? {}, extra.signal);
4630
+ break;
4631
+
4632
+ case "fusion_mcp_export":
4633
+ result = await this.fusion.export(args ?? {}, extra.signal);
4634
+ break;
4635
+
4453
4636
  default:
4454
4637
  throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
4455
4638
  }
@@ -4457,7 +4640,8 @@ class BambuPrinterMCPServer {
4457
4640
  await progressNotifications;
4458
4641
  const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
4459
4642
 
4460
- if (this.runtimeConfig.enableJsonResponse && typeof result === "object") {
4643
+ // A declared outputSchema obliges structuredContent whatever MCP_HTTP_JSON_RESPONSE says.
4644
+ if ((this.runtimeConfig.enableJsonResponse || OUTPUT_SCHEMA_TOOLS.has(name)) && typeof result === "object") {
4461
4645
  return {
4462
4646
  content: [{ type: "text", text }],
4463
4647
  structuredContent: result,
@@ -4480,9 +4664,11 @@ class BambuPrinterMCPServer {
4480
4664
  tool: name,
4481
4665
  };
4482
4666
 
4667
+ // MCP clients validate structuredContent against a declared outputSchema even on
4668
+ // errors (SDK 1.32 Client.callTool), so those tools return the error as text only.
4483
4669
  return {
4484
4670
  content: [{ type: "text", text: `Error: ${message}` }],
4485
- structuredContent: structured,
4671
+ ...(OUTPUT_SCHEMA_TOOLS.has(name) ? {} : { structuredContent: structured }),
4486
4672
  isError: true,
4487
4673
  };
4488
4674
  }
@@ -4502,6 +4688,7 @@ class BambuPrinterMCPServer {
4502
4688
  try {
4503
4689
  // Closing the MCP transport aborts its active requests before exit cleanup.
4504
4690
  await this.server.close();
4691
+ await this.fusion.close();
4505
4692
  this.httpRuntime?.httpServer.close();
4506
4693
  } catch (error) {
4507
4694
  console.error("[MCP Shutdown]", error);
@@ -0,0 +1,90 @@
1
+ // GENERATED by scripts/generate-hms-messages.mjs from Bambu Studio v02.08.02.61
2
+ // (commit 926a7192574bcb9b3a732e1ec59a46d79cb45466, src/slic3r/GUI/DeviceManager.cpp, Slic3r::get_stage_string).
3
+ // The words Bambu Studio shows for the printer's current stage, indexed by stg_cur. Do not edit by hand.
4
+ export const BAMBU_STAGES_SOURCE = {
5
+ studioTag: "v02.08.02.61",
6
+ studioCommit: "926a7192574bcb9b3a732e1ec59a46d79cb45466",
7
+ file: "src/slic3r/GUI/DeviceManager.cpp",
8
+ sha256: "7a47eae25894689fc0636e63b360aa440816384383e54b6c116d104d9e359820",
9
+ } as const;
10
+
11
+ export const BAMBU_STAGES: readonly string[] = [
12
+ "Printing", // 0
13
+ "Auto bed leveling", // 1
14
+ "Heatbed preheating", // 2
15
+ "Vibration compensation", // 3
16
+ "Changing filament", // 4
17
+ "M400 pause", // 5
18
+ "Paused (filament ran out)", // 6
19
+ "Heating nozzle", // 7
20
+ "Calibrating dynamic flow", // 8
21
+ "Scanning bed surface", // 9
22
+ "Inspecting first layer", // 10
23
+ "Identifying build plate type", // 11
24
+ "Calibrating Micro Lidar", // 12
25
+ "Homing toolhead", // 13
26
+ "Cleaning nozzle tip", // 14
27
+ "Checking extruder temperature", // 15
28
+ "Paused by the user", // 16
29
+ "Pause (front cover fall off)", // 17
30
+ "Calibrating the micro lidar", // 18
31
+ "Calibrating flow ratio", // 19
32
+ "Pause (nozzle temperature malfunction)", // 20
33
+ "Pause (heatbed temperature malfunction)", // 21
34
+ "Filament unloading", // 22
35
+ "Pause (step loss)", // 23
36
+ "Filament loading", // 24
37
+ "Motor noise cancellation", // 25
38
+ "Pause (AMS offline)", // 26
39
+ "Pause (low speed of the heatbreak fan)", // 27
40
+ "Pause (chamber temperature control problem)", // 28
41
+ "Cooling chamber", // 29
42
+ "Pause (Gcode inserted by user)", // 30
43
+ "Motor noise showoff", // 31
44
+ "Pause (nozzle clumping)", // 32
45
+ "Pause (cutter error)", // 33
46
+ "Pause (first layer error)", // 34
47
+ "Pause (nozzle clog)", // 35
48
+ "Measuring motion precision", // 36
49
+ "Enhancing motion precision", // 37
50
+ "Measure motion accuracy", // 38
51
+ "Nozzle offset calibration", // 39
52
+ "high temperature auto bed levelling", // 40
53
+ "Auto Check: Quick Release Lever", // 41
54
+ "Auto Check: Door and Upper Cover", // 42
55
+ "Laser Calibration", // 43
56
+ "Auto Check: Platform", // 44
57
+ "Confirming BirdsEye Camera location", // 45
58
+ "Calibrating BirdsEye Camera", // 46
59
+ "Auto bed leveling -phase 1", // 47
60
+ "Auto bed leveling -phase 2", // 48
61
+ "Heating chamber", // 49
62
+ "Adjusting heatbed temperature", // 50
63
+ "Printing calibration lines", // 51
64
+ "Auto Check: Material", // 52
65
+ "Live View Camera Calibration", // 53
66
+ "Waiting for heatbed to reach target temperature", // 54
67
+ "Auto Check: Material Position", // 55
68
+ "Cutting Module Offset Calibration", // 56
69
+ "Measuring Surface", // 57
70
+ "Thermal Preconditioning for first layer optimization", // 58
71
+ "Homing Blade Holder", // 59
72
+ "Calibrating Camera Offset", // 60
73
+ "Calibrating Blade Holder Position", // 61
74
+ "Hotend Pick and Place Test", // 62
75
+ "Waiting for the Chamber temperature to equalize", // 63
76
+ "Preparing Hotend", // 64
77
+ "Calibrating the detection position of nozzle clumping", // 65
78
+ "Purifying the chamber air", // 66
79
+ "Measuring Rotary Attachment", // 67
80
+ "The toolhead moves above the purge chute", // 68
81
+ "Cooling down the nozzle", // 69
82
+ "The toolhead moves to the center of the heatbed", // 70
83
+ "Active Arc Fitting", // 71
84
+ "Hotend Type Detection", // 72
85
+ "Build plate alignment detection", // 73
86
+ "Heatbed surface foreign object detection", // 74
87
+ "Heatbed underside foreign object detection", // 75
88
+ "Pre-extrusion before printing", // 76
89
+ "Preparing AMS", // 77
90
+ ];