Skip to main content
Glama

food-tracker

A small MCP server that lets Claude log what I eat and drink. I send Claude a photo of my plate, a menu screenshot, or a sentence like "two eggs and a bagel." Claude estimates the macros, saves the meal here, and tells me where I am for the day. A private web dashboard shows the totals and the last two weeks.

I built it because I already pay for Claude Pro. Food-tracking apps that estimate meals from photos are mostly an AI model behind a subscription, and I didn't want to pay for a second one while in college. Claude can already look at a photo and estimate a meal, so all it was missing was somewhere to keep the numbers.

By Maximus Desir.

How it works

Claude does all the estimating. The server never guesses nutrition: every item arrives with calories, protein, carbs, and fat already filled in, plus where the numbers came from (photo, menu, manual, template) and how confident Claude was. The server stores, edits, and adds up. That keeps it small and testable, and the source field shows later which entries were guesses.

Claude gets these tools:

Tool

What it does

log_meal

Save a meal as a list of items

log_water

Save water in fl oz

log_template, save_template, list_templates

Saved meals for plates I eat often, with optional scaling ("1.5x the usual")

edit_meal, delete_entry

Fix mistakes ("that was two chicken breasts")

get_day, get_range

A day's entries and totals, or per-day totals and averages for a check-in

set_targets

Daily targets, dated so past days keep the targets they had

find_menu_items

Look up the dining hall's published nutrition for something I ate

Every write returns the updated day totals, so Claude can answer in one message. Writes that add rows take a request_id, so a retried tool call doesn't log the same meal twice.

Optional fields cover portion weight and eight micronutrients (fiber, saturated fat, sodium, potassium, calcium, iron, magnesium, vitamin D). Totals for those report how many items had data, so a missing label doesn't read as a low intake.

Days follow local time (America/New_York by default), so an 11:30 pm snack counts toward that day. Timestamps are stored in UTC.

Dining hall menus

My dining hall publishes nutrition labels through Dine On Campus. POST /menu-import accepts the raw menu JSON the site loads in my own browser and stores the published numbers, so Claude can use real label values instead of estimating. The server never fetches the site itself. Screenshots of a nutrition panel work too: Claude copies the label and logs it as source="menu".

Dashboard

/dash is a read-only page: today's totals against targets, calorie and protein bars for the last 14 days, 7-day averages, today's meals, and micronutrients. It sits behind the same Google sign-in as Claude and doesn't refresh on its own, so an open tab doesn't keep the server awake.

Related MCP server: Cronometer MCP server

Security

  • Claude connects with MCP OAuth (dynamic client registration and PKCE). Signing in goes through Google, and only the one email in FOOD_ALLOWED_EMAIL gets in.

  • Sign-in codes can only be sent to claude.ai's callback or to a loopback address, and tokens are issued only for this server's /mcp.

  • Access tokens last an hour. Refresh tokens last 90 days and rotate on every use. Reusing an old refresh token revokes the whole grant.

  • Codes, tokens, and dashboard sessions are stored as SHA-256 hashes. The dashboard cookie is __Host-, HttpOnly, Secure, and SameSite=Lax.

  • Open endpoints (registration, sign-in starts) are capped so strangers can't fill the database.

  • Request logs are off, so one-time codes never land in logs.

  • The container drops from root to an unprivileged user after taking ownership of the data volume.

  • Deleted entries are hidden immediately and erased for good after 30 days.

Running it

You need Python 3.12 and uv.

uv sync
uv run ruff check . && uv run ruff format --check .
uv run pyright
uv run python -m food_mcp.server     # stdio, e.g. for Claude Code or the MCP Inspector

Deploying to Fly.io

It runs on one Fly machine with a 1 GB volume for the SQLite file. The machine stops when idle and starts on the next request (about a second), which keeps the cost near the price of the disk. Fly snapshots the volume daily and keeps 14 days of snapshots. SQLite needs a single writer, so never scale past one machine.

  1. Change app and FOOD_PUBLIC_URL in fly.toml, then fly apps create <name> and fly volumes create food_data --size 1 --region iad.

  2. In Google Cloud, create an OAuth client of type "Web application" with the redirect URI https://<app>.fly.dev/auth/google/callback. Leave the consent screen in Testing with yourself as a test user.

  3. Set the secrets:

    fly secrets set GOOGLE_CLIENT_ID=... GOOGLE_CLIENT_SECRET=... \
      FOOD_ALLOWED_EMAIL=you@gmail.com FOOD_IMPORT_TOKEN=$(python3 -c "import secrets; print(secrets.token_urlsafe(32))")
  4. fly deploy --ha=false

  5. In claude.ai, open Settings, then Connectors, and add a custom connector with https://<app>.fly.dev/mcp. Sign in with Google when asked.

Variable

Purpose

FOOD_PUBLIC_URL

Public base URL; the OAuth issuer

FOOD_ALLOWED_EMAIL

The one Google account allowed to sign in

GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET

Google OAuth client

FOOD_IMPORT_TOKEN

Bearer token for /menu-import, 32+ characters

FOOD_DB_PATH

SQLite file (default data/food.db; /data/food.db on Fly)

FOOD_TZ

Time zone for day boundaries (default America/New_York)

