bambu-printer-mcp 1.1.94 → 1.1.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTORS.md +1 -0
- package/README.md +16 -4
- package/dist/cad/contracts.d.ts +10 -0
- package/dist/cad/contracts.js +32 -1
- package/dist/cad-engine.js +40 -3
- package/dist/counterpart/diagnostics.d.ts +163 -0
- package/dist/counterpart/diagnostics.js +816 -0
- package/dist/counterpart/info.js +1 -0
- package/dist/counterpart/remote.js +1 -0
- package/dist/counterpart/schemas.d.ts +6 -0
- package/dist/counterpart/schemas.js +1 -0
- package/dist/fusion-mcp-bridge.d.ts +13 -0
- package/dist/fusion-mcp-bridge.js +35 -4
- package/dist/index.js +101 -3
- package/dist/tool-annotations.js +1 -0
- package/package.json +2 -2
- package/src/cad/contracts.ts +36 -1
- package/src/cad/examples/desk_clamp_hook.py +32 -0
- package/src/cad/examples/desk_edge_cable_holder.py +24 -0
- package/src/cad/examples/phone_stand.py +26 -0
- package/src/cad/geometry.py +52 -2
- package/src/cad/purpose.py +492 -0
- package/src/cad/worker.py +11 -0
- package/src/cad-engine.ts +42 -3
- package/src/counterpart/diagnostics.ts +775 -0
- package/src/counterpart/info.ts +1 -0
- package/src/counterpart/remote.ts +1 -0
- package/src/counterpart/schemas.ts +3 -0
- package/src/fusion-mcp-bridge.ts +34 -4
- package/src/index.ts +84 -3
- package/src/tool-annotations.ts +1 -0
package/src/counterpart/info.ts
CHANGED
|
@@ -46,6 +46,7 @@ export function bambuPrinterInfo(options: { server: { name: string; version: str
|
|
|
46
46
|
// camera_snapshot needs the model to choose its transport.
|
|
47
47
|
camera: model && TCP_CAMERA_MODELS.has(model) ? "bambu-tcp" : model && RTSP_CAMERA_MODELS.has(model) ? "rtsp" : "none",
|
|
48
48
|
cameraStream: !!model && (TCP_CAMERA_MODELS.has(model) || RTSP_CAMERA_MODELS.has(model)),
|
|
49
|
+
diagnostics: true,
|
|
49
50
|
filaments: "ams",
|
|
50
51
|
pause: true,
|
|
51
52
|
resume: true,
|
|
@@ -41,6 +41,7 @@ export const REMOTE_SCOPES: Readonly<Record<string, RemoteScope>> = {
|
|
|
41
41
|
blender_mcp_status: "read",
|
|
42
42
|
counterpart_printer_info: "read",
|
|
43
43
|
counterpart_self_check: "read",
|
|
44
|
+
counterpart_diagnostics: "read", // this server's own redacted logs; nothing reaches the printer
|
|
44
45
|
counterpart_print_progress: "read",
|
|
45
46
|
counterpart_print_record: "read",
|
|
46
47
|
counterpart_print_assess: "control", // local evidence mutation, never a printer command
|
|
@@ -35,6 +35,8 @@ export type PrinterInfo = {
|
|
|
35
35
|
progress: boolean; layers: boolean;
|
|
36
36
|
camera: "bambu-tcp" | "rtsp" | "http-snapshot" | "none";
|
|
37
37
|
cameraStream?: boolean;
|
|
38
|
+
/** counterpart_diagnostics is here: this server hands over its own redacted diagnostics bundle. */
|
|
39
|
+
diagnostics?: boolean;
|
|
38
40
|
filaments: "ams" | "single" | "none";
|
|
39
41
|
pause: boolean; resume: boolean; cancel: boolean; print3mf: boolean; gcode: boolean;
|
|
40
42
|
/** What slice_stl can apply with this server's slicer (the same field in mcp-3D-printer-server). */
|
|
@@ -77,6 +79,7 @@ export const PRINTER_INFO_OUTPUT_SCHEMA = {
|
|
|
77
79
|
layers: { type: "boolean" },
|
|
78
80
|
camera: { type: "string", enum: ["bambu-tcp", "rtsp", "http-snapshot", "none"] },
|
|
79
81
|
cameraStream: { type: "boolean" },
|
|
82
|
+
diagnostics: { type: "boolean", description: "counterpart_diagnostics is available." },
|
|
80
83
|
filaments: { type: "string", enum: ["ams", "single", "none"] },
|
|
81
84
|
pause: { type: "boolean" },
|
|
82
85
|
resume: { type: "boolean" },
|
package/src/fusion-mcp-bridge.ts
CHANGED
|
@@ -38,6 +38,7 @@ export const FUSION_MCP_DEFAULT_ARGS = Object.freeze([
|
|
|
38
38
|
]);
|
|
39
39
|
const DEFAULT_TIMEOUT_MS = 180_000;
|
|
40
40
|
const MAX_TIMEOUT_MS = 600_000;
|
|
41
|
+
const STATUS_PROBE_TIMEOUT_MS = 5_000;
|
|
41
42
|
const LAUNCH_WAIT_MS = 90_000;
|
|
42
43
|
const ADDIN_PING_MS = 2_000;
|
|
43
44
|
const EXPORT_NAME = /^[A-Za-z0-9][A-Za-z0-9._ -]{0,99}$/;
|
|
@@ -244,7 +245,10 @@ export const FUSION_STATUS_OUTPUT_SCHEMA = {
|
|
|
244
245
|
type: "object" as const,
|
|
245
246
|
properties: {
|
|
246
247
|
configured: { type: "boolean", description: "FUSION_MCP_COMMAND is set." },
|
|
247
|
-
connected: { type: "boolean", description: "The
|
|
248
|
+
connected: { type: "boolean", description: "The add-in answers and its command probe has not failed. Check state/ responsive for design readiness and activeDesign for an open document." },
|
|
249
|
+
responsive: { type: "boolean", description: "A fresh no-op through execute_code completed and Fusion reports startup complete; this does not guarantee a later design operation succeeds." },
|
|
250
|
+
state: { type: "string", enum: ["starting", "ready", "unresponsive"], description: "starting comes from Fusion's own isStartupComplete flag, ready requires the command probe, unresponsive means readiness could not be verified. See reason." },
|
|
251
|
+
reason: { type: "string", description: "Plain explanation and next step, provided by the MCP rather than inferred by clients." },
|
|
248
252
|
addinReachable: { type: "boolean", description: "The Fusion360MCP add-in answered a ping on FUSION_MCP_HOST:FUSION_MCP_PORT (default localhost:9877) within 2 s. Another program on that port, such as Blender's MCP add-on, does not count." },
|
|
249
253
|
fusionRunning: { type: "boolean" },
|
|
250
254
|
activeDesign: { type: "boolean", description: "When connected: whether Fusion has a design open, from the add-in's read-only get_design_type (false is its NO_ACTIVE_DESIGN). The pinned add-in refuses every design command, fusion_mcp_new_design included, without one (faust issue #12). Absent when unknown." },
|
|
@@ -255,7 +259,7 @@ export const FUSION_STATUS_OUTPUT_SCHEMA = {
|
|
|
255
259
|
server: { type: "object" },
|
|
256
260
|
error: { type: "string" },
|
|
257
261
|
},
|
|
258
|
-
required: ["configured", "connected", "addinReachable", "fusionRunning", "tools"],
|
|
262
|
+
required: ["configured", "connected", "responsive", "state", "reason", "addinReachable", "fusionRunning", "tools"],
|
|
259
263
|
};
|
|
260
264
|
|
|
261
265
|
|
|
@@ -425,7 +429,7 @@ export class FusionMcpBridge {
|
|
|
425
429
|
async status(args: Arguments, signal?: AbortSignal): Promise<Record<string, unknown>> {
|
|
426
430
|
allowedArguments(args, ["launch", "timeout_ms"]);
|
|
427
431
|
if (args.launch !== undefined && typeof args.launch !== "boolean") throw new FusionError("launch must be a boolean.");
|
|
428
|
-
const timeout = timeoutMilliseconds(args.timeout_ms);
|
|
432
|
+
const timeout = Math.min(timeoutMilliseconds(args.timeout_ms), STATUS_PROBE_TIMEOUT_MS);
|
|
429
433
|
const { host, port } = addinAddress();
|
|
430
434
|
const configured = Boolean(process.env.FUSION_MCP_COMMAND?.trim());
|
|
431
435
|
let addinReachable = await this.system.addinAnswers(host, port, ADDIN_PING_MS);
|
|
@@ -444,7 +448,8 @@ export class FusionMcpBridge {
|
|
|
444
448
|
addinReachable = await this.system.addinAnswers(host, port, ADDIN_PING_MS);
|
|
445
449
|
}
|
|
446
450
|
}
|
|
447
|
-
const result: Record<string, unknown> = { configured, connected: false,
|
|
451
|
+
const result: Record<string, unknown> = { configured, connected: false, responsive: false, state: "unresponsive",
|
|
452
|
+
reason: configured ? "Fusion isn't responding on your Mac. Restart Fusion, then Try Again." : "Set up the Fusion MCP connection first.", addinReachable, fusionRunning, tools: [], launched, transport: "stdio", pin: FUSION_MCP_PIN };
|
|
448
453
|
if (!configured) return result;
|
|
449
454
|
try {
|
|
450
455
|
await this.request({ timeout, signal }, async (live, options, dispatched) => {
|
|
@@ -467,8 +472,33 @@ export class FusionMcpBridge {
|
|
|
467
472
|
if (!failed(read, "get_design_type")) result.activeDesign = true;
|
|
468
473
|
else if (errorKind(read, "get_design_type") === "NO_ACTIVE_DESIGN") result.activeDesign = false;
|
|
469
474
|
}
|
|
475
|
+
if (result.connected === true) {
|
|
476
|
+
// At the pinned add-in execute_code traverses _MUTATION_COMMANDS snapshots and the same
|
|
477
|
+
// handler as design commands. A no-op tests that path without editing or opening a document.
|
|
478
|
+
// A late probe is harmless. Require this call's nonce; neither ping nor a design read proves readiness.
|
|
479
|
+
const nonce = randomUUID();
|
|
480
|
+
const code = `# BAMBU_FUSION status_probe
|
|
481
|
+
import json
|
|
482
|
+
json.dumps({"nonce": "${nonce}", "startupComplete": app.isStartupComplete})`;
|
|
483
|
+
const probe = await this.invoke(live, options, dispatched, "execute_code", { code });
|
|
484
|
+
if (errorKind(probe, "execute_code") === "NO_ACTIVE_DESIGN") {
|
|
485
|
+
result.activeDesign = false;
|
|
486
|
+
result.reason = "Open a design in Fusion, then Try Again.";
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
if (failed(probe, "execute_code")) throw new FusionError("Fusion's command readiness probe failed.");
|
|
490
|
+
const receipt = argumentObject(codeJson(probe), "Fusion readiness receipt");
|
|
491
|
+
if (receipt.nonce !== nonce || typeof receipt.startupComplete !== "boolean") {
|
|
492
|
+
throw new FusionError("Fusion did not return this command readiness probe's receipt.");
|
|
493
|
+
}
|
|
494
|
+
result.responsive = receipt.startupComplete;
|
|
495
|
+
result.connected = receipt.startupComplete;
|
|
496
|
+
result.state = receipt.startupComplete ? "ready" : "starting";
|
|
497
|
+
result.reason = receipt.startupComplete ? "Fusion's command path is responding." : "Fusion is still starting. Finish any sign-in or update dialog, then Try Again.";
|
|
498
|
+
}
|
|
470
499
|
});
|
|
471
500
|
} catch (error) {
|
|
501
|
+
result.connected = false;
|
|
472
502
|
result.error = error instanceof Error ? error.message : String(error);
|
|
473
503
|
}
|
|
474
504
|
return result;
|
package/src/index.ts
CHANGED
|
@@ -89,6 +89,7 @@ import { bambuProgress, offlineProgress } from "./counterpart/progress.js";
|
|
|
89
89
|
import { makeCounterpart3mf } from "./counterpart/make-3mf.js";
|
|
90
90
|
import { MAKE_3MF_OUTPUT_SCHEMA, PRINT_PROGRESS_OUTPUT_SCHEMA, PRINTER_INFO_OUTPUT_SCHEMA } from "./counterpart/schemas.js";
|
|
91
91
|
import { SELF_CHECK_OUTPUT_SCHEMA, selfCheck } from "./counterpart/self-check.js";
|
|
92
|
+
import { DIAGNOSTICS_INPUT_PROPERTIES, DIAGNOSTICS_OUTPUT_SCHEMA, appVersion, buildDiagnostics, captureServerLog, diagnosticsBudget, jsonText, recordToolError, rememberSecretArguments, serverLogText, settingsSnapshot, toolErrorsText, type DiagnosticsSource } from "./counterpart/diagnostics.js";
|
|
92
93
|
import { parseProcessOverrides } from "./slicer/process-overrides.js";
|
|
93
94
|
import { PRINT_QUALITY_PROPERTIES, withPrintQuality } from "./slicer/print-quality.js";
|
|
94
95
|
import { PrinterRefusal, withPrintDispatch, markPrintCommandSent, printOutcome } from "./refusal.js";
|
|
@@ -96,12 +97,16 @@ import { uploadProgressReporter } from "./upload-progress.js";
|
|
|
96
97
|
import { machinePauseGcode, parsePauseLayers, pausedLayers, readPlateGcode } from "./slicer/layer-pauses.js";
|
|
97
98
|
|
|
98
99
|
dotenv.config();
|
|
100
|
+
// What the server writes to stderr is also kept for counterpart_diagnostics.
|
|
101
|
+
captureServerLog();
|
|
99
102
|
|
|
100
103
|
const CAD_ENABLED = cadEnabled();
|
|
101
104
|
const DEFAULT_HOST = process.env.BAMBU_PRINTER_HOST || process.env.PRINTER_HOST || "localhost";
|
|
102
105
|
const DEFAULT_BAMBU_SERIAL = process.env.BAMBU_PRINTER_SERIAL || process.env.BAMBU_SERIAL || "";
|
|
103
106
|
const DEFAULT_BAMBU_TOKEN =
|
|
104
107
|
process.env.BAMBU_PRINTER_ACCESS_TOKEN || process.env.BAMBU_TOKEN || "";
|
|
108
|
+
/** Access-code names people try that this server does not read (counterpart_diagnostics names them when set). */
|
|
109
|
+
const UNREAD_ACCESS_CODE_NAMES = ["BAMBU_PRINTER_ACCESS_CODE", "BAMBU_ACCESS_CODE", "BAMBU_ACCESS_TOKEN", "BAMBU_PRINTER_TOKEN"];
|
|
105
110
|
const DEFAULT_BAMBU_DEV_ID = process.env.BAMBU_DEV_ID || DEFAULT_BAMBU_SERIAL;
|
|
106
111
|
// os.tmpdir(), not process.cwd() — a packaged Claude Desktop extension is
|
|
107
112
|
// spawned with a cwd we don't control (and may not be writable), so a
|
|
@@ -162,7 +167,7 @@ const SERVER_INFO = {
|
|
|
162
167
|
/** Tools that declare an outputSchema: they always return structuredContent, and errors carry none. */
|
|
163
168
|
const OUTPUT_SCHEMA_TOOLS = new Set([
|
|
164
169
|
"cad_status", "cad_setup", "cad_run", "cad_check_fit", "cad_examples",
|
|
165
|
-
"counterpart_printer_info", "counterpart_self_check", "counterpart_print_progress", "counterpart_make_3mf",
|
|
170
|
+
"counterpart_printer_info", "counterpart_self_check", "counterpart_diagnostics", "counterpart_print_progress", "counterpart_make_3mf",
|
|
166
171
|
"counterpart_discover_printers", "counterpart_setup_fields", "counterpart_propose_filaments",
|
|
167
172
|
"fusion_mcp_status", "fusion_mcp_new_design", "fusion_mcp_export",
|
|
168
173
|
"camera_stream_start", "camera_frame", "camera_stream_stop",
|
|
@@ -3574,6 +3579,12 @@ class BambuPrinterMCPServer {
|
|
|
3574
3579
|
inputSchema: { type: "object", properties: {} },
|
|
3575
3580
|
outputSchema: SELF_CHECK_OUTPUT_SCHEMA
|
|
3576
3581
|
},
|
|
3582
|
+
{
|
|
3583
|
+
name: "counterpart_diagnostics",
|
|
3584
|
+
description: "Counterpart contract (counterpart/1): this server's own diagnostics for a bug report, as files for the client to add to its export: the configured printers (model, serial, connection; firmware is not read), this server's settings, slicer path and version, CAD runtime status, recent tool errors, this run's stderr log (MQTT and connection messages). The Bambu network plug-in logs are not included. Redaction fails closed: configured secrets go in their encoded forms, JSON is redacted by key, and any log line that names a secret is withheld whole; serial numbers, error codes and whether a secret is set stay. Names, contents and notes stay within max_bytes; anything missing is listed in notes. Sends nothing to the printer.",
|
|
3585
|
+
inputSchema: { type: "object", properties: DIAGNOSTICS_INPUT_PROPERTIES, additionalProperties: false },
|
|
3586
|
+
outputSchema: DIAGNOSTICS_OUTPUT_SCHEMA
|
|
3587
|
+
},
|
|
3577
3588
|
{
|
|
3578
3589
|
name: "counterpart_discover_printers",
|
|
3579
3590
|
description: "Counterpart contract (counterpart/1): Bambu printers on the local network, from their own SSDP announcements (UDP 2021), with serial, model (as bambu_model names it), name and firmware. Listens for duration_ms (default 4000). network is \"unavailable\" when another app holds the port. Never connects to or authenticates with a printer.",
|
|
@@ -3698,12 +3709,12 @@ class BambuPrinterMCPServer {
|
|
|
3698
3709
|
},
|
|
3699
3710
|
{
|
|
3700
3711
|
name: "fusion_mcp_status",
|
|
3701
|
-
description: `Check Autodesk Fusion through the configured Fusion MCP server (fusion360-mcp-server, faust-machines or the pinned fork with document binding): whether it is configured, Fusion is running, the Fusion360MCP add-in answers on its port, and the server's tools and schemas.
|
|
3712
|
+
description: `Check Autodesk Fusion through the configured Fusion MCP server (fusion360-mcp-server, faust-machines or the pinned fork with document binding): whether it is configured, Fusion is running, the Fusion360MCP add-in answers on its port, and the server's tools and schemas. Reports state (starting, ready, unresponsive), responsive and reason from a fresh no-op execute_code command probe, capped at 5 s; a ping or design read alone is not readiness. The probe never edits or opens a document. 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)}), or run fusion_mcp_setup.`,
|
|
3702
3713
|
inputSchema: {
|
|
3703
3714
|
type: "object",
|
|
3704
3715
|
properties: {
|
|
3705
3716
|
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." },
|
|
3706
|
-
timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Connection and
|
|
3717
|
+
timeout_ms: { type: "integer", minimum: 100, maximum: 600000, description: "Connection, discovery and command-probe deadline, capped at 5000 ms even if a larger value is requested. Launch waiting is separate." }
|
|
3707
3718
|
},
|
|
3708
3719
|
additionalProperties: false
|
|
3709
3720
|
},
|
|
@@ -3762,6 +3773,7 @@ class BambuPrinterMCPServer {
|
|
|
3762
3773
|
// A designer's settings extracted for this call are removed when it settles.
|
|
3763
3774
|
this.server.setRequestHandler(CallToolRequestSchema, (request, extra) => withPrintDispatch(() => withExtractedSettingsCleanup(async () => {
|
|
3764
3775
|
const { name, arguments: args } = request.params;
|
|
3776
|
+
rememberSecretArguments(args);
|
|
3765
3777
|
const sendNativeCommand = (
|
|
3766
3778
|
options: Parameters<typeof sendCommandWithBambuNative>[0],
|
|
3767
3779
|
execution: Parameters<typeof sendCommandWithBambuNative>[1] = {}
|
|
@@ -5109,6 +5121,10 @@ class BambuPrinterMCPServer {
|
|
|
5109
5121
|
result = await selfCheck(SERVER_INFO);
|
|
5110
5122
|
break;
|
|
5111
5123
|
|
|
5124
|
+
case "counterpart_diagnostics":
|
|
5125
|
+
result = await this.diagnostics(args ?? {});
|
|
5126
|
+
break;
|
|
5127
|
+
|
|
5112
5128
|
case "counterpart_printer_info":
|
|
5113
5129
|
result = bambuPrinterInfo({ server: SERVER_INFO, host, serial: bambuSerial, model: this.displayModel(args, bambuSerial), slicerType: normalizeSlicerType(DEFAULT_SLICER_TYPE) });
|
|
5114
5130
|
break;
|
|
@@ -5243,6 +5259,7 @@ class BambuPrinterMCPServer {
|
|
|
5243
5259
|
return { content: [{ type: "text", text }] };
|
|
5244
5260
|
|
|
5245
5261
|
} catch (error) {
|
|
5262
|
+
recordToolError(name, error);
|
|
5246
5263
|
if (name.startsWith("cad_")) {
|
|
5247
5264
|
const failure = await this.cad.failure(error, name);
|
|
5248
5265
|
return {isError: true, content: [{type: "text" as const, text: failure.message}], structuredContent: failure};
|
|
@@ -5280,6 +5297,70 @@ class BambuPrinterMCPServer {
|
|
|
5280
5297
|
})));
|
|
5281
5298
|
}
|
|
5282
5299
|
|
|
5300
|
+
/** counterpart_diagnostics: this server's own redacted bundle (src/counterpart/diagnostics.ts). Sends nothing to a printer. */
|
|
5301
|
+
private async diagnostics(args: Record<string, unknown>): Promise<ReturnType<typeof buildDiagnostics>> {
|
|
5302
|
+
const unknown = Object.keys(args).filter(key => key !== "printer" && key !== "max_bytes");
|
|
5303
|
+
if (unknown.length) throw new Error(`counterpart_diagnostics takes only printer and max_bytes, not ${unknown.join(", ")}.`);
|
|
5304
|
+
if (args.printer !== undefined && typeof args.printer !== "string") throw new Error("printer must be a string.");
|
|
5305
|
+
const maxBytes = diagnosticsBudget(args.max_bytes);
|
|
5306
|
+
const wanted = (args.printer as string | undefined)?.trim().toLowerCase();
|
|
5307
|
+
const notes: string[] = [];
|
|
5308
|
+
// This server's own sentences, built only from setting names it reads: their secret words name settings.
|
|
5309
|
+
const fixedNotes: string[] = [];
|
|
5310
|
+
|
|
5311
|
+
const model = DEFAULT_BAMBU_MODEL || undefined;
|
|
5312
|
+
let connection: { mode: string; type: string } | { error: string };
|
|
5313
|
+
try { connection = resolveConnection(undefined, model); } catch (error) { connection = { error: error instanceof Error ? error.message : String(error) }; }
|
|
5314
|
+
const configured = DEFAULT_BAMBU_SERIAL || process.env.BAMBU_PRINTER_HOST || process.env.PRINTER_HOST;
|
|
5315
|
+
const printers = configured ? [{
|
|
5316
|
+
id: DEFAULT_BAMBU_SERIAL || DEFAULT_HOST,
|
|
5317
|
+
kind: "bambu",
|
|
5318
|
+
host: DEFAULT_HOST,
|
|
5319
|
+
...(DEFAULT_BAMBU_SERIAL ? { serial: DEFAULT_BAMBU_SERIAL } : {}),
|
|
5320
|
+
...(model ? { model } : {}),
|
|
5321
|
+
connection,
|
|
5322
|
+
accessCodeSet: Boolean(DEFAULT_BAMBU_TOKEN),
|
|
5323
|
+
// Firmware comes only from the printer; this tool asks it nothing.
|
|
5324
|
+
firmware: "unknown",
|
|
5325
|
+
}] : [];
|
|
5326
|
+
if (!configured) notes.push("No printer is configured (BAMBU_SERIAL and BAMBU_PRINTER_HOST are unset).");
|
|
5327
|
+
// A look-alike name this server never reads leaves accessCodeSet false; name it so the bundle says why.
|
|
5328
|
+
const ignored = UNREAD_ACCESS_CODE_NAMES.filter(key => process.env[key]);
|
|
5329
|
+
if (ignored.length) fixedNotes.push(`${ignored.join(" and ")} ${ignored.length > 1 ? "are" : "is"} set, but this server reads the access code only from BAMBU_TOKEN or BAMBU_PRINTER_ACCESS_TOKEN (in the environment or its .env).`);
|
|
5330
|
+
const selected = wanted ? printers.filter(p => [p.id, p.host, p.serial].some(v => v?.toLowerCase() === wanted)) : printers;
|
|
5331
|
+
if (wanted && !selected.length) notes.push(`No configured printer is ${args.printer}; printers.json lists none.`);
|
|
5332
|
+
if (printers.length) notes.push("Printer firmware is not included: only the printer reports it, and this tool sends it nothing.");
|
|
5333
|
+
|
|
5334
|
+
let slicer: Record<string, unknown>;
|
|
5335
|
+
try {
|
|
5336
|
+
const { fields: _fields, ...setup } = slicerSetupNow();
|
|
5337
|
+
const version = appVersion(setup.path);
|
|
5338
|
+
slicer = { ...setup, ...(version ? { version } : {}) };
|
|
5339
|
+
if (setup.type === "orca-slicer-api") { if (!setup.found) notes.push("The remote OrcaSlicer API slicer has no SLICER_API_URL."); }
|
|
5340
|
+
else if (!setup.found) notes.push(`The ${setup.type} slicer is not installed where this server looks (${setup.path ?? "no path"}).`);
|
|
5341
|
+
else if (!version && setup.path) notes.push("Slicer version is unknown: its install doesn't name it, and this tool doesn't run the slicer.");
|
|
5342
|
+
} catch (error) { slicer = { error: error instanceof Error ? error.message : String(error) }; }
|
|
5343
|
+
|
|
5344
|
+
let cad: unknown;
|
|
5345
|
+
try { cad = await this.cad.status(); } catch (error) { cad = { error: error instanceof Error ? error.message : String(error) }; }
|
|
5346
|
+
|
|
5347
|
+
const settings = settingsSnapshot(/^(?:BAMBU|PRINTER|SLICER|ORCA|CAD|BLENDER|FUSION|BED_TYPE|NOZZLE|MCP|PJARCZAK|FULU|TEMP_DIR)/);
|
|
5348
|
+
|
|
5349
|
+
const sources: DiagnosticsSource[] = [
|
|
5350
|
+
{ name: "server.json", text: jsonText({ package: SERVER_INFO.name, version: SERVER_INFO.version, node: process.version, platform: process.platform, arch: process.arch, uptimeSec: Math.round(process.uptime()) }) },
|
|
5351
|
+
{ name: "printers.json", text: jsonText({ printers: selected }) },
|
|
5352
|
+
{ name: "settings.json", text: jsonText(settings) },
|
|
5353
|
+
{ name: "slicer.json", text: jsonText(slicer) },
|
|
5354
|
+
{ name: "cad.json", text: jsonText(cad) },
|
|
5355
|
+
{ name: "tool-errors.log", text: toolErrorsText() || "No tool has failed since this server started.\n" },
|
|
5356
|
+
{ name: "server-stderr.log", text: serverLogText() || "Nothing written to stderr since this server started.\n" },
|
|
5357
|
+
];
|
|
5358
|
+
// The Bambu network plug-in and native helper logs are written by other programs, in forms this server does not
|
|
5359
|
+
// control, and can carry secrets it never held (a cloud token, another printer's code): they stay out.
|
|
5360
|
+
fixedNotes.push("The Bambu network plug-in (fulu) and native helper logs are not included: other programs write them, and they can hold secrets this server cannot recognise.");
|
|
5361
|
+
return buildDiagnostics({ package: SERVER_INFO.name, version: SERVER_INFO.version, sources, notes, fixedNotes, maxBytes, secrets: DEFAULT_BAMBU_TOKEN ? [DEFAULT_BAMBU_TOKEN] : [] });
|
|
5362
|
+
}
|
|
5363
|
+
|
|
5283
5364
|
async startStdio() {
|
|
5284
5365
|
const transport = new StdioServerTransport();
|
|
5285
5366
|
await this.server.connect(transport);
|
package/src/tool-annotations.ts
CHANGED
|
@@ -68,6 +68,7 @@ export const TOOL_ANNOTATIONS: Record<string, ToolAnnotations> = {
|
|
|
68
68
|
get_slice_settings: LOCAL_OUTPUT, // a 3MF's settings are extracted to a fixed file in the temporary directory
|
|
69
69
|
counterpart_printer_info: READ_LOCAL, // configuration and capabilities; sends nothing to the printer
|
|
70
70
|
counterpart_self_check: READ_LOCAL, // loads this install's own modules; sends nothing to the printer
|
|
71
|
+
counterpart_diagnostics: READ_LOCAL, // reads this server's own logs and settings, redacted; sends nothing to the printer
|
|
71
72
|
counterpart_setup_fields: READ_LOCAL, // the settings this server reads; no configured values
|
|
72
73
|
|
|
73
74
|
// Local outputs in the server's temporary directory
|