bambu-printer-mcp 1.1.75 → 1.1.76
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.
|
@@ -177,6 +177,10 @@ function resultText(result) {
|
|
|
177
177
|
function failed(result, name) {
|
|
178
178
|
return result.isError === true || resultText(result).trimStart().startsWith(`**${name}** ERROR`);
|
|
179
179
|
}
|
|
180
|
+
/** The add-in's error kind from faust's "**tool** ERROR (KIND)" heading (fusion360_mcp/server.py), when it failed with one. */
|
|
181
|
+
function errorKind(result, name) {
|
|
182
|
+
return new RegExp(`^\\*\\*${name}\\*\\* ERROR \\(([A-Z_]+)\\)`).exec(resultText(result).trimStart())?.[1];
|
|
183
|
+
}
|
|
180
184
|
/** The value of one " key: value" line in faust's text result. */
|
|
181
185
|
function resultField(result, key) {
|
|
182
186
|
for (const line of resultText(result).split("\n")) {
|
|
@@ -228,6 +232,7 @@ export const FUSION_STATUS_OUTPUT_SCHEMA = {
|
|
|
228
232
|
connected: { type: "boolean", description: "The Fusion MCP server started and the add-in answered its ping." },
|
|
229
233
|
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." },
|
|
230
234
|
fusionRunning: { type: "boolean" },
|
|
235
|
+
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." },
|
|
231
236
|
tools: { type: "array", items: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } },
|
|
232
237
|
launched: { type: "boolean", description: "This call started Fusion." },
|
|
233
238
|
transport: { type: "string" },
|
|
@@ -449,6 +454,25 @@ export class FusionMcpBridge {
|
|
|
449
454
|
const ping = await this.invoke(live, options, dispatched, "ping", {});
|
|
450
455
|
result.connected = !failed(ping, "ping");
|
|
451
456
|
}
|
|
457
|
+
// Whether a design is open, from the add-in itself. get_design_type reads the active document's Design product
|
|
458
|
+
// (the add-in's _design(), as every design command does) and changes nothing; with no design it fails with the
|
|
459
|
+
// add-in's own error kind NO_ACTIVE_DESIGN (its hints.py). Any other answer leaves activeDesign out: unknown.
|
|
460
|
+
if (result.connected === true && live.tools.some(tool => tool.name === "get_design_type")) {
|
|
461
|
+
let read;
|
|
462
|
+
// A read that didn't finish (timeout, cancel, lost connection): Fusion isn't usable now. request() closes the
|
|
463
|
+
// cut-off session and names what happened, which status reports as its error.
|
|
464
|
+
try {
|
|
465
|
+
read = await this.invoke(live, options, dispatched, "get_design_type", {});
|
|
466
|
+
}
|
|
467
|
+
catch (error) {
|
|
468
|
+
result.connected = false;
|
|
469
|
+
throw error;
|
|
470
|
+
}
|
|
471
|
+
if (!failed(read, "get_design_type"))
|
|
472
|
+
result.activeDesign = true;
|
|
473
|
+
else if (errorKind(read, "get_design_type") === "NO_ACTIVE_DESIGN")
|
|
474
|
+
result.activeDesign = false;
|
|
475
|
+
}
|
|
452
476
|
});
|
|
453
477
|
}
|
|
454
478
|
catch (error) {
|
package/package.json
CHANGED
package/src/fusion-mcp-bridge.ts
CHANGED
|
@@ -189,6 +189,11 @@ function failed(result: CallToolResult, name: string): boolean {
|
|
|
189
189
|
return result.isError === true || resultText(result).trimStart().startsWith(`**${name}** ERROR`);
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
+
/** The add-in's error kind from faust's "**tool** ERROR (KIND)" heading (fusion360_mcp/server.py), when it failed with one. */
|
|
193
|
+
function errorKind(result: CallToolResult, name: string): string | undefined {
|
|
194
|
+
return new RegExp(`^\\*\\*${name}\\*\\* ERROR \\(([A-Z_]+)\\)`).exec(resultText(result).trimStart())?.[1];
|
|
195
|
+
}
|
|
196
|
+
|
|
192
197
|
/** The value of one " key: value" line in faust's text result. */
|
|
193
198
|
function resultField(result: CallToolResult, key: string): string | undefined {
|
|
194
199
|
for (const line of resultText(result).split("\n")) {
|
|
@@ -242,6 +247,7 @@ export const FUSION_STATUS_OUTPUT_SCHEMA = {
|
|
|
242
247
|
connected: { type: "boolean", description: "The Fusion MCP server started and the add-in answered its ping." },
|
|
243
248
|
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." },
|
|
244
249
|
fusionRunning: { type: "boolean" },
|
|
250
|
+
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." },
|
|
245
251
|
tools: { type: "array", items: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } },
|
|
246
252
|
launched: { type: "boolean", description: "This call started Fusion." },
|
|
247
253
|
transport: { type: "string" },
|
|
@@ -449,6 +455,18 @@ export class FusionMcpBridge {
|
|
|
449
455
|
const ping = await this.invoke(live, options, dispatched, "ping", {});
|
|
450
456
|
result.connected = !failed(ping, "ping");
|
|
451
457
|
}
|
|
458
|
+
// Whether a design is open, from the add-in itself. get_design_type reads the active document's Design product
|
|
459
|
+
// (the add-in's _design(), as every design command does) and changes nothing; with no design it fails with the
|
|
460
|
+
// add-in's own error kind NO_ACTIVE_DESIGN (its hints.py). Any other answer leaves activeDesign out: unknown.
|
|
461
|
+
if (result.connected === true && live.tools.some(tool => tool.name === "get_design_type")) {
|
|
462
|
+
let read: CallToolResult;
|
|
463
|
+
// A read that didn't finish (timeout, cancel, lost connection): Fusion isn't usable now. request() closes the
|
|
464
|
+
// cut-off session and names what happened, which status reports as its error.
|
|
465
|
+
try { read = await this.invoke(live, options, dispatched, "get_design_type", {}); }
|
|
466
|
+
catch (error) { result.connected = false; throw error; }
|
|
467
|
+
if (!failed(read, "get_design_type")) result.activeDesign = true;
|
|
468
|
+
else if (errorKind(read, "get_design_type") === "NO_ACTIVE_DESIGN") result.activeDesign = false;
|
|
469
|
+
}
|
|
452
470
|
});
|
|
453
471
|
} catch (error) {
|
|
454
472
|
result.error = error instanceof Error ? error.message : String(error);
|