bambu-printer-mcp 1.1.89 → 1.1.90
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 +6 -1
- package/dist/cad/contracts.d.ts +84 -0
- package/dist/cad/contracts.js +50 -5
- package/dist/cad/examples.d.ts +22 -0
- package/dist/cad/examples.js +81 -0
- package/dist/cad/process.js +3 -0
- package/dist/cad-engine.d.ts +25 -0
- package/dist/cad-engine.js +197 -27
- package/dist/counterpart/remote.js +2 -0
- package/dist/design-guidance.d.ts +22 -1
- package/dist/design-guidance.js +35 -2
- package/dist/index.js +11 -2
- package/dist/tool-annotations.js +2 -0
- package/package.json +1 -1
- package/src/cad/contracts.ts +54 -5
- package/src/cad/examples/bag_clip.py +86 -0
- package/src/cad/examples/bistable_clicker.py +81 -0
- package/src/cad/examples/cable_clip.py +55 -0
- package/src/cad/examples/chainmail.py +45 -0
- package/src/cad/examples/hinged_box.py +101 -0
- package/src/cad/examples/knurled_knob.py +50 -0
- package/src/cad/examples/loft_handle.py +52 -0
- package/src/cad/examples/phone_stand.py +92 -0
- package/src/cad/examples/swept_hook.py +69 -0
- package/src/cad/examples/threaded_jar.py +62 -0
- package/src/cad/examples/trigger_capo.py +95 -0
- package/src/cad/examples/wall_hook.py +65 -0
- package/src/cad/examples.ts +77 -0
- package/src/cad/geometry.py +122 -4
- package/src/cad/process.ts +3 -0
- package/src/cad/worker.py +4 -0
- package/src/cad-engine.ts +221 -52
- package/src/counterpart/remote.ts +2 -0
- package/src/design-guidance.ts +35 -2
- package/src/index.ts +13 -2
- package/src/tool-annotations.ts +2 -0
package/dist/cad-engine.js
CHANGED
|
@@ -16,6 +16,11 @@ const PACKAGE_NAME = createRequire(import.meta.url)("../package.json")
|
|
|
16
16
|
export class CadEngine {
|
|
17
17
|
constructor(options) {
|
|
18
18
|
this.options = options;
|
|
19
|
+
/** How long a re-check waits for another CAD operation to let go of the engine (Counterpart reads status with 30 s). */
|
|
20
|
+
this.busyWaitMs = 25000;
|
|
21
|
+
/** Within this window a freed engine is re-checked here; later this call only waits for the other call's result, so
|
|
22
|
+
* a wait plus a ~17 s re-check cannot overrun the status deadline. */
|
|
23
|
+
this.busyRetryMs = 5000;
|
|
19
24
|
this.system = options.system ?? defaultCadSystem;
|
|
20
25
|
this.dataDir = path.resolve(options.dataDir ??
|
|
21
26
|
process.env.CAD_DATA_DIR ??
|
|
@@ -130,7 +135,7 @@ export class CadEngine {
|
|
|
130
135
|
if (args.install !== true)
|
|
131
136
|
return {
|
|
132
137
|
supported: ["darwin", "linux"].includes(this.system.platform),
|
|
133
|
-
...(await this.
|
|
138
|
+
...(await this.ensureReady(signal)),
|
|
134
139
|
};
|
|
135
140
|
if (!["darwin", "linux"].includes(this.system.platform))
|
|
136
141
|
throw new CadRefusal("cad-confinement-unavailable", `CAD confinement is unavailable on ${this.system.platform}.`);
|
|
@@ -168,29 +173,8 @@ export class CadEngine {
|
|
|
168
173
|
throw new CadRefusal("cad-uv-missing", "uv is not available on the MCP's PATH. Install uv, then run cad_setup again; no model was run.");
|
|
169
174
|
throw e;
|
|
170
175
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const request = path.join(job, "request.json");
|
|
174
|
-
await fs.writeFile(request, JSON.stringify({ output: job, home: os.homedir() }), { mode: 0o600 });
|
|
175
|
-
const result = JSON.parse((await this.confined("smoke", request, job, [request], 180000, signal)).stdout);
|
|
176
|
-
if (result.build123d !== BUILD123D ||
|
|
177
|
-
!result.watertight ||
|
|
178
|
-
!result.manifold ||
|
|
179
|
-
!result.step_valid ||
|
|
180
|
-
result.solid_count !== 1)
|
|
181
|
-
throw new Error("CAD setup's confined STL/STEP round trip failed.");
|
|
182
|
-
const storage = {
|
|
183
|
-
installed_bytes: await measureEnvironment(this.dataDir),
|
|
184
|
-
measured_at: new Date().toISOString(),
|
|
185
|
-
};
|
|
186
|
-
await fs.writeFile(path.join(this.dataDir, "ready.json"), JSON.stringify({
|
|
187
|
-
build123d: BUILD123D,
|
|
188
|
-
platform: this.system.platform,
|
|
189
|
-
verifiedAt: new Date().toISOString(),
|
|
190
|
-
fingerprint: await this.fingerprint(),
|
|
191
|
-
dataDevice: (await fs.stat(this.dataDir)).dev,
|
|
192
|
-
storage,
|
|
193
|
-
}), { mode: 0o600 });
|
|
176
|
+
this.reverifyFailure = undefined;
|
|
177
|
+
await this.verify(opts, signal);
|
|
194
178
|
return {
|
|
195
179
|
supported: true,
|
|
196
180
|
...(await this.status()),
|
|
@@ -199,6 +183,181 @@ export class CadEngine {
|
|
|
199
183
|
};
|
|
200
184
|
}, "setup", signal);
|
|
201
185
|
}
|
|
186
|
+
/**
|
|
187
|
+
* The proof setup ends with: the runtime's imports, then the confined build, STL and STEP round trip, then the ready
|
|
188
|
+
* marker with the engine fingerprint and the runtime identity it proved. Shared by cad_setup and the automatic
|
|
189
|
+
* re-verification after an update that changed only the engine's sources.
|
|
190
|
+
*/
|
|
191
|
+
async verify(opts, signal, measured) {
|
|
192
|
+
// Setup proves the fresh install's imports outside confinement first; a re-check of an unchanged runtime relies on
|
|
193
|
+
// the confined round trip, which imports the same libraries.
|
|
194
|
+
if (measured === undefined) {
|
|
195
|
+
const python = path.join(this.dataDir, "runtime", "bin", "python");
|
|
196
|
+
await this.system.run(python, ["-I", "-B", path.join(ASSETS, "worker.py"), "imports"], { ...opts, timeoutMs: 120000 });
|
|
197
|
+
}
|
|
198
|
+
const job = await fs.mkdtemp(path.join(this.dataDir, "verify-"));
|
|
199
|
+
const request = path.join(job, "request.json");
|
|
200
|
+
await fs.writeFile(request, JSON.stringify({ output: job, home: os.homedir() }), { mode: 0o600 });
|
|
201
|
+
const result = JSON.parse((await this.confined("smoke", request, job, [request], 180000, signal)).stdout);
|
|
202
|
+
if (result.build123d !== BUILD123D ||
|
|
203
|
+
!result.watertight ||
|
|
204
|
+
!result.manifold ||
|
|
205
|
+
!result.step_valid ||
|
|
206
|
+
result.solid_count !== 1)
|
|
207
|
+
throw new Error("CAD setup's confined STL/STEP round trip failed.");
|
|
208
|
+
// A re-check of an unchanged runtime keeps the size setup measured instead of walking 1.4 GB again.
|
|
209
|
+
const storage = measured ?? {
|
|
210
|
+
installed_bytes: await measureEnvironment(this.dataDir),
|
|
211
|
+
measured_at: new Date().toISOString(),
|
|
212
|
+
};
|
|
213
|
+
await fs.writeFile(path.join(this.dataDir, "ready.json"), JSON.stringify({
|
|
214
|
+
build123d: BUILD123D,
|
|
215
|
+
platform: this.system.platform,
|
|
216
|
+
verifiedAt: new Date().toISOString(),
|
|
217
|
+
fingerprint: await this.fingerprint(),
|
|
218
|
+
runtime: await this.runtimeIdentity(),
|
|
219
|
+
dataDevice: (await fs.stat(this.dataDir)).dev,
|
|
220
|
+
storage,
|
|
221
|
+
}), { mode: 0o600 });
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Re-verifies without installing when only the engine's own sources changed since the last proof (#609): the
|
|
225
|
+
* marker matches this platform, build123d and data device, its engine fingerprint differs, and the installed
|
|
226
|
+
* runtime still matches requirements.lock exactly with the same interpreter. Anything else, including a changed
|
|
227
|
+
* lock, still needs cad_setup with install: true. A failed re-verification is reported, not retried, until the
|
|
228
|
+
* engine changes again or setup runs.
|
|
229
|
+
*/
|
|
230
|
+
async ensureReady(signal, deadline) {
|
|
231
|
+
const status = await this.status();
|
|
232
|
+
if (status.ready || !status.configured)
|
|
233
|
+
return status;
|
|
234
|
+
const fingerprint = await this.fingerprint();
|
|
235
|
+
if (!(await this.onlyEngineChanged(fingerprint)))
|
|
236
|
+
return status;
|
|
237
|
+
if (this.reverifyFailure?.fingerprint === fingerprint)
|
|
238
|
+
return { ...status, error: this.reverifyFailure.error };
|
|
239
|
+
const started = performance.now();
|
|
240
|
+
// A cad_run or cad_check_fit passes its own deadline: the re-check, its waiting included, stays inside timeout_ms.
|
|
241
|
+
const outOfTime = {
|
|
242
|
+
...status,
|
|
243
|
+
error: "The automatic re-check after this MCP's update did not finish within this call's timeout_ms; the next call runs it again.",
|
|
244
|
+
};
|
|
245
|
+
if (deadline !== undefined && deadline - started < 1)
|
|
246
|
+
return outOfTime;
|
|
247
|
+
const limit = deadline === undefined ? undefined : AbortSignal.timeout(Math.ceil(deadline - started));
|
|
248
|
+
const bounded = limit ? (signal ? AbortSignal.any([signal, limit]) : limit) : signal;
|
|
249
|
+
const recheck = () => this.exclusive(async () => {
|
|
250
|
+
if ((await this.status()).ready)
|
|
251
|
+
return;
|
|
252
|
+
const env = this.environment(this.dataDir);
|
|
253
|
+
await fs.mkdir(env.TMPDIR, { recursive: true });
|
|
254
|
+
const previous = await fs
|
|
255
|
+
.readFile(path.join(this.dataDir, "ready.json"), "utf8")
|
|
256
|
+
.then((text) => JSON.parse(text).storage, () => undefined);
|
|
257
|
+
await this.verify({ env, cwd: this.dataDir, signal: bounded, timeoutMs: 600000 }, bounded, previous ?? null);
|
|
258
|
+
}, "setup", bounded);
|
|
259
|
+
try {
|
|
260
|
+
// Another call may hold the engine, usually this same re-check from another process (Counterpart reading
|
|
261
|
+
// cad_status while the design worker's first cad_run starts): wait for it and try again, never call it a failure.
|
|
262
|
+
const waited = performance.now();
|
|
263
|
+
for (let attempt = true, until = Math.min(waited + this.busyWaitMs, deadline ?? Infinity);;) {
|
|
264
|
+
try {
|
|
265
|
+
if (attempt) {
|
|
266
|
+
await recheck();
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
throw new CadRefusal("cad-setup-busy", "waiting for the other CAD operation's result");
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
if (!(e instanceof CadRefusal && e.code === "cad-setup-busy"))
|
|
273
|
+
throw e;
|
|
274
|
+
signal?.throwIfAborted();
|
|
275
|
+
if (limit?.aborted)
|
|
276
|
+
return outOfTime;
|
|
277
|
+
if ((await this.status()).ready)
|
|
278
|
+
break;
|
|
279
|
+
attempt = performance.now() - waited < this.busyRetryMs;
|
|
280
|
+
if (performance.now() >= until)
|
|
281
|
+
return {
|
|
282
|
+
...(await this.status()),
|
|
283
|
+
error: "Another CAD operation is running; this MCP re-checks its unchanged runtime by itself when that finishes. Ask again shortly.",
|
|
284
|
+
};
|
|
285
|
+
await new Promise((resolve) => setTimeout(resolve, 500));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
catch (e) {
|
|
290
|
+
signal?.throwIfAborted();
|
|
291
|
+
if (limit?.aborted)
|
|
292
|
+
return outOfTime; // ran out of this call's time: not a failed re-check, never cached
|
|
293
|
+
const reason = e instanceof Error ? e.message : String(e);
|
|
294
|
+
this.reverifyFailure = {
|
|
295
|
+
fingerprint,
|
|
296
|
+
error: `The automatic re-check after this MCP's update failed (${reason.slice(0, 300)}). Run cad_setup with install: true.`,
|
|
297
|
+
};
|
|
298
|
+
return { ...(await this.status()), error: this.reverifyFailure.error };
|
|
299
|
+
}
|
|
300
|
+
const after = await this.status();
|
|
301
|
+
return after.ready
|
|
302
|
+
? {
|
|
303
|
+
...after,
|
|
304
|
+
reverified: `Re-checked automatically after an update to the engine (${Math.round((performance.now() - started) / 1000)} s): the installed runtime was unchanged; confined import, build, STL and STEP round trip passed.`,
|
|
305
|
+
}
|
|
306
|
+
: after;
|
|
307
|
+
}
|
|
308
|
+
async onlyEngineChanged(fingerprint) {
|
|
309
|
+
try {
|
|
310
|
+
const marker = JSON.parse(await fs.readFile(path.join(this.dataDir, "ready.json"), "utf8"));
|
|
311
|
+
if (marker.build123d !== BUILD123D ||
|
|
312
|
+
marker.platform !== this.system.platform ||
|
|
313
|
+
marker.dataDevice !== (await fs.stat(this.dataDir)).dev ||
|
|
314
|
+
typeof marker.fingerprint !== "string" ||
|
|
315
|
+
marker.fingerprint === fingerprint)
|
|
316
|
+
return false;
|
|
317
|
+
const runtime = await this.runtimeIdentity();
|
|
318
|
+
if (!runtime.matchesLock)
|
|
319
|
+
return false;
|
|
320
|
+
// Markers from engines without the runtime record (bambu-printer-mcp 1.1.89, mcp-3D-printer-server 1.2.71 and
|
|
321
|
+
// earlier) qualify by the exact package match; the re-run proof decides the rest.
|
|
322
|
+
if (marker.runtime && (marker.runtime.interpreter !== runtime.interpreter || marker.runtime.lock_sha256 !== runtime.lock_sha256))
|
|
323
|
+
return false;
|
|
324
|
+
return true;
|
|
325
|
+
}
|
|
326
|
+
catch {
|
|
327
|
+
return false;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/** The interpreter the venv runs and whether its installed distributions are exactly requirements.lock's pins. */
|
|
331
|
+
async runtimeIdentity() {
|
|
332
|
+
const lock = await fs.readFile(path.join(ASSETS, "requirements.lock"), "utf8");
|
|
333
|
+
const runtime = path.join(this.dataDir, "runtime");
|
|
334
|
+
const cfg = await fs.readFile(path.join(runtime, "pyvenv.cfg"), "utf8").catch(() => "");
|
|
335
|
+
const field = (name) => cfg.match(new RegExp(`^${name}\\s*=\\s*(.+)$`, "m"))?.[1]?.trim() ?? "";
|
|
336
|
+
const interpreter = `${field("version_info") || field("version")} ${await fs.realpath(path.join(runtime, "bin", "python")).catch(() => "")}`;
|
|
337
|
+
const norm = (name) => name.toLowerCase().replace(/[-_.]+/g, "-");
|
|
338
|
+
const installed = new Map();
|
|
339
|
+
const lib = path.join(runtime, "lib");
|
|
340
|
+
for (const dir of await fs.readdir(lib).catch(() => [])) {
|
|
341
|
+
if (!/^python3\.\d+$/.test(dir))
|
|
342
|
+
continue;
|
|
343
|
+
for (const entry of await fs.readdir(path.join(lib, dir, "site-packages")).catch(() => [])) {
|
|
344
|
+
const m = entry.match(/^(.+)-([^-]+)\.dist-info$/);
|
|
345
|
+
if (m)
|
|
346
|
+
installed.set(norm(m[1]), m[2]);
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
let matchesLock = installed.size > 0;
|
|
350
|
+
for (const line of lock.split("\n")) {
|
|
351
|
+
const m = line.match(/^\s*([A-Za-z0-9][A-Za-z0-9._-]*)==([^\s;]+)\s*(;.*)?$/);
|
|
352
|
+
if (!m)
|
|
353
|
+
continue;
|
|
354
|
+
const have = installed.get(norm(m[1]));
|
|
355
|
+
// A pin behind an environment marker may not apply here: absent is fine, a different version is not.
|
|
356
|
+
if (have === undefined ? !m[3] : have !== m[2])
|
|
357
|
+
matchesLock = false;
|
|
358
|
+
}
|
|
359
|
+
return { interpreter, lock_sha256: createHash("sha256").update(lock).digest("hex"), matchesLock };
|
|
360
|
+
}
|
|
202
361
|
async fingerprint() {
|
|
203
362
|
const hash = createHash("sha256");
|
|
204
363
|
for (const file of [
|
|
@@ -346,10 +505,13 @@ export class CadEngine {
|
|
|
346
505
|
inputs[alias] = await this.inputFile(value, ext);
|
|
347
506
|
}
|
|
348
507
|
}
|
|
508
|
+
// Re-check before queueing, inside this run's deadline; a not-ready refusal still comes from inside the queue,
|
|
509
|
+
// after any queue timeout.
|
|
510
|
+
const before = await this.ensureReady(signal, deadline);
|
|
349
511
|
return this.exclusive(async (queueWaitMs) => {
|
|
350
512
|
const status = await this.status();
|
|
351
513
|
if (!status.ready)
|
|
352
|
-
throw new CadRefusal("cad-not-ready", status.error);
|
|
514
|
+
throw new CadRefusal("cad-not-ready", before.error ?? status.error);
|
|
353
515
|
const job = await fs.mkdtemp(path.join(root, `cad-${name}-`));
|
|
354
516
|
await fs.chmod(job, 0o700);
|
|
355
517
|
const script = path.join(job, `${name}.py`), parameters = path.join(job, `${name}.parameters.json`), request = path.join(job, ".cad-request.json");
|
|
@@ -484,10 +646,13 @@ export class CadEngine {
|
|
|
484
646
|
clearance < 0 ||
|
|
485
647
|
clearance > 100)
|
|
486
648
|
throw new Error("clearance_mm must be finite, between 0 and 100.");
|
|
649
|
+
// One deadline for the whole call: the automatic re-check and the fit share timeout_ms.
|
|
650
|
+
const deadline = performance.now() + milliseconds(args.timeout_ms);
|
|
651
|
+
const before = await this.ensureReady(signal, deadline);
|
|
487
652
|
return this.exclusive(async () => {
|
|
488
653
|
const status = await this.status();
|
|
489
654
|
if (!status.ready)
|
|
490
|
-
throw new CadRefusal("cad-not-ready", status.error);
|
|
655
|
+
throw new CadRefusal("cad-not-ready", before.error ?? status.error);
|
|
491
656
|
const job = await fs.mkdtemp(path.join(this.dataDir, "fit-"));
|
|
492
657
|
try {
|
|
493
658
|
await fs.copyFile(model, path.join(job, "model.stl"));
|
|
@@ -503,7 +668,12 @@ export class CadEngine {
|
|
|
503
668
|
request,
|
|
504
669
|
path.join(job, "model.stl"),
|
|
505
670
|
path.join(job, "reference.stl"),
|
|
506
|
-
],
|
|
671
|
+
], (() => {
|
|
672
|
+
const left = Math.floor(deadline - performance.now());
|
|
673
|
+
if (left <= 0)
|
|
674
|
+
throw new Error("CAD fit timed out.");
|
|
675
|
+
return left;
|
|
676
|
+
})(), signal)).stdout);
|
|
507
677
|
}
|
|
508
678
|
finally {
|
|
509
679
|
await fs.rm(job, { recursive: true, force: true });
|
|
@@ -10,7 +10,7 @@ export interface DesignPrompt {
|
|
|
10
10
|
description: string;
|
|
11
11
|
text: string;
|
|
12
12
|
}
|
|
13
|
-
export declare const FDM_CORE = "Design the finished object the user wants, with the manufacturing plan as part of the design. Preserve its function, fit, and visual identity. Use your design ability freely to make that outcome practical through geometry, orientation, materials, color placement, supports, and assembly.\n\nUse the actual printer and material context: nozzle arrangement and filament routing, build volume, nozzle and line widths, layer profile, cooling, available filaments, and relevant successful prints or calibration. Missing information is unknown, not a capability the printer automatically has. Use reasonable, labeled assumptions for reversible choices; ask only when an unknown materially changes the result.\n\nBefore committing to detailed geometry, choose a plausible way to manufacture and assemble it. For a consequential tradeoff, compare the strongest one-piece approach with a meaningfully different orientation or split. Simple parts do not need a design tournament. Judge total effort to obtain a good finished object: printing, consumed filament, likely rework, support cleanup, assembly, and extra hardware. Respect the user's priorities instead of applying fixed numerical weights.\n\nKeep assembled orientation and print orientation distinct. Preserve critical dimensions and mating surfaces. Account for measurement uncertainty and fit clearance separately; a scan or printed measuring tool does not establish its own accuracy. Use the smallest useful fit sample when uncertainty could otherwise waste a substantial print. A size the person confirmed without changing a prefilled number is not a measurement. If a case, cover, or attachment is mentioned, the bare product's size is not the size to design to.\n\nFind out before you design, and before you ask. Research whenever the request names something that exists outside the person's hands (a product, a vehicle and its year, a phone, a case, a tool, an appliance, a standard part, a material, the place the part mounts) or a decision turns on a fact about the world (how hot it gets there, what the surface is made of, what adhesive holds on it, where the buttons, ports, vents or airbags are). Do not research what exists only with the person: which of their own things, how something felt, what they prefer, an object they measured or scanned. This takes a few minutes, not an hour, and it works the same with any model that has web tools:\n1. Write down the few facts that decide this design, usually three to seven: each interface's size, where the part mounts and what surrounds that spot, what the surface is made of, the environment, the load.\n2. Search each fact by the exact name, model and year or generation plus the fact itself (\"dimensions mm\", \"technical drawing\", \"accessory design guidelines\", \"spec sheet\", \"parts diagram\", \"teardown\", \"material\"). Run the searches together when the tools allow. Makers of fitted accessories for the same object (mounts, cases, installation kits, replacement panels) publish where things go and how big the openings are; owners publish photos with a tape measure; parts catalogues show each panel's outline. Look there, not only at the maker of the object.\n3. Open the page and read the number. A search-result snippet is not a source. Prefer, in order: the maker's drawing or specification, a standard, a fitted-accessory maker, a reviewer's or owner's measurement, a retailer's listing. Two independent sources that agree beat one.\n4. When a first search finds nothing, rephrase before concluding anything: the generation or chassis code, the part number, another market's name for it, the accessory that fits it instead of the thing itself. \"Not found\" is true only after that, and you say where you looked.\n5. Keep each fact with its value, its source and its kind (maker, standard, accessory maker, measurement, listing), labelled as published, and design to it.\n6. For what is still unknown after about two rounds per fact, shape the design so that fact does not decide whether it works (an adjustable or sprung interface, a foot that suits more than one surface), or state a bounded assumption as an assumption. Ask the person only as the last resort, one short question, and only for what exists nowhere but with them. Never ask for something a search answers: a photo of their car's dashboard, the size of a named product, what a named surface is made of.\nWithout web tools, say so in the result, use what you recall labelled as recalled rather than published, and lean harder on step 6.\n\nBefore choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.\n\nChoose each fit by what that interface has to do: drop in and lift out, slide, locate without rattle, grip so it does not slip or turn, snap over, or press in to stay. There is no single fit number. Keep three things apart for each interface: the object's size and how sure it is, the correction this printer and orientation need (its own observed corrections first, when the context supplies them), and the fit the function calls for. When the size's uncertainty is wider than the function tolerates, do not answer with a better number: choose a mechanism that absorbs the difference (crush ribs, a split closed by a screw, a flexure, a snap), or ask for the one measurement that settles it. The same object changes with time and use: full and nearly empty, new and worn, soft and stiff. A fit that relies on the object giving way must still work in its stiffest, largest state, and a pocket is sized to the widest section the object passes through on the way in, with support where the object actually bears, not to its bounding box.\n\nEvaluate printability locally. Distinguish a progressively supported overhang, a bridge anchored at both ends, and a disconnected island. State overhang angles from vertical: 0 degrees is a vertical wall; 90 degrees is a horizontal underside. Convert conventions before setting slicer angles. Use relevant measured capability ahead of generic rules. A 45-degree threshold is not a universal support requirement, and a steep surface is not automatically unprintable. Judge bridge length along the actual unsupported extrusion path, with its anchors, cooling, material, and required underside quality. A feature that survives printing may still miss a cosmetic or dimensional requirement.\n\nResolve a difficult region with the least disruptive effective change: a better orientation, local geometry, suitable process settings, accessible support, a deliberate breakaway feature, or a split. Supports are an ordinary manufacturing option. Preserve attractive curves and useful complexity when modest support or cleanup achieves them. Check support removal and tool access, especially inside cavities. Avoid changing the whole object to solve a local problem.\n\nChoose layer orientation, material, walls, and joints for the actual loads and environment. Check the load path, flexing features, fastener access, and installation sequence. Judge a connection (tape, screws, a snap) against products that demonstrably work. If a check says a bought product that holds for years would fail, the check is wrong: correct it, then apply it to your design. A reduction in supports or color changes must not silently weaken the part or defeat its fit.\n\nWhen a part must flex, grip, snap, clip, spring, or hold something, consider a compliant mechanism first: one piece that bends on purpose often beats rigid jaws plus a clamp bolt, with fewer parts, no fastener to buy or lose, and a hold that follows the object. That choice is for the element that grips, clips or springs, not for the product: it is never a reason to make the whole thing one piece or to drop a joint, adjustment or base the bought versions have. Spread the bending over a long band, leaf, or arch rather than a short stub; keep the rest of the body stiff so the stroke goes where you intend; give a hand enough leverage; design the preload in; use an over-centre or cam where a hold must lock; and give every flexing direction a hard stop so a hard pull meets solid material. Keep the bending in the layer plane, where the filament runs along the strain; bending that pulls layers apart is far weaker and fails with little warning. Choose the strain by duty (bent once to assemble, bent every day, and held bent for months are different designs) and by material and direction, using the printer's own observed values when the context supplies them. Modern PLA and PETG grades are not brittle in this role: proven printed springs work daily at strains that older moulded-plastic tables would forbid. What usually ends a flexure is not a clean snap at a magic percentage but whitening and set at a sharp root, layers parting where the bend crosses them, or a held bend creeping loose, faster when warm. In sustained heat such as a parked car, a part held bent relaxes and a sun-heated dashboard can exceed what PLA or PETG carry under load: prefer a rest state that sits unstrained, and say so when the material cannot honestly do the job. A part a hand works has to be easy to work, and that is checked like its hold: say where the fingers go, how hard they push to open it, how far it opens, and how the object goes in and comes out with one hand. A grip that meets its force and is a fight to use has failed the brief.\n\nOn a shared-nozzle multicolor setup, reason about filament transitions across layers, including support-interface material. Total color count alone is a poor cost estimate. Consider color placement, shallow inlays, separately printed accents, and part orientation while preserving the requested appearance. Separate bodies on one layer-printed plate can still cause repeated swaps. Use the slicer's actual schedule and estimates when available; do not invent a fixed cost per color change.\n\nUse assembly when its benefit is worth the user's additional work. Design alignment, clearance, engagement, and assembly access deliberately. Glue is a valid planned joining method for suitable materials and loads; make joints self-locating and give them useful bonding area. Use mechanical retention when loads, repeated flexing, or serviceability call for it. State needed glue, hardware, tools, and assembly effort plainly. Avoid adding parts when a modest support or a simple one-piece print is the better result. A printed screw, nut, or threaded hole is an ordinary choice at hand sizes (M8 and up as the usual starting point, about M6 as the floor) with a coarse profile shaped to print without supports; below that floor, under sustained preload that must not relax, in heat, or under shock, a metal screw or insert is the honest choice. Keep threads out of the main load path where a shoulder, tenon, key, or serrated face can carry shear and torque, and let the thread only hold the joint closed.\n\nVerify the chosen geometry in its actual print orientation and inspect the slice when tools permit. Check critical fits, missing or floating features, toolpaths, supports, color assignments, total time, and material consumption. Treat a slicer prediction as a prediction, not a physical test. Fix consequential problems and re-slice relevant changes. Stop when the design meets the brief and no remaining improvement justifies its cost. State \"prints without supports\", \"holds\", or \"fits\" only when the engine's own checks or the slice show it, and give the number that shows it; otherwise call it an untested prediction.\n\nKeep the user-facing result short: the recommended design, why its manufacturing approach makes sense, how it prints and assembles, and any consequential unresolved assumption. Distinguish measured dimensions, slicer estimates, and untested predictions. Say where each critical size came from (measured, published, or assumed) and what each interface is meant to do and how it fits. Keep detailed analysis in the working process.";
|
|
13
|
+
export declare const FDM_CORE = "Design the finished object the user wants, with the manufacturing plan as part of the design. Preserve its function, fit, and visual identity. Use your design ability freely to make that outcome practical through geometry, orientation, materials, color placement, supports, and assembly.\n\nUse the actual printer and material context: nozzle arrangement and filament routing, build volume, nozzle and line widths, layer profile, cooling, available filaments, and relevant successful prints or calibration. Missing information is unknown, not a capability the printer automatically has. Use reasonable, labeled assumptions for reversible choices; ask only when an unknown materially changes the result.\n\nBefore committing to detailed geometry, choose a plausible way to manufacture and assemble it. For a consequential tradeoff, compare the strongest one-piece approach with a meaningfully different orientation or split. Simple parts do not need a design tournament. Judge total effort to obtain a good finished object: printing, consumed filament, likely rework, support cleanup, assembly, and extra hardware. Respect the user's priorities instead of applying fixed numerical weights.\n\nKeep assembled orientation and print orientation distinct. Preserve critical dimensions and mating surfaces. Account for measurement uncertainty and fit clearance separately; a scan or printed measuring tool does not establish its own accuracy. Use the smallest useful fit sample when uncertainty could otherwise waste a substantial print. A size the person confirmed without changing a prefilled number is not a measurement. If a case, cover, or attachment is mentioned, the bare product's size is not the size to design to.\n\nFind out before you design, and before you ask. Research whenever the request names something that exists outside the person's hands (a product, a vehicle and its year, a phone, a case, a tool, an appliance, a standard part, a material, the place the part mounts) or a decision turns on a fact about the world (how hot it gets there, what the surface is made of, what adhesive holds on it, where the buttons, ports, vents or airbags are). Do not research what exists only with the person: which of their own things, how something felt, what they prefer, an object they measured or scanned. This takes a few minutes, not an hour, and it works the same with any model that has web tools:\n1. Write down the few facts that decide this design, usually three to seven: each interface's size, where the part mounts and what surrounds that spot, what the surface is made of, the environment, the load.\n2. Search each fact by the exact name, model and year or generation plus the fact itself (\"dimensions mm\", \"technical drawing\", \"accessory design guidelines\", \"spec sheet\", \"parts diagram\", \"teardown\", \"material\"). Run the searches together when the tools allow. Makers of fitted accessories for the same object (mounts, cases, installation kits, replacement panels) publish where things go and how big the openings are; owners publish photos with a tape measure; parts catalogues show each panel's outline. Look there, not only at the maker of the object.\n3. Open the page and read the number. A search-result snippet is not a source. Prefer, in order: the maker's drawing or specification, a standard, a fitted-accessory maker, a reviewer's or owner's measurement, a retailer's listing. Two independent sources that agree beat one.\n4. When a first search finds nothing, rephrase before concluding anything: the generation or chassis code, the part number, another market's name for it, the accessory that fits it instead of the thing itself. \"Not found\" is true only after that, and you say where you looked.\n5. Keep each fact with its value, its source and its kind (maker, standard, accessory maker, measurement, listing), labelled as published, and design to it.\n6. For what is still unknown after about two rounds per fact, shape the design so that fact does not decide whether it works (an adjustable or sprung interface, a foot that suits more than one surface), or state a bounded assumption as an assumption. Ask the person only as the last resort, one short question, and only for what exists nowhere but with them. Never ask for something a search answers: a photo of their car's dashboard, the size of a named product, what a named surface is made of.\nWithout web tools, say so in the result, use what you recall labelled as recalled rather than published, and lean harder on step 6.\n\nWrite the concept down before any geometry, in a few lines: the bought product you are following, its mechanism, the load path, and how it will print. Before choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.\n\nGive it the product's form as well as its function. The bought thing's shape is evidence: a handle swells where the palm closes, a hook's arm thickens towards its root, a knob is round and knurled, a clip's jaws wrap what they hold. Do not reduce a product to a flat profile pushed up, or a box with holes, because that is quick to model and prints without thought: that is a bracket, and people can tell. Put curves where hands and objects touch and where load turns a corner. A flat, in-plane layout is right only for the element that needs it (a spring that must bend in the layer plane, a print-in-place hinge or chain), and then say so; the rest of the product keeps its form, split or turned for printing if need be. When the engine renders the model, look at a three-quarter view and ask whether a person would recognise the thing and want it.\n\nChoose each fit by what that interface has to do: drop in and lift out, slide, locate without rattle, grip so it does not slip or turn, snap over, or press in to stay. There is no single fit number. Keep three things apart for each interface: the object's size and how sure it is, the correction this printer and orientation need (its own observed corrections first, when the context supplies them), and the fit the function calls for. When the size's uncertainty is wider than the function tolerates, do not answer with a better number: choose a mechanism that absorbs the difference (crush ribs, a split closed by a screw, a flexure, a snap), or ask for the one measurement that settles it. The same object changes with time and use: full and nearly empty, new and worn, soft and stiff. A fit that relies on the object giving way must still work in its stiffest, largest state, and a pocket is sized to the widest section the object passes through on the way in, with support where the object actually bears, not to its bounding box.\n\nEvaluate printability locally. Distinguish a progressively supported overhang, a bridge anchored at both ends, and a disconnected island. State overhang angles from vertical: 0 degrees is a vertical wall; 90 degrees is a horizontal underside. Convert conventions before setting slicer angles. Use relevant measured capability ahead of generic rules. A 45-degree threshold is not a universal support requirement, and a steep surface is not automatically unprintable. Judge bridge length along the actual unsupported extrusion path, with its anchors, cooling, material, and required underside quality. A feature that survives printing may still miss a cosmetic or dimensional requirement.\n\nResolve a difficult region with the least disruptive effective change: a better orientation, local geometry, suitable process settings, accessible support, a deliberate breakaway feature, or a split. Supports are an ordinary manufacturing option. Preserve attractive curves and useful complexity when modest support or cleanup achieves them. Check support removal and tool access, especially inside cavities. Avoid changing the whole object to solve a local problem.\n\nChoose layer orientation, material, walls, and joints for the actual loads and environment. Check the load path, flexing features, fastener access, and installation sequence. Judge a connection (tape, screws, a snap) against products that demonstrably work. If a check says a bought product that holds for years would fail, the check is wrong: correct it, then apply it to your design. A reduction in supports or color changes must not silently weaken the part or defeat its fit.\n\nWhen a part must flex, grip, snap, clip, spring, or hold something, consider a compliant mechanism first: one piece that bends on purpose often beats rigid jaws plus a clamp bolt, with fewer parts, no fastener to buy or lose, and a hold that follows the object. That choice is for the element that grips, clips or springs, not for the product: it is never a reason to make the whole thing one piece or to drop a joint, adjustment or base the bought versions have. Spread the bending over a long band, leaf, or arch rather than a short stub; keep the rest of the body stiff so the stroke goes where you intend; give a hand enough leverage; design the preload in; use an over-centre or cam where a hold must lock; and give every flexing direction a hard stop so a hard pull meets solid material. Keep the bending in the layer plane, where the filament runs along the strain; bending that pulls layers apart is far weaker and fails with little warning. Choose the strain by duty (bent once to assemble, bent every day, and held bent for months are different designs) and by material and direction, using the printer's own observed values when the context supplies them. Modern PLA and PETG grades are not brittle in this role: proven printed springs work daily at strains that older moulded-plastic tables would forbid. What usually ends a flexure is not a clean snap at a magic percentage but whitening and set at a sharp root, layers parting where the bend crosses them, or a held bend creeping loose, faster when warm. In sustained heat such as a parked car, a part held bent relaxes and a sun-heated dashboard can exceed what PLA or PETG carry under load: prefer a rest state that sits unstrained, and say so when the material cannot honestly do the job. A part a hand works has to be easy to work, and that is checked like its hold: say where the fingers go, how hard they push to open it, how far it opens, and how the object goes in and comes out with one hand. A grip that meets its force and is a fight to use has failed the brief.\n\nOn a shared-nozzle multicolor setup, reason about filament transitions across layers, including support-interface material. Total color count alone is a poor cost estimate. Consider color placement, shallow inlays, separately printed accents, and part orientation while preserving the requested appearance. Separate bodies on one layer-printed plate can still cause repeated swaps. Use the slicer's actual schedule and estimates when available; do not invent a fixed cost per color change.\n\nUse assembly when its benefit is worth the user's additional work. Design alignment, clearance, engagement, and assembly access deliberately. Glue is a valid planned joining method for suitable materials and loads; make joints self-locating and give them useful bonding area. Use mechanical retention when loads, repeated flexing, or serviceability call for it. State needed glue, hardware, tools, and assembly effort plainly. Avoid adding parts when a modest support or a simple one-piece print is the better result. A printed screw, nut, or threaded hole is an ordinary choice at hand sizes (M8 and up as the usual starting point, about M6 as the floor) with a coarse profile shaped to print without supports; below that floor, under sustained preload that must not relax, in heat, or under shock, a metal screw or insert is the honest choice. Keep threads out of the main load path where a shoulder, tenon, key, or serrated face can carry shear and torque, and let the thread only hold the joint closed.\n\nVerify the chosen geometry in its actual print orientation and inspect the slice when tools permit. Check critical fits, missing or floating features, toolpaths, supports, color assignments, total time, and material consumption. Treat a slicer prediction as a prediction, not a physical test. Fix consequential problems and re-slice relevant changes. Stop when the design meets the brief and no remaining improvement justifies its cost. State \"prints without supports\", \"holds\", or \"fits\" only when the engine's own checks or the slice show it, and give the number that shows it; otherwise call it an untested prediction.\n\nFit and flexure guidance is longer than this text and is read when it applies: fdm_fit whenever a part meets a real object or another part, fdm_flexures whenever a part must flex, grip, snap, clip or spring. If your host did not attach them, read them with this MCP's design_guidance tool before you choose that fit or size that spring. Where the MCP's code engine is in use, its cad_examples tool lists worked designs to start from.\n\nKeep the user-facing result short: the recommended design, why its manufacturing approach makes sense, how it prints and assembles, and any consequential unresolved assumption. Distinguish measured dimensions, slicer estimates, and untested predictions. Say where each critical size came from (measured, published, or assumed) and what each interface is meant to do and how it fits. Keep detailed analysis in the working process.";
|
|
14
14
|
export declare const FDM_MULTICOLOR = "Apply this guidance when multiple colors or support materials share a print.\n\nPreserve the requested visual pattern. Evaluate its colors in build coordinates and across layers before committing to color geometry. On a shared nozzle, a small accent spanning many layers can create more transitions than a large region confined to a few layers. Count the slicer's actual transitions when available, including swaps back to a prior filament and support-interface swaps; color count and colored volume are only screening clues. On printers with multiple nozzles, evaluate each shared melt path; AMS slots are not independent nozzles.\n\nFor a costly pattern, consider the most promising alternatives: a different build orientation, color regions confined to fewer layers, shallow face inlays, or separately printed single-color pieces with intentional assembly. A vertical stripe in use may become a low-change feature in a different print orientation. Judge each option against load direction, surface quality, support burden, and the user's exact visual requirements. Finer layers can help an overhang while adding color-change layers; evaluate local adaptive layers and re-slice the combined plan.\n\nSeparating color bodies does not by itself eliminate swaps. Check plate scheduling. Single-color plates can remove repeated color changes; by-layer printing of different-color objects together usually cannot. Use sequential object printing only when supported and its clearance constraints are satisfied. Batch copies only when the user wants them.\n\nUse the actual directional flushing matrix and filament compatibility. Purging clears previous material; priming restores consistent extrusion. Track those separately when the slicer does. Flushing into compatible infill or supports may reduce discarded material, but it does not remove switching time, has finite capacity, and can affect appearance or strength. Do not add unnecessary infill or objects merely to hide waste.\n\nCompare the same requested quantity and finish. Report total filament and time across all plates, plus purge, tower, and support quantities only where available without double counting. Unknown metrics remain unknown. Recommend the original multicolor approach when the user values its seamless result enough to justify its cost.";
|
|
15
15
|
export declare const FDM_ASSEMBLY = "Apply this guidance when a split, insert, or joint may materially improve the result.\n\nCompare assembly against the best practical one-piece approach, including reasonable supports. A split earns its place by improving important surfaces, layer strength, fit, color efficiency, support access, repairability, or bed fit enough to justify handling and joining the pieces. Prefer a one-piece solution when its support cleanup is easier than assembly and the alternatives meet the other important requirements comparably well. Respect an explicit one-piece or no-glue requirement.\n\nPut boundaries where they are structurally sensible and visually deliberate. Use shoulders, keys, overlapping faces, tabs, or pins to locate parts and resist sliding or rotation as appropriate. Include fit clearance, lead-ins, adhesive space where needed, and a feasible insertion path. Check the assembled geometry and the order of operations, not only the separated pieces. Avoid joints whose screws, clamps, or mating faces become inaccessible during assembly.\n\nFor suitable lightly loaded rigid details, a locating pocket plus a compatible adhesive can be the simplest reliable solution. For a loaded clamp, a joint under peel or repeated bending, or a serviceable assembly, consider fasteners or mechanically captured geometry. Do not assume a tiny glued butt joint can carry the same load as an intact printed section. Select adhesive from evidence for the actual materials and conditions; superglue is an option, not a universal material property.\n\nState the practical consequence directly: which parts print in which orientations and colors, how they locate, how they are retained, which supplies are needed, and the estimated hands-on work. Keep hands-on time separate from adhesive cure time. Check a small joint sample only when its uncertain fit or strength would change the design decision.\n\nPrinted threads need a profile made for printing, not a copy of a metal V-thread. A coarse, truncated thread whose flanks sit within the printer's proven overhang (one widely printed all-plastic kit uses about a 96-degree included angle, 42 degrees from vertical, at pitches of roughly 2-3 mm for M8-M12 sizes, cleared by roughly two tenths of a millimetre per side at the pitch line) prints upright without supports and keeps its teeth in solid wall loops. Keep the pitch exactly the same on screw and hole; make clearance by shifting the profile radially, never by scaling the screw, which changes the pitch and wedges after a few turns. Give a hand screw several full turns of engagement and a knob that limits how hard it can be torqued. A long, slender screw that must pull or bend is better printed flat or split so filament runs along its length than stood upright across its layers. Where preload must survive months, heat, or shock, or the size is below about M6-M8, use a metal screw or heat-set insert and say so. When the context supplies this printer's own thread fit observation, use it ahead of any generic allowance.";
|
|
16
16
|
export declare const FDM_AFTER_SLICE = "Review this slice against the user's brief and the selected manufacturing plan. Use the returned slice, geometry, profile, and calibration evidence; do not assume missing metrics are zero.\n\nCheck that the actual toolpaths preserve critical features, fit, connected material, intended colors, and load-bearing sections. Inspect consequential first layers, bridges, islands, supported undersides, and removal access. Compare expected total print time, total material across all plates, and manual work with the best credible alternative. Keep purge, prime-tower, support, and model quantities distinct only when the data provides a non-overlapping breakdown.\n\nIf the plan is unexpectedly costly or fragile, identify the dominant cause and make the smallest change that preserves the brief. Re-slice after a relevant geometry, orientation, material, or process change. Do not optimize a minor imperfection at the expense of function or appearance, and do not invent a redesign simply to produce criticism. Check every support, fit, and hold claim in the summary against a number from the slice or the engine's checks (support area and worst overhang, engagement and gap, estimated bite at the forced opening). A claim without its number comes out or is labelled a prediction.\n\nReturn a concise decision: keep, revise, or validate one specific uncertainty. Include the decisive evidence and the exact next action. A clean slice supports a printability prediction; it does not verify physical fit, strength, or bridge quality.";
|
|
@@ -34,6 +34,27 @@ export declare const FDM_FIT_RESOURCE: {
|
|
|
34
34
|
description: string;
|
|
35
35
|
};
|
|
36
36
|
export declare const DESIGN_PROMPTS: DesignPrompt[];
|
|
37
|
+
export declare const DESIGN_GUIDANCE_TOOL: {
|
|
38
|
+
name: string;
|
|
39
|
+
description: string;
|
|
40
|
+
inputSchema: {
|
|
41
|
+
type: "object";
|
|
42
|
+
properties: {
|
|
43
|
+
name: {
|
|
44
|
+
type: string;
|
|
45
|
+
enum: string[];
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
required: string[];
|
|
50
|
+
additionalProperties: boolean;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
export declare function designGuidance(args: Record<string, unknown>): {
|
|
54
|
+
name: string;
|
|
55
|
+
title: string;
|
|
56
|
+
text: string;
|
|
57
|
+
};
|
|
37
58
|
/**
|
|
38
59
|
* How this server's configured slicer orients, makes supports and checks a slice: the slicer-specific half of a
|
|
39
60
|
* design pass's print plan (the fdm_slicing prompt). `capabilities` is what slice_stl applies on that backend, as
|
package/dist/design-guidance.js
CHANGED
|
@@ -16,7 +16,9 @@ Find out before you design, and before you ask. Research whenever the request na
|
|
|
16
16
|
6. For what is still unknown after about two rounds per fact, shape the design so that fact does not decide whether it works (an adjustable or sprung interface, a foot that suits more than one surface), or state a bounded assumption as an assumption. Ask the person only as the last resort, one short question, and only for what exists nowhere but with them. Never ask for something a search answers: a photo of their car's dashboard, the size of a named product, what a named surface is made of.
|
|
17
17
|
Without web tools, say so in the result, use what you recall labelled as recalled rather than published, and lean harder on step 6.
|
|
18
18
|
|
|
19
|
-
Before choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.
|
|
19
|
+
Write the concept down before any geometry, in a few lines: the bought product you are following, its mechanism, the load path, and how it will print. Before choosing a mechanism, establish what every working bought or published version of the thing has, and keep all of it. For example, a car phone holder turns and tilts to face the driver; a mount's base is sized by the moment of what it holds, not just its weight; an adhesive mount uses a full pad of the tape's grade, not a strip, on a surface the tape suits. Start from the complete product a capable designer would describe at once, then make it printable. A design that leaves out a feature they all have says what it lost and why that is acceptable for this person.
|
|
20
|
+
|
|
21
|
+
Give it the product's form as well as its function. The bought thing's shape is evidence: a handle swells where the palm closes, a hook's arm thickens towards its root, a knob is round and knurled, a clip's jaws wrap what they hold. Do not reduce a product to a flat profile pushed up, or a box with holes, because that is quick to model and prints without thought: that is a bracket, and people can tell. Put curves where hands and objects touch and where load turns a corner. A flat, in-plane layout is right only for the element that needs it (a spring that must bend in the layer plane, a print-in-place hinge or chain), and then say so; the rest of the product keeps its form, split or turned for printing if need be. When the engine renders the model, look at a three-quarter view and ask whether a person would recognise the thing and want it.
|
|
20
22
|
|
|
21
23
|
Choose each fit by what that interface has to do: drop in and lift out, slide, locate without rattle, grip so it does not slip or turn, snap over, or press in to stay. There is no single fit number. Keep three things apart for each interface: the object's size and how sure it is, the correction this printer and orientation need (its own observed corrections first, when the context supplies them), and the fit the function calls for. When the size's uncertainty is wider than the function tolerates, do not answer with a better number: choose a mechanism that absorbs the difference (crush ribs, a split closed by a screw, a flexure, a snap), or ask for the one measurement that settles it. The same object changes with time and use: full and nearly empty, new and worn, soft and stiff. A fit that relies on the object giving way must still work in its stiffest, largest state, and a pocket is sized to the widest section the object passes through on the way in, with support where the object actually bears, not to its bounding box.
|
|
22
24
|
|
|
@@ -34,6 +36,8 @@ Use assembly when its benefit is worth the user's additional work. Design alignm
|
|
|
34
36
|
|
|
35
37
|
Verify the chosen geometry in its actual print orientation and inspect the slice when tools permit. Check critical fits, missing or floating features, toolpaths, supports, color assignments, total time, and material consumption. Treat a slicer prediction as a prediction, not a physical test. Fix consequential problems and re-slice relevant changes. Stop when the design meets the brief and no remaining improvement justifies its cost. State "prints without supports", "holds", or "fits" only when the engine's own checks or the slice show it, and give the number that shows it; otherwise call it an untested prediction.
|
|
36
38
|
|
|
39
|
+
Fit and flexure guidance is longer than this text and is read when it applies: fdm_fit whenever a part meets a real object or another part, fdm_flexures whenever a part must flex, grip, snap, clip or spring. If your host did not attach them, read them with this MCP's design_guidance tool before you choose that fit or size that spring. Where the MCP's code engine is in use, its cad_examples tool lists worked designs to start from.
|
|
40
|
+
|
|
37
41
|
Keep the user-facing result short: the recommended design, why its manufacturing approach makes sense, how it prints and assembles, and any consequential unresolved assumption. Distinguish measured dimensions, slicer estimates, and untested predictions. Say where each critical size came from (measured, published, or assumed) and what each interface is meant to do and how it fits. Keep detailed analysis in the working process.`;
|
|
38
42
|
export const FDM_MULTICOLOR = `Apply this guidance when multiple colors or support materials share a print.
|
|
39
43
|
|
|
@@ -329,6 +333,35 @@ export const DESIGN_PROMPTS = [
|
|
|
329
333
|
{ name: "fdm_after_slice", title: "Review a slice", text: FDM_AFTER_SLICE,
|
|
330
334
|
description: "A separate review turn after a candidate has been sliced, before presenting the manufacturing recommendation: keep, revise, or validate one specific uncertainty." },
|
|
331
335
|
];
|
|
336
|
+
/**
|
|
337
|
+
* The on-demand guidance as a tool. A design worker that is handed fdm_design and the engine prompt by its host has
|
|
338
|
+
* only tools, not prompts or resources, so "add fdm_fit when a part meets an object" could never be followed there:
|
|
339
|
+
* this read-only tool returns the same texts by name.
|
|
340
|
+
*/
|
|
341
|
+
const GUIDANCE_TOPICS = {
|
|
342
|
+
fdm_fit: { title: "Choosing a fit by function", when: "a part meets a real object or another part", text: () => FDM_FIT_GUIDANCE },
|
|
343
|
+
fdm_flexures: { title: "Parts that flex, grip and snap", when: "a part must flex, grip, snap, clip, spring, or hold something by bending", text: () => FDM_FLEXURES },
|
|
344
|
+
fdm_assembly: { title: "Splits, inserts and joints", when: "a split, joint, insert or printed thread could improve the result", text: () => FDM_ASSEMBLY },
|
|
345
|
+
fdm_multicolor: { title: "Multicolour and support materials", when: "several colours or support materials share a print", text: () => FDM_MULTICOLOR },
|
|
346
|
+
fdm_after_slice: { title: "Review a slice", when: "a candidate has been sliced, before recommending it", text: () => FDM_AFTER_SLICE },
|
|
347
|
+
fdm_capability: { title: "Bridges and overhangs", when: "a bridge or overhang decides the plan and no measured capability is at hand", text: () => FDM_CAPABILITY_GUIDANCE },
|
|
348
|
+
};
|
|
349
|
+
export const DESIGN_GUIDANCE_TOOL = {
|
|
350
|
+
name: "design_guidance",
|
|
351
|
+
description: "Read one piece of this MCP's design guidance by name: " + Object.entries(GUIDANCE_TOPICS).map(([name, t]) => `${name} (when ${t.when})`).join("; ") + ". The same texts as the prompts of those names, for a worker that has tools but not prompts. Read-only.",
|
|
352
|
+
inputSchema: {
|
|
353
|
+
type: "object",
|
|
354
|
+
properties: { name: { type: "string", enum: Object.keys(GUIDANCE_TOPICS), description: "Which guidance to read." } },
|
|
355
|
+
required: ["name"],
|
|
356
|
+
additionalProperties: false,
|
|
357
|
+
},
|
|
358
|
+
};
|
|
359
|
+
export function designGuidance(args) {
|
|
360
|
+
const topic = typeof args.name === "string" ? GUIDANCE_TOPICS[args.name] : undefined;
|
|
361
|
+
if (!topic || Object.keys(args).length !== 1)
|
|
362
|
+
throw new Error(`design_guidance takes one name: ${Object.keys(GUIDANCE_TOPICS).join(", ")}.`);
|
|
363
|
+
return { name: args.name, title: topic.title, text: topic.text() };
|
|
364
|
+
}
|
|
332
365
|
const SLICER_NAMES = {
|
|
333
366
|
bambustudio: "Bambu Studio", orcaslicer: "OrcaSlicer", "orcaslicer-bambulab": "FULU OrcaSlicer-bambulab",
|
|
334
367
|
"orca-slicer-api": "the remote OrcaSlicer service (orca-slicer-api)", prusaslicer: "PrusaSlicer", cura: "Cura", slic3r: "Slic3r",
|
|
@@ -355,4 +388,4 @@ export function slicingGuidance(slicerType, capabilities) {
|
|
|
355
388
|
}
|
|
356
389
|
export const FDM_SLICING_PROMPT = { name: "fdm_slicing", title: "How this MCP slices",
|
|
357
390
|
description: "Add to every design or model-editing task: how this server's slicer orients a model and generates supports, and how to check a choice with a checkpoint slice." };
|
|
358
|
-
export const SERVER_INSTRUCTIONS = "When designing or editing a model to print, apply the fdm_design prompt and the fdm_slicing prompt. Add fdm_fit whenever a part meets a real object or another part, to choose each fit by what that interface has to do. Add fdm_flexures whenever a part must flex, grip, snap, clip, spring, or hold something by bending. Add fdm_multicolor when several colours or support materials share a print, fdm_assembly when a split, joint or printed fastener could help, and fdm_after_slice as a separate review turn after a candidate has been sliced, before presenting the manufacturing recommendation. Read " + FDM_CAPABILITY_URI + " when a bridge or overhang is consequential and there is no sufficiently specific measured capability available. Read " + FDM_FIT_URI + " for the same fit guidance as the fdm_fit prompt, in resource form.";
|
|
391
|
+
export const SERVER_INSTRUCTIONS = "When designing or editing a model to print, apply the fdm_design prompt and the fdm_slicing prompt. Add fdm_fit whenever a part meets a real object or another part, to choose each fit by what that interface has to do. Add fdm_flexures whenever a part must flex, grip, snap, clip, spring, or hold something by bending. Add fdm_multicolor when several colours or support materials share a print, fdm_assembly when a split, joint or printed fastener could help, and fdm_after_slice as a separate review turn after a candidate has been sliced, before presenting the manufacturing recommendation. Read " + FDM_CAPABILITY_URI + " when a bridge or overhang is consequential and there is no sufficiently specific measured capability available. Read " + FDM_FIT_URI + " for the same fit guidance as the fdm_fit prompt, in resource form. A worker that has tools but not prompts reads the same guidance with the design_guidance tool (fdm_fit, fdm_flexures, fdm_assembly, fdm_multicolor, fdm_after_slice, fdm_capability).";
|
package/dist/index.js
CHANGED
|
@@ -30,6 +30,8 @@ import { importFileViaBambuConnect } from "./bambu-connect.js";
|
|
|
30
30
|
import { CadEngine } from "./cad-engine.js";
|
|
31
31
|
import { CadRefusal } from "./cad/refusal.js";
|
|
32
32
|
import { CAD_TOOLS, cadEnabled } from "./cad/contracts.js";
|
|
33
|
+
import { cadExamplesTool } from "./cad/examples.js";
|
|
34
|
+
import { DESIGN_GUIDANCE_TOOL, designGuidance } from "./design-guidance.js";
|
|
33
35
|
import { BlenderMcpBridge } from "./blender-mcp-bridge.js";
|
|
34
36
|
import { FUSION_EXPORT_OUTPUT_SCHEMA, FUSION_MCP_DEFAULT_ARGS, FUSION_MCP_PIN, FUSION_NEW_DESIGN_OUTPUT_SCHEMA, FUSION_STATUS_OUTPUT_SCHEMA, FusionMcpBridge, addinAddress } from "./fusion-mcp-bridge.js";
|
|
35
37
|
import { BLENDER_SETUP_OUTPUT_SCHEMA, BlenderAddonSetup, FUSION_ADDIN_REPOSITORY, FUSION_SETUP_OUTPUT_SCHEMA, FusionAddinSetup, defaultSetupSystem, parseAddonHandshake } from "./design-app-setup.js";
|
|
@@ -119,7 +121,7 @@ const SERVER_INFO = {
|
|
|
119
121
|
};
|
|
120
122
|
/** Tools that declare an outputSchema: they always return structuredContent, and errors carry none. */
|
|
121
123
|
const OUTPUT_SCHEMA_TOOLS = new Set([
|
|
122
|
-
"cad_status", "cad_setup", "cad_run", "cad_check_fit",
|
|
124
|
+
"cad_status", "cad_setup", "cad_run", "cad_check_fit", "cad_examples",
|
|
123
125
|
"counterpart_printer_info", "counterpart_print_progress", "counterpart_make_3mf",
|
|
124
126
|
"counterpart_discover_printers", "counterpart_setup_fields", "counterpart_propose_filaments",
|
|
125
127
|
"fusion_mcp_status", "fusion_mcp_new_design", "fusion_mcp_export",
|
|
@@ -2969,6 +2971,7 @@ class BambuPrinterMCPServer {
|
|
|
2969
2971
|
required: ["stl_path"]
|
|
2970
2972
|
}
|
|
2971
2973
|
},
|
|
2974
|
+
DESIGN_GUIDANCE_TOOL,
|
|
2972
2975
|
...(CAD_ENABLED ? CAD_TOOLS : []),
|
|
2973
2976
|
{
|
|
2974
2977
|
name: "blender_mcp_status",
|
|
@@ -4384,10 +4387,16 @@ class BambuPrinterMCPServer {
|
|
|
4384
4387
|
case "counterpart_make_3mf":
|
|
4385
4388
|
result = await makeCounterpart3mf(args ?? {});
|
|
4386
4389
|
break;
|
|
4390
|
+
case "design_guidance":
|
|
4391
|
+
result = designGuidance(args ?? {});
|
|
4392
|
+
break;
|
|
4393
|
+
case "cad_examples":
|
|
4394
|
+
result = cadExamplesTool(args ?? {});
|
|
4395
|
+
break;
|
|
4387
4396
|
case "cad_status":
|
|
4388
4397
|
if (args && Object.keys(args).length)
|
|
4389
4398
|
throw new Error("cad_status takes no arguments.");
|
|
4390
|
-
result = await this.cad.
|
|
4399
|
+
result = await this.cad.ensureReady(extra.signal);
|
|
4391
4400
|
break;
|
|
4392
4401
|
case "cad_setup":
|
|
4393
4402
|
case "cad_run":
|
package/dist/tool-annotations.js
CHANGED
|
@@ -16,6 +16,8 @@ export const TOOL_ANNOTATIONS = {
|
|
|
16
16
|
cad_setup: hints(false, true, true, true),
|
|
17
17
|
cad_run: hints(false, false, false, false),
|
|
18
18
|
cad_check_fit: READ_LOCAL,
|
|
19
|
+
cad_examples: READ_LOCAL,
|
|
20
|
+
design_guidance: READ_LOCAL,
|
|
19
21
|
// Printer and cloud reads
|
|
20
22
|
get_printer_status: READ_OUTSIDE,
|
|
21
23
|
get_printer_filaments: READ_OUTSIDE,
|