The MCP command descriptions, docs and code called an entry of the app's menus a "row", the word they also use for the rows of the object list and the app's other lists. They now say "menu item", so a row is only ever a row of a list or table. Command names, arguments and Speed Dial tile ids are unchanged.
MCP harness
orca_mcp.py launches OrcaSlicer with its MCP server and talks to it, from a shell or from
Python. It uses only the standard library. docs/HLSD/mcp-server.md covers the server, and
docs/HLSD/mcp-tools.md its commands.
Commands
| Command | What it does |
|---|---|
launch [--headless [kwin|mutter] | --xvfb] [--cad] [--unrestricted-scripts] [--printer "<model>@<nozzle>"] [--vendor V] [--filament F] [--datadir DIR] [--port N] [--bin PATH] [--print-config] [-- app args] |
Start OrcaSlicer with --mcp, wait until it is ready, print the session |
call TOOL ['<json args>'] [--wait] |
Call a tool and print its JSON result; --wait follows a returned job to its result |
tools |
List the tools, with the first line of each description |
widgets ['<json args>'] |
Print the widget_list tree |
screenshot OUT [--target main|canvas|dialog] |
Save a full-size PNG, replacing OUT if it exists |
run-replay FILE [--out DIR] |
Run a replay in the launched instance and print the result; exit 0 when it passes |
stop |
Stop the app and its private display, and remove the session |
launch creates a fresh temporary datadir unless you pass --datadir. It seeds the datadir with
an OrcaSlicer.conf that has a finished setup wizard and one printer and filament (Bambu Lab X1
Carbon 0.4 by default), with update checks and daily tips turned off, and with the Orca Cloud login kept
in a token file in the datadir (use_encrypted_token_file) instead of the system's secret store, so the
instance starts signed out and never reads your login: on macOS that read would stop a newly built app at
a keychain prompt. A seeded datadir's main window opens 1600×900 at the top left of the screen's work area
(on macOS below the menu bar), so it fits on a 1920×1080 screen, instances started side by side stay on
screen, and the tests' views and screenshots all have one size; the tests that size the window ask for
the same 1600×900. --cad starts the app with
--cad, which turns the Design (CAD) tab on for that run, and with it its commands, and
--unrestricted-scripts starts it with --unrestricted-scripts, which lets Python scripts
(script_run) run unrestricted for that run. Neither writes the datadir's OrcaSlicer.conf, and a later
launch without them has the settings the datadir holds. The token comes from
ORCA_MCP_TOKEN or is generated, and it reaches the app through the environment, not the command
line. On Linux, launch also sets SSL_CERT_FILE, so a fresh datadir doesn't prompt for a CA
bundle, and if that prompt does come up anyway, as when the file it names is gone, launch answers it
with Yes, as it waits for the app to be ready: an unattended launch has no person to answer it. On
Windows, it gives the instance its own WebView2 profile in the datadir, apart from the one
your own OrcaSlicer uses, and finds build-clang\src\Release\orca-slicer.exe as well; run the
commands as python tools/mcp/orca_mcp.py …. On macOS, it finds the app bundle's binary under
build/arm64, build/x86_64, build/universal or build: the bundle the CMake target builds in
src/Release, or the one build_release_macos.sh assembles in OrcaSlicer. The app opens on the
desktop and takes focus while it starts, and needs no CA-bundle setting.
On Linux, --headless and --xvfb keep the app off your desktop, on a private screen of
--width×--height (default 1600×1000), and run it as an X11 client (GDK_BACKEND=x11). Use
--headless on a machine with a desktop. It starts a headless Wayland compositor on a session bus of
its own and runs the app on that compositor's XWayland. The app draws with the GPU's OpenGL driver,
as on your desktop, and the compositor is a window manager, so focus, stacking and popup lists
behave as they do there; dialogs show in screenshots and recordings, and the private bus keeps the
D-Bus services the app starts, such as the desktop portals, out of your session. It takes KWin
(kwin_wayland --virtual), else mutter (mutter --headless; test required: not yet run on a GNOME
machine, so check the window, input, screenshots and the OpenGL driver the app's log reports before
relying on it); --headless kwin or --headless mutter names one. The compositor's output goes to
<datadir>/mcp-display.log. When neither is installed or starts, --headless says so and falls
back to Xvfb. --xvfb is for a machine without a desktop, such as a CI runner or a server. It
starts Xvfb on a free display between :90 and :119, which draws OpenGL in software and runs no
window manager, so a popup list, such as a combo box's drop-down or the Print button's menu, closes
as soon as it opens. Xvfb runs with -noreset, and its pointer is parked in the bottom-right
corner. In the middle of the screen, the pointer would raise tooltips over whatever opens there, and
they would show in screenshots. The app's output goes to <datadir>/mcp-launch.log. --timeout
(default 120 s) limits how long launch waits for ready.
Session file
launch writes {port, token, pid, datadir, display_server, display_server_pid, display_env, display} to $ORCA_MCP_SESSION, or to ~/.cache/orca-mcp/session.json if that is unset.
display_server is kwin, mutter, xvfb or null (your desktop), and display_env holds the
variables the app was started with to reach it (null for one removed), which app_env() applies to
another process. The file is mode 0600, and every other command
reads it. To run several instances at once, give each its own ORCA_MCP_SESSION and --port.
From Python
import os, sys
sys.path.insert(0, "tools/mcp")
from orca_mcp import OrcaMcp, McpError
orca = OrcaMcp(port=13619, token=os.environ["ORCA_MCP_TOKEN"])
orca.call("project_import", paths=["/abs/path/part.stl"])
result = orca.await_job(orca.call("plate_slice")) # follows a job envelope to the end
orca.call("app_wait", **{"for": "idle"}) # "for" is a Python keyword
info, pngs = orca.images("window_screenshot", target="canvas")
call() returns the tool's JSON result and raises McpError when the tool reports an error.
call_with_text() also returns the text blocks after the JSON one, such as widget_list's tree.
images() also returns the PNG bytes of the image blocks. call_raw() returns the MCP result
unchanged. With ORCA_MCP_CALL_LOG set to a file, every call appends a JSON line with its tool, its
time in milliseconds and whether it succeeded, which shows where a test spends its time.
To drive an OrcaSlicer that is already running with the MCP server on (--mcp, or "MCP server"
under AI features in Preferences), attach to it through its datadir instead of a port and token:
orca = OrcaMcp.from_datadir() # the datadir the app uses without --datadir
orca = OrcaMcp.from_datadir("/abs/datadir") # an app started with --datadir /abs/datadir
design = orca.call_command("describe_design")["result"] # a Design command (the Design tab on)
orca.call_command("helix", radius=10, pitch=3, height=30)
from_datadir() reads the port and token from <datadir>/mcp/server.json, which the server writes
when it starts. Without a datadir it takes default_datadir(): %APPDATA%\OrcaSlicer on Windows,
~/Library/Application Support/OrcaSlicer on macOS, $XDG_CONFIG_HOME/OrcaSlicer (or
~/.config/OrcaSlicer) on Linux. A portable install keeps its datadir in data_dir beside the
binary (beside the .app on macOS) and is found only when that datadir is given, or the binary as
from_datadir(exe=...); a symlink to the binary is resolved on Linux, as the app resolves its own,
and taken as it is on Windows, as the app takes it. On macOS it is taken as it is, as the stdio
bridge (McpStdioBridge.cpp) takes it; whether the app itself resolves a symlinked binary there is
unverified, which matters only for a symlinked binary. When the file is missing, or a ping to the
port it names fails (nothing listens there, or another server answers), from_datadir() raises
McpError saying so, with the failure as its cause.
call_command(tool, **args) calls tool_call {tool, args}, follows a running job to its end and
returns the command's whole reply, which for a Design command is {"result": ...}. A call whose first
reply says a dialog blocks it fails at once, naming the dialog, rather than waiting on it. A call that
first replied running and opens a dialog later is waited on up to the timeout (600 s), since app_wait
reports only that its job is still running. Every McpError it raises starts with the command's name
("extrude: ...") and has the original error as its cause. tool_search {group: "Design"} names the
Design commands, and tool_search {tool} gives one's arguments and examples.
The skill's list of tiles
gen_skill_reference.py <skills-checkout> [--check] writes
skills/orcaslicer-mcp-skills/references/actions.md in a checkout of the orcaslicer-mcp-skills repository:
the Speed Dial's tiles section by section, from the command reference tests/data/command_catalog.json
(docs/HLSD/mcp-server.md, "Making a feature reachable"), and before them what the reference says of
particular commands: the Design commands with one form, which needs its value, and the commands of tiles
the tool list does not show. Outside the Design tab a section is a Speed Dial section (a tile's group, or
the tile_group of a command's own tile), and each tile has a row with its key, its title, the command and
arguments it runs (project_export {"format": "gcode"} for Export G-code) and its description. In the
Design section a command has a row of its own when it has a tile of its own (in_palette), and each Design
menu item folded into a command follows it as a row with the command's key, the item's title and the
arguments that open its tool (sketch_pattern with {"type": "linear"} for Linear array). It needs no
running app. With --check it writes
nothing, prints the difference and exits 1 when the file is not what it would write. When a command
changed, regenerate the reference first: run slic3rutils_tests "[Reference]" with
ORCA_UPDATE_COMMAND_REFERENCE=1 in the environment.
Smoke test
smoke_test.json is an end-to-end replay that exercises the main paths against a fresh datadir:
- an auto-answered startup or unsaved-changes prompt;
- loading, a setting change, slicing and a G-code export;
- a dialog that an action opens and the replay answers;
- screenshots of the dialog and the preview.
tools/mcp/orca_mcp.py launch --headless
tools/mcp/orca_mcp.py run-replay tools/mcp/smoke_test.json --out /tmp/orca-smoke
tools/mcp/orca_mcp.py stop
Without the harness, orca-slicer --datadir DIR --run tools/mcp/smoke_test.json --outputdir /tmp/orca-smoke runs the replay and exits. On Linux, set SSL_CERT_FILE (for
example to /etc/ssl/certs/ca-certificates.crt) as the harness does; otherwise a prompt for the CA
bundle blocks startup before the replay can run. The exit code is 0 when it passes, 1
when a step fails and 2 when the replay is invalid, cannot be read or is neither a .json nor a .py
file. The run leaves result.json and the screenshots in the --outputdir folder, or without it in
<replay name>.out beside the replay. Files that a step or a script saves without a path go to the
--outputdir folder too, or without it to <datadir>/automation/out. A --run launch is never handed to a window that is already open, whatever
the single-instance preference says, and it is refused with an action or --downward-check, which start
no GUI.
test_command_line.py [--bin PATH] [CHECK ...] checks that command line, starting the built app as its own
child on fresh data folders: that the options it does not have are refused before any GUI starts, --run's exit
codes and folders, its refusal beside an action or --downward-check, that --mcp-port alone opens the server,
that --unrestricted-scripts and --cad hold for the run without writing the configuration, and a run beside a
window already open on the same data folder. It prints one line per check and takes about two to three minutes.
test_runtime_lifecycle.py [--bin PATH] [CHECK ...] checks how the app's automation behaves while the app closes,
and while its server is switched off and on during a call, starting the built app as its own child on fresh data
folders. The app is closed with the File menu's Quit while a job runs, while a recording runs, and while a call no
stop interrupts is still running, where the app keeps the runtime rather than free it under the call and logs that
a call did not return; a --run with the endpoint never opened exits on its own; the server, switched off and
on in Preferences during a call, serves on the port it had; and with the server switched off and nothing else
driving the GUI, the log says the GUI instruments went off. It prints one line per check and takes about a minute:
the run that outlives its reply budget runs with the budget capped at 4 s (ORCA_MCP_REPLY_BUDGET_MS).
test_plugin_tools.py checks a plugin's calls into the tools in the running app: it side-loads
tests/plugins/mcp_tools_fixture into a fresh data folder and launches twice: over MCP, with the Design tab
on (its operation is in the group Plugins, reached through tool_search and tool_call and out of
tools/list; a menu item's command is found among tool_search's commands with its schema and its tile not
among its actions, and tool_call runs it; a group is a place's heading, in any case; a Design command is
found there too, in no section of its own; calls from its Script worker
and a thread it starts reach the tools, an auto-answer rule it sets is the plugin's, replay_export is
refused, nothing it calls is journaled, a script that finds its progress dialog handle can use it,
tests/plugins/mcp_tools_broken, whose load fails, offers none of its operations, and unticking the
plugin in the Plugins dialog withdraws its operation and ends its rule); and without MCP,
where a --run runs the plugin's script and its rule is still the plugin's. Run it as
python tools/mcp/test_plugin_tools.py. The
Run Script panel's .py files are not driven from here: the panel is hidden from automation and opens its
files through a file picker, so how it reads and saves them is covered by the unit tests of
decode_python_source() and encode_python_source().
A .py file given to --run runs as a Python script (script_run) instead, exiting 0 when it
finishes and 1 when it raises, is cancelled or runs out of time; its traceback goes to the log. A
script's own file access is held to OrcaSlicer's folders, and it starts no programs or threads and reaches
no network, unless scripts run unrestricted: start the app with --unrestricted-scripts for one run (as
orca_mcp.py launch --unrestricted-scripts does), or a person turns the setting on in Preferences. No tool
can turn either on.
A .py file runs as Python runs it (python file.py), with the whole plugin API: __name__ is
"__main__", __file__ and sys.argv name it, the modules beside it import (afresh each run, so an edit
shows), and the packages its PEP 723 block lists are installed first. It may open windows and progress
dialogs, which close when the run ends, and its threads and pool tasks call the tools too. The run ends once
its code and the non-daemon threads and pool tasks it started are done:
# /// script
# dependencies = ["numpy"]
# ///
import queue, threading
import orca
import helper # helper.py beside this file
def main():
progress = orca.host.ui.create_progress_dialog("Measuring", "Starting", 3)
for step in range(3):
progress.update(step + 1, helper.describe(step))
# A window's callbacks run on the UI thread and call no tools; they hand the work to the script.
pages = queue.Queue()
window = orca.host.ui.create_window("<button onclick='window.orca.postMessage({go: 1})'>Go</button>",
on_message=pages.put)
pages.get() # the person pressed Go
worker = threading.Thread(target=lambda: print(orca.host.tools.call("app_state")["ready"]))
worker.start() # waited for before the run ends
if __name__ == "__main__":
main()
A window that stays open is closed with the run, so a script that wants the person to work in it waits, as
the pages.get() above does. While a modal it opened is up, tool calls that change the project are refused,
so interactive scripts use modeless windows. docs/HLSD/mcp-server.md ("Python scripts") has the rules for
overlapping runs, imports, pools, atexit and Stop.
tests/gizmos.json drives every gizmo through the GUI tools, the way a person does: each one's icon,
its panel's fields, combos, toggles and links, and clicks or strokes at points of the model, then
checks what it left on the model (object_list), with an undo and redo and a canvas screenshot per
gizmo. It uses the fixtures beside it (tests/fixtures/star.svg, tests/fixtures/heightmap.png).
Run it at a second window size through replay_run's vars:
tools/mcp/orca_mcp.py call replay_run '{"path": "/abs/tools/mcp/tests/gizmos.json", "out_dir": "/tmp/gizmos-small", "vars": {"window_size": [1100, 760]}}' --wait
tests/scene.json checks object structure and placement: object_transform on an instance (the drop after a
scale, size, a move to another plate), on a part, what object_list reports of them (bounding boxes
on the bed, filament, the scaled volume, a mirrored part and instance), the selection as object_select and
app_state report it (parts, whole instances, one instance of two), shapes given a size
(object_add_primitive {shape, size}), object_arrange on one plate and every plate, Fill bed, the Speed
Dial no-op that action_run reports as an error, part_add (shapes at a size and a position, a model
file, one undo step, and what it refuses), and the object structure commands (Change Type, Rename,
number of instances, individual objects, Assemble, Order By and its reversal, and what each refuses). It
ends with all of them on one scene: a block with a magnet pocket and a boss, sized, moved to a second
plate, copied six times and arranged there, split into objects, one mirrored, two assembled, ordered,
the plate filled and sliced.
tests/layers.json checks height range modifiers: object_set_height_ranges with ranges given out of order
and their settings set with settings_set (target height_range), their read-back in object_list, one
undo step each (and none for the same ranges again, which keep their settings), the layer count of a slice
with them, the refusals (an overlap, a layer height beyond the printer's, a missing filament, an object
setting, an empty range), a range in the second filament, a 3MF round trip, and []. Then
variable layer height profiles on a Benchy with object_set_variable_layer_height: Adaptive called from the
Preview tab, its quality's effect on the point count, the layer count of a slice with it, Smooth as one
undo step, Reset and a Reset that changes nothing, the refusals (an argument of another action, the
assemble view), Smooth and Adaptive over height ranges, and a 3MF round trip. Last, layer G-codes on a
cube with plate_set_custom_gcode: refused before a slice, a pause by layer and custom G-code by height called
from Prepare (it shows the Preview), the same code again changing nothing, a removal and an in-place
custom edit in one call, the refusals (a layer above the top, a code where another is, nothing to remove,
a missing filament, a missing plate, a plate changed since its slice that the Preview does not show), a
filament change, a 3MF round trip, and clear.
tests/settings_targets.json checks settings_list (each type whole, a saved preset's and a slot's values,
what an object and a region take) and the settings tools' targets on a cube with a modifier and two height
ranges: a value set on the object, the modifier and a range, each read back by index and from the selection
with the value it prints with and where that comes from, and ranges replaced keeping the settings of the one
that stays. tests/view_switches.json checks view_set's sidebar, legend, G-code window, section view and
display switches, each set and read back from its reply and app_state; a cube placed in the middle of a
plate from plate_list's origin and size; and app_state's account, network plug-in and configuration folder.
test_sidebar_floating.py launches its own app twice, the second time with the sidebar floating in the saved window
layout, and checks that view_set's sidebar_width is refused there.
tests/recording.json records while it drives the GUI: clicks on the 3D view, a setting typed, the
Preferences dialog opened and closed, a slice. It stops the recording (frames, length, size) and encodes
it to H.265, then has a nested replay start a recording of the 3D view that it never stops, checks the
replay's end closed it, and encodes that to H.264. Short recordings check that a recording has no overlays
unless captions or pointer turns one on, that one started with a path and no max_seconds runs under an
hour's limit, and that one started with encode is encoded as a job once recording_stop reports it, the
encode deleting its .mkv unless keep_raw_video_file keeps it. Its
project_new and recording_stop calls pass silent: true: with no arguments they would do what a
person's pick does, asking and stopping without a report. The encodes need an ffmpeg with libx265 and libx264
(ORCA_FFMPEG, or ffmpeg on PATH) and are optional without one. Look at the videos, or at frames
ffmpeg -i session.mkv -vf fps=1 frame%02d.png extracts, for the caption, the pointer and the dialog.
tests/multicolor.json assigns filaments to objects and parts through settings_set's object and
part targets, with undo and redo, and reads them back with settings_get's effective values. It then
sets the project's slot colours, flushing multiplier, one flushing volume and plate type through
project_set_settings (in one call, the colour first), checks the refusals that leave everything as it was
(the read-only filament_is_mixed, a bad colour, a purge mode the printer has no button for, a non-zero
diagonal, a tower off the plate), and moves the prime tower with an undo, before slicing.
tests/presets.json saves filament, process and printer presets with preset_save (a user preset,
one inside the project that a saved and reopened project keeps, a detached one, and the overwrite
rule), and drops unsaved edits with settings_set {"reset_all": true}. It selects a filament the selector
does not offer, one the setup wizard has not installed, by name. It reads presets that are not selected and
compares presets (settings_get preset and compare), writes one entry of a
per-variant value, and checks settings_set's changed after the spiral vase dialog. It reads what
settings do from their meta (description, where): by key with settings_get, for one group with
settings_list, and found by the words of their descriptions, in one type and in all three. Keys named
without a type are read from the type that has each one, and a key named in the wrong type is listed with
the type that has it (type_of) and refused by settings_set. It reverts single keys (null, reset_to),
and answers the unsaved-changes prompts:
preset_select without preset_changes still opens the prompt, preset_changes transfers or discards without it,
and project_new keeps modified presets unless preset_changes is "discard". It ends by deleting the
presets it made with preset_delete: filaments the tab edits and does not, a base process and its
child, and a printer once selected, with the refusals for system presets, a preset another inherits
from, unsaved changes and a printer that is not selected. It exports a filament with the Export
Preset Bundle dialog to its out_dir (preset_export with a directory), imports the archive again
with preset_import and a path (kept while the preset exists, imported once it is deleted) and
imports tests/fixtures/mcp_import_pla.json. It changes a preference in the Preferences dialog
opened with window_open {"window": "preferences", "tab": "behaviour", "key": "auto_arrange"}, by the
control's name, and reads it back with preferences_get. It starts from the harness's default printer with one
filament slot in Simple mode, deleting slots and selecting the mode first, and reruns on the same
datadir.
tests/plates.json sets a plate type and print sequence on one plate only (with undo and redo), the
first and other layers' filament orders and spiral vase through plate_set_settings, the lock (twice,
which leaves it locked) through plate_lock and a name through plate_rename, and reads them back
with plate_list and plate_get_settings.
It brings the filament list to two slots with the filament_add and filament_delete commands first,
and ends with a mixed filament, whose slot the delete command refuses and ahead of which a new slot
goes. It reruns on the same datadir.
tests/calibration.json makes every calibration test with calibration_generate_test (each pressure advance method,
a 2 x 2 pattern batch, the four flow ratio passes) and checks the objects it added, the parameters
it used and the presets it changed, slicing some of them. It checks the temperature rounding, the
refusals that leave the project as it was (modified presets without preset_changes, an argument the test
does not take), preset_changes: "keep" keeping an edit, and project_new dropping the test's settings. It
starts from the harness's default printer and reruns on the same datadir.
tests/ops_*.json drive each operation of the operations layer (docs/HLSD/mcp-server.md, "The
operations layer") through the routes that reach it: the command, a Speed Dial tile run with action_run
where one runs it from a call, and, for presets, a pick in the sidebar and the plugin API called from a
script_run step. One replay per operation, named after it: G-code, sliced 3MF, model 3MF and STL exports, a model
import, a project opened, started anew and saved, a plate selected and locked, arrange, slice, the
Preview's layer range, a printer or process preset selected (ops_select_preset), a filament assigned
to a slot on a printer with one slot and with several (ops_assign_filament_preset_one_slot,
_multi_slot), presets imported, an object's instance count, and the refusals of printer_send's tile,
whose id is send_gcode, which never sets a print host, so nothing is sent. Each records what a call leaves: its reply or its
refusal's text, the state read back after it, and the undo snapshots it took, which
tests/fixtures/ops_undo.py reads from the app's log since no tool lists the undo history. Their
expects are on the setup and on what is read back. A replay cannot assert a refusal's text, so a
call that a route refuses is optional, and result.json is the record of those texts, to compare
between two builds.
The preset replays share tests/fixtures/ops_presets.py, which sets the slots, colours and flushing
volumes to known values before each case, and each needs a freshly launched app, since a hidden
preset that preset_select shows stays shown until a restart. The replays whose calls write files
need a fresh --out, since some of those calls write without overwrite. Launch the app from a folder that
holds no .py files, since the app's working directory is on Python's module path and a file there can
shadow a standard module that script_run needs.
test_operation_routes.py asserts what those replays only record: that a command, a Speed Dial tile that
runs it and the plugin API's binding refuse the same states with the same code and words, and accept the
same ones: a layer asked of a Preview with none (the Go to layer tile and view_set), a mixed-colour
filament slot, and a hidden printer selected through the plugin API. It also checks what a command refuses
or does in those states alone: a project saved under a .gcode.3mf name, the exports of a project with no
objects, and an arrangement from the assemble view and with a gizmo open. Run
it on a freshly launched app, for the reasons above and because the Preview keeps the last slice's
layers.
The Design-tab replays drive the Design commands through tool_call and need an instance launched with
--cad. Each starts from a new project and checks what it builds by volume and by what the reading
commands give back, under each reply's result; steps
marked optional are calls that must be refused and change nothing.
tests/cad_sketch_to_solid.jsontakes sketches to solids: an L-bracket profile on XZ through the modeling origin with its inside corner filleted in the sketch (after an empty commit that must fail and leave the sketch open), a shelf-pin jig plate whose five holes are in its sketch, a lip sketched on the plate's top face and joined to it, one loop of the plate's sketch extruded alone, and a ring revolved about its sketch's centerline.tests/cad_sketch_edit.jsondrives the sketch tools: the bench's hex standoff from a polygon 8 mm across the flats, a trim and an extend on crossing lines, and a plate with a chamfered and a rounded corner, two slots (one an array copy turned upright), an elliptic hole and four holes arrayed about a point, constrained from picks and from named points, with a refused constraint rolled back and one deleted.tests/cad_topology_targets.jsonbuilds the bench's J wall hook from what the reading commands give back: its inside corners found by convexity, M4 countersinks seated on the front face on the axes of pilot holes, the cones' kind, apex side and radii frombody_describe, the hole heights and the plate's thickness frommeasure, a datum plane midway through the plate and one 70 mm up with a sketch on it, a refused tangent plane, and the back face pushed out 2 mm.tests/cad_features.jsonthreads, sweeps, lofts and splits: the bench's M5 hex standoff tapped on its bore (M5 inferred from the bore) and again on the XY plane, each within the bench's volume bounds; a spring swept along a helix in round and square wire; a square-to-circle loft between XY and a datum plane 40 mm up; the loft split by that datum and its lower half cut again by XY turned over.tests/cad_doc.jsonreads and edits features as their cards do: a variable bound to an extrude, then removed, and literal edits withfeature_edit. Then it commits the design to the plate, recommits over the first object and undoes that in one step, exports STEP and reads it back into a new design, and commits two bodies both ways. Last it walks the Design history (undo/redoof an edit and of a rename), suppresses, moves and deletes features, names, hides and colours bodies, commits only the shown one, and saves and reopens the project to check that a body's name and colour were kept.tests/cad_canvas.jsondrives the Design view as a canvas:view_setshows the Design tab and points its camera (and refuses Prepare's and Preview's fields there), canvas and widget screenshots capture the view, a click at its centre picks the block and a right click lists the verbs for the pick, andkeyboard_pressreaches the Design panel's key hook (Shift+E opens the Extrude card, Escape with no target closes it). Last, a change made only in the Design tab marks the project modified, and reopening the saved design-only project withdiscard_changesasks nothing and names the project after its file.
Three harness tests run on an instance launched with --cad. test_cad_replay.py makes calls as a
client, so they are journaled, exports the session with replay_export, replays it into a new
project and compares the body's mass properties and the features. The session has an empty sketch
commit, a missed hole and a fillet the kernel refuses, which must fail and be left out, a shell thicker
than the plate answering ok false, which stays in, and face and edge ids passed with their generation,
which the journal drops.
test_cad_slow_build.py runs a long thread build (an M8 thread tapped 60 mm deep, about 8 s) and
checks that while it builds app_state answers, a window screenshot succeeds, widget_list lists
the progress dialog and a screenshot of that dialog captures it, and another Design command is refused.
test_cad_failed_job.py sweeps a coil whose every rebuild outlasts the reply budget (its turns sized from the
session's first build), then a hole that misses it replies with a running job and fails after
the reply budget: an export while it runs leaves it out and names it in left_out_running, the
export after it has the rename made next and not the hole, and that replay runs to the same coil.
It takes four to eight minutes, or under a minute with the reply budget capped at 4 s by
ORCA_MCP_REPLY_BUDGET_MS=4000 for the app and the test, as the sweep runs it. test_cad_examples.py runs the examples tool_search {tool} gives for
every Design command, and for undo and redo, each on a fresh design, and fails one whose call fails or
whose result has ok false, an error, or is the person's form; --tool NAME runs one command's.
test_cad_commands.py checks what the Design commands' arguments do where the Design panel's own functions
answer, which the unit tests, on a bare document, do not reach. Each rung starts from an empty design, calls
commands with their arguments and grades what describe_design, feature_describe, sketch_describe and
body_mass_properties read back: the operation and type words and the suppressed feature; each of ten
shapes drawn once with its tool on the canvas and once with sketch_draw, which must agree in entities,
constraints, loops and degrees of freedom; sketch_edit and its replace, cancel and refusals;
sketch_project with and without an open sketch, sketch_text, sketch_insert_svg and Scale artwork;
feature_edit's refs and a card's picks while it edits a feature; view_set's Design options;
select_geometry, confirm_tool, cancel_tool and body_place; the Boolean card a call opens; and a
pick of a folded item's tile from the Speed Dial, and its replay. Its docstring lists the rungs.
Three more harness tests on a --cad instance drive the Design tab the way a person does. Every action goes
through the UI tools (view_set, widget_click, mouse_gesture, keyboard_press, widget_set_value,
dialog_answer and dialog_auto_answer), and the Design commands only read the result back (sketch_describe,
describe_design, feature_describe), save for one call in the scale rung; the right-click menu's layout they
grade against is read from scripts/CAD/tool_atlas.json, the Design table the app's own is generated from,
for the selection describe_design names. Buttons and rows are found by label, and canvas positions come from
a calibration that maps the open sketch's plane to canvas pixels, so nothing in them is tuned to a window
size, screen scaling or theme. A map fitted from five probe points is reused, once one probe confirms it,
while the canvas size and the camera stay the ones it was fitted on. The sketch tool's pick budgets and badge layout are in the canvas's GL pixels,
which cad_gui.py turns into click pixels by the canvas scale that view_set's camera_state gives (zoom
over click_px_per_mm). What they share is in cad_gui.py beside them. test_cad_sketching.py draws each
sketch tool's primitive with clicks on the canvas and types its exact values into the canvas's value field,
drives the edit operations and each constraint button on drawn geometry, undoes inside a sketch and across its
commit, saves the project and opens it again through the File menu, and draws on top of a sketch holding 1204
entities. That last rung, scale, loads them with one sketch_draw command while the rectangle tool is armed:
the one call in these tests that changes the sketch outside the UI, on purpose, since a bulk add made while a
creation tool is armed must not be read as a drawn gesture that swallows the next key and click.
test_cad_context_menu.py checks that the right-click offer names what was clicked and lists exactly the
verbs the Design table says apply to it, and drives from the menu every sketch verb that has no key, a Text
typed into the Text dialog and an SVG import (tests/fixtures/rect_40x20.svg) among them.
test_cad_click_edit.py checks that each value field a drawing tool opens takes digits typed with no click
into it and that Return commits them, for the line, rectangle, circle, slot, polygon, ellipse and arc tools
armed by their keys, the rounded rectangle armed from the offer, and a rectangle's width label clicked in
Select.
tools/mcp/orca_mcp.py launch --cad
tools/mcp/test_cad_sketching.py
tools/mcp/test_cad_context_menu.py
tools/mcp/test_cad_click_edit.py rect label
tools/mcp/test_cad_commands.py words select
Each prints ok or FAIL for every check and exits 1 if any failed. Rungs named on the command line
run alone, in that order (each test's docstring lists them); with none named, every rung runs.
test_cad_sketching.py selfcheck-recovery runs only when named: it fails on purpose with the mouse
button held, the offer asked for and a tool armed, to show that the rungs after a failed one start
clean. The tests find widgets, menu paths and verbs by their English names, so they need an English
UI: on any other language, or with the Design tab off, they exit 2 before the first check and say how
to fix it. On Linux the steps that need a file picker answered with a path, the sketching test's
roundtrip and the context-menu test's SVG import, print skip, since a GTK picker can't take a
path from MCP (docs/HLSD/mcp-server.md, "Dialogs and web views"). The app logs each picker a rule
answers in <datadir>/log/debug_*.log.0, with the reason when it cancels one a rule gave a path. MCP
input reaches the app through wxWidgets, not the OS, so a focus problem that only a window manager
causes is out of the tests' reach.
tests/dialogs_canvas_input.json checks that an auto-answered Transfer or Discard on the
unsaved-changes dialog does its work, that a toolbar item a selection just enabled takes a click at
once, and that a negative part, and a point seen through the bed from below, are click targets.
tests/context_menus.json right-clicks a cube, the empty bed and two selected objects, and clicks a
preset edit button that opens a menu: each menu is listed in the reply, or an item of it run with
popup_item (a modifier, a primitive, Delete), and none is ever shown, so on macOS the run finishes
with nobody pressing Escape. It also picks the Edit menu's Undo and Redo by the paths Edit>Undo and
Edit>Redo, which name them on every platform, though macOS shows their keys after them.
tests/rows.json drives rows and popups: object list rows (plates, an object and its parts, Ctrl
to add a row, the Printable column, a double click), the object's and a part's menus run from their
rows, Compare presets' rows, the object settings table, the print button's popup and the plate type
drop-down list. On Linux run it with --headless: under Xvfb those popups close as soon as they open.
tests/plate_icons.json clicks the Prepare view's plate icons by {plate_icon, plate}: lock twice,
Plate Settings opened and cancelled, arrange of a second plate's two cubes (the reply waits for the
job), the plate menu from a right click, and move to front.
test_webview_modal.py runs JavaScript in the web views of modal dialogs: the preset bundle dialog's
page takes it by default and by locator, webview_run_javascript is refused in the Home tab's web view behind a
modal and in a dialog under the topmost, the Flushing volumes dialog's page takes it as any topmost
dialog's does, and a page that closes its dialog replies closed at once.
Web pages are driven like widgets: widget_list lists each shown page's elements under its web view
with d refs, and widget_click, widget_set_value, keyboard_press, mouse_gesture and dialog_answer act on them, by
ref or by {web: "Next", kind, css, within, index}. tests/web_dialogs.json drives Orca's own web
dialogs that way alone: the preset bundle dialog, the colour picker behind a filament swatch (its hex
field, and a drag on its spectrum) and the setup wizard's first steps. test_web_ui.py covers every
kind of page control, action and what it changed on its page, refusal, locator, timeout and close on
the pages of a fixture plugin, in a modal dialog, a modeless window, a dock panel and the Plugins
dialog's configuration frame, a token in a page's URL shown redacted, and the permission prompt the
plugin's thread opens, answered with dialog_answer and with a rule registered while it is open, and the
plugin's page among the main window's tabs, which the Go to tab tile shows by its id.
Side-load the plugin into the datadir first:
tools/mcp/test_web_ui.py --install /tmp/orca-mcp-test
tools/mcp/orca_mcp.py launch --datadir /tmp/orca-mcp-test
tools/mcp/test_web_ui.py
test_list_windows.py checks window_list: the main window first, the Plugins window (which doesn't
block the app) with a ref that window_screenshot captures alone, widget_list reads alone and keyboard_press Escape
closes, Preferences last as a modal dialog, and Action Replay listed as hidden, without a ref.
test_set_window.py checks window_set on the main window (sized twice, moved, placed over its
display's work area, maximized, minimized and restored), on the Plugins window by its ref and on
Preferences by its {label} locator. On Wayland it checks
that a window screenshot is the size the reply gives and skips positions, which Wayland neither reports
nor takes. On X11 it reads the X server's stacking order through libX11 to check that the main window,
restored and raised while Preferences is open, stays under it.
test_action_replay_hidden.py opens Action Replay
and checks that the GUI tools don't see it: widget_list lists no window for it, webview_run_javascript
without a target behaves as before it opened, and a key sent without a target never reaches it. It
then shows the Run Script panel on
Prepare and checks the same for it, with no more web views in widget_list than before, a key sent
without a target reaching the 3D view, a window screenshot, and an agent's script_run finishing
while it is shown; replay_run still runs the smoke test and a nested inline replay.
test_speed_dial_open.py goes from Home to Prepare, the Design tab (launched with --cad) and Preview by
their tabs, and checks that the page's 3D view then holds the keyboard focus and that Space opens the Speed
Dial, which Escape closes. A pointer entering a view also gives it the focus, so the tab switch itself is
proved only where no pointer rests on the view: on a native Wayland display, or a desktop with the pointer
elsewhere. Where KWin runs the display, it also checks through KWin's D-Bus that KWin draws no title bar on
the dial.
tests/slice_stats.json slices one cube, then two cubes in two colours, and checks the statistics of
plate_slice's reply: layers, max Z, filament changes, and each filament slot's model, flush and
prime tower grams.
tests/preview.json slices a cube and reads it back with plate_slice_stats (summary, feature and layer
tables, the object, the legend's state and colour ranges) and app_state.preview as view_set
changes the layer (by number and by height), the view type, legend rows and time estimate, then
reads the cube's G-code opened for viewing the same way. Run it on a fresh datadir: modified presets
left by an earlier replay make opening the G-code ask about them. test_set_view_preview.py checks
what that replay cannot: view_set {view_type} acts as the legend's combo (a feature type hidden by
a click on its row shows again on Line Type, and the pick reaches the app config), a canvas
screenshot straight after a layer or view type change shows the new layers and the legend laid out
(it matches the capture after it), and the refusals of the preview arguments.
test_set_view_camera.py, on an instance launched with --cad, checks view_set's look_at and zoom
on Prepare, Preview and the Design tab, and orbit on Prepare and the Design tab, against the reply's
camera_state and app_state.camera, including straight after project_new, whose fit runs at the
next frame, and a fit on Prepare after the window was sized on the Home tab.
tests/agent_forms.json calls commands the way agents often write them: a lone path for paths,
object for objects with the index as a string, an action by the key inside its id, action for
id, a camera direction as view_set's canvas, which is read as its camera, object_transform to a
position, key for keys, app_wait with no condition, a gizmo by its toolbar title, plate for
plates, legend rows in another case or with _ for a space, and project_export with the format taken
from the path. It also checks that a type's whole settings_list listing leaves meta out.
test_stdio_bridge.py [--bin PATH] checks orca-slicer --mcp-stdio against the launched instance:
the handshake, notifications, tool calls in both protocol eras, and errors. With no instance
answering, it checks that the bridge answers the handshake and lists the launched instance's tools
without starting OrcaSlicer, and that a tool call then starts OrcaSlicer on the bridge's port (the
test stops that app).
test_recovery_under_load.py fills the server's connections with 32 blocked app_wait calls and 32
idle or half-sent connections while a dialog is open, and checks that dialog_answer on a new
connection still closes it. test_cancel_pending_slice.py cancels a slice while it still waits for
the update a setting change scheduled, and checks that it never starts. test_ref_locator_export.py
uses ImGui refs after their items changed (the Text gizmo's font button, whose label shows the font,
and a Texture Displacement layer row renamed by its place when a layer before it goes) and checks
that the exported session replays. test_worker_admission.py starts a long arrange three ways
(object_arrange with arguments, action_run of its Auto-Arrange tile, whose id is obj_arrange, a click on
the Arrange options panel's button) and
checks that changes, canvas keys and toolbar clicks are refused while it runs, reads answer, and job_cancel
stops it. test_export_running_job.py exports while a call's job runs past
its reply budget (left out, named in left_out_running), after it ends (an await: false step that
replays) and while a dialog holds its call (kept); it takes about 100 s, or about 45 s with the reply budget
capped at 10 s by ORCA_MCP_REPLY_BUDGET_MS=10000 for the app and the test, as the sweep runs it.
test_send_gcode.py starts an OctoPrint-compatible stub host and sends a sliced cube to it with
printer_send's Speed Dial tile, send_gcode, the Send dialog answered with widget_set_value and dialog_answer: the
tile is refused for a Bambu network printer and one without a print host, an upload the stub accepts
reads uploading at 99 until the stub answers and then completed in app_state.uploads, its exported
replay uploads again, and one the stub refuses with HTTP 500 never reads completed and ends as an
error whose dialog dialog_answer closes.
tests/tiles_ask.json and test_person_forms.py check a call with exactly a tile's arguments, which may ask
as a person's pick of the tile does: calibration_generate_test {test} asks in the test's dialog and with
silent runs with its defaults, View: Top turns the Design tab's camera, Go to tab and Go to layer take their
value through action_run, and the slice tiles slice and show the Preview tab (the replay, on an instance
launched with --cad); project_save {save_as: true} and project_export {format: gcode} open their file
pickers while a path writes without one, preset_export always opens its dialog, object_arrange {} and
object_select {all: true} (and action_run of their tiles) reply as their commands do, the selection in the
assemble view's too, and the Speed Dial's own picks of a view tile, Deselect All, Go to layer, Auto-Arrange and
Select All Objects run in place (the script). test_project_open_settings.py
launches its own app, whose Preferences load a project's geometry only, and checks that project_open loads
the settings a project was saved with all the same.
The commands that do a menu item's job take their targets by index, and the replays call them so and read each
back: tests/menu_items_objects.json (rename, instances, separate, delete, height ranges),
menu_items_structure.json (split, assemble, change type, order), menu_items_placement.json (add a
primitive by numbers, mirror, drop, centre, scale to fit, auto-orient) and menu_items_plates.json
(duplicate, rename, lock, select and delete a plate);
objects_state.json (object_set_printable, object_fix, object_set_auto_drop), objects_files.json
(object_clone, object_reload_from_disk, part_replace, with the files tests/fixtures/objects_files.py
writes), objects_order.json (object_order {order}), filaments_and_files.json (a slot merged into
another, a mixed filament, exports of some objects and of each object, a ZIP's entries, a STEP file),
settings_targets.json (settings_list, and the settings commands' targets object, part and height range),
presets_and_plate_map.json (preset_list's filters, a plate's filament map, a nozzle variant) and
view_switches.json (view_set's display switches, sidebar and legend, and an object placed by a plate's
origin and size). A replay cannot expect an error, so the refusals are Python tests:
test_menu_items_refusals.py checks that each object command made from menu items refuses with its own
reason, and test_additions_refusals.py the filament, preset, export and import commands'.
test_preferences.py checks
preferences_get and preferences_set against the Preferences dialog, tab by tab. Some launch their own app,
on a fresh data folder and printers the sweep does not seed: test_install_printers.py and
test_install_filaments.py (installs and uninstalls, read back after a restart), test_plugin_commands.py
(the plugin commands on the fixture plugins of tests/plugins, against the Plugins window),
test_printer_extruders.py (a printer of two extruders) and test_sidebar_floating.py (view_set's
sidebar_width refused while the sidebar floats).
test_every_tile.py runs each of the 129 Speed Dial tiles of tests/data/speed_dial_tiles.json through
action_run, each from a state its table sets up afresh, answers the dialog or file picker it opens, and reads what
its menu item's job leaves: a change only that tile makes, the window it opens, the file it writes, or the refusal of a
tile that needs a printer or an account. It also checks the reply's ran and the step replay_export keeps against
tests/data/speed_dial_tile_calls.json. Its web-page and configuration-folder tiles hand over to the system's
browser and file manager, so the sweep runs it on its own.
The sweep
run_sweep.py runs every test above, smoke_test.json, tests/*.json and test_*.py, each on a
freshly launched app, several at a time: -j N (or --jobs N) runs N at once, as a build's -j does,
and defaults to half the cores, up to six. It exits 0 when all of them pass and no OrcaSlicer crash
report appeared (macOS). sweep.json lists each test
with what it needs, and a test file it does not list stops the run before anything starts, so a new
test is never skipped by accident. Each test runs in a folder of its own under --out (by default a
new orca-sweep-<time> folder in the temporary folder), with its own datadir, port (from 14100 up),
session file (ORCA_MCP_SESSION), temporary folder (TMPDIR, TMP, TEMP) and empty working
folder, and leaves test.log there and results.jsonl beside them. The longest tests start first,
by each one's last passing time in --history (~/.cache/orca-mcp/sweep-times.json). Tests that
share a lock never run at the same time, and exclusive tests run after the rest, one at a time with
nothing else running. A test that runs out of time is interrupted, as Ctrl-C would, so its own cleanup
closes the apps it started (on Windows its process tree is ended), and a test the runner could not run is
recorded as an error, so a run that leaves a test without a result never exits 0. --only and --skip
pick tests by name, and --list prints the order and exits.
On Linux the runner opens each app on your desktop as an X11 client (GDK_BACKEND=x11), so a sweep
leaves its windows on your screen while it runs, and a window manager un-minimizes a window on request
and reports its position. --wayland runs them as native Wayland clients instead, as a Wayland session
does: the compositor then owns positions, minimization and activation, so a check that needs a window
moved, or a minimized one brought back, is reported SKIP and does not fail its test. --headless runs
them on a private compositor instead, as orca_mcp.py launch --headless does, which is what a machine
without a desktop needs. Each flag is Linux-only, and --headless can't be combined with --wayland,
since the app on the compositor it starts is an X11 client. Without either flag the run needs an X
display, and --wayland needs a Wayland session; --list needs neither.
An entry's keys:
path: the test, relative totools/mcp.launch:app(the default; the runner launches and stops the app),own(the test starts its own) ornone(no app).cad: launch with the Design tab on.setup: arguments for a run of the test's own file before the launch;args: the test's arguments. Both fill in{bin}and{datadir}.env: variables for the launch and the test.exclusive,locks, andwhy, which each of them needs: what the test shares with others.timeout_s: how long the test may run (900 by default).
test_run_sweep.py checks the runner without the app, and that sweep.json lists every test there is.