Metadata-Version: 2.4
Name: macrolog
Version: 0.1.0
Summary: Log meals by chatting with Claude; track calories, macros and weight in a local dashboard.
Author: Eric Liswung
License-Expression: MIT
Project-URL: Homepage, https://github.com/ericliswan/macrolog
Keywords: mcp,claude,nutrition,calories,macros,food-log
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Utilities
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: mcp<3,>=2
Requires-Dist: starlette
Requires-Dist: uvicorn
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Provides-Extra: app
Requires-Dist: pywebview>=6; extra == "app"
Dynamic: license-file

# macrolog

A food diary that lives in the Claude desktop app. You tell Claude what you ate. Claude estimates the calories and macros, and an MCP server stores them in a local SQLite file and keeps the totals. A dashboard shows today's budget, your meals, trend charts and weight. Everything stays on your computer. The full design is in [SPEC.md](SPEC.md).

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ericliswan/macrolog/main/docs/screenshots/dashboard-dark.png">
  <img alt="Macrolog dashboard: today's calories left with a progress ring, macro bars, the weekly budget, today's meals and a six-month record" src="https://raw.githubusercontent.com/ericliswan/macrolog/main/docs/screenshots/dashboard-light.png">
</picture>

<details>
<summary>Trends: averages, calorie and protein charts, macro split, body weight, meal types and top foods</summary>

<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ericliswan/macrolog/main/docs/screenshots/trends-dark.png">
  <img alt="Macrolog trends: stat tiles, calories per day, protein per day, calories from each macro, body weight, calories by meal type and top foods" src="https://raw.githubusercontent.com/ericliswan/macrolog/main/docs/screenshots/trends-light.png">
</picture>
</details>

Screenshots use the demo data from `scripts/seed_demo.py`. The dashboard follows your system's light or dark mode.

## Install

### Mac app (no Python needed)

1. Download `Macrolog-…-mac-arm64.zip` (Apple Silicon) or `…-mac-x86_64.zip` (Intel) from [Releases](https://github.com/ericliswan/macrolog/releases), unzip it, and drag Macrolog to Applications.
2. Open it. The app isn't signed by Apple yet, so macOS blocks it the first time: click Done, then open System Settings → Privacy & Security, scroll down to "Macrolog was blocked" and click **Open Anyway**. (Or run `xattr -dr com.apple.quarantine /Applications/Macrolog.app` once.)
3. In the Claude desktop app, open Settings → Developer → Edit Config and add:

```json
{
  "mcpServers": {
    "macrolog": {
      "command": "/Applications/Macrolog.app/Contents/MacOS/Macrolog",
      "args": ["mcp"]
    }
  }
}
```

Opening Macrolog shows the dashboard in its own window. Claude runs the same app in the background (`mcp`) to log your meals. Both use the same database, so they stay in sync.

### With Python (any OS)

```bash
pipx install macrolog              # or: pipx install "macrolog[app]" to also get the macrolog-app window
which macrolog-mcp                 # use this full path as "command" in the config above, without "args"
```

On Windows the path looks like `C:\\Users\\you\\.local\\bin\\macrolog-mcp.exe`. Backslashes must be doubled in JSON.

### Then

1. Fully quit the Claude app and open it again.
2. Click "+" in the chat box, then Connectors. macrolog and its tools should be listed. The app asks for your approval the first time Claude uses each tool.
3. Say what you ate. The first time, Claude asks about your goal and targets (defaults: maintain weight, 2000 kcal). You can change them later in the dashboard's Settings.

## Configuration

Set these environment variables in an `"env": {}` block next to `"command"`:

| Variable | Default | Meaning |
|---|---|---|
| `MACROLOG_DB` | `~/.macrolog/macrolog.db` | Path to the database file |
| `MACROLOG_PORT` | `8765` | Dashboard port |
| `MACROLOG_DASHBOARD` | `1` | Set to `0` to stop the MCP server from also running the dashboard |

## Dashboard

The Mac app shows the dashboard in a window. The MCP server also serves it at http://127.0.0.1:8765 whenever the Claude app is open, and `macrolog-dash` starts it on its own. It only accepts connections from `127.0.0.1` and `localhost`.

## Backups and export

- **Backups:** the first time the MCP server connects each day, it writes a copy of the database to `<db folder>/backups/`. The last 14 copies are kept. To restore, quit the Claude app and copy a backup over the database file.
- **Export:** Settings → Export (CSV) downloads your meals and items, weights, or targets.

## Demo data

To try the dashboard without touching your real diary:

```bash
python scripts/seed_demo.py                 # writes ~/.macrolog/demo.db
MACROLOG_DB=~/.macrolog/demo.db MACROLOG_PORT=8799 macrolog-dash
```

Then open http://127.0.0.1:8799. The script won't write to the real database or overwrite an existing file.

## Troubleshooting

- Check `mcp.log` and `mcp-server-macrolog.log` in the Claude app's logs folder:
  - macOS: `~/Library/Logs/Claude`
  - Windows: `%APPDATA%\Claude\logs`
  - Linux: `~/.config/Claude/logs`
- Run `macrolog-mcp` (or `/Applications/Macrolog.app/Contents/MacOS/Macrolog mcp`) in a terminal to see startup errors.
- If the dashboard doesn't load, port 8765 may already be in use. Set `MACROLOG_PORT` to a different port.

## Development

```bash
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev,app]"
pytest
pip install pyinstaller && pyinstaller packaging/macrolog.spec    # builds dist/Macrolog.app
```

## Releasing

Bump `version` in `pyproject.toml`, commit, then push a matching tag: `git tag v0.2.0 && git push origin v0.2.0`. The release workflow publishes to PyPI and attaches Apple Silicon and Intel builds of Macrolog.app to a GitHub release.

One-time setup: on PyPI, add a trusted publisher for this repo (workflow `release.yml`, environment `pypi`), and create an environment named `pypi` in the repo's GitHub settings.
