bambu-printer-mcp 1.1.57 → 1.1.59
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 +2 -2
- package/dist/3mf_parser.d.ts +2 -0
- package/dist/3mf_parser.js +18 -1
- package/dist/counterpart/info.d.ts +12 -0
- package/dist/counterpart/info.js +15 -0
- package/dist/counterpart/schemas.d.ts +21 -0
- package/dist/counterpart/schemas.js +5 -0
- package/dist/index.js +36 -7
- package/dist/slicer/print-quality.d.ts +5 -3
- package/dist/slicer/print-quality.js +7 -5
- package/dist/slicer/process-overrides.d.ts +3 -1
- package/dist/slicer/process-overrides.js +18 -1
- package/package.json +1 -1
- package/src/3mf_parser.ts +17 -1
- package/src/counterpart/info.ts +16 -1
- package/src/counterpart/schemas.ts +7 -0
- package/src/index.ts +46 -16
- package/src/slicer/print-quality.ts +7 -5
- package/src/slicer/process-overrides.ts +16 -2
package/README.md
CHANGED
|
@@ -1075,7 +1075,7 @@ If the project does not match those assumptions, the tool fails fast with a stru
|
|
|
1075
1075
|
|
|
1076
1076
|
#### Counterpart tools (`counterpart/1`)
|
|
1077
1077
|
|
|
1078
|
-
[Counterpart](https://github.com/DMontgomery40/scan-to-make) (Scan to Make) reads printers through a small contract that this server and [mcp-3D-printer-server](https://github.com/DMontgomery40/mcp-3D-printer-server) share. Each tool declares an `outputSchema` and returns `structuredContent`, plus the same JSON as text for older clients. An error is returned as text only, because MCP clients check `structuredContent` against the schema even on errors. Other tools return an error's details in `structuredContent` (`status`, `retryable`, `suggestion`, `message`). When the printer refuses a print,
|
|
1078
|
+
[Counterpart](https://github.com/DMontgomery40/scan-to-make) (Scan to Make) reads printers through a small contract that this server and [mcp-3D-printer-server](https://github.com/DMontgomery40/mcp-3D-printer-server) share. Each tool declares an `outputSchema` and returns `structuredContent`, plus the same JSON as text for older clients. An error is returned as text only, because MCP clients check `structuredContent` against the schema even on errors. Other tools return an error's details in `structuredContent` (`status`, `retryable`, `suggestion`, `message`). When the printer refuses a print, the error also carries a stable `code`, either `printer-command-rejected` or `printer-not-ready`, so a client can act on the code rather than the wording. `counterpart_printer_info` reports `capabilities.slicing` (`supports`, `copies`, `orient`), so a client can offer those choices without knowing the slicer. `counterpart_printer_info` and `counterpart_print_progress` take the usual optional `host`, `bambu_serial`, `bambu_token` and `bambu_model` (default `BAMBU_MODEL`) arguments.
|
|
1079
1079
|
|
|
1080
1080
|
- **`counterpart_printer_info`** returns `{contract, server: {name, version}, printer: {kind: "bambu", model, serial, host}, capabilities}`. `capabilities` lists progress, layers, the camera transport (`bambu-tcp` for A1/P1, `rtsp` for X1, P2S, H2 and X2D, `none` without a model), `cameraStream: true` for supported camera models, `filaments: "ams"`, pause, resume, cancel, `print3mf` and `gcode` (false on X2D). It sends nothing to the printer and never returns the access code.
|
|
1081
1081
|
- **`counterpart_print_route`** reads or changes how prints and Stop/Pause/Resume reach the printer: `{route, mode, type, choices, savedTo}`, where `route` is `lan` (the local network, in the configured `BAMBU_DEFAULT_CONNECTION_MODE`) or `cloud` (Bambu Cloud through the [FULU bridge](docs/FULU.md)). Pass `route` to change it; the next print and control use it at once, and it is written to the `.env` in the server's working directory when one exists (`savedTo`, otherwise `null`). It is not part of the shared contract: it has no `outputSchema`, and mcp-3D-printer-server has no Bambu Cloud route.
|
|
@@ -1198,7 +1198,7 @@ When `slicer_type` is `bambustudio` (the default), these additional parameters a
|
|
|
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
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
|
|
1201
|
+
| `strength` | string | `standard`, `strong` or `max`: the server picks walls and infill (at least 4 walls and 25%, or 6 and 40%; a process that already has more keeps it; standard keeps the process as it is) |
|
|
1202
1202
|
| `layer_height` | number | Layer height in mm, such as 0.28, 0.2 or 0.12; at most the nozzle diameter |
|
|
1203
1203
|
| `wall_loops` | integer | Number of walls, 0 to 1000 |
|
|
1204
1204
|
| `sparse_infill_density` | string | Sparse infill density, such as `"15%"` |
|
package/dist/3mf_parser.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ThreeMFData, CollarCharmAnalysis, ThreeMFAmsRequirements, ThreeMFPlateObjects } from './types.js';
|
|
2
2
|
export { ThreeMFData };
|
|
3
3
|
export declare function parse3MF(filePath: string): Promise<ThreeMFData>;
|
|
4
|
+
/** Whether a 3MF carries its own Bambu Studio/Orca process (a designer's project, not a bare mesh archive). */
|
|
5
|
+
export declare function hasBambuProjectSettings(filePath: string): Promise<boolean>;
|
|
4
6
|
export declare function extractBambuTemplateSettings(filePath: string, outputDir: string): Promise<string>;
|
|
5
7
|
export declare function analyzeCollarCharm3MF(filePath: string, plateIndex?: number): Promise<CollarCharmAnalysis>;
|
|
6
8
|
export declare function getCollarCharmRolePolicy(): {
|
package/dist/3mf_parser.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import JSZip from 'jszip';
|
|
2
2
|
import { parseStringPromise } from 'xml2js';
|
|
3
3
|
import * as fs from 'fs/promises';
|
|
4
|
+
import { createHash } from 'crypto';
|
|
4
5
|
// Parses Bambu Studio's JSON config data
|
|
5
6
|
function parseBambuJSONConfig(jsonData) {
|
|
6
7
|
const config = {};
|
|
@@ -219,6 +220,20 @@ export async function parse3MF(filePath) {
|
|
|
219
220
|
throw new Error(`Failed to parse 3MF file: ${error.message}`);
|
|
220
221
|
}
|
|
221
222
|
}
|
|
223
|
+
/** Whether a 3MF carries its own Bambu Studio/Orca process (a designer's project, not a bare mesh archive). */
|
|
224
|
+
export async function hasBambuProjectSettings(filePath) {
|
|
225
|
+
try {
|
|
226
|
+
const zip = await JSZip.loadAsync(await fs.readFile(filePath));
|
|
227
|
+
const settings = zip.file('Metadata/project_settings.config');
|
|
228
|
+
if (!settings)
|
|
229
|
+
return false;
|
|
230
|
+
const parsed = JSON.parse(await settings.async('string'));
|
|
231
|
+
return !!parsed && typeof parsed === 'object' && !Array.isArray(parsed) && parsed.layer_height !== undefined;
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
222
237
|
export async function extractBambuTemplateSettings(filePath, outputDir) {
|
|
223
238
|
const data = await fs.readFile(filePath);
|
|
224
239
|
const zip = await JSZip.loadAsync(data);
|
|
@@ -233,7 +248,9 @@ export async function extractBambuTemplateSettings(filePath, outputDir) {
|
|
|
233
248
|
if (!file)
|
|
234
249
|
continue;
|
|
235
250
|
const content = await file.async('string');
|
|
236
|
-
|
|
251
|
+
// Named by content, so two projects sliced at once never share (or overwrite) one settings file.
|
|
252
|
+
const digest = createHash('sha256').update(content).digest('hex').slice(0, 16);
|
|
253
|
+
const outputPath = `${outputDir}/${digest}_${name.replace(/\//g, '_')}`;
|
|
237
254
|
await fs.writeFile(outputPath, content, 'utf8');
|
|
238
255
|
return outputPath;
|
|
239
256
|
}
|
|
@@ -1,4 +1,15 @@
|
|
|
1
1
|
import { type PrinterInfo } from "./schemas.js";
|
|
2
|
+
/** Backends that slice through the Bambu Studio / OrcaSlicer CLI, where supports, copies and auto-orient all apply. */
|
|
3
|
+
export declare const BAMBU_CLI_SLICERS: readonly ["bambustudio", "orcaslicer", "orcaslicer-bambulab"];
|
|
4
|
+
/**
|
|
5
|
+
* What slice_stl applies on each backend: the Bambu Studio / OrcaSlicer CLIs take all three; remote orca-slicer-api
|
|
6
|
+
* takes supports and orient but refuses repetitions; PrusaSlicer, Slic3r and Cura take none of them here.
|
|
7
|
+
*/
|
|
8
|
+
export declare function bambuSliceCapabilities(slicerType: string | undefined): {
|
|
9
|
+
supports: boolean;
|
|
10
|
+
copies: boolean;
|
|
11
|
+
orient: boolean;
|
|
12
|
+
};
|
|
2
13
|
export declare function bambuPrinterInfo(options: {
|
|
3
14
|
server: {
|
|
4
15
|
name: string;
|
|
@@ -7,4 +18,5 @@ export declare function bambuPrinterInfo(options: {
|
|
|
7
18
|
host: string;
|
|
8
19
|
serial?: string;
|
|
9
20
|
model?: string;
|
|
21
|
+
slicerType?: string;
|
|
10
22
|
}): PrinterInfo;
|
package/dist/counterpart/info.js
CHANGED
|
@@ -5,6 +5,19 @@ import { SERIAL_MODELS } from "../safety/printer-state.js";
|
|
|
5
5
|
import { COUNTERPART_CONTRACT } from "./schemas.js";
|
|
6
6
|
/** Bambu's display names ("P1S", "A1 Mini", "H2D Pro"), keyed by normalized model. */
|
|
7
7
|
const DISPLAY_NAMES = new Map(Object.values(SERIAL_MODELS).map(name => [normalizeModel(name), name]));
|
|
8
|
+
/** Backends that slice through the Bambu Studio / OrcaSlicer CLI, where supports, copies and auto-orient all apply. */
|
|
9
|
+
export const BAMBU_CLI_SLICERS = ["bambustudio", "orcaslicer", "orcaslicer-bambulab"];
|
|
10
|
+
/**
|
|
11
|
+
* What slice_stl applies on each backend: the Bambu Studio / OrcaSlicer CLIs take all three; remote orca-slicer-api
|
|
12
|
+
* takes supports and orient but refuses repetitions; PrusaSlicer, Slic3r and Cura take none of them here.
|
|
13
|
+
*/
|
|
14
|
+
export function bambuSliceCapabilities(slicerType) {
|
|
15
|
+
if (slicerType === undefined || BAMBU_CLI_SLICERS.includes(slicerType))
|
|
16
|
+
return { supports: true, copies: true, orient: true };
|
|
17
|
+
if (slicerType === "orca-slicer-api")
|
|
18
|
+
return { supports: true, copies: false, orient: true };
|
|
19
|
+
return { supports: false, copies: false, orient: false };
|
|
20
|
+
}
|
|
8
21
|
export function bambuPrinterInfo(options) {
|
|
9
22
|
const model = normalizeModel(options.model);
|
|
10
23
|
const serial = options.serial?.trim();
|
|
@@ -30,6 +43,8 @@ export function bambuPrinterInfo(options) {
|
|
|
30
43
|
print3mf: true,
|
|
31
44
|
// X2D jobs go through its native route; FTPS/remote-file G-code starts stay blocked there.
|
|
32
45
|
gcode: model !== "x2d",
|
|
46
|
+
// From the configured slicer backend, as slice_stl uses it (remote orca-slicer-api makes no copies).
|
|
47
|
+
slicing: bambuSliceCapabilities(options.slicerType),
|
|
33
48
|
},
|
|
34
49
|
};
|
|
35
50
|
}
|
|
@@ -70,6 +70,12 @@ export type PrinterInfo = {
|
|
|
70
70
|
cancel: boolean;
|
|
71
71
|
print3mf: boolean;
|
|
72
72
|
gcode: boolean;
|
|
73
|
+
/** What slice_stl can apply with this server's slicer (the same field in mcp-3D-printer-server). */
|
|
74
|
+
slicing?: {
|
|
75
|
+
supports: boolean;
|
|
76
|
+
copies: boolean;
|
|
77
|
+
orient: boolean;
|
|
78
|
+
};
|
|
73
79
|
};
|
|
74
80
|
};
|
|
75
81
|
export declare const PRINTER_INFO_OUTPUT_SCHEMA: {
|
|
@@ -148,6 +154,21 @@ export declare const PRINTER_INFO_OUTPUT_SCHEMA: {
|
|
|
148
154
|
gcode: {
|
|
149
155
|
type: string;
|
|
150
156
|
};
|
|
157
|
+
slicing: {
|
|
158
|
+
type: string;
|
|
159
|
+
required: string[];
|
|
160
|
+
properties: {
|
|
161
|
+
supports: {
|
|
162
|
+
type: string;
|
|
163
|
+
};
|
|
164
|
+
copies: {
|
|
165
|
+
type: string;
|
|
166
|
+
};
|
|
167
|
+
orient: {
|
|
168
|
+
type: string;
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
};
|
|
151
172
|
};
|
|
152
173
|
required: string[];
|
|
153
174
|
};
|
|
@@ -46,6 +46,11 @@ export const PRINTER_INFO_OUTPUT_SCHEMA = {
|
|
|
46
46
|
cancel: { type: "boolean" },
|
|
47
47
|
print3mf: { type: "boolean" },
|
|
48
48
|
gcode: { type: "boolean" },
|
|
49
|
+
slicing: {
|
|
50
|
+
type: "object",
|
|
51
|
+
required: ["supports", "copies", "orient"],
|
|
52
|
+
properties: { supports: { type: "boolean" }, copies: { type: "boolean" }, orient: { type: "boolean" } },
|
|
53
|
+
},
|
|
49
54
|
},
|
|
50
55
|
required: ["progress", "layers", "camera", "filaments", "pause", "resume", "cancel", "print3mf", "gcode"],
|
|
51
56
|
},
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ import { importFileViaBambuConnect } from "./bambu-connect.js";
|
|
|
19
19
|
import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
|
|
20
20
|
import { FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFAULT_ARGS, FUSION_NEW_DESIGN_OUTPUT_SCHEMA, FUSION_STATUS_OUTPUT_SCHEMA, FusionMcpBridge } from "./fusion-mcp-bridge.js";
|
|
21
21
|
import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, hasAmsMappingInput, normalizeAmsMappingObject, normalizeBridgeAmsTrayValue, studioAmsMappingInfo, trayColour } from "./ams-mapping.js";
|
|
22
|
-
import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, parse3MF } from './3mf_parser.js';
|
|
22
|
+
import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, hasBambuProjectSettings, parse3MF } from './3mf_parser.js';
|
|
23
23
|
import { BambuImplementation, assertDirectPrintSupported, checkedFile, defaultResumeStateDir } from "./printers/bambu.js";
|
|
24
24
|
import { resolveStudioPrintOptions, usedNozzleCount } from "./studio-print-options.js";
|
|
25
25
|
import { inspectPrintFile } from "./safety/print-file.js";
|
|
@@ -27,7 +27,7 @@ import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./saf
|
|
|
27
27
|
import { isDualNozzleModel } from "./safety/limits.js";
|
|
28
28
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName } from "./safety/artifact.js";
|
|
29
29
|
import { detectProfilesRoot } from "./slicer/profile-flatten.js";
|
|
30
|
-
import { bambuPrinterInfo } from "./counterpart/info.js";
|
|
30
|
+
import { bambuPrinterInfo, bambuSliceCapabilities } from "./counterpart/info.js";
|
|
31
31
|
import { DESIGN_PROMPTS, FDM_CAPABILITY_GUIDANCE, FDM_CAPABILITY_RESOURCE, FDM_CAPABILITY_URI, SERVER_INSTRUCTIONS } from "./design-guidance.js";
|
|
32
32
|
import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
|
|
33
33
|
import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
|
|
@@ -708,6 +708,20 @@ async function resolveTemplateSlicerProfilePath(templatePath, tempDir) {
|
|
|
708
708
|
function hasExplicitSlicerProfile(args) {
|
|
709
709
|
return typeof args?.slicer_profile === "string" && args.slicer_profile.trim().length > 0;
|
|
710
710
|
}
|
|
711
|
+
/**
|
|
712
|
+
* A 3MF that carries its own process (a designer's project) as its slicing template, when the call names
|
|
713
|
+
* no profile or template of its own. A configured default profile or template must not replace the
|
|
714
|
+
* designer's layer height, walls and infill; the machine still comes from the chosen printer preset.
|
|
715
|
+
*/
|
|
716
|
+
/** The template this call names: template_name (resolved by the caller) or template_3mf_path. */
|
|
717
|
+
function namedTemplatePath(args, fromName) {
|
|
718
|
+
return fromName || (typeof args?.template_3mf_path === "string" && args.template_3mf_path.trim() ? String(args.template_3mf_path) : undefined);
|
|
719
|
+
}
|
|
720
|
+
async function ownProcessTemplate(args, modelPath, requestedTemplatePath) {
|
|
721
|
+
if (hasExplicitSlicerProfile(args) || requestedTemplatePath || !modelPath.toLowerCase().endsWith(".3mf"))
|
|
722
|
+
return undefined;
|
|
723
|
+
return await hasBambuProjectSettings(modelPath) ? modelPath : undefined;
|
|
724
|
+
}
|
|
711
725
|
async function resolveTemplateFirstSlicerProfilePath(args, configuredProfile, template3mfPath, tempDir) {
|
|
712
726
|
if (hasExplicitSlicerProfile(args)) {
|
|
713
727
|
return configuredProfile || undefined;
|
|
@@ -1167,7 +1181,9 @@ class BambuPrinterMCPServer {
|
|
|
1167
1181
|
nozzleType: resolveNozzleType(args?.nozzle_type),
|
|
1168
1182
|
nozzleVolumeType: resolveNozzleVolumeType(args?.nozzle_volume_type),
|
|
1169
1183
|
};
|
|
1170
|
-
|
|
1184
|
+
// A designer's project slices with its own process here too, as slice_stl and the LAN route do.
|
|
1185
|
+
const ownProcess = await ownProcessTemplate(args, threeMFPath, namedTemplatePath(args, typeof args?.template_name === "string" && args.template_name.trim() ? String(args.template_name) : undefined));
|
|
1186
|
+
threeMFPath = await this.stlManipulator.sliceSTL(threeMFPath, slicerType, slicerPath, ownProcess ? await resolveTemplateSlicerProfilePath(ownProcess, TEMP_DIR) : slicerProfile || undefined, undefined, printPreset, autoSliceOptions);
|
|
1171
1187
|
console.error("Auto-sliced to: " + threeMFPath);
|
|
1172
1188
|
return { threeMFPath, autoSliced: true };
|
|
1173
1189
|
}
|
|
@@ -2079,7 +2095,7 @@ class BambuPrinterMCPServer {
|
|
|
2079
2095
|
},
|
|
2080
2096
|
{
|
|
2081
2097
|
name: "slice_stl",
|
|
2082
|
-
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. A failed slice's text starts with those words.",
|
|
2098
|
+
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. A failed slice's text starts with those words. A 3MF that carries its own process settings (a designer's Bambu Studio or Orca project) slices with them unless slicer_profile, template_name or template_3mf_path is given; the machine still comes from bambu_model. quality and strength adjust that process, and strength never lowers its walls or infill.",
|
|
2083
2099
|
inputSchema: {
|
|
2084
2100
|
type: "object",
|
|
2085
2101
|
properties: {
|
|
@@ -3660,10 +3676,19 @@ class BambuPrinterMCPServer {
|
|
|
3660
3676
|
throw new Error("Missing required parameter: stl_path");
|
|
3661
3677
|
}
|
|
3662
3678
|
const { slicerType, slicerPath, slicerProfile } = this.resolveSlicerConfigFromArgs(args, "slice_stl");
|
|
3679
|
+
// Copies only where the backend makes them (counterpart_printer_info capabilities.slicing); elsewhere one copy
|
|
3680
|
+
// would be sliced without a word.
|
|
3681
|
+
if (args?.repetitions !== undefined && Number(args.repetitions) > 1 && !bambuSliceCapabilities(slicerType).copies) {
|
|
3682
|
+
throw new Error(`Copies (repetitions) need the Bambu Studio or OrcaSlicer CLI, not ${slicerType}; nothing was sliced.`);
|
|
3683
|
+
}
|
|
3663
3684
|
const sliceModel = await this.resolveBambuModel(args?.bambu_model);
|
|
3664
3685
|
const nozzleDiam = String(args?.nozzle_diameter || DEFAULT_NOZZLE_DIAMETER);
|
|
3665
|
-
const activeSlicerProfile = await resolveSlicerProfilePath(slicerProfile || undefined, resolveTemplatePathFromName(["json", "config", "3mf"]) || explicitTemplatePath || undefined, TEMP_DIR);
|
|
3666
3686
|
const explicitSlicerProfile = hasExplicitSlicerProfile(args);
|
|
3687
|
+
const requestedTemplatePath = namedTemplatePath(args, resolveTemplatePathFromName(["json", "config", "3mf"]));
|
|
3688
|
+
const ownProcess3mf = await ownProcessTemplate(args, String(args.stl_path), requestedTemplatePath);
|
|
3689
|
+
const activeSlicerProfile = ownProcess3mf
|
|
3690
|
+
? await resolveSlicerProfilePath(undefined, ownProcess3mf, TEMP_DIR)
|
|
3691
|
+
: await resolveSlicerProfilePath(slicerProfile || undefined, requestedTemplatePath || explicitTemplatePath || undefined, TEMP_DIR);
|
|
3667
3692
|
// Resolve printer preset for BambuStudio slicer
|
|
3668
3693
|
const printerPreset = BAMBU_MODEL_PRESETS[sliceModel]?.(nozzleDiam);
|
|
3669
3694
|
const sliceBambuOptions = {};
|
|
@@ -3786,7 +3811,11 @@ class BambuPrinterMCPServer {
|
|
|
3786
3811
|
const printBedType = resolveBedType(args?.bed_type);
|
|
3787
3812
|
const printNozzles = requestedPrintNozzles(args);
|
|
3788
3813
|
const printNozzle = String(printNozzles?.[0] ?? DEFAULT_NOZZLE_DIAMETER);
|
|
3789
|
-
const
|
|
3814
|
+
const requestedPrintTemplate = namedTemplatePath(args, resolveTemplatePathFromName(["json", "config", "3mf"]));
|
|
3815
|
+
const ownPrintProcess = await ownProcessTemplate(args, String(args.three_mf_path), requestedPrintTemplate);
|
|
3816
|
+
const activeSlicerProfile = ownPrintProcess
|
|
3817
|
+
? await resolveTemplateSlicerProfilePath(ownPrintProcess, TEMP_DIR)
|
|
3818
|
+
: await resolveTemplateFirstSlicerProfilePath(args, slicerProfile || undefined, requestedPrintTemplate || explicitTemplatePath || undefined, TEMP_DIR);
|
|
3790
3819
|
const explicitSlicerProfile = hasExplicitSlicerProfile(args);
|
|
3791
3820
|
const printPreset = BAMBU_MODEL_PRESETS[printModel]?.(printNozzle);
|
|
3792
3821
|
const plateIndex = args?.plate_index !== undefined ? Number(args.plate_index) : 0;
|
|
@@ -4013,7 +4042,7 @@ class BambuPrinterMCPServer {
|
|
|
4013
4042
|
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);
|
|
4014
4043
|
break;
|
|
4015
4044
|
case "counterpart_printer_info":
|
|
4016
|
-
result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial) });
|
|
4045
|
+
result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial), slicerType: normalizeSlicerType(DEFAULT_SLICER_TYPE) });
|
|
4017
4046
|
break;
|
|
4018
4047
|
case "counterpart_print_route": {
|
|
4019
4048
|
let savedTo = null;
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* slice_stl's `quality` and `strength` (PRD §8.4): a client's print-sheet choice, mapped here to the
|
|
3
3
|
* slicer's own numbers so no client carries layer heights, wall counts or infill. Draft and Fine set
|
|
4
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
|
|
6
|
-
*
|
|
5
|
+
* and Max raise walls and infill to at least their values: a process that already has more (a
|
|
6
|
+
* designer's 3MF at 100% infill) keeps it, so a stronger choice never prints weaker. Standard sends
|
|
7
|
+
* nothing: the resolved process decides. An explicit layer_height, wall_loops or
|
|
8
|
+
* sparse_infill_density in the same call wins over these and is written as given.
|
|
7
9
|
*/
|
|
8
10
|
export declare const PRINT_QUALITIES: readonly ["draft", "standard", "fine"];
|
|
9
11
|
export declare const PRINT_STRENGTHS: readonly ["standard", "strong", "max"];
|
|
@@ -21,6 +23,6 @@ export declare const PRINT_QUALITY_PROPERTIES: {
|
|
|
21
23
|
readonly strength: {
|
|
22
24
|
readonly type: "string";
|
|
23
25
|
readonly enum: readonly ["standard", "strong", "max"];
|
|
24
|
-
readonly description: "Part strength: standard (the
|
|
26
|
+
readonly description: "Part strength: standard (the process's own walls and infill), strong or max (at least more walls and denser infill; a process that already has more keeps it). The server picks the values; explicit wall_loops or sparse_infill_density win.";
|
|
25
27
|
};
|
|
26
28
|
};
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* slice_stl's `quality` and `strength` (PRD §8.4): a client's print-sheet choice, mapped here to the
|
|
3
3
|
* slicer's own numbers so no client carries layer heights, wall counts or infill. Draft and Fine set
|
|
4
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
|
|
6
|
-
*
|
|
5
|
+
* and Max raise walls and infill to at least their values: a process that already has more (a
|
|
6
|
+
* designer's 3MF at 100% infill) keeps it, so a stronger choice never prints weaker. Standard sends
|
|
7
|
+
* nothing: the resolved process decides. An explicit layer_height, wall_loops or
|
|
8
|
+
* sparse_infill_density in the same call wins over these and is written as given.
|
|
7
9
|
*/
|
|
8
10
|
export const PRINT_QUALITIES = ["draft", "standard", "fine"];
|
|
9
11
|
export const PRINT_STRENGTHS = ["standard", "strong", "max"];
|
|
@@ -34,9 +36,9 @@ export function withPrintQuality(args, nozzleDiameter) {
|
|
|
34
36
|
const walls = STRENGTH[strength];
|
|
35
37
|
if (walls) {
|
|
36
38
|
if (out.wall_loops === undefined)
|
|
37
|
-
out.
|
|
39
|
+
out.wall_loops_floor = walls.wall_loops;
|
|
38
40
|
if (out.sparse_infill_density === undefined)
|
|
39
|
-
out.
|
|
41
|
+
out.sparse_infill_density_floor = walls.sparse_infill_density;
|
|
40
42
|
}
|
|
41
43
|
return out;
|
|
42
44
|
}
|
|
@@ -48,6 +50,6 @@ export const PRINT_QUALITY_PROPERTIES = {
|
|
|
48
50
|
},
|
|
49
51
|
strength: {
|
|
50
52
|
type: "string", enum: [...PRINT_STRENGTHS],
|
|
51
|
-
description: "Part strength: standard (the
|
|
53
|
+
description: "Part strength: standard (the process's own walls and infill), strong or max (at least more walls and denser infill; a process that already has more keeps it). The server picks the values; explicit wall_loops or sparse_infill_density win.",
|
|
52
54
|
},
|
|
53
55
|
};
|
|
@@ -5,7 +5,9 @@
|
|
|
5
5
|
* "15%"), so the machine preset and every other process value stay as resolved.
|
|
6
6
|
*/
|
|
7
7
|
export declare const PROCESS_OVERRIDE_KEYS: readonly ["layer_height", "wall_loops", "sparse_infill_density", "enable_support", "support_type", "support_threshold_angle"];
|
|
8
|
-
|
|
8
|
+
/** Minimums from a strength choice: the resolved process keeps its own value when it is already higher. */
|
|
9
|
+
export declare const PROCESS_FLOOR_KEYS: readonly ["wall_loops_floor", "sparse_infill_density_floor"];
|
|
10
|
+
export type ProcessOverrides = Partial<Record<(typeof PROCESS_OVERRIDE_KEYS)[number] | (typeof PROCESS_FLOOR_KEYS)[number], string>>;
|
|
9
11
|
/** Bambu Studio's and OrcaSlicer's support_type values. */
|
|
10
12
|
export declare const SUPPORT_TYPES: readonly ["normal(auto)", "tree(auto)", "normal(manual)", "tree(manual)"];
|
|
11
13
|
/** Validate the tool arguments; undefined when none are given. */
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* "15%"), so the machine preset and every other process value stay as resolved.
|
|
6
6
|
*/
|
|
7
7
|
export const PROCESS_OVERRIDE_KEYS = ["layer_height", "wall_loops", "sparse_infill_density", "enable_support", "support_type", "support_threshold_angle"];
|
|
8
|
+
/** Minimums from a strength choice: the resolved process keeps its own value when it is already higher. */
|
|
9
|
+
export const PROCESS_FLOOR_KEYS = ["wall_loops_floor", "sparse_infill_density_floor"];
|
|
8
10
|
/** Bambu Studio's and OrcaSlicer's support_type values. */
|
|
9
11
|
export const SUPPORT_TYPES = ["normal(auto)", "tree(auto)", "normal(manual)", "tree(manual)"];
|
|
10
12
|
/** Validate the tool arguments; undefined when none are given. */
|
|
@@ -33,6 +35,11 @@ export function parseProcessOverrides(args, nozzleDiameter) {
|
|
|
33
35
|
throw new Error('sparse_infill_density must be a percentage from 0% to 100%, such as "15%".');
|
|
34
36
|
overrides.sparse_infill_density = `${Number(match[1])}%`;
|
|
35
37
|
}
|
|
38
|
+
// Written by withPrintQuality for strong/max, never by a caller.
|
|
39
|
+
if (typeof args?.wall_loops_floor === "number")
|
|
40
|
+
overrides.wall_loops_floor = String(args.wall_loops_floor);
|
|
41
|
+
if (typeof args?.sparse_infill_density_floor === "string")
|
|
42
|
+
overrides.sparse_infill_density_floor = args.sparse_infill_density_floor;
|
|
36
43
|
const enableSupport = args?.enable_support;
|
|
37
44
|
if (enableSupport !== undefined) {
|
|
38
45
|
if (typeof enableSupport !== "boolean")
|
|
@@ -58,5 +65,15 @@ export function parseProcessOverrides(args, nozzleDiameter) {
|
|
|
58
65
|
}
|
|
59
66
|
/** The process profile with the overrides written over its values. */
|
|
60
67
|
export function applyProcessOverrides(profile, overrides) {
|
|
61
|
-
|
|
68
|
+
const { wall_loops_floor: wallFloor, sparse_infill_density_floor: densityFloor, ...exact } = overrides;
|
|
69
|
+
const out = { ...profile };
|
|
70
|
+
const number = (value) => {
|
|
71
|
+
const parsed = Number.parseFloat(String(Array.isArray(value) ? value[0] : value ?? ""));
|
|
72
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
73
|
+
};
|
|
74
|
+
if (wallFloor !== undefined && (number(out.wall_loops) ?? -1) < Number(wallFloor))
|
|
75
|
+
out.wall_loops = wallFloor;
|
|
76
|
+
if (densityFloor !== undefined && (number(out.sparse_infill_density) ?? -1) < Number.parseFloat(densityFloor))
|
|
77
|
+
out.sparse_infill_density = densityFloor;
|
|
78
|
+
return { ...out, ...exact };
|
|
62
79
|
}
|
package/package.json
CHANGED
package/src/3mf_parser.ts
CHANGED
|
@@ -2,6 +2,7 @@ import JSZip from 'jszip';
|
|
|
2
2
|
import { parseStringPromise } from 'xml2js';
|
|
3
3
|
import { ThreeMFData, BambuSlicerConfig, ThreeMFMetadata, ThreeMFObject, ThreeMFBuildItem, AMSFilamentMapping, CollarCharmAnalysis, CollarCharmRole, ThreeMFAmsRequirements, ThreeMFPlateObjects } from './types.js';
|
|
4
4
|
import * as fs from 'fs/promises';
|
|
5
|
+
import { createHash } from 'crypto';
|
|
5
6
|
|
|
6
7
|
// Parses Bambu Studio's JSON config data
|
|
7
8
|
function parseBambuJSONConfig(jsonData: any): Partial<BambuSlicerConfig> {
|
|
@@ -227,6 +228,19 @@ export async function parse3MF(filePath: string): Promise<ThreeMFData> {
|
|
|
227
228
|
}
|
|
228
229
|
}
|
|
229
230
|
|
|
231
|
+
/** Whether a 3MF carries its own Bambu Studio/Orca process (a designer's project, not a bare mesh archive). */
|
|
232
|
+
export async function hasBambuProjectSettings(filePath: string): Promise<boolean> {
|
|
233
|
+
try {
|
|
234
|
+
const zip = await JSZip.loadAsync(await fs.readFile(filePath));
|
|
235
|
+
const settings = zip.file('Metadata/project_settings.config');
|
|
236
|
+
if (!settings) return false;
|
|
237
|
+
const parsed = JSON.parse(await settings.async('string'));
|
|
238
|
+
return !!parsed && typeof parsed === 'object' && !Array.isArray(parsed) && parsed.layer_height !== undefined;
|
|
239
|
+
} catch {
|
|
240
|
+
return false;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
230
244
|
export async function extractBambuTemplateSettings(
|
|
231
245
|
filePath: string,
|
|
232
246
|
outputDir: string
|
|
@@ -245,7 +259,9 @@ export async function extractBambuTemplateSettings(
|
|
|
245
259
|
if (!file) continue;
|
|
246
260
|
|
|
247
261
|
const content = await file.async('string');
|
|
248
|
-
|
|
262
|
+
// Named by content, so two projects sliced at once never share (or overwrite) one settings file.
|
|
263
|
+
const digest = createHash('sha256').update(content).digest('hex').slice(0, 16);
|
|
264
|
+
const outputPath = `${outputDir}/${digest}_${name.replace(/\//g, '_')}`;
|
|
249
265
|
await fs.writeFile(outputPath, content, 'utf8');
|
|
250
266
|
return outputPath;
|
|
251
267
|
}
|
package/src/counterpart/info.ts
CHANGED
|
@@ -7,7 +7,20 @@ import { COUNTERPART_CONTRACT, type PrinterInfo } from "./schemas.js";
|
|
|
7
7
|
/** Bambu's display names ("P1S", "A1 Mini", "H2D Pro"), keyed by normalized model. */
|
|
8
8
|
const DISPLAY_NAMES = new Map(Object.values(SERIAL_MODELS).map(name => [normalizeModel(name), name]));
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
/** Backends that slice through the Bambu Studio / OrcaSlicer CLI, where supports, copies and auto-orient all apply. */
|
|
11
|
+
export const BAMBU_CLI_SLICERS = ["bambustudio", "orcaslicer", "orcaslicer-bambulab"] as const;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* What slice_stl applies on each backend: the Bambu Studio / OrcaSlicer CLIs take all three; remote orca-slicer-api
|
|
15
|
+
* takes supports and orient but refuses repetitions; PrusaSlicer, Slic3r and Cura take none of them here.
|
|
16
|
+
*/
|
|
17
|
+
export function bambuSliceCapabilities(slicerType: string | undefined): { supports: boolean; copies: boolean; orient: boolean } {
|
|
18
|
+
if (slicerType === undefined || (BAMBU_CLI_SLICERS as readonly string[]).includes(slicerType)) return { supports: true, copies: true, orient: true };
|
|
19
|
+
if (slicerType === "orca-slicer-api") return { supports: true, copies: false, orient: true };
|
|
20
|
+
return { supports: false, copies: false, orient: false };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function bambuPrinterInfo(options: { server: { name: string; version: string }; host: string; serial?: string; model?: string; slicerType?: string }): PrinterInfo {
|
|
11
24
|
const model = normalizeModel(options.model);
|
|
12
25
|
const serial = options.serial?.trim();
|
|
13
26
|
return {
|
|
@@ -32,6 +45,8 @@ export function bambuPrinterInfo(options: { server: { name: string; version: str
|
|
|
32
45
|
print3mf: true,
|
|
33
46
|
// X2D jobs go through its native route; FTPS/remote-file G-code starts stay blocked there.
|
|
34
47
|
gcode: model !== "x2d",
|
|
48
|
+
// From the configured slicer backend, as slice_stl uses it (remote orca-slicer-api makes no copies).
|
|
49
|
+
slicing: bambuSliceCapabilities(options.slicerType),
|
|
35
50
|
},
|
|
36
51
|
};
|
|
37
52
|
}
|
|
@@ -33,6 +33,8 @@ export type PrinterInfo = {
|
|
|
33
33
|
cameraStream?: boolean;
|
|
34
34
|
filaments: "ams" | "single" | "none";
|
|
35
35
|
pause: boolean; resume: boolean; cancel: boolean; print3mf: boolean; gcode: boolean;
|
|
36
|
+
/** What slice_stl can apply with this server's slicer (the same field in mcp-3D-printer-server). */
|
|
37
|
+
slicing?: { supports: boolean; copies: boolean; orient: boolean };
|
|
36
38
|
};
|
|
37
39
|
};
|
|
38
40
|
|
|
@@ -75,6 +77,11 @@ export const PRINTER_INFO_OUTPUT_SCHEMA = {
|
|
|
75
77
|
cancel: { type: "boolean" },
|
|
76
78
|
print3mf: { type: "boolean" },
|
|
77
79
|
gcode: { type: "boolean" },
|
|
80
|
+
slicing: {
|
|
81
|
+
type: "object",
|
|
82
|
+
required: ["supports", "copies", "orient"],
|
|
83
|
+
properties: { supports: { type: "boolean" }, copies: { type: "boolean" }, orient: { type: "boolean" } },
|
|
84
|
+
},
|
|
78
85
|
},
|
|
79
86
|
required: ["progress", "layers", "camera", "filaments", "pause", "resume", "cancel", "print3mf", "gcode"],
|
|
80
87
|
},
|
package/src/index.ts
CHANGED
|
@@ -48,7 +48,7 @@ import { importFileViaBambuConnect } from "./bambu-connect.js";
|
|
|
48
48
|
import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
|
|
49
49
|
import { FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFAULT_ARGS, FUSION_NEW_DESIGN_OUTPUT_SCHEMA, FUSION_STATUS_OUTPUT_SCHEMA, FusionMcpBridge } from "./fusion-mcp-bridge.js";
|
|
50
50
|
import { bridgeAmsMapping2Entry, bridgeAmsMappingValue, externalTrayForNozzle, hasAmsMappingInput, normalizeAmsMappingObject, normalizeBridgeAmsTrayValue, studioAmsMappingInfo, trayColour } from "./ams-mapping.js";
|
|
51
|
-
import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, parse3MF } from './3mf_parser.js';
|
|
51
|
+
import { analyze3MFAmsRequirements, analyze3MFPlateObjects, analyzeCollarCharm3MF, extractBambuTemplateSettings, getCollarCharmRolePolicy, hasBambuProjectSettings, parse3MF } from './3mf_parser.js';
|
|
52
52
|
import type { ThreeMFAmsRequirements } from "./types.js";
|
|
53
53
|
import { BambuImplementation, assertDirectPrintSupported, checkedFile, defaultResumeStateDir } from "./printers/bambu.js";
|
|
54
54
|
import { resolveStudioPrintOptions, usedNozzleCount, type CallerPrintOptions } from "./studio-print-options.js";
|
|
@@ -57,7 +57,7 @@ import { SERIAL_MODELS, externalStorageState, validatePrinterState } from "./saf
|
|
|
57
57
|
import { isDualNozzleModel } from "./safety/limits.js";
|
|
58
58
|
import { withPrinterOperation, withPrintSnapshot, uniquePrintName } from "./safety/artifact.js";
|
|
59
59
|
import { detectProfilesRoot } from "./slicer/profile-flatten.js";
|
|
60
|
-
import { bambuPrinterInfo } from "./counterpart/info.js";
|
|
60
|
+
import { bambuPrinterInfo, bambuSliceCapabilities } from "./counterpart/info.js";
|
|
61
61
|
import { DESIGN_PROMPTS, FDM_CAPABILITY_GUIDANCE, FDM_CAPABILITY_RESOURCE, FDM_CAPABILITY_URI, SERVER_INSTRUCTIONS } from "./design-guidance.js";
|
|
62
62
|
import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
|
|
63
63
|
import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
|
|
@@ -920,6 +920,21 @@ function hasExplicitSlicerProfile(args: any): boolean {
|
|
|
920
920
|
return typeof args?.slicer_profile === "string" && args.slicer_profile.trim().length > 0;
|
|
921
921
|
}
|
|
922
922
|
|
|
923
|
+
/**
|
|
924
|
+
* A 3MF that carries its own process (a designer's project) as its slicing template, when the call names
|
|
925
|
+
* no profile or template of its own. A configured default profile or template must not replace the
|
|
926
|
+
* designer's layer height, walls and infill; the machine still comes from the chosen printer preset.
|
|
927
|
+
*/
|
|
928
|
+
/** The template this call names: template_name (resolved by the caller) or template_3mf_path. */
|
|
929
|
+
function namedTemplatePath(args: any, fromName: string | undefined): string | undefined {
|
|
930
|
+
return fromName || (typeof args?.template_3mf_path === "string" && args.template_3mf_path.trim() ? String(args.template_3mf_path) : undefined);
|
|
931
|
+
}
|
|
932
|
+
|
|
933
|
+
async function ownProcessTemplate(args: any, modelPath: string, requestedTemplatePath: string | undefined): Promise<string | undefined> {
|
|
934
|
+
if (hasExplicitSlicerProfile(args) || requestedTemplatePath || !modelPath.toLowerCase().endsWith(".3mf")) return undefined;
|
|
935
|
+
return await hasBambuProjectSettings(modelPath) ? modelPath : undefined;
|
|
936
|
+
}
|
|
937
|
+
|
|
923
938
|
async function resolveTemplateFirstSlicerProfilePath(
|
|
924
939
|
args: any,
|
|
925
940
|
configuredProfile: string | undefined,
|
|
@@ -1525,8 +1540,10 @@ class BambuPrinterMCPServer {
|
|
|
1525
1540
|
nozzleType: resolveNozzleType(args?.nozzle_type),
|
|
1526
1541
|
nozzleVolumeType: resolveNozzleVolumeType(args?.nozzle_volume_type),
|
|
1527
1542
|
};
|
|
1543
|
+
// A designer's project slices with its own process here too, as slice_stl and the LAN route do.
|
|
1544
|
+
const ownProcess = await ownProcessTemplate(args, threeMFPath, namedTemplatePath(args, typeof args?.template_name === "string" && args.template_name.trim() ? String(args.template_name) : undefined));
|
|
1528
1545
|
threeMFPath = await this.stlManipulator.sliceSTL(
|
|
1529
|
-
threeMFPath, slicerType, slicerPath, slicerProfile || undefined,
|
|
1546
|
+
threeMFPath, slicerType, slicerPath, ownProcess ? await resolveTemplateSlicerProfilePath(ownProcess, TEMP_DIR) : slicerProfile || undefined,
|
|
1530
1547
|
undefined,
|
|
1531
1548
|
printPreset,
|
|
1532
1549
|
autoSliceOptions
|
|
@@ -2613,7 +2630,7 @@ class BambuPrinterMCPServer {
|
|
|
2613
2630
|
},
|
|
2614
2631
|
{
|
|
2615
2632
|
name: "slice_stl",
|
|
2616
|
-
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. A failed slice's text starts with those words.",
|
|
2633
|
+
description: "Slice an STL or 3MF file using a slicer to generate printable G-code or sliced 3MF. IMPORTANT: bambu_model must be specified to ensure the slicer generates safe G-code for the correct printer. The text result is the sliced file's path. When Bambu Studio or OrcaSlicer writes a result.json, structuredContent.slicer_result carries it verbatim, success or error: error_string, return_code and each sliced_plates[].warning_message, such as a floating cantilever. A failed slice's text starts with those words. A 3MF that carries its own process settings (a designer's Bambu Studio or Orca project) slices with them unless slicer_profile, template_name or template_3mf_path is given; the machine still comes from bambu_model. quality and strength adjust that process, and strength never lowers its walls or infill.",
|
|
2617
2634
|
inputSchema: {
|
|
2618
2635
|
type: "object",
|
|
2619
2636
|
properties: {
|
|
@@ -4318,14 +4335,23 @@ class BambuPrinterMCPServer {
|
|
|
4318
4335
|
args as Record<string, unknown> | undefined,
|
|
4319
4336
|
"slice_stl"
|
|
4320
4337
|
);
|
|
4338
|
+
// Copies only where the backend makes them (counterpart_printer_info capabilities.slicing); elsewhere one copy
|
|
4339
|
+
// would be sliced without a word.
|
|
4340
|
+
if (args?.repetitions !== undefined && Number(args.repetitions) > 1 && !bambuSliceCapabilities(slicerType).copies) {
|
|
4341
|
+
throw new Error(`Copies (repetitions) need the Bambu Studio or OrcaSlicer CLI, not ${slicerType}; nothing was sliced.`);
|
|
4342
|
+
}
|
|
4321
4343
|
const sliceModel = await this.resolveBambuModel(args?.bambu_model as string | undefined);
|
|
4322
4344
|
const nozzleDiam = String(args?.nozzle_diameter || DEFAULT_NOZZLE_DIAMETER);
|
|
4323
|
-
const activeSlicerProfile = await resolveSlicerProfilePath(
|
|
4324
|
-
slicerProfile || undefined,
|
|
4325
|
-
resolveTemplatePathFromName(["json", "config", "3mf"]) || explicitTemplatePath || undefined,
|
|
4326
|
-
TEMP_DIR
|
|
4327
|
-
);
|
|
4328
4345
|
const explicitSlicerProfile = hasExplicitSlicerProfile(args);
|
|
4346
|
+
const requestedTemplatePath = namedTemplatePath(args, resolveTemplatePathFromName(["json", "config", "3mf"]));
|
|
4347
|
+
const ownProcess3mf = await ownProcessTemplate(args, String(args.stl_path), requestedTemplatePath);
|
|
4348
|
+
const activeSlicerProfile = ownProcess3mf
|
|
4349
|
+
? await resolveSlicerProfilePath(undefined, ownProcess3mf, TEMP_DIR)
|
|
4350
|
+
: await resolveSlicerProfilePath(
|
|
4351
|
+
slicerProfile || undefined,
|
|
4352
|
+
requestedTemplatePath || explicitTemplatePath || undefined,
|
|
4353
|
+
TEMP_DIR
|
|
4354
|
+
);
|
|
4329
4355
|
// Resolve printer preset for BambuStudio slicer
|
|
4330
4356
|
const printerPreset = BAMBU_MODEL_PRESETS[sliceModel]?.(nozzleDiam);
|
|
4331
4357
|
|
|
@@ -4449,12 +4475,16 @@ class BambuPrinterMCPServer {
|
|
|
4449
4475
|
const printBedType = resolveBedType(args?.bed_type as string | undefined);
|
|
4450
4476
|
const printNozzles = requestedPrintNozzles(args as Record<string, any>);
|
|
4451
4477
|
const printNozzle = String(printNozzles?.[0] ?? DEFAULT_NOZZLE_DIAMETER);
|
|
4452
|
-
const
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4478
|
+
const requestedPrintTemplate = namedTemplatePath(args, resolveTemplatePathFromName(["json", "config", "3mf"]));
|
|
4479
|
+
const ownPrintProcess = await ownProcessTemplate(args, String(args.three_mf_path), requestedPrintTemplate);
|
|
4480
|
+
const activeSlicerProfile = ownPrintProcess
|
|
4481
|
+
? await resolveTemplateSlicerProfilePath(ownPrintProcess, TEMP_DIR)
|
|
4482
|
+
: await resolveTemplateFirstSlicerProfilePath(
|
|
4483
|
+
args,
|
|
4484
|
+
slicerProfile || undefined,
|
|
4485
|
+
requestedPrintTemplate || explicitTemplatePath || undefined,
|
|
4486
|
+
TEMP_DIR
|
|
4487
|
+
);
|
|
4458
4488
|
const explicitSlicerProfile = hasExplicitSlicerProfile(args);
|
|
4459
4489
|
const printPreset = BAMBU_MODEL_PRESETS[printModel]?.(printNozzle);
|
|
4460
4490
|
const plateIndex = args?.plate_index !== undefined ? Number(args.plate_index) : 0;
|
|
@@ -4762,7 +4792,7 @@ class BambuPrinterMCPServer {
|
|
|
4762
4792
|
break;
|
|
4763
4793
|
|
|
4764
4794
|
case "counterpart_printer_info":
|
|
4765
|
-
result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial) });
|
|
4795
|
+
result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial), slicerType: normalizeSlicerType(DEFAULT_SLICER_TYPE) });
|
|
4766
4796
|
break;
|
|
4767
4797
|
|
|
4768
4798
|
case "counterpart_print_route": {
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
* slice_stl's `quality` and `strength` (PRD §8.4): a client's print-sheet choice, mapped here to the
|
|
3
3
|
* slicer's own numbers so no client carries layer heights, wall counts or infill. Draft and Fine set
|
|
4
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
|
|
6
|
-
*
|
|
5
|
+
* and Max raise walls and infill to at least their values: a process that already has more (a
|
|
6
|
+
* designer's 3MF at 100% infill) keeps it, so a stronger choice never prints weaker. Standard sends
|
|
7
|
+
* nothing: the resolved process decides. An explicit layer_height, wall_loops or
|
|
8
|
+
* sparse_infill_density in the same call wins over these and is written as given.
|
|
7
9
|
*/
|
|
8
10
|
export const PRINT_QUALITIES = ["draft", "standard", "fine"] as const;
|
|
9
11
|
export const PRINT_STRENGTHS = ["standard", "strong", "max"] as const;
|
|
@@ -36,8 +38,8 @@ export function withPrintQuality(args: Record<string, unknown>, nozzleDiameter?:
|
|
|
36
38
|
if (layer !== undefined && out.layer_height === undefined) out.layer_height = Math.round(layer * scale * 100) / 100;
|
|
37
39
|
const walls = STRENGTH[strength as PrintStrength];
|
|
38
40
|
if (walls) {
|
|
39
|
-
if (out.wall_loops === undefined) out.
|
|
40
|
-
if (out.sparse_infill_density === undefined) out.
|
|
41
|
+
if (out.wall_loops === undefined) out.wall_loops_floor = walls.wall_loops;
|
|
42
|
+
if (out.sparse_infill_density === undefined) out.sparse_infill_density_floor = walls.sparse_infill_density;
|
|
41
43
|
}
|
|
42
44
|
return out;
|
|
43
45
|
}
|
|
@@ -50,6 +52,6 @@ export const PRINT_QUALITY_PROPERTIES = {
|
|
|
50
52
|
},
|
|
51
53
|
strength: {
|
|
52
54
|
type: "string", enum: [...PRINT_STRENGTHS],
|
|
53
|
-
description: "Part strength: standard (the
|
|
55
|
+
description: "Part strength: standard (the process's own walls and infill), strong or max (at least more walls and denser infill; a process that already has more keeps it). The server picks the values; explicit wall_loops or sparse_infill_density win.",
|
|
54
56
|
},
|
|
55
57
|
} as const;
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export const PROCESS_OVERRIDE_KEYS = ["layer_height", "wall_loops", "sparse_infill_density", "enable_support", "support_type", "support_threshold_angle"] as const;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
/** Minimums from a strength choice: the resolved process keeps its own value when it is already higher. */
|
|
10
|
+
export const PROCESS_FLOOR_KEYS = ["wall_loops_floor", "sparse_infill_density_floor"] as const;
|
|
11
|
+
|
|
12
|
+
export type ProcessOverrides = Partial<Record<(typeof PROCESS_OVERRIDE_KEYS)[number] | (typeof PROCESS_FLOOR_KEYS)[number], string>>;
|
|
10
13
|
|
|
11
14
|
/** Bambu Studio's and OrcaSlicer's support_type values. */
|
|
12
15
|
export const SUPPORT_TYPES = ["normal(auto)", "tree(auto)", "normal(manual)", "tree(manual)"] as const;
|
|
@@ -36,6 +39,9 @@ export function parseProcessOverrides(args: Record<string, unknown> | undefined,
|
|
|
36
39
|
if (!match || Number(match[1]) > 100) throw new Error('sparse_infill_density must be a percentage from 0% to 100%, such as "15%".');
|
|
37
40
|
overrides.sparse_infill_density = `${Number(match[1])}%`;
|
|
38
41
|
}
|
|
42
|
+
// Written by withPrintQuality for strong/max, never by a caller.
|
|
43
|
+
if (typeof args?.wall_loops_floor === "number") overrides.wall_loops_floor = String(args.wall_loops_floor);
|
|
44
|
+
if (typeof args?.sparse_infill_density_floor === "string") overrides.sparse_infill_density_floor = args.sparse_infill_density_floor;
|
|
39
45
|
const enableSupport = args?.enable_support;
|
|
40
46
|
if (enableSupport !== undefined) {
|
|
41
47
|
if (typeof enableSupport !== "boolean") throw new Error("enable_support must be true or false.");
|
|
@@ -61,5 +67,13 @@ export function parseProcessOverrides(args: Record<string, unknown> | undefined,
|
|
|
61
67
|
|
|
62
68
|
/** The process profile with the overrides written over its values. */
|
|
63
69
|
export function applyProcessOverrides(profile: Record<string, unknown>, overrides: ProcessOverrides): Record<string, unknown> {
|
|
64
|
-
|
|
70
|
+
const { wall_loops_floor: wallFloor, sparse_infill_density_floor: densityFloor, ...exact } = overrides;
|
|
71
|
+
const out: Record<string, unknown> = { ...profile };
|
|
72
|
+
const number = (value: unknown) => {
|
|
73
|
+
const parsed = Number.parseFloat(String(Array.isArray(value) ? value[0] : value ?? ""));
|
|
74
|
+
return Number.isFinite(parsed) ? parsed : undefined;
|
|
75
|
+
};
|
|
76
|
+
if (wallFloor !== undefined && (number(out.wall_loops) ?? -1) < Number(wallFloor)) out.wall_loops = wallFloor;
|
|
77
|
+
if (densityFloor !== undefined && (number(out.sparse_infill_density) ?? -1) < Number.parseFloat(densityFloor)) out.sparse_infill_density = densityFloor;
|
|
78
|
+
return { ...out, ...exact };
|
|
65
79
|
}
|