Skip to main content
Glama
lye-calc-mcp

lye-calc-mcp

README.md
# lye-calc-mcp

Soap lye math as an MCP server: how much sodium hydroxide (bar soap) or potassium hydroxide (liquid soap) and water
your oils need at a given superfat, the soap qualities of the recipe against SoapCalc's suggested ranges, and how much
oil fills a mold or makes a batch of a given weight. Three read-only tools, no sign-in, nothing stored.

It is the calculator of the **[Lye Calc](https://zhukovskyi.space/apps/lye-calc/)** soap app by Dre Dev, ported from
Dart to Python and checked against the app's own test values. The same calculator runs free in the browser:
[soap lye calculator](https://zhukovskyi.space/calculators/soap/lye-calculator.html).

- App: [Google Play](https://play.google.com/store/apps/details?id=com.andrii.soapcalc) ·
  [zhukovskyi.space/apps/lye-calc](https://zhukovskyi.space/apps/lye-calc/)
- Server: `https://mcp.zhukovskyi.space/lye-calc/mcp` (streamable HTTP)

## Tools

| Tool | Gives |
|---|---|
| `calculate_soap_recipe` | NaOH / KOH (purity included) and water to weigh, fragrance, batch weight, lye concentration and water : lye ratio, each oil's share and SAP, the seven soap qualities with ranges, and warnings (superfat, solution strength, soft bar, cloudy liquid soap) |
| `find_soap_oil` | SAP (NaOH and KOH), iodine, INS and fatty acids of 78 oils, butters and fats; names in 12 languages (olive, Оливкова олія, Olivenöl, オリーブオイル…) |
| `size_soap_batch` | Oil weight for a mold (length × width × fill height) or for a target batch weight, split per oil |

Weights in g, kg, oz or lb. Bar, liquid (KOH) and dual-lye soap. Water as lye concentration, % of oils or
water : lye ratio. All tools: `readOnlyHint: true`, `destructiveHint: false`, `openWorldHint: false`.

## Connect

**Claude (claude.ai, Desktop), ChatGPT (developer mode), Cursor, VS Code** — add a remote MCP server with the URL
`https://mcp.zhukovskyi.space/lye-calc/mcp`, no authentication.

**Local (stdio):**

```bash
git clone https://github.com/andronaft/lye-calc-mcp && cd lye-calc-mcp
python3 -m venv .venv && .venv/bin/pip install -r requirements.txt
```

```json
{ "mcpServers": { "lye-calc": { "command": "/path/to/lye-calc-mcp/.venv/bin/python",
                                "args": ["/path/to/lye-calc-mcp/server.py", "--stdio"] } } }
```

Ask, for example: *"Lye and water for 700 g olive, 200 g coconut and 100 g shea at 5 % superfat"* or
*"How much oil for a 10 × 3.5 in loaf mold filled 3 in high, 60 % olive, 30 % coconut, 10 % castor?"*

## Method

- lye = Σ oil weight × SAP(KOH) × (1 − superfat) ÷ purity; KOH → NaOH by molar mass 39.997 / 56.106.
- SAP values, iodine, INS and fatty acids as published in the [SoapCalc oil list](https://soapcalc.net/oil-list)
  (snapshot 2026-10-25, `data/oils.json`); soap qualities and their ranges as SoapCalc defines them.
- Mold: cubic inches × 0.4 = ounces of oil (the soapers' rule of thumb). Batch weight: exact, since lye, water and
  fragrance all scale with the oils.
- Checked against: 100 % olive at 5 % → 128.6 g NaOH per kg (SoapCalc); a published palm-free bar (63 g NaOH for
  450 g oils); a published KOH liquid soap (115.8 g of 90 % KOH). See `test_server.py`.
- Not counted: acid additives (citric, lactic acid, vinegar) that use up lye. The Lye Calc app counts them.

Lye amounts are estimates from average SAP values; a supplier's certificate of analysis may differ. Lye is caustic:
goggles, gloves, lye into water, and a scale that reads 1 g.

## Run and test

```bash
pip install -r requirements.txt
python server.py                  # http://127.0.0.1:8000/mcp
python server.py --stdio
python -m unittest discover tests   # 12 tests
```

Hosted with the other Dre Dev MCP servers in one process; `build_app()` is mounted at `/lye-calc`.

## Licence

MIT for the code. Oil numbers: SoapCalc's published oil list. Made by Andrii Zhukovskyi
([Dre Dev](https://zhukovskyi.space/)).