Mesh Repair MCP
by alphadl
README.md
# Mesh Repair MCP
Mesh Repair MCP is a local [Model Context Protocol](https://modelcontextprotocol.io/) server for repairing 3D triangle meshes. Give an AI agent a Blender object, STL or OBJ file and it can find duplicate faces, remove unused vertices and correct face winding. Each proposed edit has a before-and-after inspection. Accept or reject the proposal; undo an accepted edit to restore the previous geometry.

**One extra triangle made three edges look non-manifold.** In the pictured example, cleanup removed the duplicate and exposed a closed, inside-out shell. A second edit turned the shell outward. The exported OBJ reopened with four triangles, zero non-manifold edges and the same geometry digest as the accepted revision. Its report still says `needs_review`: the kernel did not check for self-intersection.
## Run your first repair
In the project folder (the directory containing `pyproject.toml`), use Python 3.10 or newer. On macOS or Linux:
```sh
python -m venv .venv
source .venv/bin/activate
python -m pip install .
mesh-repair demo --out-dir first-repair
```
On Windows PowerShell, create the environment with `py -m venv .venv`, install with `.\.venv\Scripts\python.exe -m pip install .`, then run `.\.venv\Scripts\mesh-repair.exe demo --out-dir first-repair`.
A successful demo creates revision 2 with 4 vertices and 4 triangles. Open `first-repair/candidate.obj` in a mesh viewer. Read `first-repair/report.json` for the original diagnostics, accepted edits and outstanding checks. The demo runs without Blender or a model API key.
To try your own STL or geometry-only OBJ, use a new output directory:
```sh
mesh-repair run part.stl --out-dir part-review --save-candidate
```
This command writes `part-review/candidate.obj` and `part-review/report.json`. Without `--save-candidate`, the geometry stays in the session for review. An existing output directory is refused. Choose a new name for a second run, or omit `--out-dir` to create one automatically.
| Your input | How to open it | Available output |
| --- | --- | --- |
| STL, plain indexed triangle OBJ, geometry NPZ or mesh JSON | CLI or `mesh_open` | `run --save-candidate` writes OBJ. The `mesh_export` tool also writes NPZ and mesh JSON. STL is input-only. |
| Saved Blender scene with UVs, materials or multiple objects | `blender_open` with a local `.blend` path and a mesh object name | `blender_copy` writes a new `.blend`. For a textured OBJ or GLB, first import it into Blender and save the scene. |
## Connect a Blender or mesh agent
Generate an MCP stdio configuration pointing at the demo’s existing session:
```sh
mesh-repair mcp-config --workspace first-repair/workspace
```
Copy the generated server entry into your MCP client's configuration and reconnect. Give the client the session ID from the report and ask:
> Inspect this mesh and tell me which defects were fixed. Show the before-and-after counts and explain why it still needs review.
For a saved Blender scene, add `--blender /absolute/path/to/blender` when generating the configuration. Then try:
> Open the object “Housing” in my local housing.blend file. Check its face winding. If an edit is needed, propose it and show me what it changes before accepting it.
Replace the object name and file path with your own. The agent can read a named object, preview the edit and write a **new** scene containing both the original and the candidate. Blender writeback checks the source file fingerprint before saving. Operate on trusted local assets and use the Blender path when materials, UVs or object structure matter.
## Three reproducible cases
| Case | What happened | What was checked |
| --- | --- | --- |
| [Inside-out tetrahedron with a duplicate face](examples/meshes/inverted-tetrahedron.obj) | Two accepted edits reduced 5 vertices and 5 triangle rows to 4 of each. Non-manifold edges fell from 3 to 0. | The reopened OBJ matched the accepted geometry digest. |
| Nested shells around a cavity | The bounds of two shells overlapped. The agent’s orientation proposal was refused because turning both shells outward could change the inner wall’s meaning. | All 8 triangles, the original digest and revision 0 were preserved. The conservative bounds check can also flag disjoint shells. |
| [Blender part with UVs and two materials](examples/blender_fixture.py) | In Blender 4.3.2, the repaired copy had 0 inward shells, down from 1. It kept the UV layer `Print layout` and both material slots. | Per-corner UVs and per-face material assignments were checked during writeback. Both objects were reopened; the source file’s SHA-256 was unchanged. |
Run the first two cases with `python examples/cases.py case-results`. To run all three:
```sh
AGENTIC_MESH_BLENDER=/path/to/blender python examples/cases.py case-results-blender --blender
```
Each command expects a new directory. The [case generator](examples/cases.py) and [measured results](docs/cases.json) describe synthetic fixtures. Real-asset success rates and model-specific planning quality have not been measured.
## What an agent can do
| Task | MCP tools |
| --- | --- |
| Inspect a file or Blender object | `mesh_open`, `blender_open`, `mesh_inspect` |
| Preview and decide on an edit | `mesh_propose`, `mesh_accept`, `mesh_reject` |
| Review history or restore geometry | `mesh_trace`, `mesh_undo` |
| Write a reviewed result | `mesh_export`, `blender_copy` |
The server exposes **10 tools** and **3 geometry operations**: `compact` removes unused vertices, `clean` also removes degenerate or duplicate indexed faces, and `orient` fixes winding where the kernel can establish a consistent orientation. Direct file input supports plain triangle OBJ, STL, geometry NPZ and mesh JSON. Hole filling, remeshing and self-intersection certification are outside this release’s scope.
Run `mesh-repair tools` for machine-readable schemas. See the [tool reference](docs/tools.md), [Python API](docs/api.md), [architecture](docs/architecture.md), [migration guide](docs/migration.md) and [release checks](docs/release.md).
MIT licensed. [License](LICENSE) · [Project lineage](PROVENANCE.md).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues