mesh2cad
Convert STL/OBJ/PLY meshes into B-rep CAD (STEP) with primitive fitting — CLI + MCP server
Safety scan
A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.
Check it deeper on your machine
It has changed since its scan on 11 Nov 2026.
As a Claude Code plugin, install it and then ask Claude Code:
/plugin marketplace add keithmackay/mackayi/plugin install scanskillsafety@mackayiDo a deep scan of https://github.com/emirmrkaljevic/mesh2cad with scanskillsafety
Or from a terminal, clone it and run it:
git clone https://github.com/keithmackay/scanskillsafety-skill ~/.claude/skills/scanskillsafetynode ~/.claude/skills/scanskillsafety/cli.cjs --deep 'https://github.com/emirmrkaljevic/mesh2cad'
It checks the exact commit: every file, its packages against OSV (api.osv.dev), how it compares with this page's scan (findsafeskills.com receives the repository's address), and, if you agree, Claude reading every file with your own Claude subscription. It never runs the code.
Badge for your README
Markdown
[](/listings/emirmrkaljevic--mesh2cad)HTML
<a href="/listings/emirmrkaljevic--mesh2cad"><img src="/api/listings/emirmrkaljevic--mesh2cad/badge.svg" alt="findsafeskills safety rating" /></a>Install
Install instructions from the README
As written by the repo's author. findsafeskills has not verified these steps.
pip install mesh2cad # CLI + STEP pip install "mesh2cad[mcp]" # + MCP server pip install "mesh2cad[cadquery]" # + run/verify generated CadQuery scripts
OpenSCAD scripts are plain text. Verifying one needs the `openscad` program ([openscad.org](https://openscad.org)); it is not a Python dependency. Without it the `.scad` file is still written.
What was scanned
The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.
README.md · README · 97 lines
View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)
This file has changed since it was scanned, so this is not exactly the text that was scanned, and no line is marked. The findings are listed with the safety scan above.
- # mesh2cad
- mesh2cad converts an STL mesh of a simple mechanical part into editable parametric CAD: STEP, CadQuery, OpenSCAD, and FreeCAD scripts. It is also an MCP server.
- [](https://github.com/emirmrkaljevic/mesh2cad/actions/workflows/ci.yml)
- [](https://pypi.org/project/mesh2cad/)
- [](https://glama.ai/mcp/servers/emirmrkaljevic/mesh2cad)
- <p align="center"><a href="https://skintoscan.com/#packages"><img src=".github/assets/skintoscan-support.svg" width="684" alt="Support my open-source work: get a SkinToScan pack"></a><br><sub>If you find this useful, you can support me by getting a SkinToScan pack, my other project. It's a one-time purchase that directly funds my open-source work.</sub></p>
- <p align="center"><a href="https://skintoscan.com/checkout/?add-to-cart=138"><img src=".github/assets/skintoscan-pack-1.svg" width="220" alt="Buy Single Picture Check, €4.49"></a> <a href="https://skintoscan.com/checkout/?add-to-cart=139"><img src=".github/assets/skintoscan-pack-5.svg" width="220" alt="Buy 5 Picture Pack, €19.99 (popular)"></a> <a href="https://skintoscan.com/checkout/?add-to-cart=140"><img src=".github/assets/skintoscan-pack-15.svg" width="220" alt="Buy 15 Picture Pack, €54.99"></a></p>
- OBJ and PLY meshes work the same way. The fit runs on your machine. Nothing is uploaded.
- A STEP file is the solid. When the fit is exact, a hole is one cylindrical face, not a ring of triangles. A script is for changing a dimension and rebuilding. CadQuery is Python. OpenSCAD is the text the Customizer on Thingiverse and Printables edits. The FreeCAD file is a macro. All three use the same names, so `hole_1_d` is the same hole in each of them.
- 
- *Left: a 21k-triangle mesh with 0.1 mm noise. Right: the STEP file mesh2cad writes, 10 planes and 2 cylinders, max deviation 0.05 mm from the true part.*
- 
- Four printer parts, with the STEP files and the generated scripts, are in the [example gallery](https://huggingface.co/spaces/mesh2cad/mesh2cad).
- Hackaday wrote about it: [Mesh2Cad Automates Re-Modelling](https://hackaday.com/2026/11/19/mesh2cad-automates-re-modelling/).
- ## Install
- ```
- pip install mesh2cad
- ```
- Python 3.10 or newer. That install is the command line tool and STEP export. OpenCascade comes in with the package (`cadquery-ocp`).
- `pip install "mesh2cad[mcp]"` adds the server. `pip install "mesh2cad[cadquery]"` lets mesh2cad run a generated `.py` and check it before the file is written. OpenSCAD and FreeCAD are separate programs, not pip packages. Without `openscad` on `PATH`, a `.scad` file is still written and the command says it was not verified. A `.FCMacro` is written only when a check passes. What happens when `freecadcmd` is missing is in [Install](docs/install.md).
- ## Quick start
- ```
- mesh2cad convert plate.stl --cadquery plate.py
- mesh2cad edit plate.py --set hole_grid_1_d=8 --in-place -o plate.step
- ```
- The first command writes `plate.py`. Diameters, thicknesses, and positions are names at the top of the file. A four-hole grid is `hole_grid_1_d`. The second sets that diameter to 8 mm, rewrites the script, and writes `plate.step`. Every other byte of the file stays as it was.
- `mesh2cad edit bracket.py --set base_x=+2` adds 2 mm to the current length. A leading `+` or `-` is a change from the current number, not how you set a negative value. `mesh2cad params bracket.py` prints each name, its value, and the unit when there is one.
- A STEP file on its own is `mesh2cad convert part.stl -o part.step`. Add `--report report.md` for the numbers: Hausdorff and RMS deviation, volume error, face types, and the method (`exact`, `faceted-hybrid`, or `faceted`). Open that STEP file in FreeCAD, Fusion, Onshape, or another CAD tool and select a face.
- If the part is outside what a script can express, or the rebuilt solid misses the check, the script is not written and the command exits with code 2. The reason is printed. The same convert can write `.scad` and `.FCMacro`. Flags are in the [CLI reference](docs/cli.md). What the scripts contain is in [CadQuery](docs/cadquery.md), [OpenSCAD](docs/openscad.md), and [FreeCAD](docs/freecad.md). The edit rules are in [Parameters](docs/parameters.md).
- ## What it handles
- It is meant for simple mechanical parts: plates, brackets, and boxes with holes, bolt circles, slots, bosses (including on an extruded outline), countersunk and counterbored holes on that outline, and fillets. A Z extrusion can also carry one radius on every vertical corner of the outline. It fits planes, cylinders, spheres, cones, and constant-radius rounds, and writes those as faces you can select.
- It does not recover organic or sculpted shapes, scans, or free-form surfaces. When a fit is poor it does not invent a surface. STEP output falls back to a faceted solid that is still valid, and the report names that fallback. A script is held to a tighter check: deviation at most max(4 times the tolerance, 0.1 mm), and volume error at most 1%. Miss that, and the script is refused.
- Six Original Prusa i3 MK3S printed parts in the test set come back as exact STEP, and all six also as a script. The measurements, including the small belt-profile patches that stay faceted, are in [Real parts](docs/real-parts.md). Synthetic noise tests are in [Benchmarks](docs/benchmarks.md). The fitted-surface list, the parameter names, and the refusals are in [Limits](docs/limits.md) (v0.31.0). The pipeline is in [How it works](docs/how-it-works.md).
- ## MCP
- ```
- pip install "mesh2cad[mcp]"
- mesh2cad mcp
- ```
- That starts the server on stdio. Point a client at it like this:
- ```json
- { "mcpServers": { "mesh2cad": { "command": "mesh2cad", "args": ["mcp"] } } }
- ```
- The tools are `convert`, `analyze`, `report`, `to_cadquery`, `to_openscad`, `to_freecad`, `list_params`, and `edit_params`. Arguments, return values, and the directory listings are in [MCP](docs/mcp.md).
- ## Docs
- - [Install: extras, OpenSCAD and FreeCAD](docs/install.md)
- - [CLI reference: every command and flag](docs/cli.md)
- - [CadQuery scripts: parameters and the check](docs/cadquery.md)
- - [OpenSCAD scripts](docs/openscad.md)
- - [FreeCAD macros](docs/freecad.md)
- - [Editing a parameter: `params` and `edit`](docs/parameters.md)
- - [MCP server: tools and arguments](docs/mcp.md)
- - [How it works: the fitting pipeline](docs/how-it-works.md)
- - [Limits: what is fitted and what is refused](docs/limits.md)
- - [Benchmarks: synthetic noise tests](docs/benchmarks.md)
- - [Real parts: Prusa printer parts](docs/real-parts.md)
- - [Development: tests and demo images](docs/development.md)
- - [Changelog](CHANGELOG.md)
- - [Project site with an overview and FAQ](https://emirmrkaljevic.github.io/mesh2cad/)
- A mesh that converts badly can go in a [GitHub issue](https://github.com/emirmrkaljevic/mesh2cad/issues/new/choose). There is a template for an STL that fails.
- ## License
- MIT. See [LICENSE](LICENSE).
- <!-- mcp-name: io.github.emirmrkaljevic/mesh2cad -->
Ratings and comments
Sign in to rate this skill.
Sign inFree to use. If it’s helped, pass it on.