Shapr3D Native MCP
# Shapr3D Native MCP
A local MCP server (for Claude Code, Codex and other MCP clients) that sends commands to a native bridge inside **Shapr3D Native Lab**, a separate copy of your own Shapr3D. The bridge calls Shapr3D's internal functions on its main thread. Modeling does not simulate mouse or keyboard input. DXF supplies sketch curves; Shapr3D creates the solids and the history timeline.
**Unofficial.** Not made or endorsed by Shapr3D. It modifies a local copy of the app and uses internal functions; check that Shapr3D's terms allow this for you, and use it at your own risk. **This is not full Shapr3D coverage.** No Shapr3D files are part of this repository.
## Requirements
- A **Mac with Apple silicon**. Windows, Linux and Intel Macs are not supported: the bridge is native macOS code written against the arm64 app.
- **Shapr3D 26.180.0 (build 11926)** from the App Store, with your own account and plan. Other versions are refused. Keep a copy of this version if the App Store updates yours; `setup_lab.py --app` accepts its path.
- Xcode Command Line Tools (`xcode-select --install`) and Python 3.11 or newer.
## Install
```bash
git clone https://github.com/21Suspect/Shapr3D-MCP.git
cd Shapr3D-MCP
python3 -m venv .venv # needs Python 3.11+
.venv/bin/pip install mcp==1.27.2
.venv/bin/python native-source/setup_lab.py
```
The setup copies the installed app (about 1.6 GB) to `~/Library/Caches/local.codex.shapr3d-native-lab`, adds the bridge, signs the copy locally and builds the modeling module. The installed app is not changed. Add `--black-sections` for solid black section cuts.
Register the server with your MCP client, using absolute paths, for example:
```bash
claude mcp add shapr3d_native --scope user -- "$PWD/.venv/bin/python" "$PWD/native_mcp.py"
```
## Start
1. Start Native Lab: `.venv/bin/python native-source/launch_lab.py`
2. Sign in if asked. The sign-in link normally opens the regular app, so run `.venv/bin/python native-source/url_handler.py set-lab`, sign in, then `.venv/bin/python native-source/url_handler.py restore`.
3. Open a project in Modeling.
4. Call `native_approve_project`. **You** click Allow in the macOS dialog.
Module **77** loads on demand. Restarting Native Lab signs it out, so it needs the sign-in steps again. `native_look` needs the Screen Recording permission.
## Project approval and restore points
- Any project can be used once you allow it. Approvals are kept in `approved-projects.plist` in the lab folder. `native_revoke_project` withdraws one.
- The approval is a guard against mistakes, not a security boundary: any program running as your user could edit that file or write to the bridge folder.
- Every modeling tool saves a restore point first. `native_checkpoint` saves a named one; `native_restore` undoes back to it. It also undoes manual edits made after it, and depends on Shapr3D's undo history (do not expect it to survive reopening the project).
- Experimental commands can damage a project. Prefer a copy of important work.
## Tools added on top of the original set
| Tool | Purpose |
|---|---|
| `native_scene` | Bodies with sizes, sketch planes, history, variables, saved references |
| `native_look` | Picture of the Native Lab window from a chosen view (needs Screen Recording permission) |
| `native_topology_of`, `native_find_parts`, `native_select_parts` | Faces and edges by meaning: `at`, `facing`, `parallel`, `shape`, `near`, `limit` |
| `native_save_reference` | Name such a description; it is re-resolved after every edit |
| `native_fillet_edges`, `native_chamfer_edges`, `native_shell_body` | Features on described or referenced parts |
| `native_subtract_bodies`, `native_intersect_bodies` | Body booleans |
| `native_run_script` | A small modeling language (variables, `for`, `if`, lists, f-strings) |
| `native_mirror_bodies` | Mirror across a flat face (world planes cannot be picked) |
| `native_scale_bodies` | Uniform scale about the selection centre |
| `native_linear_pattern` | Grid along world X, Y, Z |
| `native_revolve_profile` | Revolve a sketch region about a world axis |
| `native_sweep_profile` | Sweep a sketch region along body edges (tested with one edge) |
| `native_align` | Put one flat face on another, area centre to area centre |
| `native_constrain_sketch` | Constraints on sketch curves; tested: coincident, parallel, perpendicular, equal |
| `native_tips` | Hide (default) or show the green tip cards |
| `native_import_file` | Import from any folder: STEP, IGES, Parasolid, STL, DXF, DWG (untested) |
| `native_export` | Export to any folder: step, parasolid, iges, stl, 3mf, obj, glb, usdz, shapr, dxf_sketch, dwg_sketch, svg (ZIP) |
| `native_set_variable` | Change a variable; undone automatically if it breaks the model |
Script example:
```python
spots = [(x, y) for x in [-12, 12] for y in [-7, 7]]
holes = []
for x, y in spots:
holes = holes + circle(x, y, 2.5)
import_profile("Holes", holes, z_mm=15)
for x, y in spots:
extrude_profile(x, y, -15, z_mm=15, result="subtract")
```
The script is interpreted node by node (`native_script.py`): no `eval`, imports, attribute access or function definitions, and operations are limited. It cannot approve, revoke or restore (except `restore_on_error`).
## Building many parts (module 76+)
`native_build_parts` takes one list of boxes, prisms and cylinders, in any direction, with `repeat` and a rotated `frame`. Use it for anything beyond a few solids.
```json
{"folder": "Frame", "frame": {"origin": [0, 0, 0], "rotate_z": 45},
"parts": [
{"name": "Post", "box": [0, 0, 0, 100, 100, 2000], "repeat": {"count": 5, "step": [600, 0, 0]}},
{"name": "Brace", "profile": [[100,0,1360],[100,0,1500],[600,0,2000],[740,0,2000]], "thickness": 100, "direction": [0,1,0]}]}
```
A round part is `{"name": "Dowel", "cylinder": {"center": [0, 0, 0], "radius": 20, "height": 300, "axis": [1, 0, 0]}}`, with `center` in the middle of the start face. For a round hole, build the cylinder and cut it with `native_subtract_bodies`. Verified in an empty test project: upright, horizontal, downward and tilted cylinders, a rotated frame, and two round holes cut through a box (the measured volume matched). While the tool bodies are still inside the holes, `native_find_parts` does not find the hole faces; delete them first.
Edits answer with the new history steps and bodies only. `native_history` gives the full parameters of a step.
How it works, measured on build 11926:
- 3D DXF lines give vertical and sloped sketch planes, so nothing is built aside and rotated.
- One Extrude takes regions on many planes (selection mode 4 adds). 100 regions: 9 s.
- Touching regions would merge, and faces of earlier parts split later regions, so touching parts are built on separate levels and lowered at the end.
- An Extrude touching an existing solid defaults to Union; the result mode is set to New Body.
- A failed or wrongly shaped build is undone and reported.
A 264-part timber building took 96 s in an almost empty project.
Building where solids already exist (the tool then builds above the model and lowers it) has only been tried on one box in a small test project, not in a large one.
Also new: `native_delete_bodies`, `native_set_visibility` and `native_check_geometry` (extents and box overlaps from a mesh export; sloped parts give false positives). Restore points are stored as hashes; the file had grown to 17 MB.
Not covered yet: sketch folders cannot be deleted or hidden, and Duplicate (command 73) is refused. Each region pick still takes about 80 ms.
## Section drawings
`native_section_drawing` and `native_section_drawings` (several at once from one mesh export) write PDF or SVG sections in which every cut surface is filled 100 % black, with the visible edges behind as thin lines and land and water as dashed lines. Pure Python, no extra libraries. Eighteen sections of the whole model took about 10 s.
- `along` is the axis drawn left to right ("u" or "v" of the building grid, `rotate_z` default 45), `at` the cut position in mm, `look` 1 or -1 the viewing direction (a mirrored view is avoided: facing +v the right side is +u, facing +u it is -v).
- `cut_fill` is "black" by default. "none" leaves the cut surfaces white (they still hide what lies behind) and draws only an outline, 0.35 mm unless `cut_line` or a `weights` rule says otherwise; a colour like "#808080" fills grey. A `weights` rule may carry its own `"fill"`, so some objects can be black and others outlines only.
- `line_width` (edges behind, default 0.13 mm on paper), `cut_line` (outline around every cut surface, default 0) and `weights` [{"name": prefix, "cut": mm, "edge": mm}] set line thicknesses per object type; the first matching rule wins. A cut outline makes small, dense members such as lockers or purlins read heavier.
- `include` / `exclude` choose bodies by name prefix, `window` [x0, x1, z0, z1] crops, `levels` adds labelled level lines, `scale` defaults to 100.
- Only visible bodies are drawn (the mesh export skips hidden ones). Hidden-line removal uses a depth map: an edge counts as hidden only where most pixels around it show something clearly nearer, and one hidden sample inside a visible run is ignored. Very thin faces seen at a grazing angle can still lose short edge pieces.
- Not covered: hatching of materials, dimensions and section marks in plans.
## Import and export
Native Lab cannot read your home folder. Files are staged through the lab folder, and exports are picked up from the app's temporary folder. Export runs the app's own menu handler, so plan limits apply (JT shows the Studio subscription screen; the server closes it and reports it). Only during a server export, the Mac save panel is answered with Cancel before it appears. The app's current export settings are used.
Not working: OBJ and 3MF import (dropped without a message); PDF, image and drawing exports (app error; need drawings).
## Parametric models
Variables drive history fields, not sketch dimensions. Pattern for a part whose size you can change:
1. `native_create_variable` for each dimension.
2. Extrude a small base sketch; set the distance to `height`.
3. Offset one side face per direction; set it to `width - <base> mm`.
4. Holes: extrude a tool cylinder (`height + 4 mm`), offset its face with type Diameter (`native_set_history_choice` key 3) set to `hole_d`, pattern it with spacing `width - 12 mm` (occurrence 0) and `depth - 12 mm` (occurrence 1), then Subtract.
5. Fillet edges; set Radius to `corner_r`.
Change values with `native_set_variable` or in Shapr3D's history. Verified on such a block: all five variables, including rejection of values that break it.
## Body sizes
The app pads its whole-body bounding box on flat sides only. Sizes in `native_scene` are measured from per-face boxes instead.
## How faces and edges are found
The app has no call to list them, so `native_topology.py` casts a grid of rays at a body from all six directions plus tilted ones, and describes what they hit (about 0.5 s for a small part). Very small features, and surfaces no ray can reach (deep or undercut cavities), can be missed. References are stored as descriptions against a body *name*, not as IDs.
## Verified on 2026-11-30 (build 11926)
Approval of a new untitled project; refusal without approval; scene; screenshot over MCP; restore over 1–4 undo steps; a saved edge reference after a height change and a fillet; Fillet and Chamfer on several edges; Shell (persists); extrude-cut; Subtract; Intersect; a variable driving a history dimension; script and batch execution.
Offline tests: `.venv/bin/python -W ignore -m unittest tests.test_offline`
## Known problems and limits
- **Not supported:** circular pattern (the tool turns about the body's own centre and the axis could not be set), Projection, Wrap/Emboss, construction planes, non-uniform scale, drawing sketches with the pen tools, dimension constraints.
- Sketches are still imported flat (XY) curves; a sweep path must be a body edge.
- Constraints concentric, midpoint, tangent, horizontal/vertical and lock are offered but untested.
- Tip blocking hides `UserIntentHintBubbleView`; no card had appeared to confirm it (`native_tips` reports `hidden_so_far`). It only affects Native Lab, from the first tool call after a start.
- Sketch coordinates and distances go up to ±200 m (since module 70; building-sized work checked on one project). Face finding on large bodies is coarse and misses most edges.
- The bridge can group items into a new folder and move items into a folder (`module_group_items`, `module_move_items`); neither is an MCP tool yet. A union gives the result a new default name and puts it at the top level.
- Picking a sketch region exactly on a world axis fails; pick a point beside it.
- Once, after the combined Fillet/Chamfer command (223) was refused, history edits reported success without applying. 223 is no longer used, and such edits now raise an error. The cause is unknown.
- Selection "add" values (1 for edges, 0 for faces) were found by trial.
- For cuts, the app's distance callback may never fire; the server then checks the field value.
- Union, Move/Rotate, Loft and face Offset were not rerun after these changes.
## Isolation
Native Lab is a separate copy of the app with its own data folder; the regular app and its local containers are untouched. Projects sync through your Shapr3D account, so cloud projects are visible in both. No license, account or paywall checks are bypassed.
## License
[MIT](LICENSE), for the code in this repository only. It gives no rights to Shapr3D or its files.
TDQS
Scored across 60 tools
Several tool pairs have boundaries that only careful reading resolves: native_section_drawing vs native_section_drawings, native_create_length_variable vs native_create_variable, native_select_part_at vs native_pick_parts_at vs native_find_parts vs native_select_parts, and native_fillet_edges vs native_fillet_edge_at. Descriptions do supply distinguishing cues (singular vs batch, inspect vs select, verified vs untested), so an agent can disambiguate, but it needs effort at 60 tools.
Most tools follow a snake_case verb_noun pattern (native_create_variable, native_extrude_profile, native_mirror_bodies), but a large cluster of read-only tools are bare nouns (native_scene, native_items, native_history, native_status, native_variables, native_tips). Near-synonym verbs are applied to similar operations (pick/select/find, set/create), which weakens predictability.
60 tools is heavy even for a full CAD surface; many are fine-grained variants of the same operation (three variable tools, four selection/inspection tools, singular/plural drawing pairs) that could be folded into parameters on a smaller set. The domain is genuinely broad, so it is not a trivial mismatch, but the count is well past comfortable scoping.
The surface covers the whole modeling lifecycle: project authorization, scene/status/history inspection, sketch import and constraints, extrude/revolve/loft/sweep, booleans, fillet/chamfer/shell, transforms/patterns/mirror/scale, variables and history expressions, checkpoints and restore, import/export, and sectional drawing output. Almost no dead ends remain for an agent working in this domain.