FOOD_GOAL

Optional goal Claude checks progress against, e.g. lean bulk to 180 lb by 2027-06-01, about 0.25 lb/week

FOOD_DINING_HALL

Optional name of your dining hall, so "I ate at North" triggers a menu lookup

FOOD_BREAKFAST_END, FOOD_LUNCH_END, FOOD_DINNER_END

Cutoffs for guessing the meal type (defaults 10:30, 15:30, 21:00)

Layout

src/food_mcp/
  server.py       MCP tools; thin wrappers over repo and summary
  web.py          HTTP app: /mcp, /dash, /auth/google/callback, /menu-import, /health
  auth.py         OAuth provider backed by SQLite, Google sign-in check
  repo.py         all SQL
  summary.py      day and range totals, remaining vs. targets
  dashboard.py    the dashboard page
  menu_import.py  Dine On Campus JSON to menu items
  timeutil.py     local day and UTC conversion
  migrations/     numbered SQL files, applied in order

Limits

Photo estimates are rough, especially for big or mixed plates. Treat the numbers as ballpark figures: steady logging and a weekly look at the trend matter more than any single entry. It's built for one person: one allowed Google account and one database. The browser bookmarklet that sends the dining hall menu isn't written yet; for now, menu data comes from screenshots.

Available Tools

11 tools
delete_entryA

Delete a meal or water entry by id (from get_day or a log result). Returns that day's updated totals.

Inputs: id (required), kind (required). Returns: object

edit_mealA

Correct a logged meal: replace its items or change its type, time, or notes. Unspecified fields stay as they are. Returns the updated meal and its day's totals.

Inputs: meal_id (required), items, notes, eaten_at, +1 more. Returns: object

find_menu_itemsA

Search the imported dining-hall menu for a date (default today) for published per-serving nutrition. Use it before estimating anything eaten at the dining hall. Returns up to 15 matches, or a note when no menu was imported for that date.

Inputs: query (required), date, meal. Returns: object

get_dayA

Get every meal (with items and ids) and water entry for one local day, plus totals and remaining vs. that day's targets. Use for 'what did I eat' and before edits or deletes.

Inputs: date. Returns: object

get_rangeA

Per-day totals and averages over a date range (max 92 days). Use for weekly check-ins and trends rather than calling get_day repeatedly.

Inputs: end (required), start (required). Returns: object

list_templatesA

List saved meals with their total macros. Use to find the exact name for log_template.

Inputs: no named parameters. Returns: object

log_mealA

Log a meal you have already itemized with macros. Use this for any food except a saved meal the user names (use log_template). Returns meal_id and the day's totals vs. targets.

Inputs: items (required), source (required), confidence (required), request_id (required), +3 more. Returns: object

log_templateA

Log a saved meal by name, optionally scaled. Use when the user names a saved meal instead of describing food. Returns meal_id, the logged items, and the day's totals vs. targets.

Inputs: name (required), request_id (required), scale, eaten_at, +1 more. Returns: object

log_waterB

Log water in fl oz. Returns water_id and the day's totals, including water vs. target.

Inputs: fl_oz (required), request_id (required), logged_at. Returns: object

save_templateA

Create or overwrite a saved meal, from explicit items or from an existing meal_id. Returns the saved items and totals, plus today's totals.

Inputs: name (required), items, meal_id. Returns: object

set_targetsA

Set daily targets starting on a local date (default today). Omitted fields keep their current values; earlier days keep their old targets. Returns the stored targets row and today's totals.

Inputs: kcal, fat_g, carbs_g, fiber_g, +9 more. Returns: object

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 11 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose, and the descriptions explicitly resolve the riskiest overlaps: log_meal vs log_template (itemized vs named saved meal), log_template vs save_template vs list_templates, and get_day vs get_range (single day vs trend window). Even edge tools like find_menu_items and set_targets sit in unambiguous territory.

    Naming Consistency5/5

    Every tool follows a strict verb_noun snake_case pattern (log_meal, get_range, save_template, edit_meal, delete_entry, set_targets, find_menu_items). Verbs are used consistently for their action class (log/save/list/get/set/edit/delete/find).

    Tool Count5/5

    11 tools is well within the ideal range, and each one earns its place: meal logging, water logging, template management, retrieval, targets, and menu lookup. No redundant or filller tools.

    Completeness4/5

    Meal lifecycle (log/edit/delete/get), water logging with delete, template create/list/apply, target setting, and range queries are all covered. Minor gaps remain: no way to delete or rename a saved template, no editing of a water entry (only delete), and no standalone get_targets, but these are workable around.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      B
      maintenance
      Connect MyFitnessPal to Claude or any MCP client. Log meals, search food database with macros, track trends, and export nutrition history against your real MyFitnessPal diary.
      18
      284 PyPI
      39
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to access your MyFitnessPal diary—foods, portions, meal and daily nutrition totals, water, exercise, steps, and weight—through a custom connector on web, desktop, and mobile.
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables logging meals, tracking calories and macros, reviewing daily and range summaries, setting weight goals, searching foods and recipes, and getting meal suggestions from any Claude client, with optional multi-user household support. Includes a local food database for items missing from FatSecret and OAuth-based authentication to FatSecret profiles.
      MIT