Skip to main content
Glama
kerfkit-mcp

kerfkit-mcp

Official
by junixlabs
README.md
# kerfkit

**Laser cutting file checker and fixer: validate and repair SVG/DXF for laser cutters (open paths, double lines, tiny segments, kerf and slot fit), generate slot gauges and test sheets. CLI, Python, MCP server and Claude plugin.**

[![CI](https://github.com/junixlabs/kerfkit/actions/workflows/ci.yml/badge.svg)](https://github.com/junixlabs/kerfkit/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
![Python 3.10+](https://img.shields.io/badge/python-3.10%2B-blue)
[![MCP server](https://img.shields.io/badge/MCP-stdio%20server-6b5bd2)](#use-it-from-claude-or-any-mcp-client)

Catch the problems that waste a sheet *before* you press start: a file that imports 33 % too small, an outline
that is not closed, a line the laser cuts twice, slots drawn for 3.0 mm ply when yours measures 3.2. Then fix the
safe ones automatically and work out the slot width for your sheet and kerf.

![kerfkit check, fix and slot in a terminal](assets/demo.gif)

| Before: `kerfkit check` finds 4 failures | After: `kerfkit fix`, re-checked: pass |
|---|---|
| ![a messy panel with an open hole, a double line, a stray node and pixel units](assets/before.png) | ![the same panel fixed: mm units, red hairline cuts, black engrave](assets/after.png) |

Files: [`examples/messy-panel.svg`](examples/messy-panel.svg) → [`examples/messy-panel.fixed.svg`](examples/messy-panel.fixed.svg)

## Install

```bash
pip install git+https://github.com/junixlabs/kerfkit           # CLI + Python
pip install "kerfkit[dxf] @ git+https://github.com/junixlabs/kerfkit"   # + DXF input
```

Or run it without installing anything permanent, with [uv](https://docs.astral.sh/uv/):

```bash
uvx --from git+https://github.com/junixlabs/kerfkit kerfkit check my-file.svg
```

Python 3.10+. Dependencies: numpy, shapely, svgpathtools (and ezdxf for DXF). Runs on CPU, no browser, no network.

## 30-second tour

```bash
kerfkit check panel.svg                            # every check, pass / warn / fail, locations in mm
kerfkit check panel.svg --thickness 3 --kerf 0.15  # + slot widths against your sheet
kerfkit fix panel.svg -o panel.fixed.svg           # safe repairs, clean mm SVG out
kerfkit slot --thickness 3.2 --kerf 0.15           # "Draw slots 3.050 mm wide"
kerfkit refit shelf.svg -o shelf.3.2.svg --thickness 3.2 --kerf 0.15
kerfkit testsheet -o test.svg --thickness 3        # slot gauge + key + kerf square
kerfkit kerf square 20.16 19.84                    # "kerf = 0.160 mm"
```

`check` exits 1 when anything fails, so it works as a pre-flight step in scripts and CI.

## What it checks

| Check | What it catches |
|---|---|
| `units` | width/height in px or missing (imports 75 % or 133 % off between 72 and 96 DPI apps), mismatched viewBox scale |
| `layers` | colour → layer mapping (red cut, blue score, black/blue fill engrave), filled or thick cut lines, lines named "engrave" but drawn in cut red. A per-colour table is in the JSON |
| `text-outlined` | live `<text>`, clones (`<use>`), embedded objects; raster images |
| `tiny-strays` | paths shorter than 0.5 mm: stray nodes the laser fires on |
| `tiny-segments` | zero-length segments, and files made of thousands of sub-0.05 mm segments (node cleanup) |
| `closed-paths` | open outlines (gap > 0.01 mm), told apart from slits/living hinges inside a part and deliberate holding bridges |
| `open-fragments` | outlines made of loose pieces that only close end to end |
| `self-intersection` | outlines that cross themselves |
| `no-duplicates` | double and overlapping cut lines (> 0.5 mm within 0.02 mm), including a path retracing itself |
| `islands`, `parts-overlap` | loose pieces inside cut-outs, parts cutting through each other |
| `min-feature` | necks and strips narrower than the minimum bridge (default 1.2 mm) |
| `min-hole` | cut-outs narrower than 1.0 mm |
| `fits-bed` | parts or layout bigger than your bed (`--bed 400x300`) |
| `slot-width` | slots not at thickness − kerf + clearance (`--thickness 3 --kerf 0.15`) |
| `finger-depth` | finger notches not one sheet deep (`--profile box`) |

Profiles (`--profile`) switch checks on for a kind of job: `generic` (default), `strict` (requires the colour
convention), `box`, `tray`, `kerf-test`, `ornament` (one piece + hanging hole), `name`, `silhouette`, `engrave`
(engrave-only files are valid), `layered`, `refit`. Every threshold is a parameter.

## What `fix` changes, and what it never touches

Changes (each can be switched off): real size in mm · zero-length segments and stray nodes removed · colours mapped
to cut / score / engrave (override with `--map 'stroke:#e8251b=cut'`) · fill-only shapes turned into cut outlines
when that is unambiguous · double cuts merged · open ends joined where each end has exactly one partner within
`--gap-max` (0.2 mm) · optional kerf compensation (`--kerf 0.15`: outlines out, holes in by half the kerf).

Never touched: thin bridges, small holes, self-intersections, islands, slot widths. Those are design decisions; `check`
reports them with locations and you decide.

## Kerf and slots

Slots are drawn on their centre line and the beam removes half the kerf on each side, so:

```
draw slot = measured thickness − kerf + clearance
```

`kerfkit slot --thickness 3.0 --kerf 0.1` → draw 2.90 mm. Add `--drawn 3.0` to judge a slot already in a file
(tight / ok / loose), `--dowel 3` to size a dowel hole.

Find your kerf from one test cut (`kerfkit testsheet`):

* **Kerf square**: a 20 mm square hole; measure the hole and the square that drops out. `kerfkit kerf square HOLE SQUARE`
  gives (hole − square) / 2, which cancels most caliper error.
* **Slot gauge**: five notches around thickness − kerf, each labelled with the kerf to use if it is the snug one.
  Push the key (cut from the same sheet) into each.
* Also: `kerf part DRAWN MEASURED`, `kerf hole DRAWN MEASURED`, `kerf comb TOTAL MEASURED --cuts N`.

`kerfkit refit FILE -o OUT --thickness 3.2 --kerf 0.15` redraws every closed rectangular slot at the new width,
keeping its centre, angle and length. The model is not scaled.

## Python

```python
from kerfkit import check_file, fix_svg, slot_width, refit_slots, test_sheet

rep = check_file("panel.svg", thickness_mm=3.0, kerf_mm=0.15, bed_mm=[400, 300])
print(rep["pass"], [c["id"] for c in rep["checks"] if c["status"] == "fail"])

result = fix_svg("panel.svg", gap_max=0.2)
open("panel.fixed.svg", "w").write(result.svg)

slot_width(3.2, kerf=0.15, clearance=0.05)   # 3.1
```

## Use it from Claude or any MCP client

kerfkit ships a stdio MCP server, `kerfkit-mcp`, with seven tools: `check_laser_file`, `fix_laser_svg`,
`slot_width`, `kerf_from_test`, `refit_slots`, `make_slot_gauge`, `make_test_sheet`. It reads and writes local files
only and makes no network calls.

**Claude Code plugin** (MCP server + skill in one step):

```
/plugin marketplace add junixlabs/kerfkit
/plugin install kerfkit@junixlabs
```

The plugin also lists an optional second server, `fit`: the remote [MocMakes Fit](https://fit.thejunix.com/?via=github)
MCP server (sign-in with OAuth via `/mcp`), with the `/kerfkit:fit-projects` and `/kerfkit:fit-build` commands for
your own Fit projects. It is only contacted if you authenticate it; kerfkit's own tools stay local and need no account.

**Claude Code, MCP only:**

```bash
claude mcp add kerfkit -- uvx --with ezdxf --from git+https://github.com/junixlabs/kerfkit kerfkit-mcp
```

**Claude Desktop, Cursor, VS Code, other MCP clients** (`mcpServers` JSON):

```json
{
  "mcpServers": {
    "kerfkit": {
      "command": "uvx",
      "args": ["--with", "ezdxf", "--from", "git+https://github.com/junixlabs/kerfkit", "kerfkit-mcp"]
    }
  }
}
```

**Skill only:** copy [`skills/kerfkit/`](skills/kerfkit/SKILL.md) into `~/.claude/skills/`. It teaches the assistant
the workflow (check → fix → re-check → slot width → test cut) and the formulas, and uses the CLI.

Then ask things like *"check ~/Downloads/box.svg for my 3 mm ply, kerf 0.15"* or *"make me a slot gauge for 6 mm
MDF"*.

## FAQ

**How do I check an SVG before laser cutting?**
`kerfkit check file.svg`. It reports units, layers, open paths, double lines, stray nodes, thin bridges, small holes and
bed fit, each with the location in mm. Add `--thickness` and `--kerf` to check slot widths too.

**How do I find my laser's kerf?**
Cut `kerfkit testsheet -o test.svg --thickness 3` and measure the 20 mm square hole and the square that drops out:
`kerfkit kerf square 20.16 19.84` → 0.16 mm. On 3 mm plywood it is usually 0.1 to 0.2 mm.

**Why are my slots too loose?**
The slot was drawn at the nominal thickness and the beam widened it by the kerf, or your sheet is thinner than the
label. Measure the sheet, then `kerfkit slot --thickness 2.9 --kerf 0.15 --drawn 3.0` tells you how loose and what
width to draw; `kerfkit refit` redraws closed slots for you.

**Why are my slots too tight?**
Usually the sheet is thicker than the file assumed: plywood sold as 3 mm can measure anywhere from 2.7 to 3.2 mm.
Same commands as above.

**Why does my SVG import at the wrong size?**
Its width and height are in pixels or missing, and apps disagree on 72 vs 96 pixels per inch (75 % / 133 %).
`kerfkit check` flags it, `kerfkit fix` writes real millimetres.

**Which colours does it expect?**
Red `#FF0000` hairline = cut, blue `#0000FF` = score, black (or blue) fill = engrave, a common convention in shared
files. Laser apps such as LightBurn put each colour on its own layer, so near-misses like `#e8251b` end up on a
separate layer. Other colours are read leniently and `fix` maps them; `--strict` requires the convention.

**Does it work with LightBurn, Glowforge, xTool?**
It checks and writes plain SVG (and reads DXF), which they all import. It does not read `.lbrn` or `.gf` project files
yet.

**Is this a guarantee the file cuts?**
No. These are geometry checks against cut rules; machines, focus and materials vary. Cut the small test sheet first.

## Honest scope (v0.1)

* SVG in and out; DXF in (checks only). No DXF writing, no LightBurn/xTool project files yet.
* `refit` moves closed rectangular slots only. Edge notches, tabs and finger joints are found and reported by `check`,
  not moved.
* `fix` writes a new, flattened SVG (one path per shape, transforms baked in). Groups, layer names and
  metadata of the original are not kept. Text and images are left out with a warning.
* Kerf compensation and fill merging turn curves into fine polylines.
* No raster analysis: engraving line widths and photos are not judged.

Roadmap: a jig board generator and batch names from CSV (v0.2), DXF out and LightBurn export (v0.3). Ideas and
bug reports are welcome in [Issues](https://github.com/junixlabs/kerfkit/issues) and
[Discussions](https://github.com/junixlabs/kerfkit/discussions).

## Made by MocMakes

kerfkit is the open-source core of the checks behind [MocMakes](https://moc.thejunix.com/?via=github), where we design
slot-together laser kits.

* **[MocMakes Fit](https://fit.thejunix.com/?via=github)**: free browser tools built on the same logic: refit every
  slot, tab and finger joint of a file to your sheet ([slot fit](https://fit.thejunix.com/app?via=github)), a
  [box generator](https://fit.thejunix.com/box-generator?via=github) and a
  [jig board generator](https://fit.thejunix.com/jig-board-generator?via=github) for batch engraving.
* **[Free laser files](https://moc.thejunix.com/free-laser-files?via=github)**: checked SVG/DXF files to cut.

## Contributing

Bug reports with a sample file are the most useful thing you can send (strip anything private first). See
[CONTRIBUTING.md](CONTRIBUTING.md). Security issues: [SECURITY.md](SECURITY.md).

MIT licence © MocMakes.

TDQS

A3.7/5.0

Scored across 7 tools

Disambiguation5/5

Each tool has a distinct role: checking, repairing, calculating slot widths, deriving kerf, refitting slots, and generating a gauge or test sheet. The closest pairs (slot_width vs refit_slots, make_slot_gauge vs make_test_sheet) are clearly separated by whether they calculate, modify an SVG, or generate a test artifact.

Naming Consistency4/5

Most names follow a clear snake_case verb_noun or action-oriented pattern such as check_laser_file, fix_laser_svg, refit_slots, and make_test_sheet. The noun phrases slot_width and kerf_from_test are minor deviations, but the overall naming remains readable and consistent.

Tool Count5/5

Seven tools is well-scoped for a laser-cutting preparation toolkit. Each tool covers a meaningful stage in the workflow without redundant entries.

Completeness4/5

The surface covers checking, safe repair, slot sizing, kerf derivation, slot refitting, and test artifact generation, which is strong lifecycle coverage. The explicit v0.1 limitation that refit_slots does not move edge notches, tabs, or finger joints leaves a notable gap, but most core workflows are supported.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues