# BaroCSS CAD — AI Agent & MCP Tool Contract
> 132 structured CAD actions for `cad-mcp`, `cad-cli`, Browser AI Runner, and WebMCP, plus autonomy guardrails (L1–L4) and typed refusal codes.
---
# Designing with the AI Copilot
BaroCSS CAD's AI Copilot works directly on the live `.bcad` document using the exact same parametric modeling, drawing, DFM, and inspection commands you use in Studio. Every geometry edit is validated by the B-Rep kernel — never approximated meshes.
## Three AI runtime modes (Provider-Agnostic)
Switch runtimes directly from the Chat header without restarting Studio:
1. **Browser AI Runner (BYOK).** Connect directly from the browser using your own Anthropic, OpenAI, or Gemini API key. Runs the full tool loop client-side with automatic multi-angle visual self-verification.
2. **Local CLI bridge.** Connect Studio to your signed-in local CLI session without exposing credentials to the browser.
3. **External coding agents (MCP).** Connect Claude Code or other MCP-compatible agents directly to `.bcad` files — see [Headless CLI & MCP Server](/agent/cli) for 1-command setup.
## ⌘K 3D Spatial Pin & Floating Proposal Bar
You do not need to type coordinates or feature IDs in a sidebar chat:
1. Select any face, edge, or body in the 3D viewport and press ⌘K (`Ctrl+K`).
2. The **3D Spatial Pin** inline prompt anchors directly to the picked geometry, automatically attaching its persistent face/edge identity, surrounding model context, and a live viewport capture.
3. Describe the edit (for example, `"add 2 mm fillets around this pocket"` or `"mount four M5 holes 8 mm from the corners"`).
4. Review structural edits right on the canvas in the **Floating Proposal Review Bar** with **Preview**, **Accept**, and **Reject**.
Need multiple design directions at once? Open the [Generative Variant Explorer](/agent/variants) to evaluate parallel candidates with live parameter sliders.
## What the agent can do
- **Model & edit parametrically:** Run any Studio command, author parametric features, place assembly parts and mates, edit 2D drawings, and manipulate SubD cages.
- **Inspect exact geometry & visuals:** Query feature trees, persistent face/edge references, exact distances, mass properties, interference, wall thickness, draft angles, DFM reports, and multi-angle renders.
- **Maintain the design brief:** Track user-stated vs. agent-assumed parameters and run hard/soft requirement checks automatically. User-stated values are never silently overwritten.
- **Work from images & drawings:** Attach up to four PNG, JPEG, WebP, or GIF files per turn to trace profiles into solids or create confirmable draft features.
- **Load verified Shop Rows:** Attach a JSON rows file and ask the agent to load it (see [Shop rows](/studio/rows)).
## Guardrails & autonomy (L1–L4)
- **People own shop standards:** The agent cannot fabricate or load its own fastener/casting tables (`[ROWS_NOT_FROM_PERSON]`).
- **Explicit approval for high-impact edits:** At default autonomy (`L2`), single-feature parameter tweaks and initial empty-part builds apply directly (with instant **Undo**). Structural edits, assemblies, mates, drawings, robot settings, and locked parts always wait in a reviewable proposal. See [Proposals and autonomy](/agent/proposals).
- **Concurrent editing:** Keep modeling while a turn runs — non-colliding changes merge automatically, while colliding edits surface cleanly as proposals.
## Example turn flow
These captures show the deterministic proposal lifecycle exercised against the real tool layer:
1. *"A 60 × 40 plate, 8 thick."* On an empty part at `L2`, the initial build applies directly with an **Applied by the agent** toast and one-click **Undo**.

2. *"Make it 10 thick, with an 8 mm hole in the middle."* Because this combines a dimension change with a new structural feature, `L2` refuses direct mutation and returns **P1** for visual preview and approval.

