Skip to main content
Glama
tanklog-mcp

tanklog-mcp

README.md
# tanklog-mcp

Aquarium and reef tank water math as an MCP server: how much of a total ammonia reading is toxic free ammonia (NH3)
at your pH and temperature, salinity in ppt to specific gravity and back (refractometer and hydrometer scales) with
the salt for new saltwater, how big a water change brings nitrate, GH, KH or TDS to a target, grams of planted-tank
fertilizer or KH/GH buffer for a ppm or degree rise, and tank volume in litres and gallons. Five read-only tools, no
sign-in, nothing stored.

It is the calculator of the **[TankLog](https://zhukovskyi.space/apps/tanklog/)** aquarium log app by Dre Dev, ported
from Dart to Python and checked against the app's own test values. The salinity converter also runs in the browser:
[salinity to specific gravity](https://zhukovskyi.space/calculators/aquarium/salinity-to-specific-gravity.html).

- App: [zhukovskyi.space/apps/tanklog](https://zhukovskyi.space/apps/tanklog/) (Android, in testing)
- Server: `https://mcp.zhukovskyi.space/tanklog/mcp` (streamable HTTP)

## Tools

| Tool | Gives |
|---|---|
| `calculate_free_ammonia` | Free NH3 and NH4+ from a total ammonia test, pH and temperature (°C or °F), the NH3 share and pKa |
| `convert_salinity_and_mix_salt` | ppt ↔ specific gravity on the 25/25 °C, 20/20 °C and 60/60 °F scales, density, dissolved salts per litre; salt for new saltwater, salt to raise salinity or fresh water to swap in to lower it |
| `plan_aquarium_water_change` | One change that reaches a target, two equal changes, the 10–50 % step TankLog suggests, how many changes of a given size it takes with the value after each, and the volume to change |
| `dose_aquarium_fertilizer` | Grams of KNO3, KH2PO4, K2SO4, MgSO4·7H2O, gypsum or any product by its label %, or of baking soda, calcium carbonate or Epsom salt for KH/GH, for a target rise; or what a dose adds |
| `calculate_aquarium_volume` | Litres, US and imperial gallons of a rectangular or cylinder tank from inside dimensions (cm or in), minus decor and substrate |

Volumes in L, US gal or UK gal; temperature in °C or °F; hardness in °dH or ppm CaCO3. 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/tanklog/mcp`, no authentication.

**Local (stdio):**

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

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

Ask, for example: *"My kit reads 1 ppm ammonia at pH 8.2 and 26 °C. How much of it is toxic NH3?"* or
*"My refractometer reads 1.023 in my 300 L reef tank. How much salt to bring it to 1.026?"*

## Method

- Free ammonia: Emerson, Russo, Lund and Thurston (1975), J. Fish. Res. Board Can. 32: 2379–2383, as used by the US
  EPA (1999) ammonia criteria: pKa = 0.09018 + 2729.92 / T (kelvin), NH3 share = 1 / (10^(pKa − pH) + 1), 0–50 °C.
- Salinity: UNESCO (1981) one-atmosphere equation of state of seawater, EOS-80 (Millero and Poisson 1981). Specific
  gravity t/t = ρ(S, t) ÷ ρ(0, t); salt = S × ρ(S, 25 °C) ÷ 1000 × litres (dissolved salts); lowering salinity replaces
  a share 1 − target ÷ current with fresh water.
- Water changes: mass balance, new = old × (1 − f) + new water × f; n = ⌈ln((target − new) ÷ (old − new)) ÷ ln(1 − f)⌉.
- Fertilizers: mass fractions from CIAAW standard atomic weights, mg = ppm × litres ÷ fraction. Hardness:
  1 °dH = 10 mg/L CaO = 17.848 ppm CaCO3 (DIN 38409-6), so per 1 °dH in 1 L baking soda 29.96 mg, calcium carbonate
  17.85 mg, Epsom salt 43.95 mg.
- Volume: 1 L = 1000 cm³, 1 US gal = 3.785411784 L (NIST Handbook 44), 1 UK gal = 4.54609 L.
- Checked against the app's tests: the UNESCO density check values (ρ(35, 25) = 1023.34306 kg/m³); 35 ppt = SG 1.0264
  at 25 °C, 1.025 = 33.2 ppt; 100 L at 35 ppt = 3581.7 g; EPA table 0.566 % NH3 at 25 °C, pH 7; 1 ppm at pH 8.2,
  26 °C = 0.088 ppm NH3; 1.957 g KNO3 for 10 ppm NO3 in 120 L; baking soda 3.0 g per °dKH in 100 L; the UKAPS case
  (TDS 300 → 150 with 25 L changes on 140 L = 5 changes); a 30 × 12 × 12 in tank = 18.7 US gal. See `test_server.py`.

Results are estimates for guidance. The tool gives the free ammonia share, not a safe limit for a species. Salt mixes
hold moisture and need a little more than the dissolved-salt figure: follow the package and confirm with a calibrated
refractometer. Dose in steps, follow the product label and test before adding more.

## 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   # 11 tests
```

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

## Licence

MIT for the code. Made by Andrii Zhukovskyi ([Dre Dev](https://zhukovskyi.space/)).