All guides
Nutrition

Log nutrition with an AI agent or MCP

Log food, calories and macros with an AI agent through the JustGains MCP server. Connect your assistant, describe a meal, and save it to your food diary.

Updated November 6, 20266 min readNutrition

JustGains lets you log nutrition with an AI agent through MCP (Model Context Protocol). Connect your assistant to your JustGains account, tell it what you ate, and it saves the food with calories and macros to your food diary. The same entries sync to the JustGains mobile app.

For example, ask: "Log two eggs, two slices of whole wheat toast and a latte for breakfast in JustGains." Your assistant can save the whole meal in one request. You can then ask how much protein you have logged today, correct a portion, or remove something you did not eat.

How to log nutrition with MCP

  1. Have a JustGains account and an assistant that supports remote MCP servers with OAuth sign-in.
  2. Add the JustGains MCP server to your assistant. For coding agents and general MCP clients, use https://justgains.com/connect/mcp. Claude and ChatGPT connectors use https://justgains.com/mcp.
  3. Sign in on the JustGains website and review the account access you are granting. You do not need to copy an API key or share your password with the agent.
  4. Tell the assistant what you actually ate and ask it to log the meal in JustGains. Include portions or the brand when you know them.
  5. Check the saved meal in the assistant's result or your JustGains food diary. Estimated portions and nutrition are marked so you can correct them.

The AI assistant connection guide has the setup commands for Claude Code and Codex, plus configuration for Cursor and VS Code. For chat apps, follow the Claude guide or ChatGPT guide. Your client needs to support the browser sign-in flow as well as remote MCP.

What to ask your nutrition agent

Use ordinary meal descriptions. Counts, cups and ounces are useful; you do not need to calculate macros yourself before logging. These are example requests, not meals that have been saved to your account:

  • "Log a turkey sandwich with two slices of wheat bread, one slice of cheddar and a tablespoon of mayo for lunch."
  • "Log 6 oz of grilled chicken, a cup of cooked rice and broccoli for dinner."
  • "I had a banana and one scoop of whey mixed with water. Log that as a snack."
  • "Show today's food diary and how much protein I have left against my target."
  • "Log the same breakfast I had yesterday."

A request to log food saves an entry. Asking what to eat next or planning tomorrow's dinner should not record a meal as eaten. If you ask for "the same as yesterday," the assistant reads that day's diary to find the actual foods first.

How calories, macros and portions are resolved

JustGains checks your recent foods and its cached food catalog when the agent saves a meal. Reliable catalog nutrition and known serving weights take precedence over the assistant's estimates. If there is no reliable match, the meal can still be saved with an estimate, which is marked in the result.

For packaged food, include the brand and serving count. If you have the label, provide its nutrition and the amount you ate. For a homemade meal, name the ingredients and portions you know. An unspecified latte size or cooking fat can change the total; review the assumptions and correct them when needed.

Calories, protein, carbohydrates and fat are recorded with the saved food. Ask to see your diary when you want daily totals and your existing targets. For an explanation of those numbers, read Macros 101.

Correct a meal without logging it twice

Follow-up details can update the saved entry. Say "That latte was a large with whole milk" or "I only ate half of that sandwich." The agent should correct the existing food and portion, keeping its original meal and date. If it cannot tell which entry you mean, it should ask.

To delete an entry, ask "Remove the banana I just logged." Removing one serving from a two-serving entry is a portion correction; removing the whole entry deletes it from the diary. Changes update the day's totals and sync to the mobile app when it connects.

Nutrition MCP tools for developers

The JustGains nutrition MCP server exposes these tools to an authenticated client. Let your client discover the current input schemas through MCP; tool names below refer to the actual server tools.

ToolPurpose
log_my_foodSave a meal with multiple foods, repeat a previous food, or correct a saved entry.
get_my_food_diaryRead saved foods, daily totals, targets and recent food history.
search_foodsLook up foods and recent meals when the user asks to search.
remove_my_foodRemove the specific diary entries the user asks to delete.

For routine food logging, call log_my_food directly with all foods and portions in one request. The server handles catalog matching. Include the stated serving count and unit, plus portion and macro estimates as fallback; disclose estimated portions. A separate search_foods call is not required before every meal.

Keep the same requestId when retrying a save so a lost response does not duplicate the meal. For a correction, use diaryEntryId and expectedUpdatedAt from the latest food result. A stale correction needs a fresh diary read. The tool response confirms the server save; the phone may still be syncing.

Account access and mobile syncing

Food logging and diary reads require your JustGains sign-in. The connection uses OAuth, and its account permissions also cover the fitness tools shown on the consent screen. It is not limited to a single meal. You can end the assistant's session in JustGains account settings to revoke access.

MCP food logging needs an internet connection. Meals are saved to your account, and the mobile app pulls updates on notification or reconnect. See JustGains Nutrition for the food logging options in the app.

Common questions

Keep reading

The natural next steps from this guide.

Still stuck on something?

Tell us what you were trying to do and where it went sideways. We read every message, and the common ones turn into new guides.

support@justgains.com
All guidesTrain hard. Read the instructions when you need them.