Continue to [Generative Variant Explorer & Visual Self-Verification](/agent/variants), [Tools](/agent/tools), [MCP and CLI](/agent/cli), or [AI-Ready Docs (`/llms.txt`)](/agent/ai-ready).
---
# Generative Variant Explorer and Visual Self-Verification
BaroCSS CAD combines parallel background evaluation with closed-loop visual inspection so AI-assisted edits stay fast, comparable, and geometrically sound.
## Generative Variant Explorer
Instead of committing to a single AI guess, the **Generative Variant Explorer** evaluates multiple parametric and topological candidates in parallel without blocking your viewport:
- **Parallel comparison cards:** View 3D previews of candidate designs side by side while continuing to orbit or inspect.
- **Live parameter sliders:** Scrub exposed dimensions across variants and watch exact volume, mass, and bounding boxes update in real time.
- **Requirement & DFM scoring:** Compare each candidate against active design brief constraints before promoting one to the active document.
- **Non-destructive promotion:** Accepting a variant writes a single undoable step into the feature history.
## Visual self-verification and 1-click repair
### Multi-angle visual inspection loop
In the Browser AI Runner, the agent does not stop after making a modeling edit:
1. After authoring or modifying geometry, the agent captures multi-angle visual views of the evaluated 3D solid.
2. The multimodal model inspects those views alongside exact mass properties, bounds, interference, and requirement checks to catch misplaced holes, inverted extrusions, or unintended intersections before presenting a proposal.
### Design Health & 3D error callout
When a parametric edit invalidates a downstream feature (for example, an oversized fillet radius or a missing face reference):
- The **Design Health** indicator in the top bar highlights the exact failure count and diagnostic category.
- Clicking an issue focuses a **3D error callout** directly on the affected face or edge in the viewport.
- Choose **1-click repair** to apply a deterministic fix (such as clamping a radius to geometric bounds) or send the structured diagnostic straight to the AI Copilot for a guided proposal.
See [AI Copilot & Spatial Pin](/agent/), [Proposals and autonomy](/agent/proposals), and [Refusal Codes](/reference/refusals).
---
# Tools (v2 actions)
The agent works through one tool contract, `barocss-cad-tools-v2`. The chat, [`cad-mcp`](/agent/cli) and
[`cad-cli`](/agent/cli) all serve this list and nothing else. It has 13 tools:
- `model`
- `features`
- `query`
- `history`
- `requirements`
- `proposals`
- `assembly`
- `library`
- `print`
- `drawing`
- `subd`
- `image`
- `describe`
## How a call looks
A call names a tool, and its arguments carry an `action`:
```json
{ "name": "query", "arguments": { "action": "measure", "a": "n1.top" } }
```
That is `query.measure`.
- **One action.** A tool with a single action takes it without saying so: `model` with `{ "source": … }` runs a
script.
- **The handlers.** Each action stands for one of the tool layer's handlers. The call goes through that handler's own
gates and gives its results and refusals.
- **Naming faces and edges.** Faces and edges are named as the studio names them: `n1.top`, or an edge as two faces,
`n1.side0|n1.side1`. Selectors work too: `{"feature": 1, "role": "top"}`, `{"normal": [0, 0, 1], "pick": "max"}`.
## `describe`
The list a model reads each turn stays short, and `describe` gives the detail on request:
| Ask | Returns |
|---|---|
| `{}` | Every tool's actions |
| `{"tool"}` | That tool's actions |
| `{"tool", "action"}` | The action's full description and arguments |
| `{"command"}` | A command's selection and values |
| `{"feature"}` | A feature kind's node JSON |
New commands and feature kinds need no change to the list. The `features` tool names them, and `describe` gives their
detail.
For example, the agent mounts a motor with `features.command` and the command `mount`, on a picked face, after
loading the person's mount rows with `features.load_rows` and the kind `mounts`. A mount adds features, so at L1 and L2
it is proposed. See [Part features](/studio/features#machine-elements).
## Results and refusals
- **Data back.** A call returns JSON. A read gives what it read; a change says what it changed.
- **Refusals.** A refused call leaves the part exactly as it was and says why, often with a code the agent can act on.
For example, `needs_proposal` at L2, or `needs_approval` for a change to the assembly, mates, the drawing, the robot
or a locked part.
- **A command's refusal.** When the build behind `features.command` refuses, the call returns that refusal as its
error, as `: `, and the part is left unchanged.
- **Rows.** Rows the agent wrote itself are refused with `[ROWS_NOT_FROM_PERSON]`.
- **All or nothing.** `features.batch` runs several calls all or nothing, and `dryRun` tries them without keeping
them. `model.run` runs a whole script the same way.
### Use the result for the next call
An accepted part edit returns `ok: true`, `did`, `feature_count`, `facts` and `change`. Use these fields to check what
changed before making another edit. Body details depend on `response_format` and the result's size; an omitted face
list does not mean the body has no faces. Read the part summary before using a face or edge name you have not seen.
To work on the version you reviewed, pass the `revision` from `query.render` or `query.rebuild` as
`expectedRevision` on `features.edit`, `features.command` or `features.delete`. Use the same part scope for both calls.
### Chamfer a sketch corner
Call `query.edit_fields` with the sketch's `index` and `includeSketchCorners: true`. Each
`sketchCorners` entry gives a point in sketch mm and the two saved side IDs that meet there.
Copy the read's `id` into `sketchChamfer.sketch` and its `revision` into `expectedRevision`.
For example, use this as an operation in `proposals.propose` and approve it in Studio.
```json
{
"tool": "features",
"args": {
"action": "edit",
"index": 0,
"expectedRevision": "0123456789abcdef",
"sketchChamfer": { "sketch": "n0", "sides": ["e1", "e2"], "distance": 6 }
}
}
```
The distance is the setback in mm along each of the two straight sides. This edit supports one
independent material outline with saved side IDs and no holes. The edit is refused if the corner
cannot fit, a constraint or binding would be lost, or the part revision has changed.
For a corner whose sides have horizontal and vertical constraints or a shared perpendicular
constraint, Chamfer uses the bevel length and its 135° joint angle to hold both setbacks through
a later sketch point drag. You can inspect these constraints in Studio. This applies to convex
and reflex corners, including eligible pairs in a grouped edit.
To edit the setback of a saved constrained Chamfer in Studio, reopen the sketch, select the
bevel edge, and choose **Edit Chamfer**. Enter the new setback in **Distance** and apply the preview.
For an Agent edit, call `query.edit_fields` with `includeSketchCorners: true`. Read the saved
bevel side ID and current setback from `sketchChamfers`. Use that side ID as `bevel` with the
same sketch ID, feature index and revision. Stage the operation with `proposals.propose`
and approve it in Studio.
```json
{ "sketchChamfer": { "sketch": "n0", "bevel": "e9", "distance": 8 } }
```
For a saved Chamfer on a standalone XY sketch with one straight extrusion, use the
`modelReviewRevision` from `proposals.list` to request the four-view PNG with `query.render`.
Pass the base `expectedRevision`, the proposal ID, and `expectedProposalRevision` as shown in
the group workflow below. Read the changed setback and any retained bevels on a shared side in
`chamferResize.faces`. Inspect those native wall faces using `candidate.reviewRevision` from that
image as `expectedReviewRevision`. Approve the reviewed change in Studio.
### Round a sketch corner
For the same read and approval workflow, send `sketchRound` instead of `sketchChamfer`:
```json
{ "sketchRound": { "sketch": "n0", "sides": ["e1", "e2"], "radius": 6 } }
```
Include the sketch's `index` and `expectedRevision` as above. Round places a tangent circular arc
between two straight sides. Its radius is editable in Studio after approval. The edit refuses a
radius that cannot fit, makes contact with another edge, or would remove a saved constraint or binding.
### Edit several sketch corners together
Use `corners` in place of `sides` to send two or more pairs from the same `query.edit_fields` result.
Keep its sketch ID, feature index and revision in the request. Use one radius or distance in mm for the
whole edit.
```json
{ "sketchRound": { "sketch": "n0", "corners": [["e3", "e4"], ["e4", "e5"]], "radius": 6 } }
```
For a bevel, use `sketchChamfer` with `distance` and the same list of pairs. Stage the full edit as
one operation in `proposals.propose` and approve it in Studio. Each pair must identify a distinct
corner. If any pair fails or the edits consume a shared side, the sketch stays as it was.
For visual review of a group on a standalone sketch with one straight extrusion, read the
`modelReviewRevision` from `proposals.list`. Call `query.render` with the proposal ID, the base
`expectedRevision` from `query.rebuild`, and that proposal pin as `expectedProposalRevision`.
The response includes the four-view PNG, its `imageSha256`, the native body hash, and the new
wall names and their input side pairs in `cornerBatch.faces`. Pass those names as `faces` to
`query.inspect` with the same pins and the returned `candidate.reviewRevision` as
`expectedReviewRevision`. Inspection returns the native plane or cylinder for each face.
Both calls read the proposal on a copy. Approve the group in Studio after review.
### Review a rectangular S-bend duct
For one pending Exact Sweep from a standalone tagged XY rectangle with one centered rectangular
opening and one visible Direct S-bend path, read the `modelReviewRevision` from `proposals.list`.
Use the same `query.render` and `query.inspect` pins as for a sketch corner group. The render identifies
the selected path and its revision in `rectangularDuct`. It also lists both open end-cap faces with their
outer and inner edge IDs and the eight joined edge IDs. Use the cap face names and the image's
`candidate.reviewRevision` to inspect the two native cap planes. Approve the reviewed proposal in Studio.
If the model has changed, `EDIT_STALE`, `COMMAND_STALE` or `DELETE_STALE` returns the requested and current revisions.
Review the current part before resubmitting. For delete, read the current feature tree to find the new index.
In `features.batch`, the pin applies to the document at the operation's position.
A part-tool refusal returns `ok: false` and `error`; fields such as `code`, `detail` and `kept` appear when the handler
supplies them. Do not assume every tool result has the object API's `code`, `where` and `details` error fields.
Use an available code to select the response, and read the error text for the input to change. For `needs_proposal`
or `needs_approval`, use the proposal workflow. For an invalid selection or value, ask `describe` for the action's
`input` schema or the command's `selection` and `values`, then correct that input. An unknown tool, action, command
or feature request to `describe` returns `error` with the available names; use those names rather than guessing.
These calls come from `samples/agent-mcp.test.mjs`, which runs them through `cad-mcp` on a 60 × 40 × 8 plate:
```js
// query.measure: a face by its name.
assert.deepEqual(await s.call('query', { action: 'measure', a: 'n1.top' }),
{ isError: false, label: 'Planar face', area: 2400 });
// A new feature at autonomy L2 (the default): refused, the part unchanged.
const hole = await s.call('features', { action: 'command', command: 'hole', faces: ['n1.top'], values: { d: 8, x: 30, y: 20 } });
assert.equal(hole.isError, true);
assert.equal(hole.code, 'needs_proposal');
assert.equal(hole.kept, 'the part is unchanged');
// A call the part can't answer: refused with the reason.
assert.deepEqual(await s.call('features', { action: 'delete', index: 9 }),
{ isError: true, ok: false, error: 'There is no feature 9 (features 0–1).' });
```
At autonomy L3 the same hole applies, and `cad-mcp` saves the file at once:
```js
const hole = await s.call('features', { action: 'command', command: 'hole', faces: ['n1.top'], values: { d: 8, x: 30, y: 20 } });
assert.equal(hole.isError, false);
```
## Review a proposal's drawing
Read the working sheet with `drawing.dimensions`. For printed diameter and radius annotations, pass
`include_callouts: true` to get the visible text and the drawing source printed in the title block.
To review an open proposal, read its ID and `proposalRevision` with `proposals.list`. Call `drawing.dimensions`
again with the same `sheet` and a `review` object. Pass the ID as `proposal`, the working sheet's revision as
`expectedRevision`, and the proposal revision as `expectedProposalRevision`.
The result contains the working sheet at the top level and the replayed sheet in `candidate`. Both include their
own source, revision, dimensions and printable callouts. Omit `include_callouts` or set it to `true` during review.
If a proposal reorders the sheets, the candidate reports
the new number of the selected sheet. A removed sheet or a stale proposal returns a refusal. The comparison
leaves the working file and the proposal decision unchanged.
## The per-turn budget
Everything a model reads every turn is held to 25,000 characters at most: the tool list as MCP lists it, and the
system prompt. A test fails if it grows past that, so the detail stays behind `describe`.
## Every action
These tables are generated from the contract's source (`chat/groups.ts`), and the docs check fails if they fall
behind it.
### `model`: Model (script)
Builds or changes the part with a script, all or nothing (the language is below).
| Action | Handler | Arguments and notes |
|---|---|---|
| `model.run` | `run_script` | source, dryRun? |
### `features`: Features
Edit features. Use face and edge names ("n1.top", "n1.side0|n1.side1") or selectors ({"feature":1,"role":"top"}, {"normal":[0,0,1],"pick":"max"}, {"between":[face,face]}).
| Action | Handler | Arguments and notes |
|---|---|---|
| `features.command` | `run_command` | command, values?, faces?, edges?, bodies?, point?, expectedRevision? |
| `features.add` | `add_features` | features: [node] — raw feature nodes (sketches, extrudes, revolves, sweeps, lofts, …) |
| `features.edit` | `edit_feature` | index, values? \| feature?, expectedRevision? — detachToDistance:true fixes Extrude length; Box corner proposal: absolute X or match to a second vertex (see describe) |
| `features.parameters` | `set_parameters` | add?, set?, rename?, bind?, remove? — named parameters; bind a feature's value to one |
| `features.load_rows` | `load_rows` | kind, file, part?, feature? — rows from the person’s conversation file |
| `features.delete` | `delete_feature` | index, expectedRevision? |
| `features.material` | `set_material` | material, bodies?, part? — what bodies are made of |
| `features.stock` | `set_stock` | file?, remove?, allowance? — the shop's stock list and the allowance |
| `features.frame_stock` | `set_frame_stock` | file?, remove?, kerf? — the shop's stock lengths for frames and the saw's kerf |
| `features.frame_sections` | `set_frame_sections` | file?, remove? — your section library: rows a frame names by {kind: "library", id} |
| `features.welds` | `set_welds` | welds?, remove?, beadOwnership? — joint welds and ownership policy |
| `features.casting` | `set_casting` | machined?, allowance?, shrink?, gate? — casting faces, allowances and gate |
| `features.batch` | `apply_ops` | ops: [{tool, args, opId?}], dryRun? — several calls all or nothing |
### `query`: Query
Reads the part without changing it.
| Action | Handler | Arguments and notes |
|---|---|---|
| `query.summary` | `get_part_summary` | body?, page? — features and persistent geometry names |
| `query.inspect` | `inspect` | faces?, edges?, curve?, surface?, guidedFill? — native detail and review pins |
| `query.measure` | `measure` | a, b? — a face or edge, or the distance and angle between two |
| `query.mass` | `mass_properties` | bodies? — describe for full area |
| `query.interference` | `interference` | bodies? — overlap and clearance |
| `query.section` | `section` | axis, at |
| `query.native_joints` | `list_native_joints` | body |
| `query.edge_continuity` | `measure_edge_continuity` | body, edgeId, expectedRevision, curvature? |
| `query.edge_curvature` | `measure_edge_curvature` | body, edgeId, expectedRevision |
| `query.wall` | `wall_thickness` | body?, below? |
| `query.draft` | `draft` | body?, pull?, draftMin? |
| `query.stability` | `check_stability` | datumZ?, minMarginMm?, gravity?, includeInstances? — tipping stability |
| `query.drop_settle` | `simulate_drop_settle` | datumZ?, dropHeightMm?, durationSec?, body? — gravity drop settle |
| `query.fit_clearance` | `fit_clearance` | hole?, shaft?, hole_class?, shaft_class?, size? — hole–shaft fit limits |
| `query.edit_fields` | `list_feature_edit_fields` | index — edit fields and revision |
| `query.rebuild` | `rebuild_report` | feature timings, kernel calls and mate loops |
| `query.welds` | `weld_list` | — frame weld joints and seams |
| `query.cutlist` | `cut_list` | csv? — frame cut list and stock nesting (FR4a, FRb) |
| `query.bom` | `output_bom` | expectedRevision? — BOM files |
| `query.purchase_csv` | `output_purchase_csv` | withMade?, expectedRevision? |
| `query.clearance` | `output_clearance` | near?, expectedRevision? — current assembly map |
| `query.cam` | `output_cam_package` | part?, toolDiameter?, expectedRevision? — NOT FOR PRODUCTION |
| `query.render` | `render_views` | highlight?, section?, labels?, explode?, diff?, expectedRevision?, proposal?, expectedProposalRevision? |
| `query.select` | `select` | faces?, edges?, bodies? — shows them selected in the studio |
| `query.manufacturability` | `check_printability` | direction?, finish?, sides? — DFM report (print, mould, machining, casting) |
### `history`: History
Checkpoints, versions and branches.
| Action | Handler | Arguments and notes |
|---|---|---|
| `history.checkpoint` | `checkpoint` | name |
| `history.restore` | `restore` | name |
| `history.best` | `restore_best` | — |
| `history.diff` | `diff` | from?, to? |
| `history.version` | `make_version` | name? |
| `history.versions` | `list_versions` | — |
| `history.restore_version` | `restore_version` | id |
| `history.compare` | `compare_versions` | from?, to? |
| `history.approval_evidence` | `approved_requirement_evidence` | from, to, part, later? |
| `history.branch` | `make_branch` | name |
| `history.switch` | `switch_branch` | branch |
| `history.merge` | `merge_branch` | from, resolve? |
### `requirements`: Requirements
The brief (the part's intent), the locked reference bodies it must fit (datums, keep-outs), and the checks the kernel runs.
| Action | Handler | Arguments and notes |
|---|---|---|
| `requirements.set` | `set_requirements` | requirements: [{id, source, hard?, check}], replace? |
| `requirements.check` | `check_spec` | validate? or pinned Thicken wall requirement |
| `requirements.evidence` | `output_requirement_evidence` | part?, expectedRevision? — pinned report |
| `requirements.plan_tasks` | `inspect_local_task_plan` | occurrences, expectedRevision? |
| `requirements.brief` | `set_brief` | fields — authored design intent |
| `requirements.gaps` | `get_brief` | — the brief, its gaps and what it applies |
| `requirements.references` | `get_references` | — the locked reference bodies, their faces, datums and keep-outs |
| `requirements.reference` | `add_reference` | name, step \| mesh, at? — a locked reference body |
| `requirements.datum` | `add_datum` | reference + face + kind \| reference + vertex \| kind + origin + normal \| direction |
| `requirements.keepout` | `add_keepout` | box \| cylinder \| around + offset, clearance? |
| `requirements.drafts` | `get_drafts` | — features from an image or drawing and their dimensions to confirm |
| `requirements.drawing` | `import_drawing` | dxf, name?, plane? — a DXF profile as a sketch draft |
| `requirements.unref` | `delete_reference_item` | id — a datum or keep-out |
| `requirements.keepouts` | `check_keepouts` | keepout?, body? — clear, violated or undecided, the chord tolerance stated |
| `requirements.ask` | `ask_user` | questions: [{id, text, kind, options?, unit?, blocks: {field} \| {requirement}}] — only what blocks, ≤ 5, ≤ 2 batches |
### `proposals`: Proposals
A change tried on a copy for the user to accept; the part stays as it is.
| Action | Handler | Arguments and notes |
|---|---|---|
| `proposals.propose` | `propose` | title, ops (as features.batch), plan?, requirements? |
| `proposals.accept` | `accept_proposal` | id, leave_out? |
| `proposals.list` | `list_proposals` | all? |
### `assembly`: Assembly
Parts placed and mated with the base part; changes to it are proposed. A part tool with "part" builds that part.
| Action | Handler | Arguments and notes |
|---|---|---|
| `assembly.add_step` | `add_assembly_step` | name, parts: exact occurrence IDs — propose for user approval |
| `assembly.bundle` | `output_bundle` | baseline?, expectedRevision? — approved current evidence files |
| `assembly.get` | `get_assembly` | faces_of?, include_steps?, step_index?, step_presentation? — saved assembly steps |
| `assembly.add_part` | `add_part` | name, copy_of?, position?, rotation?, grounded? |
| `assembly.place` | `place_part` | part, position?, rotation?, name?, grounded?, hidden?, ghost?, opacity?, rigidity?, flexible?, joints?, looks? |
| `assembly.delete_part` | `delete_part` | part |
| `assembly.add_mate` | `add_mate` | kind, a, b, distance?, angle?, flip? — a/b {part,face,at?} |
| `assembly.edit_mate` | `edit_mate` | id, distance?, angle?, flip?, connectors? |
| `assembly.lock` | `lock_part` | part, to — fixed to it where they stand |
| `assembly.pattern` | `pattern_part` | seed, kind: linear \| circular, count, spacing?, direction? \| angle?, axis?, origin?, orientation?, skip? — the part repeated; copies driven by it |
| `assembly.edit_pattern` | `edit_pattern` | id, count?, skip?, spacing?, direction? \| angle?, axis?, origin?, orientation? |
| `assembly.delete_pattern` | `delete_pattern` | id |
| `assembly.cut` | `cut_parts` | id?, profile, at, dir, depth, parts |
| `assembly.delete_mate` | `delete_mate` | id |
| `assembly.inputs` | `set_inputs` | inputs: {name: {type, default, bindings, unit?, min?, max?, choices?} \| null} |
| `assembly.variants` | `set_variants` | variants?: {name: {input: value} \| null}, active? |
| `assembly.insert` | `insert_part` | library, part, variant?, params?, name?, position?, rotation? |
| `assembly.snap` | `snap_part` | a, b, offset? |
| `assembly.joints` | `get_joints` | — links and joints from the base |
| `assembly.frames` | `set_frames` | frames: {name: {link, position?, rotation?, kind?} \| null} — tool and sensor frames |
| `assembly.pose` | `forward_kinematics` | values: {joint key: degrees \| mm} — where each part is |
| `assembly.set_pose` | `set_pose` | values: {joint key: degrees \| mm} — shown there, nothing stored |
| `assembly.waypoint` | `set_waypoint` | motion, values?, at?, remove?, limits? — a stored motion's waypoints (degrees, mm) |
| `assembly.check_path` | `check_path` | motion — a stored motion checked for contact along its timing |
| `assembly.play` | `play_motion` | motion, samples? — a stored motion's poses over time |
| `assembly.inertia` | `link_inertia` | — each link's mass, centre of mass and inertia (MMGS, link frame) |
| `assembly.urdf` | `export_urdf` | name? — the robot as URDF, checked |
| `assembly.mjcf` | `export_mjcf` | name? — the robot as a MuJoCo MJCF model, checked |
| `assembly.sweep` | `sweep_path` | to, from? — a joint move checked for collisions, certified |
| `assembly.motion_clearance` | `check_motion_clearance` | to, from?, steps?, minClearanceMm? — FK clearance & face IDs |
| `assembly.gravity` | `gravity_torques` | values?, g? — the static torque each joint holds |
| `assembly.move` | `motion_torques` | to, profile, limits, from?, joint_limits? — a move's peak and RMS torques |
| `assembly.size` | `size_actuators` | to, profile, limits, from?, joint_limits?, dwell?, serviceLife?, stopDeceleration?, coupled?, motors?, reducers? — motor and reducer sizing |
| `assembly.set_joints` | `set_joints` | base?, joints?: {key: {lower?, upper?, effort?, velocity?} \| null} |
### `library`: Library
Standard and team parts.
| Action | Handler | Arguments and notes |
|---|---|---|
| `library.standards` | `standards_lookup` | table?, row?, field? — a standards-derived value and its source |
| `library.list` | `list_library` | library? |
| `library.add` | `add_library` | library — a library document |
| `library.add_part` | `add_library_part` | library, part, face, point, variant?, params?, x_direction?, context? |
### `print`: 3D print
Printability on an FDM printer (check: as query.manufacturability).
| Action | Handler | Arguments and notes |
|---|---|---|
| `print.layers` | `output_print_layers` | part?, layers?, layerHeight?, direction?, overhangLimit?, expectedRevision? |
| `print.check` | `check_printability` | direction? (an alias, kept for agents that know it) |
| `print.orient` | `orient_for_print` | apply? |
### `drawing`: Drawing
The part's 2D drawing; a drawing change is always the user's, so make it as ops of proposals.propose.
| Action | Handler | Arguments and notes |
|---|---|---|
| `drawing.issues` | `drawing_issues` | include_targets? — opaque dimension IDs and view for this snapshot only |
| `drawing.tolerances` | `tolerance_suggestions` | mode? |
| `drawing.dimensions` | `get_drawing_dimensions` | sheet?, include_diameters?, include_radii?, include_callouts?, include_svg?, review? |
| `drawing.stack` | `calculate_drawing_tolerance_stack` | sheet?, expectedRevision from dimensions, terms: [{id, sign: 1 or -1}] |
| `drawing.auto` | `auto_dimension` | layout? |
| `drawing.fix` | `fix_drawing` | codes? |
| `drawing.accept` | `accept_tolerances` | ids?, mode? |
| `drawing.set` | `set_drawing` | drawing scope, sheet, views, units, annotations and tables; describe gives the fields; propose changes |
### `subd`: SubD
Edit a SubD cage by feature index.
| Action | Handler | Arguments and notes |
|---|---|---|
| `subd.cage` | `subd_cage` | index |
| `subd.select` | `subd_select` | index, what, normal?, withinAngle?, box?, edge?, limit?, seedFaces?, cageRevision? |
| `subd.move` | `subd_move` | index, delta, vertices?, edges?, faces? |
| `subd.scale` | `subd_scale` | index, cageRevision, factor, vertices?, edges?, faces? |
| `subd.rotate` | `subd_rotate` | index, cageRevision, axis, degrees, pivotVertex?, vertices?, edges?, faces? |
| `subd.extrude` | `subd_extrude` | index, faces? \| edges?, offset? \| distance? |
| `subd.insert_loop` | `subd_insert_loop` | index, edge, t? |
| `subd.bridge` | `subd_bridge` | index, edges |
| `subd.fill` | `subd_fill` | index, edges |
| `subd.weld` | `subd_weld` | index, vertices, tolerance? |
| `subd.crease` | `subd_crease` | index, edges? \| faces?, on? |
| `subd.delete` | `subd_delete` | index, faces |
### `image`: Image
A traced picture (a character, logo, icon) as solids.
| Action | Handler | Arguments and notes |
|---|---|---|
| `image.layers` | `get_image_layers` | image? |
| `image.measure_pair` | `measure_photo_pair` | frontImage, sideImage, reference, parts |
| `image.propose_pair` | `propose_photo_pair` | frontImage, sideImage, reference, parts, traceRevision |
| `image.extrude` | `extrude_image_layer` | width, height, image?, layer?, base?, orientation?, at?, y? |
| `image.inflate` | `inflate_image_layer` | width, depth, image?, layer?, mode?, body_depth?, orientation?, at?, y? |
---
# cad-mcp and cad-cli
The studio's tools also run outside the browser:
- **`cad-mcp`** serves them to any MCP client, such as Claude Code or Claude Desktop, on a `.bcad` file of its own.
- **`cad-cli`** runs scripts and checks from a shell.
Both use the same tool layer as the studio's chat, with the same gates and the same proposals, and the same tool
contract (see [Tools](/agent/tools)). Both work on local files only.
## cad-mcp: the tools over MCP
```bash
node apps/cad-studio/scripts/cad-mcp.mjs --doc part.bcad [--autonomy 1|2|3|4] [--libraries dir]
```
- **`--doc`** is the part the tools work on, a `.bcad` (or `.json`) file. A file that doesn't exist yet starts as an
empty part and is written on the first change.
- **`--autonomy`** works as in the studio: the default is 2. See [Proposals and autonomy](/agent/proposals).
- **`--libraries`** is a folder of team library files (`.json`) the library tools can insert from.
In an MCP client's configuration:
```json
{ "command": "node", "args": ["/apps/cad-studio/scripts/cad-mcp.mjs", "--doc", "/absolute/path/part.bcad"] }
```
- **Talking to it.** It speaks MCP over stdio, and stdout carries only the protocol. It builds itself from the
TypeScript sources when it starts.
- **Saving.** Each change is saved at once, and atomically: a temporary file is renamed over the part.
- **Proposals.** They are kept in the file. Open it in the studio to preview and accept them.
A session from `samples/agent-mcp.test.mjs`:
```js
// query.measure: a face by its name.
assert.deepEqual(await s.call('query', { action: 'measure', a: 'n1.top' }),
{ isError: false, label: 'Planar face', area: 2400 });
// A new feature at autonomy L2 (the default): refused, the part unchanged.
const hole = await s.call('features', { action: 'command', command: 'hole', faces: ['n1.top'], values: { d: 8, x: 30, y: 20 } });
assert.equal(hole.isError, true);
assert.equal(hole.code, 'needs_proposal');
assert.equal(hole.kept, 'the part is unchanged');
// A call the part can't answer: refused with the reason.
assert.deepEqual(await s.call('features', { action: 'delete', index: 9 }),
{ isError: true, ok: false, error: 'There is no feature 9 (features 0–1).' });
```
### Read requirement evidence for a saved revision
Call the `requirements` tool with `{"action":"evidence"}` to read the base part. Pass `part` for an exact
top-level occurrence ID. The checks use the selected part's local coordinates and apply its occurrence
material overrides.
The response contains `requirement-evidence.json` with its byte count and SHA-256. The file keeps authored
source and confirmation data separate from the check result and its freshness. Use the returned
`revision` as `expectedRevision` in a later call to require the same authored inputs. A mismatch refuses
the report. The evidence revision includes the full authored inputs except the document's proposal and design
history logs. The report also gives the standard `documentRevision`. The file's SHA-256 verifies the report
bytes. A current pass requires a matching evidence revision, an `ok` result with a `pass` verdict, and
`current` freshness.
The local MCP server reads its document when the session starts. Start a fresh session on the saved file
after Studio makes a change. Open proposals stay separate from the measurements in this report.
## cad-cli: scripts and checks
```bash
node apps/cad-studio/scripts/cad-cli.mjs …
```
Or `pnpm cli …` from `apps/cad-studio`. Commands print JSON results; help, usage errors and some
failures are plain text. Read stdout, stderr and the exit code together. The exit codes:
| Code | Meaning |
|---|---|
| 0 | Done |
| 1 | Refused or failed: the output says why |
| 2 | A usage error |
| 3 | A hard requirement fails (`run --check`, `check`) |
### Running a script
```bash
cad-cli run