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.
- package/README.md +116 -2
- package/dist/blender-mcp-bridge.d.ts +15 -0
- package/dist/blender-mcp-bridge.js +21 -3
- package/dist/counterpart/info.d.ts +10 -0
- package/dist/counterpart/info.js +34 -0
- package/dist/counterpart/make-3mf.d.ts +16 -0
- package/dist/counterpart/make-3mf.js +219 -0
- package/dist/counterpart/progress.d.ts +28 -0
- package/dist/counterpart/progress.js +254 -0
- package/dist/counterpart/schemas.d.ts +322 -0
- package/dist/counterpart/schemas.js +124 -0
- package/dist/fusion-mcp-bridge.d.ts +182 -0
- package/dist/fusion-mcp-bridge.js +557 -0
- package/dist/index.js +192 -12
- package/dist/printers/bambu-stages.d.ts +7 -0
- package/dist/printers/bambu-stages.js +89 -0
- package/dist/printers/bambu.d.ts +76 -4
- package/dist/printers/bambu.js +297 -37
- package/dist/printers/camera-models.d.ts +7 -0
- package/dist/printers/camera-models.js +18 -0
- package/dist/safety/hms-messages.d.ts +42 -0
- package/dist/safety/hms-messages.js +6194 -0
- package/dist/safety/printer-state.d.ts +18 -0
- package/dist/safety/printer-state.js +3 -3
- package/dist/slicer/process-overrides.d.ts +12 -0
- package/dist/slicer/process-overrides.js +33 -0
- package/dist/slicer/remote-slicer.js +2 -0
- package/dist/stl/stl-manipulator.d.ts +2 -0
- package/dist/stl/stl-manipulator.js +19 -0
- package/package.json +1 -1
- package/src/blender-mcp-bridge.ts +22 -3
- package/src/counterpart/info.ts +36 -0
- package/src/counterpart/make-3mf.ts +220 -0
- package/src/counterpart/progress.ts +254 -0
- package/src/counterpart/schemas.ts +154 -0
- package/src/fusion-mcp-bridge.ts +545 -0
- package/src/index.ts +199 -12
- package/src/printers/bambu-stages.ts +90 -0
- package/src/printers/bambu.ts +315 -37
- package/src/printers/camera-models.ts +18 -0
- package/src/safety/hms-messages.ts +6198 -0
- package/src/safety/printer-state.ts +4 -4
- package/src/slicer/process-overrides.ts +42 -0
- package/src/slicer/remote-slicer.ts +2 -0
- package/src/stl/stl-manipulator.ts +22 -0
package/dist/index.js
CHANGED
|
@@ -14,14 +14,20 @@ import { BambuNetworkBridge, describeBambuNetworkPrintError } from "./bambu-netw
|
|
|
14
14
|
import { assertBambuNativeAvailable, bambuNativeControlsAvailable, bambuNativeUnavailableReason, interruptNativeOperations, validateBambuNativeMetadata, buildBambuNativeFanCommand, buildBambuNativeTemperatureCommand, printWithBambuNative, sendCommandWithBambuNative, uploadWithBambuNative, } from "./bambu-native.js";
|
|
15
15
|
import { importFileViaBambuConnect } from "./bambu-connect.js";
|
|
16
16
|
import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
|
|
17
|
+
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";
|
|
17
18
|
import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, hasAmsMappingInput, normalizeAmsMappingObject, normalizeBridgeAmsTrayValue } from "./ams-mapping.js";
|
|
18
19
|
import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, parse3MF } from './3mf_parser.js';
|
|
19
|
-
import { BambuImplementation, assertDirectPrintSupported } from "./printers/bambu.js";
|
|
20
|
+
import { BambuImplementation, assertDirectPrintSupported, checkedFile } from "./printers/bambu.js";
|
|
20
21
|
import { inspectPrintFile } from "./safety/print-file.js";
|
|
21
|
-
import { externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
22
|
+
import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./safety/printer-state.js";
|
|
22
23
|
import { isDualNozzleModel } from "./safety/limits.js";
|
|
23
24
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName } from "./safety/artifact.js";
|
|
24
25
|
import { detectProfilesRoot } from "./slicer/profile-flatten.js";
|
|
26
|
+
import { bambuPrinterInfo } from "./counterpart/info.js";
|
|
27
|
+
import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
|
|
28
|
+
import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
|
|
29
|
+
import { MAKE_3MF_OUTPUT_SCHEMA, PRINT_PROGRESS_OUTPUT_SCHEMA, PRINTER_INFO_OUTPUT_SCHEMA } from "./counterpart/schemas.js";
|
|
30
|
+
import { parseProcessOverrides } from "./slicer/process-overrides.js";
|
|
25
31
|
dotenv.config();
|
|
26
32
|
const DEFAULT_HOST = process.env.BAMBU_PRINTER_HOST || process.env.PRINTER_HOST || "localhost";
|
|
27
33
|
const DEFAULT_BAMBU_SERIAL = process.env.BAMBU_PRINTER_SERIAL || process.env.BAMBU_SERIAL || "";
|
|
@@ -55,6 +61,16 @@ const DEFAULT_BAMBU_MODEL = process.env.BAMBU_PRINTER_MODEL?.trim().toLowerCase(
|
|
|
55
61
|
const DEFAULT_BAMBU_CONNECTION_MODE = process.env.BAMBU_DEFAULT_CONNECTION_MODE?.trim().toLowerCase() || "";
|
|
56
62
|
const DEFAULT_BED_TYPE = process.env.BED_TYPE?.trim().toLowerCase() || "textured_plate";
|
|
57
63
|
const DEFAULT_NOZZLE_DIAMETER = process.env.NOZZLE_DIAMETER?.trim() || "0.4";
|
|
64
|
+
/** MCP initialize name/version; counterpart_printer_info reports the same values. */
|
|
65
|
+
const SERVER_INFO = {
|
|
66
|
+
name: "bambu-printer-mcp",
|
|
67
|
+
version: String(JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version),
|
|
68
|
+
};
|
|
69
|
+
/** Tools that declare an outputSchema: they always return structuredContent, and errors carry none. */
|
|
70
|
+
const OUTPUT_SCHEMA_TOOLS = new Set([
|
|
71
|
+
"counterpart_printer_info", "counterpart_print_progress", "counterpart_make_3mf",
|
|
72
|
+
"fusion_mcp_status", "fusion_mcp_call", "fusion_mcp_new_design", "fusion_mcp_export",
|
|
73
|
+
]);
|
|
58
74
|
/** Bound for each Linux X2D emergency MQTT send (BAMBU_EMERGENCY_MQTT_TIMEOUT_MS, 1–60000 ms). */
|
|
59
75
|
function withEmergencyMqttTimeout(send) {
|
|
60
76
|
const raw = Number(process.env.BAMBU_EMERGENCY_MQTT_TIMEOUT_MS?.trim() || 15000);
|
|
@@ -913,13 +929,11 @@ if (!fs.existsSync(TEMP_DIR)) {
|
|
|
913
929
|
class BambuPrinterMCPServer {
|
|
914
930
|
constructor() {
|
|
915
931
|
this.blender = new BlenderMcpBridge();
|
|
932
|
+
this.fusion = new FusionMcpBridge();
|
|
916
933
|
this.shuttingDown = false;
|
|
917
934
|
this.confirmationTimeoutMs = parseConfirmationTimeout(process.env.BAMBU_CONFIRMATION_TIMEOUT_MS);
|
|
918
935
|
this.runtimeConfig = readRuntimeConfig();
|
|
919
|
-
this.server = new Server({
|
|
920
|
-
name: "bambu-printer-mcp",
|
|
921
|
-
version: JSON.parse(fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")).version
|
|
922
|
-
}, {
|
|
936
|
+
this.server = new Server(SERVER_INFO, {
|
|
923
937
|
capabilities: {
|
|
924
938
|
resources: {},
|
|
925
939
|
tools: {}
|
|
@@ -965,6 +979,15 @@ class BambuPrinterMCPServer {
|
|
|
965
979
|
this.setupResourceHandlers();
|
|
966
980
|
this.setupToolHandlers();
|
|
967
981
|
}
|
|
982
|
+
/**
|
|
983
|
+
* The model for display-only counterpart tools: the argument, then the
|
|
984
|
+
* configured model, then the serial prefix. Never a safety decision and
|
|
985
|
+
* never elicited; print routes use resolveBambuModel and fresh identity.
|
|
986
|
+
*/
|
|
987
|
+
displayModel(args, serial) {
|
|
988
|
+
const requested = typeof args?.bambu_model === "string" ? args.bambu_model.trim() : "";
|
|
989
|
+
return requested || DEFAULT_BAMBU_MODEL || SERIAL_MODELS[serial.trim().toUpperCase().slice(0, 3)] || undefined;
|
|
990
|
+
}
|
|
968
991
|
/**
|
|
969
992
|
* Resolve the Bambu printer model from args, env, or by asking the user via elicitation.
|
|
970
993
|
* This is critical for safety: the wrong model can cause physical damage to the printer.
|
|
@@ -1207,6 +1230,7 @@ class BambuPrinterMCPServer {
|
|
|
1207
1230
|
const clientJobId = args?.client_job_id !== undefined ? Number(args.client_job_id) : Date.now();
|
|
1208
1231
|
return withPrinterOperation(devIp, devId, assertActive => withPrintSnapshot(threeMFPath, async (snapshot, retainForDispatchedUpload) => {
|
|
1209
1232
|
const inspection = await inspectPrintFile(snapshot, { model: printModel, nozzleDiameters: printNozzles, plateIndex, bedType: printBedType });
|
|
1233
|
+
const resumeFile = await checkedFile(inspection, snapshot);
|
|
1210
1234
|
let mapping = finalAmsMapping?.slice();
|
|
1211
1235
|
if (finalAmsSlots) {
|
|
1212
1236
|
if (finalAmsSlots.length !== inspection.usedFilamentPositions.length)
|
|
@@ -1317,7 +1341,7 @@ class BambuPrinterMCPServer {
|
|
|
1317
1341
|
assertActive();
|
|
1318
1342
|
} });
|
|
1319
1343
|
assertActive();
|
|
1320
|
-
this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements);
|
|
1344
|
+
this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements, resumeFile, false);
|
|
1321
1345
|
return { ...nativeResult, autoSliced, projectName, plateIndex, useAMS, amsMapping: mapping };
|
|
1322
1346
|
}
|
|
1323
1347
|
const bridgeOptions = {
|
|
@@ -1357,7 +1381,7 @@ class BambuPrinterMCPServer {
|
|
|
1357
1381
|
(reported ? ` Plug-in reported: ${reported}.` : ""));
|
|
1358
1382
|
}
|
|
1359
1383
|
assertActive();
|
|
1360
|
-
this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements);
|
|
1384
|
+
this.bambu.recordCheckedJob(devIp, devId, remoteFileName, requirements, resumeFile, false);
|
|
1361
1385
|
return {
|
|
1362
1386
|
status: "success",
|
|
1363
1387
|
message: `FULU BambuNetwork ${bridgePrintMethod} command for ${threeMfFilename} sent successfully.`,
|
|
@@ -2013,7 +2037,10 @@ class BambuPrinterMCPServer {
|
|
|
2013
2037
|
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." },
|
|
2014
2038
|
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." },
|
|
2015
2039
|
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." },
|
|
2016
|
-
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." }
|
|
2040
|
+
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." },
|
|
2041
|
+
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." },
|
|
2042
|
+
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." },
|
|
2043
|
+
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." }
|
|
2017
2044
|
},
|
|
2018
2045
|
required: ["stl_path", "bambu_model"]
|
|
2019
2046
|
}
|
|
@@ -2287,7 +2314,7 @@ class BambuPrinterMCPServer {
|
|
|
2287
2314
|
},
|
|
2288
2315
|
{
|
|
2289
2316
|
name: "resume_print",
|
|
2290
|
-
description: "Resume a paused
|
|
2317
|
+
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.",
|
|
2291
2318
|
inputSchema: {
|
|
2292
2319
|
type: "object",
|
|
2293
2320
|
properties: {
|
|
@@ -2689,6 +2716,121 @@ class BambuPrinterMCPServer {
|
|
|
2689
2716
|
: ["stl_path", "operations"],
|
|
2690
2717
|
additionalProperties: false
|
|
2691
2718
|
}
|
|
2719
|
+
},
|
|
2720
|
+
{
|
|
2721
|
+
name: "counterpart_printer_info",
|
|
2722
|
+
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.",
|
|
2723
|
+
inputSchema: {
|
|
2724
|
+
type: "object",
|
|
2725
|
+
properties: {
|
|
2726
|
+
bambu_model: { type: "string", description: "Printer model; defaults to BAMBU_MODEL. Selects the camera transport." },
|
|
2727
|
+
host: { type: "string", description: "Hostname or IP of the printer (default: value from env)" },
|
|
2728
|
+
bambu_serial: { type: "string", description: "Serial number (default: value from env)" },
|
|
2729
|
+
bambu_token: { type: "string", description: "Access token (default: value from env); never returned." }
|
|
2730
|
+
}
|
|
2731
|
+
},
|
|
2732
|
+
outputSchema: PRINTER_INFO_OUTPUT_SCHEMA,
|
|
2733
|
+
annotations: { readOnlyHint: true }
|
|
2734
|
+
},
|
|
2735
|
+
{
|
|
2736
|
+
name: "counterpart_print_progress",
|
|
2737
|
+
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.",
|
|
2738
|
+
inputSchema: {
|
|
2739
|
+
type: "object",
|
|
2740
|
+
properties: {
|
|
2741
|
+
bambu_model: { type: "string", description: "Printer model; defaults to BAMBU_MODEL. Used for the chamber sensor and Bambu's per-model messages." },
|
|
2742
|
+
host: { type: "string", description: "Hostname or IP of the printer (default: value from env)" },
|
|
2743
|
+
bambu_serial: { type: "string", description: "Serial number (default: value from env)" },
|
|
2744
|
+
bambu_token: { type: "string", description: "Access token (default: value from env)" }
|
|
2745
|
+
}
|
|
2746
|
+
},
|
|
2747
|
+
outputSchema: PRINT_PROGRESS_OUTPUT_SCHEMA,
|
|
2748
|
+
annotations: { readOnlyHint: true }
|
|
2749
|
+
},
|
|
2750
|
+
{
|
|
2751
|
+
name: "counterpart_make_3mf",
|
|
2752
|
+
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.",
|
|
2753
|
+
inputSchema: {
|
|
2754
|
+
type: "object",
|
|
2755
|
+
properties: {
|
|
2756
|
+
parts: {
|
|
2757
|
+
type: "array",
|
|
2758
|
+
minItems: 1,
|
|
2759
|
+
maxItems: 64,
|
|
2760
|
+
description: "The parts, in filament order.",
|
|
2761
|
+
items: {
|
|
2762
|
+
type: "object",
|
|
2763
|
+
properties: {
|
|
2764
|
+
stl_path: { type: "string", description: "Path to the part's STL file." },
|
|
2765
|
+
name: { type: "string", description: "The part's name, shown in the slicer." },
|
|
2766
|
+
filament: { type: "integer", minimum: 1, maximum: 64, description: "1-based project filament for this part; defaults to the part's position (1, 2, ...)." }
|
|
2767
|
+
},
|
|
2768
|
+
required: ["stl_path", "name"],
|
|
2769
|
+
additionalProperties: false
|
|
2770
|
+
}
|
|
2771
|
+
},
|
|
2772
|
+
out_path: { type: "string", description: "New .3mf path whose parent directory exists. Existing files are never overwritten." }
|
|
2773
|
+
},
|
|
2774
|
+
required: ["parts", "out_path"],
|
|
2775
|
+
additionalProperties: false
|
|
2776
|
+
},
|
|
2777
|
+
outputSchema: MAKE_3MF_OUTPUT_SCHEMA
|
|
2778
|
+
},
|
|
2779
|
+
{
|
|
2780
|
+
name: "fusion_mcp_status",
|
|
2781
|
+
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)}).`,
|
|
2782
|
+
inputSchema: {
|
|
2783
|
+
type: "object",
|
|
2784
|
+
properties: {
|
|
2785
|
+
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." },
|
|
2786
|
+
timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Connection and discovery deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
|
|
2787
|
+
},
|
|
2788
|
+
additionalProperties: false
|
|
2789
|
+
},
|
|
2790
|
+
outputSchema: FUSION_STATUS_OUTPUT_SCHEMA
|
|
2791
|
+
},
|
|
2792
|
+
{
|
|
2793
|
+
name: "fusion_mcp_call",
|
|
2794
|
+
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.",
|
|
2795
|
+
inputSchema: {
|
|
2796
|
+
type: "object",
|
|
2797
|
+
properties: {
|
|
2798
|
+
tool_name: { type: "string", description: "Exact tool name advertised by the Fusion MCP server." },
|
|
2799
|
+
arguments: { type: "object", description: "Arguments matching the remote tool's discovered input schema." },
|
|
2800
|
+
timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Total deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
|
|
2801
|
+
},
|
|
2802
|
+
required: ["tool_name"],
|
|
2803
|
+
additionalProperties: false
|
|
2804
|
+
},
|
|
2805
|
+
outputSchema: FUSION_CALL_OUTPUT_SCHEMA
|
|
2806
|
+
},
|
|
2807
|
+
{
|
|
2808
|
+
name: "fusion_mcp_new_design",
|
|
2809
|
+
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.",
|
|
2810
|
+
inputSchema: {
|
|
2811
|
+
type: "object",
|
|
2812
|
+
properties: {
|
|
2813
|
+
timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Total deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
|
|
2814
|
+
},
|
|
2815
|
+
additionalProperties: false
|
|
2816
|
+
},
|
|
2817
|
+
outputSchema: FUSION_NEW_DESIGN_OUTPUT_SCHEMA
|
|
2818
|
+
},
|
|
2819
|
+
{
|
|
2820
|
+
name: "fusion_mcp_export",
|
|
2821
|
+
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.",
|
|
2822
|
+
inputSchema: {
|
|
2823
|
+
type: "object",
|
|
2824
|
+
properties: {
|
|
2825
|
+
output_dir: { type: "string", description: "Existing directory for the three files." },
|
|
2826
|
+
name: { type: "string", description: "File name without extension, such as bracket." },
|
|
2827
|
+
body_name: { type: "string", description: "The body to export as STL. Optional when the design has exactly one body." },
|
|
2828
|
+
timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Total deadline in milliseconds; defaults to FUSION_MCP_TIMEOUT_MS or 180000." }
|
|
2829
|
+
},
|
|
2830
|
+
required: ["output_dir", "name"],
|
|
2831
|
+
additionalProperties: false
|
|
2832
|
+
},
|
|
2833
|
+
outputSchema: FUSION_EXPORT_OUTPUT_SCHEMA
|
|
2692
2834
|
}
|
|
2693
2835
|
]
|
|
2694
2836
|
};
|
|
@@ -3416,6 +3558,13 @@ class BambuPrinterMCPServer {
|
|
|
3416
3558
|
sliceBambuOptions.skipModifiedGcodes = Boolean(args.skip_modified_gcodes);
|
|
3417
3559
|
if (args?.slice_plate !== undefined)
|
|
3418
3560
|
sliceBambuOptions.slicePlate = Number(args.slice_plate);
|
|
3561
|
+
const processOverrides = parseProcessOverrides(args, Number(nozzleDiam));
|
|
3562
|
+
if (processOverrides)
|
|
3563
|
+
sliceBambuOptions.processOverrides = processOverrides;
|
|
3564
|
+
if (sliceBambuOptions.loadFilamentIds && String(args.stl_path).toLowerCase().endsWith(".3mf")) {
|
|
3565
|
+
// Bambu Studio's CLI refuses --load-filament-ids for 3MF input and counts it per input file.
|
|
3566
|
+
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.");
|
|
3567
|
+
}
|
|
3419
3568
|
const usePrinterFilaments = args?.use_printer_filaments !== undefined ? Boolean(args.use_printer_filaments) : true;
|
|
3420
3569
|
if (usePrinterFilaments &&
|
|
3421
3570
|
!explicitSlicerProfile &&
|
|
@@ -3692,12 +3841,40 @@ class BambuPrinterMCPServer {
|
|
|
3692
3841
|
case "blender_mcp_edit_model":
|
|
3693
3842
|
result = await this.blender.edit(args ?? {}, this.resolveExecutableSelectorArg(args?.bridge_command, "blender_mcp_edit_model", "bridge_command", true) ?? (!process.env.BLENDER_MCP_COMMAND?.trim() ? this.runtimeConfig.blenderBridgeCommand : undefined), extra.signal);
|
|
3694
3843
|
break;
|
|
3844
|
+
case "counterpart_printer_info":
|
|
3845
|
+
result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial) });
|
|
3846
|
+
break;
|
|
3847
|
+
case "counterpart_print_progress": {
|
|
3848
|
+
const report = await this.bambu.readProgressReport(host, bambuSerial, bambuToken);
|
|
3849
|
+
result = report
|
|
3850
|
+
? bambuProgress(report.raw, { receivedAt: report.receivedAt, serial: bambuSerial, model: this.displayModel(args, bambuSerial) })
|
|
3851
|
+
: offlineProgress(Date.now());
|
|
3852
|
+
break;
|
|
3853
|
+
}
|
|
3854
|
+
case "counterpart_make_3mf":
|
|
3855
|
+
result = await makeCounterpart3mf(args ?? {});
|
|
3856
|
+
break;
|
|
3857
|
+
case "fusion_mcp_status":
|
|
3858
|
+
result = await this.fusion.status(args ?? {}, extra.signal);
|
|
3859
|
+
break;
|
|
3860
|
+
case "fusion_mcp_call": {
|
|
3861
|
+
// The remote result passes through unchanged; its structuredContent satisfies the open schema.
|
|
3862
|
+
const remote = await this.fusion.call(args ?? {}, extra.signal);
|
|
3863
|
+
return { ...remote, structuredContent: remote.structuredContent ?? {} };
|
|
3864
|
+
}
|
|
3865
|
+
case "fusion_mcp_new_design":
|
|
3866
|
+
result = await this.fusion.newDesign(args ?? {}, extra.signal);
|
|
3867
|
+
break;
|
|
3868
|
+
case "fusion_mcp_export":
|
|
3869
|
+
result = await this.fusion.export(args ?? {}, extra.signal);
|
|
3870
|
+
break;
|
|
3695
3871
|
default:
|
|
3696
3872
|
throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`);
|
|
3697
3873
|
}
|
|
3698
3874
|
await progressNotifications;
|
|
3699
3875
|
const text = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
3700
|
-
|
|
3876
|
+
// A declared outputSchema obliges structuredContent whatever MCP_HTTP_JSON_RESPONSE says.
|
|
3877
|
+
if ((this.runtimeConfig.enableJsonResponse || OUTPUT_SCHEMA_TOOLS.has(name)) && typeof result === "object") {
|
|
3701
3878
|
return {
|
|
3702
3879
|
content: [{ type: "text", text }],
|
|
3703
3880
|
structuredContent: result,
|
|
@@ -3718,9 +3895,11 @@ class BambuPrinterMCPServer {
|
|
|
3718
3895
|
message,
|
|
3719
3896
|
tool: name,
|
|
3720
3897
|
};
|
|
3898
|
+
// MCP clients validate structuredContent against a declared outputSchema even on
|
|
3899
|
+
// errors (SDK 1.32 Client.callTool), so those tools return the error as text only.
|
|
3721
3900
|
return {
|
|
3722
3901
|
content: [{ type: "text", text: `Error: ${message}` }],
|
|
3723
|
-
structuredContent: structured,
|
|
3902
|
+
...(OUTPUT_SCHEMA_TOOLS.has(name) ? {} : { structuredContent: structured }),
|
|
3724
3903
|
isError: true,
|
|
3725
3904
|
};
|
|
3726
3905
|
}
|
|
@@ -3739,6 +3918,7 @@ class BambuPrinterMCPServer {
|
|
|
3739
3918
|
try {
|
|
3740
3919
|
// Closing the MCP transport aborts its active requests before exit cleanup.
|
|
3741
3920
|
await this.server.close();
|
|
3921
|
+
await this.fusion.close();
|
|
3742
3922
|
this.httpRuntime?.httpServer.close();
|
|
3743
3923
|
}
|
|
3744
3924
|
catch (error) {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const BAMBU_STAGES_SOURCE: {
|
|
2
|
+
readonly studioTag: "v02.08.02.61";
|
|
3
|
+
readonly studioCommit: "926a7192574bcb9b3a732e1ec59a46d79cb45466";
|
|
4
|
+
readonly file: "src/slic3r/GUI/DeviceManager.cpp";
|
|
5
|
+
readonly sha256: "7a47eae25894689fc0636e63b360aa440816384383e54b6c116d104d9e359820";
|
|
6
|
+
};
|
|
7
|
+
export declare const BAMBU_STAGES: readonly string[];
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
};
|
|
10
|
+
export const BAMBU_STAGES = [
|
|
11
|
+
"Printing", // 0
|
|
12
|
+
"Auto bed leveling", // 1
|
|
13
|
+
"Heatbed preheating", // 2
|
|
14
|
+
"Vibration compensation", // 3
|
|
15
|
+
"Changing filament", // 4
|
|
16
|
+
"M400 pause", // 5
|
|
17
|
+
"Paused (filament ran out)", // 6
|
|
18
|
+
"Heating nozzle", // 7
|
|
19
|
+
"Calibrating dynamic flow", // 8
|
|
20
|
+
"Scanning bed surface", // 9
|
|
21
|
+
"Inspecting first layer", // 10
|
|
22
|
+
"Identifying build plate type", // 11
|
|
23
|
+
"Calibrating Micro Lidar", // 12
|
|
24
|
+
"Homing toolhead", // 13
|
|
25
|
+
"Cleaning nozzle tip", // 14
|
|
26
|
+
"Checking extruder temperature", // 15
|
|
27
|
+
"Paused by the user", // 16
|
|
28
|
+
"Pause (front cover fall off)", // 17
|
|
29
|
+
"Calibrating the micro lidar", // 18
|
|
30
|
+
"Calibrating flow ratio", // 19
|
|
31
|
+
"Pause (nozzle temperature malfunction)", // 20
|
|
32
|
+
"Pause (heatbed temperature malfunction)", // 21
|
|
33
|
+
"Filament unloading", // 22
|
|
34
|
+
"Pause (step loss)", // 23
|
|
35
|
+
"Filament loading", // 24
|
|
36
|
+
"Motor noise cancellation", // 25
|
|
37
|
+
"Pause (AMS offline)", // 26
|
|
38
|
+
"Pause (low speed of the heatbreak fan)", // 27
|
|
39
|
+
"Pause (chamber temperature control problem)", // 28
|
|
40
|
+
"Cooling chamber", // 29
|
|
41
|
+
"Pause (Gcode inserted by user)", // 30
|
|
42
|
+
"Motor noise showoff", // 31
|
|
43
|
+
"Pause (nozzle clumping)", // 32
|
|
44
|
+
"Pause (cutter error)", // 33
|
|
45
|
+
"Pause (first layer error)", // 34
|
|
46
|
+
"Pause (nozzle clog)", // 35
|
|
47
|
+
"Measuring motion precision", // 36
|
|
48
|
+
"Enhancing motion precision", // 37
|
|
49
|
+
"Measure motion accuracy", // 38
|
|
50
|
+
"Nozzle offset calibration", // 39
|
|
51
|
+
"high temperature auto bed levelling", // 40
|
|
52
|
+
"Auto Check: Quick Release Lever", // 41
|
|
53
|
+
"Auto Check: Door and Upper Cover", // 42
|
|
54
|
+
"Laser Calibration", // 43
|
|
55
|
+
"Auto Check: Platform", // 44
|
|
56
|
+
"Confirming BirdsEye Camera location", // 45
|
|
57
|
+
"Calibrating BirdsEye Camera", // 46
|
|
58
|
+
"Auto bed leveling -phase 1", // 47
|
|
59
|
+
"Auto bed leveling -phase 2", // 48
|
|
60
|
+
"Heating chamber", // 49
|
|
61
|
+
"Adjusting heatbed temperature", // 50
|
|
62
|
+
"Printing calibration lines", // 51
|
|
63
|
+
"Auto Check: Material", // 52
|
|
64
|
+
"Live View Camera Calibration", // 53
|
|
65
|
+
"Waiting for heatbed to reach target temperature", // 54
|
|
66
|
+
"Auto Check: Material Position", // 55
|
|
67
|
+
"Cutting Module Offset Calibration", // 56
|
|
68
|
+
"Measuring Surface", // 57
|
|
69
|
+
"Thermal Preconditioning for first layer optimization", // 58
|
|
70
|
+
"Homing Blade Holder", // 59
|
|
71
|
+
"Calibrating Camera Offset", // 60
|
|
72
|
+
"Calibrating Blade Holder Position", // 61
|
|
73
|
+
"Hotend Pick and Place Test", // 62
|
|
74
|
+
"Waiting for the Chamber temperature to equalize", // 63
|
|
75
|
+
"Preparing Hotend", // 64
|
|
76
|
+
"Calibrating the detection position of nozzle clumping", // 65
|
|
77
|
+
"Purifying the chamber air", // 66
|
|
78
|
+
"Measuring Rotary Attachment", // 67
|
|
79
|
+
"The toolhead moves above the purge chute", // 68
|
|
80
|
+
"Cooling down the nozzle", // 69
|
|
81
|
+
"The toolhead moves to the center of the heatbed", // 70
|
|
82
|
+
"Active Arc Fitting", // 71
|
|
83
|
+
"Hotend Type Detection", // 72
|
|
84
|
+
"Build plate alignment detection", // 73
|
|
85
|
+
"Heatbed surface foreign object detection", // 74
|
|
86
|
+
"Heatbed underside foreign object detection", // 75
|
|
87
|
+
"Pre-extrusion before printing", // 76
|
|
88
|
+
"Preparing AMS", // 77
|
|
89
|
+
];
|
package/dist/printers/bambu.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inspectPrintFile } from "../safety/print-file.js";
|
|
1
|
+
import { inspectPrintFile, type PrintFileInspection } from "../safety/print-file.js";
|
|
2
2
|
import { type PrinterStateRequirements } from "../safety/printer-state.js";
|
|
3
3
|
export declare function assertDirectPrintSupported(model: string | undefined, serial?: string): void;
|
|
4
4
|
interface BambuPrintOptionsInternal {
|
|
@@ -26,6 +26,27 @@ interface BambuPrintOptionsInternal {
|
|
|
26
26
|
amsSlots?: number[];
|
|
27
27
|
md5?: string;
|
|
28
28
|
}
|
|
29
|
+
/** A merged MQTT report and when it last arrived (ms since epoch). */
|
|
30
|
+
export type ProgressReport = {
|
|
31
|
+
raw: Record<string, any>;
|
|
32
|
+
receivedAt: number;
|
|
33
|
+
};
|
|
34
|
+
/** The inspected bytes and limits of a started job, for the resume prompt and byte check. */
|
|
35
|
+
export type CheckedFile = {
|
|
36
|
+
sha256: string;
|
|
37
|
+
/** A project's printed plate: its number and the SHA-256 of its Metadata/plate_<index>.gcode. */
|
|
38
|
+
plate?: {
|
|
39
|
+
index: number;
|
|
40
|
+
sha256: string;
|
|
41
|
+
};
|
|
42
|
+
model: string;
|
|
43
|
+
maxNozzleTemperature: number;
|
|
44
|
+
maxBedTemperature: number;
|
|
45
|
+
maxChamberTemperature: number;
|
|
46
|
+
materials: string[];
|
|
47
|
+
};
|
|
48
|
+
/** What a resume needs to know about a started file (filePath, the inspected snapshot): its bytes, printed plate, limits and used materials. */
|
|
49
|
+
export declare function checkedFile(inspection: PrintFileInspection, filePath: string): Promise<CheckedFile>;
|
|
29
50
|
export type PrintPreflight = {
|
|
30
51
|
finishedJob?: string;
|
|
31
52
|
serial: string;
|
|
@@ -40,10 +61,22 @@ export declare function cameraFrameParser(onFrame: (jpeg: Buffer) => void, onErr
|
|
|
40
61
|
export declare class BambuImplementation {
|
|
41
62
|
private readonly confirm?;
|
|
42
63
|
private printerStore;
|
|
64
|
+
/**
|
|
65
|
+
* The job each printer may resume, keyed host and serial. Cancel, a report
|
|
66
|
+
* that it ended after it was seen running, or another job seen in its place
|
|
67
|
+
* retires it, so a later job that reuses the name is never resumed.
|
|
68
|
+
*/
|
|
43
69
|
private checkedJobs;
|
|
70
|
+
/** In-flight counterpart_print_progress reads, one per printer. */
|
|
71
|
+
private progressReads;
|
|
44
72
|
private clearedErrors;
|
|
45
73
|
constructor(confirm?: ((message: string) => Promise<boolean>) | undefined);
|
|
46
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Ask a person through MCP elicitation. BAMBU_REQUIRE_CONFIRMATION=0 skips
|
|
76
|
+
* ordinary prompts; a physical check, or a prompt with requiredBecause (why
|
|
77
|
+
* this one cannot be skipped), always asks.
|
|
78
|
+
*/
|
|
79
|
+
confirmHardwareAction(message: string, physicalCheck?: boolean, requiredBecause?: string): Promise<void>;
|
|
47
80
|
private finishedJobIdentity;
|
|
48
81
|
/**
|
|
49
82
|
* Record the current job and notices during preflight so a changed printer state
|
|
@@ -53,12 +86,34 @@ export declare class BambuImplementation {
|
|
|
53
86
|
/** Stop a print whose confirmed situation changed: a newly finished job, or a hidden HMS notice the preflight did not name. */
|
|
54
87
|
assertPrintPreflight(status: any, preflight: PrintPreflight): void;
|
|
55
88
|
private getPrinter;
|
|
56
|
-
/**
|
|
57
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Internal handoff from a successful inspected transport; never exposed as
|
|
91
|
+
* an MCP tool. uploadedHere is false for the plug-in routes, where Bambu's
|
|
92
|
+
* plug-in or cloud put the file on the printer at a path this server has not
|
|
93
|
+
* verified: a resume then re-reads it if it can and otherwise matches the
|
|
94
|
+
* unique name, as KAN-216 does for firmware that cannot download a file.
|
|
95
|
+
*/
|
|
96
|
+
recordCheckedJob(host: string, serial: string, remotePath: string, requirements: PrinterStateRequirements, file: CheckedFile, uploadedHere?: boolean): void;
|
|
97
|
+
/** Feed one merged report to the resume record (internal; the client store calls it for every report). */
|
|
98
|
+
observeReport(host: string, serial: string, raw: Record<string, any> | undefined): void;
|
|
58
99
|
private validateLoadedGcodeState;
|
|
59
100
|
private resolveProjectFileMetadata;
|
|
60
101
|
/** Safety reads never use the display cache or configured-serial model inference. */
|
|
61
102
|
getSafetyStatus(host: string, serial: string, token: string): Promise<any>;
|
|
103
|
+
/**
|
|
104
|
+
* The merged MQTT report for counterpart_print_progress and when it arrived.
|
|
105
|
+
* On a held session it comes from the cache with no printer traffic. PushAll
|
|
106
|
+
* is sent only to fill a cold cache, or at most once per STALE_REPORT_MS when
|
|
107
|
+
* the printer has been quiet for longer than that (P1-series firmware lags
|
|
108
|
+
* when asked often). The whole read, connection and publish included, is
|
|
109
|
+
* bounded by timeoutMs: the MQTT connect to an unreachable printer keeps
|
|
110
|
+
* retrying, so it must not hold the call. Then the result is null, or a stale
|
|
111
|
+
* report that could not be refreshed in time. Display data only; safety
|
|
112
|
+
* checks use getSafetyStatus.
|
|
113
|
+
*/
|
|
114
|
+
readProgressReport(host: string, serial: string, token: string, timeoutMs?: number): Promise<ProgressReport | null>;
|
|
115
|
+
private firstProgressReport;
|
|
116
|
+
private refreshProgressReport;
|
|
62
117
|
getStatus(host: string, serial: string, token: string): Promise<any>;
|
|
63
118
|
print3mf(host: string, serial: string, token: string, options: BambuPrintOptionsInternal): Promise<any>;
|
|
64
119
|
private print3mfPrepared;
|
|
@@ -69,7 +124,22 @@ export declare class BambuImplementation {
|
|
|
69
124
|
/** Raw MQTT heater-off; switching off needs no material or model declaration. */
|
|
70
125
|
sendHeaterOffOverMqtt(host: string, serial: string, token: string, heater: "bed" | "nozzle", signal?: AbortSignal): Promise<any>;
|
|
71
126
|
pauseJob(host: string, serial: string, token: string, dispatch?: () => Promise<any>): Promise<any>;
|
|
127
|
+
/**
|
|
128
|
+
* Resume reheats and moves the printer, so it is gated like a print start:
|
|
129
|
+
* only the job this server inspected and started, while a fresh report shows
|
|
130
|
+
* it paused, with its bytes re-read over FTPS and compared, and after human
|
|
131
|
+
* confirmation (unless BAMBU_REQUIRE_CONFIRMATION=0). The record must still
|
|
132
|
+
* be current at every check, including the native helper's last one.
|
|
133
|
+
*/
|
|
72
134
|
resumeJob(host: string, serial: string, token: string, dispatch?: (assertActive: () => void, beforeDispatch: () => Promise<void>) => Promise<any>): Promise<any>;
|
|
135
|
+
/**
|
|
136
|
+
* Re-read a started job's bytes over FTPS: the uploaded file, else the plate
|
|
137
|
+
* G-code the printer extracted from the project to print it. The first file
|
|
138
|
+
* that can be read decides; a mismatch is reported as changed.
|
|
139
|
+
*/
|
|
140
|
+
private rereadJob;
|
|
141
|
+
/** SHA-256 of a printer file, streamed from an FTPS download into a private directory. */
|
|
142
|
+
private remoteSha256;
|
|
73
143
|
clearHmsErrors(host: string, serial: string, token: string, dispatch?: (assertActive: () => void, beforeDispatch: () => Promise<void>) => Promise<any>): Promise<any>;
|
|
74
144
|
setPrintSpeed(host: string, serial: string, token: string, speedMode: string | number): Promise<any>;
|
|
75
145
|
setAirductMode(host: string, serial: string, token: string, mode: string): Promise<any>;
|
|
@@ -123,6 +193,7 @@ export declare class BambuImplementation {
|
|
|
123
193
|
printRequested: boolean;
|
|
124
194
|
dispatch: "started" | "unconfirmed";
|
|
125
195
|
remotePath: string;
|
|
196
|
+
jobName: string;
|
|
126
197
|
message: string;
|
|
127
198
|
}>;
|
|
128
199
|
private printRawPrepared;
|
|
@@ -139,6 +210,7 @@ export declare class BambuImplementation {
|
|
|
139
210
|
printRequested: boolean;
|
|
140
211
|
dispatch: "started" | "unconfirmed";
|
|
141
212
|
remotePath: string;
|
|
213
|
+
jobName: string;
|
|
142
214
|
message: string;
|
|
143
215
|
}>;
|
|
144
216
|
private ftpDownload;
|