databasedmcp

← Articles

Alternative to MyFitnessPal: a food diary with ChatGPT

Tell ChatGPT what you ate in a sentence. It estimates the calories and macros and keeps the diary in a database you can query.

6 min read

databasedmcp gives your AI assistant databases it keeps between conversations, so everything in this article works from the day you connect it. Free to start, no card.

Get started free

Why build it yourself

For many people, MyFitnessPal is a diary: what you ate, and roughly how many calories and how much protein that was. Finding the right entry in a food database, picking a portion and repeating that for every ingredient is where people give up.

ChatGPT can read "a chicken burrito bowl with rice, beans and a bit of cheese" and give you an estimate in one go. With a database behind it, those estimates add up into a diary. You get today's meals and this week's totals. The breakfast you have every day is saved once and logged in four words.

Connect ChatGPT to databasedmcp

databasedmcp is a remote MCP server that gives AI assistants private SQLite databases, with nothing to install.

ChatGPT connects to remote MCP servers as custom connectors in developer mode. That's on paid plans, on the web. Turn on developer mode in ChatGPT's settings, then create a connector: give it a name, enter https://databasedmcp.com/mcp as the URL and choose OAuth. When ChatGPT opens a databasedmcp page, sign in and select Allow. In a new chat, turn the connector on from the tools menu.

ChatGPT moves these menus between releases. If yours look different, search its settings for developer mode and custom connectors.

Any other MCP client works the same way; the docs have the details.

Copy this prompt to build it

Paste this into ChatGPT to set up the database, its tables and its guide in one go. The rest of this article walks through what it makes and how you use it.

prompt
Set up a food diary for me in databasedmcp, in one go.

