shapr3d-mcp
by unfernandito
README.md
# shapr3d-mcp
An [MCP](https://modelcontextprotocol.io) server that lets AI agents (Claude, Cursor, any MCP client) read
[Shapr3D](https://www.shapr3d.com) projects and drive the Shapr3D app on macOS.
> **Unofficial.** Not affiliated with, endorsed by, or supported by Shapr3D Zrt. "Shapr3D" is a trademark of its
> owner. This project ships no Shapr3D code; it reads files you already have and talks to the app you already
> installed. See [Disclaimer](#disclaimer).
```text
You: "What features does lamp.shapr have, and how deep is the base extrusion?"
Agent → shapr_inspect → 144 features: Sketch 01, Lamp base plate extrusion 1 (Extrude), …
Agent → shapr_feature(id 1) → value (length) = 1 mm, angle (draftAngle) = 0°, toClosestPoint = false, …
```
## Why
Shapr3D has no public scripting API: no AppleScript dictionary, no plugin SDK, no CLI. This server uses the
two doors that do exist, found by analysing the app (details in
[docs/reverse-engineering.md](docs/reverse-engineering.md)):
1. **The `.shapr` file.** It is a ZIP with a SQLite database that stores the full parametric history. The server
reads it offline: no app, no account, no network.
2. **The app's file and URL handlers.** `open -a Shapr3D <file>` imports STEP/STL/3MF/X_T/DXF/… and
`shapr3d://project/<uuid>?team=<id>` opens a cloud project.
## Tools
| Tool | What it does | Needs the app |
|------|--------------|:-:|
| `shapr_inspect` | Kernel versions, ordered feature history (name, operation, suppressed), sketches with plane origin/normal in mm, drawings, counts | no |
| `shapr_feature` | Every parameter of one feature, decoded (lengths in mm, angles in degrees, bools, enums, references) and named for 45 operations | no |
| `shapr_list_samples` | Sample projects bundled with Shapr3D, handy to try the tools | installed |
| `shapr_open` | Open a `.shapr` or import a CAD/mesh/image file into the running app | yes |
| `shapr_open_cloud_project` | Open a cloud project from its web link `https://app.shapr3d.com/p/<uuid>` (or bare UUID) and team id | yes, signed in |
Creating geometry: the agent writes a STEP or STL (for example with CadQuery or build123d) and calls
`shapr_open`. Shapr3D shows its import dialog and a person confirms it.
## Requirements
- macOS for the app-facing tools; reading `.shapr` files also works on Linux.
- Node.js ≥ 22.5 (uses the built-in `node:sqlite`).
- `unzip` on `PATH` (preinstalled on macOS).
- Shapr3D installed at `/Applications/Shapr3D.app` for the app-facing tools.
## Install
```bash
git clone https://github.com/unfernandito/shapr3d-mcp.git
```
```bash
cd shapr3d-mcp && npm install
```
### Claude Code
```bash
claude mcp add shapr3d -- node /absolute/path/to/shapr3d-mcp/server.js
```
### Claude Desktop, Cursor and other clients
Add to the client's MCP config (`claude_desktop_config.json`, `.cursor/mcp.json`, …):
```json
{
"mcpServers": {
"shapr3d": {
"command": "node",
"args": ["/absolute/path/to/shapr3d-mcp/server.js"]
}
}
}
```
## Usage examples
Ask your agent things like:
- "List the Shapr3D sample projects and summarise the drone's design history."
- "In `~/Downloads/bracket.shapr`, which fillets are suppressed and what radius do they use?"
- "Make a 40 × 20 × 5 mm plate with four M3 holes as STEP and open it in Shapr3D."
- "Open https://app.shapr3d.com/p/<uuid> in Shapr3D, team `<team-id>`."
### Getting your files and ids
- **`.shapr` files.** Projects saved in Shapr3D live in its sandbox, which macOS blocks other apps from reading.
Export the project as `.shapr` from Shapr3D and point the tools at that file.
- **Project UUID.** It is the last part of the web link `https://app.shapr3d.com/p/<uuid>`.
- **Team id.** Shapr3D ignores project links without it, and it isn't stored in `.shapr` files.
## How it works
```mermaid
flowchart LR
A[MCP client<br/>Claude / Cursor] -- stdio JSON-RPC --> S[server.js<br/>tool definitions]
S --> L[lib.js]
L -- unzip + node:sqlite --> F[(.shapr<br/>ZIP → SQLite)]
L -- MessagePack / JSON decode --> H[HistoryTreeNodes]
L -- signatures.json --> N[parameter names]
L -- open -a --> APP[Shapr3D.app]
L -- open shapr3d://project/… --> APP
```
**Reading a project** (`shapr_inspect`, `shapr_feature`):
1. Unzip the `.shapr` into a temp folder (`workspace` is SQLite, `.metadata` is JSON) and open it read-only.
2. Read `HistoryTreeNodes`. The root node lists feature ids in timeline order; each feature node holds its name,
operation (`Extrude`, `Fillet`, …) and the ids of its parameter nodes.
3. Decode each parameter, a tagged value: tag 12 is a quantity in SI units (converted to mm or degrees),
1 bool, 2 enum, 9 a list of topology references, 0 empty.
4. Name the parameters from `signatures.json`. That table was recovered from the app's own registry of
operations, where each parameter has an internal name and a UI label (`value` → `length`).
The storage format changed over time and all three generations are handled:
| `SchemaVersion` | Node encoding |
|-----------------|---------------|
| 86005 (2023) | JSON |
| 203000 | MessagePack `[flag, name, op, params]` |
| 307000 and later | MessagePack `[a, b, name, op, params]`, root `["<root>", ids]` |
**Driving the app** (`shapr_open`, `shapr_open_cloud_project`): macOS `open` hands the file or URL to Shapr3D,
which runs its normal import flow or its `shapr3d://` router. The server validates file extensions and UUIDs
first, so an agent cannot pass arbitrary URLs to the app.
## Limits
- Read-only for `.shapr`: it never writes project files or edits history inside the app.
- Body geometry (Parasolid partitions) is counted, not exported.
- Parameter names come from Shapr3D 26.211; a later app version may add or reorder parameters. Positions and
values are always returned, names when known.
- Tested against Shapr3D 26.211 on Apple silicon.
## Development
```bash
npm test
```
Tests use `node:test`. The ones that read real projects use the samples bundled with Shapr3D and are skipped when
the app isn't installed (as in CI).
Regenerating `signatures.json` after a Shapr3D update takes a Ghidra 12 headless pass over the app binary; the
scripts and steps are in [`scripts/`](scripts) and [docs/reverse-engineering.md](docs/reverse-engineering.md).
## Disclaimer
This is an independent interoperability project. It was built by inspecting a legitimately installed copy of
Shapr3D and the sample files it ships, so that other software can read the user's own projects. It contains no
Shapr3D source code, binaries, assets or sample files. Check that your use complies with the Shapr3D terms that
apply to you. Provided as-is, without warranty (see [LICENSE](LICENSE)).
## License
[MIT](LICENSE)
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues