bambu-printer-mcp 1.1.55 → 1.1.56
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 +3 -1
- package/dist/index.js +3 -1
- package/dist/slicer/print-quality.d.ts +26 -0
- package/dist/slicer/print-quality.js +53 -0
- package/package.json +1 -1
- package/src/index.ts +3 -1
- package/src/slicer/print-quality.ts +55 -0
package/README.md
CHANGED
|
@@ -1197,6 +1197,8 @@ When `slicer_type` is `bambustudio` (the default), these additional parameters a
|
|
|
1197
1197
|
| `min_save` | boolean | Produce smaller output 3MF (faster uploads) |
|
|
1198
1198
|
| `skip_modified_gcodes` | boolean | Ignore stale custom gcodes in the 3MF |
|
|
1199
1199
|
| `slice_plate` | number | Which plate to slice (0 = all plates, default: 0) |
|
|
1200
|
+
| `quality` | string | `draft`, `standard` or `fine`: the server picks the layer height for the nozzle in use (0.28 and 0.12 mm on 0.4 mm; standard keeps the preset) |
|
|
1201
|
+
| `strength` | string | `standard`, `strong` or `max`: the server picks walls and infill (4 walls at 25%, 6 at 40%; standard keeps the preset) |
|
|
1200
1202
|
| `layer_height` | number | Layer height in mm, such as 0.28, 0.2 or 0.12; at most the nozzle diameter |
|
|
1201
1203
|
| `wall_loops` | integer | Number of walls, 0 to 1000 |
|
|
1202
1204
|
| `sparse_infill_density` | string | Sparse infill density, such as `"15%"` |
|
|
@@ -1204,7 +1206,7 @@ When `slicer_type` is `bambustudio` (the default), these additional parameters a
|
|
|
1204
1206
|
| `support_type` | string | `normal(auto)`, `tree(auto)`, `normal(manual)` or `tree(manual)` |
|
|
1205
1207
|
| `support_threshold_angle` | integer | Overhang threshold for automatic supports, 0 to 90 degrees (0 lets the slicer decide) |
|
|
1206
1208
|
|
|
1207
|
-
`layer_height`, `wall_loops`, `sparse_infill_density` and the three support arguments are written as a process override on top of the machine and process preset the tool resolves, using Bambu Studio's keys and string forms (`"0.2"`, `"2"`, `"15%"`). Every other preset value, and the machine preset, stay as resolved, and your own profile files are not changed. They work with every Bambu-compatible slicer, including remote `orca-slicer-api` slicing, and are refused for PrusaSlicer, Slic3r and Cura.
|
|
1209
|
+
`quality` and `strength` let a client send the person's choice without slicer numbers; an explicit `layer_height`, `wall_loops` or `sparse_infill_density` wins over them. `layer_height`, `wall_loops`, `sparse_infill_density` and the three support arguments are written as a process override on top of the machine and process preset the tool resolves, using Bambu Studio's keys and string forms (`"0.2"`, `"2"`, `"15%"`). Every other preset value, and the machine preset, stay as resolved, and your own profile files are not changed. They work with every Bambu-compatible slicer, including remote `orca-slicer-api` slicing, and are refused for PrusaSlicer, Slic3r and Cura.
|
|
1208
1210
|
|
|
1209
1211
|
**Example: Slice with auto-orient and 3 copies**
|
|
1210
1212
|
```json
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
|
|
|
33
33
|
import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
|
|
34
34
|
import { MAKE_3MF_OUTPUT_SCHEMA, PRINT_PROGRESS_OUTPUT_SCHEMA, PRINTER_INFO_OUTPUT_SCHEMA } from "./counterpart/schemas.js";
|
|
35
35
|
import { parseProcessOverrides } from "./slicer/process-overrides.js";
|
|
36
|
+
import { PRINT_QUALITY_PROPERTIES, withPrintQuality } from "./slicer/print-quality.js";
|
|
36
37
|
import { machinePauseGcode, parsePauseLayers, pausedLayers, readPlateGcode } from "./slicer/layer-pauses.js";
|
|
37
38
|
dotenv.config();
|
|
38
39
|
const DEFAULT_HOST = process.env.BAMBU_PRINTER_HOST || process.env.PRINTER_HOST || "localhost";
|
|
@@ -2135,6 +2136,7 @@ class BambuPrinterMCPServer {
|
|
|
2135
2136
|
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." },
|
|
2136
2137
|
pause_at_layers: { type: "array", items: { type: "integer", minimum: 2 }, description: "Pause before each of these layers (1-based, as Bambu Studio and OrcaSlicer number them in the preview), for example to drop in magnets or nuts. The slicer writes the printer's own pause G-code there (M400 U1 on Bambu printers); the printer stops by itself and waits for Resume. Bambu Studio or OrcaSlicer CLI only. Pauses already in a project 3MF are kept." },
|
|
2137
2138
|
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." },
|
|
2139
|
+
...PRINT_QUALITY_PROPERTIES,
|
|
2138
2140
|
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." },
|
|
2139
2141
|
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." },
|
|
2140
2142
|
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." },
|
|
@@ -3719,7 +3721,7 @@ class BambuPrinterMCPServer {
|
|
|
3719
3721
|
if (pauses)
|
|
3720
3722
|
sliceBambuOptions.pauseAtLayers = pauses;
|
|
3721
3723
|
}
|
|
3722
|
-
const processOverrides = parseProcessOverrides(args, Number(nozzleDiam));
|
|
3724
|
+
const processOverrides = parseProcessOverrides(withPrintQuality(args, Number(nozzleDiam)), Number(nozzleDiam));
|
|
3723
3725
|
if (processOverrides)
|
|
3724
3726
|
sliceBambuOptions.processOverrides = processOverrides;
|
|
3725
3727
|
if (sliceBambuOptions.loadFilamentIds && String(args.stl_path).toLowerCase().endsWith(".3mf")) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* slice_stl's `quality` and `strength` (PRD §8.4): a client's print-sheet choice, mapped here to the
|
|
3
|
+
* slicer's own numbers so no client carries layer heights, wall counts or infill. Draft and Fine set
|
|
4
|
+
* the layer height for the nozzle in use (0.28 and 0.12 mm on a 0.4 mm nozzle, scaled with it); Strong
|
|
5
|
+
* and Max set walls and infill. Standard sends nothing: the resolved preset decides. An explicit
|
|
6
|
+
* layer_height, wall_loops or sparse_infill_density in the same call wins over these.
|
|
7
|
+
*/
|
|
8
|
+
export declare const PRINT_QUALITIES: readonly ["draft", "standard", "fine"];
|
|
9
|
+
export declare const PRINT_STRENGTHS: readonly ["standard", "strong", "max"];
|
|
10
|
+
export type PrintQuality = (typeof PRINT_QUALITIES)[number];
|
|
11
|
+
export type PrintStrength = (typeof PRINT_STRENGTHS)[number];
|
|
12
|
+
/** The call's arguments with `quality` and `strength` written out as slicer settings. */
|
|
13
|
+
export declare function withPrintQuality(args: Record<string, unknown>, nozzleDiameter?: number): Record<string, unknown>;
|
|
14
|
+
/** slice_stl input-schema properties for both arguments. */
|
|
15
|
+
export declare const PRINT_QUALITY_PROPERTIES: {
|
|
16
|
+
readonly quality: {
|
|
17
|
+
readonly type: "string";
|
|
18
|
+
readonly enum: readonly ["draft", "standard", "fine"];
|
|
19
|
+
readonly description: "Print quality: draft (thicker layers, faster), standard (the preset's own layer height) or fine (thinner layers). The server picks the layer height for the nozzle in use; an explicit layer_height wins.";
|
|
20
|
+
};
|
|
21
|
+
readonly strength: {
|
|
22
|
+
readonly type: "string";
|
|
23
|
+
readonly enum: readonly ["standard", "strong", "max"];
|
|
24
|
+
readonly description: "Part strength: standard (the preset's walls and infill), strong or max (more walls and denser infill). The server picks the values; explicit wall_loops or sparse_infill_density win.";
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* slice_stl's `quality` and `strength` (PRD §8.4): a client's print-sheet choice, mapped here to the
|
|
3
|
+
* slicer's own numbers so no client carries layer heights, wall counts or infill. Draft and Fine set
|
|
4
|
+
* the layer height for the nozzle in use (0.28 and 0.12 mm on a 0.4 mm nozzle, scaled with it); Strong
|
|
5
|
+
* and Max set walls and infill. Standard sends nothing: the resolved preset decides. An explicit
|
|
6
|
+
* layer_height, wall_loops or sparse_infill_density in the same call wins over these.
|
|
7
|
+
*/
|
|
8
|
+
export const PRINT_QUALITIES = ["draft", "standard", "fine"];
|
|
9
|
+
export const PRINT_STRENGTHS = ["standard", "strong", "max"];
|
|
10
|
+
/** Layer heights on the reference 0.4 mm nozzle; other nozzles scale from it. */
|
|
11
|
+
const REFERENCE_NOZZLE_MM = 0.4;
|
|
12
|
+
const LAYER_MM_ON_REFERENCE = { draft: 0.28, fine: 0.12 };
|
|
13
|
+
const STRENGTH = {
|
|
14
|
+
strong: { wall_loops: 4, sparse_infill_density: "25%" },
|
|
15
|
+
max: { wall_loops: 6, sparse_infill_density: "40%" },
|
|
16
|
+
};
|
|
17
|
+
/** The call's arguments with `quality` and `strength` written out as slicer settings. */
|
|
18
|
+
export function withPrintQuality(args, nozzleDiameter) {
|
|
19
|
+
if (args.quality === undefined && args.strength === undefined)
|
|
20
|
+
return args;
|
|
21
|
+
const quality = args.quality === undefined ? "standard" : args.quality;
|
|
22
|
+
const strength = args.strength === undefined ? "standard" : args.strength;
|
|
23
|
+
if (typeof quality !== "string" || !PRINT_QUALITIES.includes(quality)) {
|
|
24
|
+
throw new Error(`quality must be one of ${PRINT_QUALITIES.join(", ")}.`);
|
|
25
|
+
}
|
|
26
|
+
if (typeof strength !== "string" || !PRINT_STRENGTHS.includes(strength)) {
|
|
27
|
+
throw new Error(`strength must be one of ${PRINT_STRENGTHS.join(", ")}.`);
|
|
28
|
+
}
|
|
29
|
+
const out = { ...args };
|
|
30
|
+
const scale = typeof nozzleDiameter === "number" && Number.isFinite(nozzleDiameter) && nozzleDiameter > 0 ? nozzleDiameter / REFERENCE_NOZZLE_MM : 1;
|
|
31
|
+
const layer = LAYER_MM_ON_REFERENCE[quality];
|
|
32
|
+
if (layer !== undefined && out.layer_height === undefined)
|
|
33
|
+
out.layer_height = Math.round(layer * scale * 100) / 100;
|
|
34
|
+
const walls = STRENGTH[strength];
|
|
35
|
+
if (walls) {
|
|
36
|
+
if (out.wall_loops === undefined)
|
|
37
|
+
out.wall_loops = walls.wall_loops;
|
|
38
|
+
if (out.sparse_infill_density === undefined)
|
|
39
|
+
out.sparse_infill_density = walls.sparse_infill_density;
|
|
40
|
+
}
|
|
41
|
+
return out;
|
|
42
|
+
}
|
|
43
|
+
/** slice_stl input-schema properties for both arguments. */
|
|
44
|
+
export const PRINT_QUALITY_PROPERTIES = {
|
|
45
|
+
quality: {
|
|
46
|
+
type: "string", enum: [...PRINT_QUALITIES],
|
|
47
|
+
description: "Print quality: draft (thicker layers, faster), standard (the preset's own layer height) or fine (thinner layers). The server picks the layer height for the nozzle in use; an explicit layer_height wins.",
|
|
48
|
+
},
|
|
49
|
+
strength: {
|
|
50
|
+
type: "string", enum: [...PRINT_STRENGTHS],
|
|
51
|
+
description: "Part strength: standard (the preset's walls and infill), strong or max (more walls and denser infill). The server picks the values; explicit wall_loops or sparse_infill_density win.",
|
|
52
|
+
},
|
|
53
|
+
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -63,6 +63,7 @@ import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
|
|
|
63
63
|
import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
|
|
64
64
|
import { MAKE_3MF_OUTPUT_SCHEMA, PRINT_PROGRESS_OUTPUT_SCHEMA, PRINTER_INFO_OUTPUT_SCHEMA } from "./counterpart/schemas.js";
|
|
65
65
|
import { parseProcessOverrides } from "./slicer/process-overrides.js";
|
|
66
|
+
import { PRINT_QUALITY_PROPERTIES, withPrintQuality } from "./slicer/print-quality.js";
|
|
66
67
|
import { machinePauseGcode, parsePauseLayers, pausedLayers, readPlateGcode } from "./slicer/layer-pauses.js";
|
|
67
68
|
|
|
68
69
|
dotenv.config();
|
|
@@ -2667,6 +2668,7 @@ class BambuPrinterMCPServer {
|
|
|
2667
2668
|
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." },
|
|
2668
2669
|
pause_at_layers: { type: "array", items: { type: "integer", minimum: 2 }, description: "Pause before each of these layers (1-based, as Bambu Studio and OrcaSlicer number them in the preview), for example to drop in magnets or nuts. The slicer writes the printer's own pause G-code there (M400 U1 on Bambu printers); the printer stops by itself and waits for Resume. Bambu Studio or OrcaSlicer CLI only. Pauses already in a project 3MF are kept." },
|
|
2669
2670
|
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." },
|
|
2671
|
+
...PRINT_QUALITY_PROPERTIES,
|
|
2670
2672
|
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." },
|
|
2671
2673
|
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." },
|
|
2672
2674
|
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." },
|
|
@@ -4359,7 +4361,7 @@ class BambuPrinterMCPServer {
|
|
|
4359
4361
|
if (args?.skip_modified_gcodes !== undefined) sliceBambuOptions.skipModifiedGcodes = Boolean(args.skip_modified_gcodes);
|
|
4360
4362
|
if (args?.slice_plate !== undefined) sliceBambuOptions.slicePlate = Number(args.slice_plate);
|
|
4361
4363
|
{ const pauses = parsePauseLayers(args?.pause_at_layers); if (pauses) sliceBambuOptions.pauseAtLayers = pauses; }
|
|
4362
|
-
const processOverrides = parseProcessOverrides(args as Record<string, unknown>, Number(nozzleDiam));
|
|
4364
|
+
const processOverrides = parseProcessOverrides(withPrintQuality(args as Record<string, unknown>, Number(nozzleDiam)), Number(nozzleDiam));
|
|
4363
4365
|
if (processOverrides) sliceBambuOptions.processOverrides = processOverrides;
|
|
4364
4366
|
if (sliceBambuOptions.loadFilamentIds && String(args.stl_path).toLowerCase().endsWith(".3mf")) {
|
|
4365
4367
|
// Bambu Studio's CLI refuses --load-filament-ids for 3MF input and counts it per input file.
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* slice_stl's `quality` and `strength` (PRD §8.4): a client's print-sheet choice, mapped here to the
|
|
3
|
+
* slicer's own numbers so no client carries layer heights, wall counts or infill. Draft and Fine set
|
|
4
|
+
* the layer height for the nozzle in use (0.28 and 0.12 mm on a 0.4 mm nozzle, scaled with it); Strong
|
|
5
|
+
* and Max set walls and infill. Standard sends nothing: the resolved preset decides. An explicit
|
|
6
|
+
* layer_height, wall_loops or sparse_infill_density in the same call wins over these.
|
|
7
|
+
*/
|
|
8
|
+
export const PRINT_QUALITIES = ["draft", "standard", "fine"] as const;
|
|
9
|
+
export const PRINT_STRENGTHS = ["standard", "strong", "max"] as const;
|
|
10
|
+
|
|
11
|
+
export type PrintQuality = (typeof PRINT_QUALITIES)[number];
|
|
12
|
+
export type PrintStrength = (typeof PRINT_STRENGTHS)[number];
|
|
13
|
+
|
|
14
|
+
/** Layer heights on the reference 0.4 mm nozzle; other nozzles scale from it. */
|
|
15
|
+
const REFERENCE_NOZZLE_MM = 0.4;
|
|
16
|
+
const LAYER_MM_ON_REFERENCE: Partial<Record<PrintQuality, number>> = { draft: 0.28, fine: 0.12 };
|
|
17
|
+
const STRENGTH: Partial<Record<PrintStrength, { wall_loops: number; sparse_infill_density: string }>> = {
|
|
18
|
+
strong: { wall_loops: 4, sparse_infill_density: "25%" },
|
|
19
|
+
max: { wall_loops: 6, sparse_infill_density: "40%" },
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/** The call's arguments with `quality` and `strength` written out as slicer settings. */
|
|
23
|
+
export function withPrintQuality(args: Record<string, unknown>, nozzleDiameter?: number): Record<string, unknown> {
|
|
24
|
+
if (args.quality === undefined && args.strength === undefined) return args;
|
|
25
|
+
const quality = args.quality === undefined ? "standard" : args.quality;
|
|
26
|
+
const strength = args.strength === undefined ? "standard" : args.strength;
|
|
27
|
+
if (typeof quality !== "string" || !(PRINT_QUALITIES as readonly string[]).includes(quality)) {
|
|
28
|
+
throw new Error(`quality must be one of ${PRINT_QUALITIES.join(", ")}.`);
|
|
29
|
+
}
|
|
30
|
+
if (typeof strength !== "string" || !(PRINT_STRENGTHS as readonly string[]).includes(strength)) {
|
|
31
|
+
throw new Error(`strength must be one of ${PRINT_STRENGTHS.join(", ")}.`);
|
|
32
|
+
}
|
|
33
|
+
const out: Record<string, unknown> = { ...args };
|
|
34
|
+
const scale = typeof nozzleDiameter === "number" && Number.isFinite(nozzleDiameter) && nozzleDiameter > 0 ? nozzleDiameter / REFERENCE_NOZZLE_MM : 1;
|
|
35
|
+
const layer = LAYER_MM_ON_REFERENCE[quality as PrintQuality];
|
|
36
|
+
if (layer !== undefined && out.layer_height === undefined) out.layer_height = Math.round(layer * scale * 100) / 100;
|
|
37
|
+
const walls = STRENGTH[strength as PrintStrength];
|
|
38
|
+
if (walls) {
|
|
39
|
+
if (out.wall_loops === undefined) out.wall_loops = walls.wall_loops;
|
|
40
|
+
if (out.sparse_infill_density === undefined) out.sparse_infill_density = walls.sparse_infill_density;
|
|
41
|
+
}
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** slice_stl input-schema properties for both arguments. */
|
|
46
|
+
export const PRINT_QUALITY_PROPERTIES = {
|
|
47
|
+
quality: {
|
|
48
|
+
type: "string", enum: [...PRINT_QUALITIES],
|
|
49
|
+
description: "Print quality: draft (thicker layers, faster), standard (the preset's own layer height) or fine (thinner layers). The server picks the layer height for the nozzle in use; an explicit layer_height wins.",
|
|
50
|
+
},
|
|
51
|
+
strength: {
|
|
52
|
+
type: "string", enum: [...PRINT_STRENGTHS],
|
|
53
|
+
description: "Part strength: standard (the preset's walls and infill), strong or max (more walls and denser infill). The server picks the values; explicit wall_loops or sparse_infill_density win.",
|
|
54
|
+
},
|
|
55
|
+
} as const;
|