1. Create a database called food_diary, described as "Food diary: what I ate, with calorie and macro estimates".
2. Create two tables:
   - foods: id, name (required, unique, like "usual breakfast"), serving (how much one serving is), calories, protein_g, carbs_g, fat_g, source (estimate or label, defaults to estimate).
   - entries: id, eaten_on (date, defaults to today), meal (breakfast, lunch, dinner or snack), what (required, my description), food_id (references foods, when it's a saved food), servings (defaults to 1), calories, protein_g, carbs_g, fat_g.
3. Write the database a guide that says what each table is for, that the numbers are your estimates from my description unless I give you a label, to check foods for a saved name before estimating, and the queries for "what did I eat today" and "daily totals for the last 7 days".

From then on: when I say what I ate, add an entry with your best estimate and tell me the numbers. When I say "save this as" a name, add it to foods. When I correct something, update the entry. Don't give me diet advice unless I ask. Show me the tables when you're finished.

Ask for the database

You don't write the schema. Describe what you want:

Set up a food diary in databasedmcp. When I say what I ate, log it with your estimate of the calories, protein, carbs and fat. Let me save foods I eat often so I can log them by name.

ChatGPT creates a database called food_diary and its tables:

schema
CREATE TABLE foods (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL UNIQUE,
  serving TEXT,
  calories INTEGER,
  protein_g REAL,
  carbs_g REAL,
  fat_g REAL,
  source TEXT NOT NULL DEFAULT 'estimate' CHECK (source IN ('estimate', 'label'))
);

CREATE TABLE entries (
  id INTEGER PRIMARY KEY,
  eaten_on TEXT NOT NULL DEFAULT (date('now')),
  meal TEXT CHECK (meal IN ('breakfast', 'lunch', 'dinner', 'snack')),
  what TEXT NOT NULL,
  food_id INTEGER REFERENCES foods(id),
  servings REAL NOT NULL DEFAULT 1,
  calories INTEGER,
  protein_g REAL,
  carbs_g REAL,
  fat_g REAL
);

It also writes the database a guide on how the tables are meant to be used. The guide comes back with the schema whenever an assistant looks the database up. ChatGPT files things the same way next week as today, and so does any other assistant you connect.

guide
# food_diary: meals and estimates

- **foods**: foods I eat often, saved by name ("usual breakfast"). `source` is label when I gave you the numbers from a package, estimate otherwise.
- **entries**: one row per thing I ate. `what` is my description. `food_id` is set when it's a saved food; the numbers are then the food's times `servings`.

The numbers are estimates from what I describe, not measurements. Check foods for a saved name before estimating. Don't give diet advice unless asked.

Today: `SELECT meal, what, calories, protein_g FROM entries WHERE eaten_on = date('now') ORDER BY id`

Last 7 days: `SELECT eaten_on, sum(calories) AS calories, round(sum(protein_g)) AS protein_g, round(sum(carbs_g)) AS carbs_g, round(sum(fat_g)) AS fat_g FROM entries WHERE eaten_on >= date('now', '-6 days') GROUP BY eaten_on ORDER BY eaten_on`

Use it

From here on you talk, and ChatGPT writes the rows. Each request below is one statement:

Lunch was a chicken burrito bowl: rice, black beans, salsa and a bit of cheese.
execute
INSERT INTO entries (meal, what, calories, protein_g, carbs_g, fat_g) VALUES (?, ?, ?, ?, ?, ?)
-- params: ["lunch","Chicken burrito bowl with rice, black beans, salsa and cheese",720,42,85,22]

The numbers are ChatGPT's estimate from your description, not a measurement. Say how big it was, or read it the label, and the estimate gets closer.

Save my usual breakfast: 40 g oats with 200 ml milk, a banana and a spoon of peanut butter.
execute
INSERT INTO foods (name, serving, calories, protein_g, carbs_g, fat_g) VALUES (?, ?, ?, ?, ?, ?) RETURNING id
-- params: ["usual breakfast","40 g oats, 200 ml milk, 1 banana, 1 tbsp peanut butter",470,18,68,15]
Had my usual breakfast.
execute
INSERT INTO entries (meal, what, food_id, servings, calories, protein_g, carbs_g, fat_g) SELECT ?, name, id, ?, calories * ?, protein_g * ?, carbs_g * ?, fat_g * ? FROM foods WHERE name = ?
-- params: ["breakfast",1,1,1,1,1,"usual breakfast"]

A saved food logs with the numbers you saved, so the same breakfast counts the same every day.

Correction: there was no cheese in the burrito bowl.
execute
UPDATE entries SET what = ?, calories = calories - ?, protein_g = protein_g - ?, fat_g = fat_g - ? WHERE id = ?
-- params: ["Chicken burrito bowl with rice, black beans and salsa",80,5,7,1]

Ask it questions

Once there's data, each report you'd pay for is a single query:

What have I eaten today?
query
SELECT meal, what, calories, protein_g FROM entries WHERE eaten_on = date('now') ORDER BY id
Show me my daily totals for the last week.
query
SELECT eaten_on, sum(calories) AS calories, round(sum(protein_g)) AS protein_g, round(sum(carbs_g)) AS carbs_g, round(sum(fat_g)) AS fat_g FROM entries WHERE eaten_on >= date('now', '-6 days') GROUP BY eaten_on ORDER BY eaten_on
Which meal gives me most of my calories this month?
query
SELECT meal, sum(calories) AS calories, round(100.0 * sum(calories) / (SELECT sum(calories) FROM entries WHERE eaten_on >= date('now', '-30 days')), 1) AS pct FROM entries WHERE eaten_on >= date('now', '-30 days') GROUP BY meal ORDER BY calories DESC

You can also open the database on the website, page through its rows and run read-only SQL yourself.

What you give up

Every number here is an estimate. MyFitnessPal has a large food database and barcode scanning, so a packaged food comes in with the numbers from its label. Here, ChatGPT estimates from your words, and a vague description gets a rough answer. When it matters, read it the label.

There's no syncing with step counters, watches or other fitness apps, no barcode scanner and no phone app made for logging. You log in a chat. It's a diary, not a plan: it won't set targets or tell you what to eat. If you're changing how you eat for a health reason, talk to a doctor or a dietitian.

Try it

databasedmcp is free to start, with no card. Free has 100 tool calls a week, enough to set this up and try it for a week. Starter has 1,000 for everyday use.

Create an account

More articles · databasedmcp · Docs