{
  "openapi": "3.1.1",
  "info": {
    "title": "3D Mesh Repair (STL, OBJ, PLY) API",
    "version": "1.0.0",
    "summary": "Weld, clean, reorient and close small holes in a mesh; get a report of every change.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://renderloommeshrepair.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Weld, clean, reorient and close small holes in a mesh; get a report of every change.",
        "description": "Repair an STL, OBJ or PLY mesh: weld duplicate vertices, remove zero-area and duplicate triangles, make the winding consistent with outward normals and fill small holes. Download the repaired file and a before/after report.\n\nMethodology:\n- Steps run in a fixed order: weld vertices within the tolerance, remove triangles with a repeated vertex or an area of at most 1e-12 × diagonal², remove triangles that use the same three vertices as an earlier triangle, then drop unused vertices.\n- Winding is propagated breadth-first across edges shared by exactly two triangles, so neighbours traverse their common edge in opposite directions. Open surfaces keep the majority of their original windings.\n- Each closed shell is turned outward when its divergence-theorem volume is negative. Shells inside other shells (cavities) are detected by ray-casting parity and point inward. Up to 64 closed shells are checked for nesting.\n- Boundary loops with at most the chosen number of edges are projected onto their best-fit (Newell) plane and filled by ear clipping. Loops that touch themselves or cross themselves in projection are left open. Orientation is checked again after filling.\n- The repaired mesh is written in the chosen format. Binary STL and PLY store 32-bit floating-point coordinates.\n\nHoles are closed with flat ear-clipped patches, which may not match the intended surface. Self-intersections, thin walls and overlapping parts are not repaired. Inspect the result before printing.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "renderloom_mesh_repair",
        "x-owner-app": "renderloom",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RenderloomMeshRepairInput"
              },
              "examples": {
                "example1": {
                  "summary": "Close an open box, fix a flipped and a duplicated triangle (OBJ → binary STL)",
                  "value": {
                    "file": {
                      "filename": "open-box.obj",
                      "contentType": "model/obj",
                      "contentBase64": "IyBSZW5kZXJsb29tIG1lc2ggKHVzZWZ1bHdlYi5zaXRlKQp2IDAgMCAwCnYgMjAgMCAwCnYgMjAgMjAgMAp2IDAgMjAgMAp2IDAgMCAyMAp2IDIwIDAgMjAKdiAyMCAyMCAyMAp2IDAgMjAgMjAKZiAxIDIgMwpmIDEgNCAzCmYgMSAyIDYKZiAxIDYgNQpmIDIgMyA3CmYgMiA3IDYKZiAzIDQgOApmIDMgOCA3CmYgNCAxIDUKZiA0IDUgOApmIDEgNiA1Cg=="
                    },
                    "output": "stl-binary"
                  }
                },
                "example2": {
                  "summary": "Turn an inside-out tetrahedron outward (ASCII PLY)",
                  "value": {
                    "meshText": "ply\nformat ascii 1.0\ncomment Renderloom mesh (usefulweb.site)\nelement vertex 4\nproperty float x\nproperty float y\nproperty float z\nelement face 4\nproperty list uchar int vertex_indices\nend_header\n0 0 0\n30 0 0\n0 30 0\n0 0 30\n3 0 1 2\n3 0 3 1\n3 0 2 3\n3 1 3 2\n"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RenderloomMeshRepairResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RenderloomMeshRepairInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "file": {
            "title": "Mesh file (STL, OBJ or PLY)",
            "description": "Binary or ASCII STL, OBJ, or ASCII/binary PLY up to 30 MB and 500000 triangles. Upload as {filename, contentType?, contentBase64}. Max 30720 KiB. Accepts .stl,.obj,.ply,model/stl,model/obj,model/x-ply,text/plain,application/octet-stream.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "meshText": {
            "title": "Or paste an ASCII STL, OBJ or PLY mesh",
            "type": "string",
            "maxLength": 2000000
          },
          "output": {
            "title": "Output format",
            "type": "string",
            "enum": [
              "same",
              "stl-binary",
              "stl-ascii",
              "obj",
              "ply-binary",
              "ply-ascii"
            ],
            "default": "same"
          },
          "weld": {
            "title": "Vertex welding",
            "type": "string",
            "enum": [
              "auto",
              "exact",
              "loose"
            ],
            "default": "auto"
          },
          "fillHoles": {
            "title": "Fill small holes",
            "type": "boolean",
            "default": true
          },
          "maxHoleEdges": {
            "title": "Largest hole to fill (edges)",
            "type": "integer",
            "minimum": 3,
            "maximum": 200,
            "default": 64
          }
        },
        "required": []
      },
      "RenderloomMeshRepairResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "report",
              "sections",
              "format",
              "file",
              "openInApp"
            ],
            "properties": {
              "report": {
                "type": "object"
              },
              "sections": {
                "type": "array",
                "items": {
                  "type": "object"
                }
              },
              "format": {
                "type": "string"
              },
              "file": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "openInApp": {
                "type": "string"
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}