CLI and Python (no MCP)¶
For agents that run shell commands, and for you:
uv tool install b123d-print
(pip install b123d-print works too, in a Python 3.12 environment. For unreleased code:
uv tool install git+https://github.com/KD5RYN/b123d-print.)
b123d-print init ~/parts && cd ~/parts
b123d-print new bracket
Edit parts/bracket/bracket.py (or let your agent do it), then:
b123d-print build bracket --formats 3mf,png
b123d-print check
Warning
The CLI does not sandbox: it runs part scripts like any Python. Use it for scripts you wrote or read. Model-written scripts are safer through the MCP server.
Commands¶
| Command | Does |
|---|---|
init [dir] [--update-agents] [--git \| --no-git] |
create a workspace: b123d-print.toml, AGENTS.md, parts/; --update-agents replaces AGENTS.md with this version's text. In a terminal it asks whether to keep a version history (git, on this machine only); --git starts one without asking, --no-git never asks. Nothing is done without a yes |
setup [--printer p] [--material m] [--formats f] [--style s] [--hole-comp mm] [--hole-comp-h mm] [--workspace] [--overwrite] [--no-input] |
first-run setup: asks for the printer (search words, then pick one), material, export formats, default style and, opt-in, a measured hole compensation to build into the files, and writes them to your user config (--workspace: this workspace's b123d-print.toml; a measured hole compensation with a printer goes to its calibration). A value already set is kept unless you say yes or pass --overwrite. --no-input (the default when stdin is not a terminal) writes only the flags given, for scripts. Ends with the calibration coupons to print next |
new <name> [-d/--description text] [--from <example>] [--sketch] |
scaffold parts/<name>/<name>.py from the template, or from a bundled example; --sketch: the sketch-first template |
sketch <part> [name] [--variant v] [--no-dims] [--small] |
sketch first: draw a 2D shape from the script's sketches(d) to out/images/<part>_sketch_<name>.png with its dimensions, print its sizes, holes, slots and radii, and run the sketch checks; exit code 1 on a failure. --no-dims: the shape and grid only |
build [parts] [--variant v] [--formats f] [--only pieces] |
export + section views, report sizes and each piece's faces and build time; --formats overrides the formats setting; --only a,b builds and exports only those pieces of build() (lazy pieces) |
check [parts] [--variant v] [-v/--verbose] [--json] |
run the checks; exit code 1 on any failure; -v also lists passing checks |
bom [parts] [--variant v] [--count N] [--csv] |
what to buy: the hardware the parts declare in hardware(d) as one Markdown table, identical items merged across parts and summed; --count multiplies the quantities, --csv prints CSV instead. Builds nothing |
metrics [parts] [--variant v] [--style s] [--up +Y] [--json] |
the design review numbers and the suggestions the part's style triggers (filament roughly ±20 %, time a rough estimate); never fails |
orient [parts] [--variant v] [--piece name] [--load X] [--image] [--json] |
rank the ways to put each part on the bed: supports, contact, height, time, bridges, tip-over, the load against the layers; prints the Rot(...) to apply in build(d) (see suggest_orientation); --image renders the top choice to out/images/<part>_orient.png; never fails, changes nothing |
fit [parts] [--variant v] [--hole-tol mm] [-v/--verbose] [--json] |
fit between the pieces of each part's assembly(d): overlaps, gaps under the clearance, hole alignment across pieces; exit code 1 on any failure; -v also lists the pairs that fit |
trace <image> [--dpi n] [--grid mm] [--reference card\|L,S] [--points x1,y1,x2,y2 --distance mm] [--tolerance mm] [--smooth] [--pick x,y] [--threshold t] [--invert] [-o/--out folder] [--json] |
trace a flat object in a scan or photo into an outline in mm: writes <image>_outline.json, <image>_outline.py (a snippet for a part script) and <image>_trace.png (the outline on the image) next to the image or into --out |
recipes [name] |
list the recipe library, or print one recipe's code, example, printing notes and sources |
faces <part> [--variant v] [--part name] [--highlight ID] [--json] |
the part's flat faces with their ids, holes and sides, for a face template; --highlight draws one in red (fit-test templates) |
template <part> --slice XY:3 \| --face ID \| --crop x,y,z:sx,sy,sz [--thickness t] [--no-label] [--no-base] [--name id] [--variant v] [--part name] [--formats f] |
make a fit-test template, write it to out/print/templates/ (STEP to out/cad/, pictures to out/images/) and check it; exit code 1 if a check fails |
view <part> [--variant v] [--parts a,b] [--assembly] [--open] |
write out/docs/<part>_view.html, a self-contained 3D view of the part (viewer and model inline: opens offline, from file://); the printable parts on the bed, or --assembly; --open also opens the browser |
edges <part> [--variant v] [--part name] [--face ID] [--kind type] [--convexity c] [--near x,y,z] [--radius mm] [--limit n] [--highlight IDS] [--json] |
the part's edges with their ids, type, length, convexity (convex, concave, tangent, seam) and the faces they join, for a fillet or chamfer; --highlight 3,4,7 draws those in red and prints a verified selector for them (choosing edges) |
diagnose <part> [--variant v] [--only pieces] [--json] |
a failed or broken build: builds each piece on its own and prints the likely cause and specific fixes (where in the script, the numbers), what makes a built piece unprintable, and for an invalid solid which faces and edges are bad; exit code 1 if a piece fails or has a problem (diagnosis) |
spec <part> [--variant v] [--json] [--strict] |
the replication spec of a part copied from a physical original: its MEASURE.md joined with the script's Dims (measured vs modeled, class, why changed) and the flags; --strict exits 1 on any warning. Builds nothing |
params <part> [--json] |
the part's Dims fields with type, value and source comment, its derived values and each variant's overrides, read from the script without running it |
set <part> FIELD=VALUE... [--variant v] [--no-build] |
change Dims values in the script in place (everything else in the file stays as it was; values are Python literals: WIDTH=42 LABEL='"lid"'), then build and print each piece's size and volume before and after; --variant changes that variant's override in VARIANTS |
measure <part> --distance A,B \| --wall x,y,z \| --faces ID,ID \| --hole [ID] [--at x,y,z] [--of name] [--dir dx,dy,dz] [--frame auto/print/assembly] [--variant v] [--image] [--json] |
precise measurements in mm with the points: the gap or interference between two pieces or assembly labels, a wall's thickness at a point, the distance or angle between two flat faces (ids from faces), a hole's size and depth; --image draws what was measured in red |
styles [name] |
list the design styles and where each comes from (workspace, user, built-in), or show one with based_on applied |
printer list [words] |
search the printer profiles |
printer show [name] |
show a printer (default: the active one) |
printer use <name> [--material m] [--nickname n] |
set the active printer (and material); generic clears it. --nickname names one of two printers of the same model, each with its own calibration; use <nickname> switches back to it |
printer hole-comp <value> |
store a hole compensation for the active printer + material: 0 records that the slicer corrects holes; a measured value is an opt-in built into every file |
printer calibrate <key> <value> |
store a value measured with a calibration coupon (hole_comp, hole_comp_h, clearance, press_fit, free_fit, pip_clearance, max_overhang, max_bridge) for the active printer + material (--workspace: in this workspace's b123d-print.toml) |
compare <reference> <candidate> [--json] [--image png] [--threshold name=value] [--samples n] [--no-icp] [--seed n] |
measure a part against a reference (STL, 3MF or STEP): differences, a 0-100 score, pass/fail; exit code 1 on fail (comparing parts) |
to-step <in.stl/3mf> [-o/--output out.step] [--scale s] [--max-triangles n] [--no-merge] |
convert a mesh to a STEP solid, the same way import_model does: coplanar triangles merged into faces, small gaps closed; reports faces before and after merging and whether curves stayed faceted |
setup-ssh --key <file.pub> --workspace <name> [--host h] [--add] [--authorized-keys file] |
on the server: the authorized_keys line that gives one client key the MCP server in one workspace, and the client config to match; --add writes it (Remote over SSH) |
ssh-serve --workspace <folder> [--dest user@host] [--timeout s] [--check-timeout s] |
the forced command in that line: runs the MCP server, pull, push or version as $SSH_ORIGINAL_COMMAND asks, refuses anything else; not for running by hand |
pull <part> --from user@host [--formats f] [--variant v] [-o/--out folder] [--ssh cmd] |
on the client: copy a part from an SSH server into parts/<part>/ of the project folder (-o, default the current one): the script, out/ (narrowed by --formats / --variant) and ref/, the same layout as a local install, out/ sorted into its folders (an older flat local copy too) (--ssh passes ssh options, e.g. 'ssh -i key -p 2222') |
push <file> --part <name> --to user@host [--name n] [--overwrite] [--ssh cmd] |
on the client: copy a model to remix (STL, 3MF or STEP, up to 50 MB) to an SSH server, into parts/<name>/ref/ |
save [message] [--part name] |
save a version of every part (or one): the script, ref/, MEASURE.md, the .py files beside the script and b123d-print.toml, never out/; prints the Dims values that changed. Needs a version history (init --git) |
versions [part] [--limit n] |
the saved versions, newest first: date, id, message and the values that changed; with a part, numbered for restore, plus what is not saved yet |
restore <part> <version> |
bring a part back to a saved version (a number from versions <part>, or a commit id) and save that as a new version: nothing is lost, files added later are kept; refused while the part has unsaved changes |
config |
the settings in effect, and which config files were found |
list |
parts in the workspace |
examples |
the bundled example parts |
mcp [options] |
run the MCP server, the same as b123d-print-mcp with all its options; lets uvx b123d-print mcp start it |
Global options, before the command: --root <folder> (the workspace; default the nearest
folder with a b123d-print.toml, else the current folder) and --version.
parts is a list of part names or script paths; without it, build, check, bom, metrics and orient take every part
in the workspace. Each command's full --help output is in the Reference.
Agents and AGENTS.md¶
AGENTS.md (written by init) carries the workflow for agents that read it, such as Codex and
Cursor; for Claude Code put @AGENTS.md in CLAUDE.md. Its text is in
Workflow rules.
Running a part script directly¶
A part script ends with run(__file__), so it runs on its own:
uv run parts/bracket/bracket.py
| Option | Does |
|---|---|
--variant <key> |
build one variant (standard for the default); default: all |
--formats <list> |
comma-separated from step,stl,3mf,png or all; default: the formats setting |
--only <pieces> |
comma-separated piece names from build(): build and export only those, without the checks |
--no-check |
export only, skip the checks |
From Python¶
Everything the CLI and the server use is importable from b123d_print: export, render,
section, the check classes (see Checks API), load_settings,
hole_comp, clearance and printer.
The --formats choice print,hardware writes a print sheet and a versioned declared hardware
BOM (_hardware.json); bom and bom_csv write the shopping list as _bom.md and _bom.csv; spec writes the replication spec (_spec.md) of a part with a MEASURE.md;
all includes them all. Hardware quantities cover the entire selected
variant even with --only (declaring hardware).