mesh2cad
mesh2cad is an MCP server for converting simple mechanical meshes into editable CAD and inspecting or editing the generated models.
convert: fit planes, cylinders, spheres, cones, and fillets from an STL/OBJ/PLY mesh and write a STEP B-rep with a fidelity report.analyze: segment a mesh and report detected surfaces without writing STEP.report: generate a full Markdown fidelity report for converting a mesh.to_cadquery,to_openscad,to_freecad: write editable parametric CadQuery, OpenSCAD, or FreeCAD scripts for supported simple parts, with validation/deviation results where possible.list_params: list editable parameters of a generated.py,.scad, or.FCMacroscript.edit_params: change named parameters, re-render to STEP/STL, validate the result, and return old/new values and render details; invalid edits are refused.
Allows generating editable parametric OpenSCAD scripts from 3D meshes and optionally rendering and verifying them with the OpenSCAD CLI, enabling use with OpenSCAD-based workflows such as the Customizer.
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.
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.
Hackaday wrote about it: Mesh2Cad Automates Re-Modelling.
Install
pip install mesh2cadPython 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.
Related MCP server: ai-cad-workbench
Quick start
mesh2cad convert plate.stl --cadquery plate.py
mesh2cad edit plate.py --set hole_grid_1_d=8 --in-place -o plate.stepThe 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. What the scripts contain is in CadQuery, OpenSCAD, and FreeCAD. The edit rules are in Parameters.
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. Synthetic noise tests are in Benchmarks. The fitted-surface list, the parameter names, and the refusals are in Limits (v0.31.0). The pipeline is in How it works.
MCP
pip install "mesh2cad[mcp]"
mesh2cad mcpThat starts the server on stdio. Point a client at it like this:
{ "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
A mesh that converts badly can go in a GitHub issue. There is a template for an STL that fails.
License
MIT. See LICENSE.
Available Tools
8 toolsanalyzeC
Segment a mesh and report detected surfaces without writing STEP.
Inputs: input_path (required), tol, cones, spheres, +1 more.
convertA
Convert an STL/OBJ/PLY mesh into a STEP B-rep with fitted planes, cylinders, spheres, cones, and constant-radius fillets.
Args: input_path: path to the mesh file. output_path: STEP path to write (default: input with .step suffix). tol: fit tolerance in model units (~ mesh noise); default 0.1% of bbox diagonal. cylinders: also fit cylinders (holes, bosses, plane-plane fillets). spheres: also fit spheres (domes, spherical bosses). cones: also fit cones (chamfers, countersinks, tapered bosses). Returns the fidelity report (method, faces, deviation, volume error) and output path.
Inputs: input_path (required), tol, cones, spheres, +2 more.
edit_paramsA
Change named parameters in a script mesh2cad generated and re-render the solid.
Args: script_path: path to a .py, .scad, or .FCMacro file written by mesh2cad. changes: mapping of parameter name to a new number, or to a string that starts with + or - to add that delta (for example {"hole_1_d": 8, "base_x": "+2"}). output_path: STEP or STL to write. CadQuery and FreeCAD accept .step or .stl. OpenSCAD accepts .stl. When omitted, a .step (or .stl for OpenSCAD) is written next to the script if that backend is available. The script is updated in place. Every byte outside the replaced numbers stays the same. Unknown names are refused with the valid list. An edit that does not produce one valid solid, or a hole larger than the wall it sits in, is refused and nothing is written. Returns old and new values, the rendered path, validity, volume and bounding-box delta, and warnings. Returns an "error" key when the edit is refused or the backend needed for output_path is not available.
Inputs: changes (required), script_path (required), output_path.
list_paramsA
List the editable parameters of a CadQuery, OpenSCAD, or FreeCAD script mesh2cad generated.
Args: script_path: path to a .py, .scad, or .FCMacro file written by mesh2cad. Returns name, value, kind, and unit for each parameter. Outline and cutout point lists are included and are not single numbers. Returns an "error" key when the file is not a script mesh2cad generated.
Inputs: script_path (required).
reportC
Full Markdown fidelity report for converting this mesh.
Inputs: input_path (required), tol, cones, spheres, +1 more. Returns: result
to_cadqueryC
Write an editable parametric CadQuery script (.py) for a simple part.
Works for a box/plate base with rectangular pads, holes along X, Y, or Z (through, blind, counterbored, and countersunk when the axis is vertical), bosses along X, Y, or Z (straight, and drafted or chamfered when the axis is vertical), fillet_r on the four vertical corners, edge_fillet_r when every edge of the box shares one radius (a through-hole that clears those rounds is cut after the fillet, and a straight boss that clears them is fused after it), fillet_r on every vertical edge of an L-bracket including the inner corner (base_x, base_y, base_t, leg_x, leg_y), through-holes in the foot and the upright of that bracket (base_hole_N_d, leg_hole_N_d), a row, axis-aligned grid, or bolt circle of plain Z through-holes (hole_row_1_n, hole_row_1_pitch, hole_grid_1_nx, hole_grid_1_pitch_x, hole_circle_1_n, hole_circle_1_r), a straight obround through-slot along Z (slot_1_len, slot_1_w, slot_1_x, slot_1_y, slot_1_angle), a fillet at the base of a vertical boss (boss_N_fillet), a round on a vertical hole rim (hole_N_rim_r, hole_N_bot_rim_r) and a blind-hole floor fillet (hole_N_floor_r), a straight extrusion of a 2D outline along X, Y, or Z (straight round bosses on the top face of a Z extrusion are boss_N_d, boss_N_h, boss_N_x, boss_N_y; a vertical countersink on that Z extrusion is hole_N_csk_d and hole_N_csk_angle, and a counterbore is hole_N_cbore_d and hole_N_cbore_depth; vertical corners of that Z extrusion that share one radius are outline_fillet_r), and a small boolean of those extrusions (intersection, or one minus a cut along another axis) with round through-holes, counterbores, and a few planar clips. Each dimension is a named parameter (e.g. hole_1_d = 6.0, extrude_len): edit it and run the script with Python to regenerate the part. Returns the parameters and the measured deviation of the script's output from the mesh. Returns an "error" key when the part is outside that vocabulary.
Inputs: input_path (required), tol, output_path.
to_freecadB
Write an editable parametric FreeCAD macro (.FCMacro) for a simple part.
Same parts as to_cadquery: a box/plate base with rectangular pads, holes and bosses along X, Y, or Z (countersink, draft, and chamfer only when the axis is vertical), one radius on the four vertical corners, edge_fillet_r when every edge of the box shares one radius (a through-hole that clears those rounds is cut after the fillet, and a straight boss that clears them is fused after it), fillet_r on every vertical edge of an L-bracket including the inner corner (leg_x, leg_y), through-holes in the foot and the upright of that bracket (base_hole_N_d, leg_hole_N_d), a row, axis-aligned grid, or bolt circle of plain Z through-holes (hole_row_1_n, hole_row_1_pitch, hole_grid_1_nx, hole_circle_1_n, hole_circle_1_r), a straight obround through-slot along Z (slot_1_len, slot_1_w, slot_1_angle), a quarter-torus fillet on a vertical boss or hole (boss_N_fillet, hole_N_rim_r, hole_N_floor_r), a straight extrusion of a 2D outline (straight round bosses on the top face of a Z extrusion are boss_N_d, boss_N_h, boss_N_x, boss_N_y; a vertical countersink on that Z extrusion is hole_N_csk_d and hole_N_csk_angle; vertical corners of that Z extrusion that share one radius are outline_fillet_r), and a small boolean of those extrusions. Parameter names match the CadQuery script (hole_1_d, hole_row_1_n, hole_circle_1_r, slot_1_len, boss_1_h, fillet_r, edge_fillet_r, leg_x, base_hole_1_d, boss_1_fillet, extrude_len, ...). Edit one and run the macro in FreeCAD, or with freecadcmd. Returns the parameters, whether freecadcmd verified the macro against the mesh, and the measured deviation when it did. Without freecadcmd the same deviation and volume check is run with CadQuery, or with OpenSCAD when CadQuery is not installed. The macro is written only when that check passes, and verified is false because FreeCAD did not measure it. Returns an "error" key when the part is outside that vocabulary or the check refuses.
Inputs: input_path (required), tol, output_path.
to_openscadB
Write an editable parametric OpenSCAD script (.scad) for a simple part.
Same parts as to_cadquery: a box/plate base with rectangular pads, holes and bosses along X, Y, or Z (countersink, draft, and chamfer only when the axis is vertical), one radius on the four vertical corners, edge_fillet_r when every edge of the box shares one radius (a through-hole that clears those rounds is cut after the fillet, and a straight boss that clears them is fused after it), fillet_r on every vertical edge of an L-bracket including the inner corner (leg_x, leg_y), through-holes in the foot and the upright of that bracket (base_hole_N_d, leg_hole_N_d), a row, axis-aligned grid, or bolt circle of plain Z through-holes (hole_row_1_n, hole_row_1_pitch, hole_grid_1_nx, hole_circle_1_n, hole_circle_1_r), a straight obround through-slot along Z (slot_1_len, slot_1_w, slot_1_angle), a quarter-torus fillet on a vertical boss or hole (boss_N_fillet, hole_N_rim_r, hole_N_floor_r), a straight extrusion of a 2D outline (straight round bosses on the top face of a Z extrusion are boss_N_d, boss_N_h, boss_N_x, boss_N_y; a vertical countersink on that Z extrusion is hole_N_csk_d and hole_N_csk_angle; vertical corners of that Z extrusion that share one radius are outline_fillet_r), and a small boolean of those extrusions. Parameter names match the CadQuery script (hole_1_d, hole_row_1_n, hole_circle_1_r, slot_1_len, boss_1_h, fillet_r, edge_fillet_r, leg_x, base_hole_1_d, boss_1_fillet, extrude_len, ...). Edit one and render in OpenSCAD. Returns the parameters, whether the openscad CLI verified the script against the mesh, and the measured deviation when it did. Without the openscad program the script is still written and verified is false. Returns an "error" key when the part is outside that vocabulary.
Inputs: input_path (required), tol, output_path.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 8 tools
The core operations are clearly distinct: analyze (surface report only), convert (mesh→STEP B-rep), the three to_* tools (parametric script generation), and edit_params/list_params operate on already-generated scripts. The three to_* backends are explicitly described as producing 'same parts as to_cadquery', so the boundary is the backend, which is unambiguous. Minor overlap: 'report' and the fidelity report returned by 'convert' both cover the same conversion assessment, and a user could be unsure which to call first.
Three conventions coexist: bare verbs (analyze, convert, report), to_noun backend variants (to_cadquery, to_openscad, to_freecad), and verb_noun parameter tools (edit_params, list_params). Each group is internally consistent and readable, but the set as a whole mixes patterns rather than following one verb_noun scheme.
Eight tools is well-scoped for a mesh-to-CAD conversion server: one analysis, one direct conversion, three backend script writers, two parameter tools, and one report. No tool appears redundant given the multi-backend design.
The surface covers the full lifecycle: analyze the mesh, convert directly, generate editable scripts in three backends, list and edit parameters, and report fidelity. Minor gaps remain—there is no tool to validate or re-check an existing STEP/script against the mesh outside edit_params, and no batch/multi-part operation—but core workflows are fully covered.
Maintenance
Related MCP Connectors
Headless CAD engine & MCP server for 2D/3D drafting, solids, DXF/SVG export, and automation.
6 3D/CAD MCP tools: STL repair, OBJ/GLB/SVG conversion, slicing, G-code M600, SVG optimize.
Free 3D conversion (FBX, GLB, OBJ, STL, PLY, DAE, USDZ, 3MF) as a remote MCP server. No account.
Convert files, URLs, and documents to clean, AI-ready Markdown via MCP.
Related MCP Servers
- FlicenseAqualityBmaintenanceCAD-engineering MCP tool server for parametric modeling, DFM validation, mechanical calculations, and more. Enables code-CAD builds (build123d/CadQuery), model inspection, meshing, and mechanical calculators via MCP stdio.11-
- AlicenseNot gradedqualityDmaintenanceMCP server for AI-driven CAD operations, enabling parametric modeling, build, inspection, measurement, rendering, and diff comparison with STEP, DXF, and GLB export.MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI agents and software to create, edit, inspect, validate, and export CAD geometry through MCP using backend-neutral typed operations, with FreeCAD/OpenCascade as the authoritative B-rep backend and JSCAD preview.1Apache 2.0
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to convert raw STL mesh files into production-grade STEP AP242 solid B-Rep models and compact semantic CAD Features JSON, with sub-second deterministic processing and high mathematical fidelity.28PolyForm Noncommercial 1.0.0