nutrition_db
This server is an AI-powered personalized nutrition and meal planning assistant. Here's what you can do with it:
Look up food nutrients: Query macros (calories, protein, carbs, fat, fiber, sugar) for any food item using a cached API Ninjas lookup or internal catalog.
Compute personalized daily targets: Calculate daily calorie and macro targets from your profile (weight, height, age, gender, activity level, goal) using the Mifflin-St Jeor BMR → TDEE → goal adjustment formula, with optional weather-based adjustments.
Generate a 7-day meal plan: Create a full week of varied meals tailored to your profile, dietary preferences (e.g., vegetarian, vegan), allergies, and calorie/macro targets — with best-effort allergen exclusion.
Log daily food intake: Record foods eaten on a given date and track running nutritional totals.
Adjust and catch up on daily calories: Compare logged intake against your target; if under, receive catch-up food suggestions or roll the shortfall into the next day.
Get current weather conditions: Fetch temperature and humidity for a city to adjust calorie and hydration recommendations.
Offline mode: Falls back to a bundled food catalog and cache when external API keys are unavailable.
Integrates with OpenAI's API to propose concrete, varied meals for personalized 7-day meal plans based on user profile and goals.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@nutrition_db I need a 7-day meal plan for weight loss"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
🥗 MCP Nutrition - AI Meal Planner
Generate a personalized 7-day meal plan from your profile and goal, get daily calorie catch-up when you fall short, and track your progress over time. It runs as a FastAPI web app and, because the same engine is exposed over the Model Context Protocol (MCP), also as AI tools, resources, and prompts any MCP client (Claude Desktop, etc.) can use.
The intelligence is a deliberate blend:
🤖 OpenAI proposes concrete, varied meals for each day.
🥦 API Ninjas looks up macros for each food when your key returns them. Heads-up: the free API Ninjas tier gates
calories/protein, so in practice many values fall back to the bundled ~29-food catalog or an Atwater estimate (see Data & limits).🌤️ OpenWeather nudges calories/hydration for the day's conditions.
🧮 Deterministic Python computes the targets, keeps the LLM out of the arithmetic, reconciles each day to the calorie goal, and runs the catch-up math - the parts that are guaranteed and unit-tested.
Runs offline too: with no API keys, it falls back to a bundled food catalog + cache, so
git clone && runworks immediately.
Quickstart
# 1. Install (uv recommended)
uv sync --extra dev
# 2. (optional) add API keys for live LLM meals + real macros
cp .env.example .env # then edit .env
# 3. Run the web app
uv run uvicorn app.main:app --reload
# open http://127.0.0.1:8000Prefer pip? python -m venv .venv && . .venv/Scripts/activate && pip install -e ".[dev]".
Environment (all optional)
Key | Enables | Without it |
| LLM-generated meals | meals come from the bundled catalog |
| real macro numbers | macros come from cache / catalog |
| weather-based adjustment | adjustment is skipped |
Related MCP server: Gamito
Run it as an MCP server
The planner is also a stdio MCP server named nutrition_db:
uv run nutrition-mcp # or: python -m mcp_serverRegister it in an MCP client (e.g. Claude Desktop claude_desktop_config.json):
{
"mcpServers": {
"nutrition_db": {
"command": "uv",
"args": ["run", "nutrition-mcp"],
"cwd": "/absolute/path/to/MCP Nutrition"
}
}
}It exposes all three MCP primitives, not just tools:
Tools:
get_food_nutrients,get_current_conditions,compute_targets,generate_weekly_meal_plan,log_daily_intake,adjust_daily_calories.Resources (read-only context):
nutrition://catalog,nutrition://profile,nutrition://targets,nutrition://log/today,nutrition://history.Prompts (guided flows):
plan_my_week,log_my_meal,what_should_i_eat_now.
How it works
flowchart LR
UI["Web UI (form)"] -->|HTTP| API["FastAPI · app/"]
MCP["MCP client<br/>(Claude Desktop)"] -->|tools · resources · prompts| SRV["nutrition_db · mcp_server/"]
API --> CORE
SRV --> CORE
subgraph CORE["core/ engine - single source of truth"]
direction LR
T["targets<br/>(BMR→TDEE→goal)"] --> P["planner"]
P --> R["reconcile ±10%"]
ADJ["catch-up adjuster"]
H["history"]
end
P -->|propose foods| OA["OpenAI"]
P -->|ground macros| AN["API Ninjas"]
T -->|weather adjust| OW["OpenWeather"]core/ is the single source of truth; the web app and the MCP server are thin layers over it.
See docs/DECISIONS.md for the design tradeoffs and roadmap.
Plan generation (core/planner.py), per day: OpenAI proposes foods → API Ninjas returns real
macros (cached) → deterministic code scales portions to hit the calorie target (±10%). A rolling
"avoid recently-used items" list keeps the week varied. No OpenAI key? The bundled catalog builds
the day instead.
Calorie catch-up (core/adjuster.py): compares logged intake to target. If you're under, it
suggests catch-up foods for the meals you have left today, or rolls a capped portion of the
shortfall into tomorrow. (This is the opposite of naively lowering the goal when you under-eat.)
Targets (core/targets.py): Mifflin-St Jeor BMR → activity TDEE → goal adjustment
(-500 weight loss / +300 muscle gain) → macro split.
Project layout
core/ deterministic engine + service facade + API/LLM clients (the brains)
mcp_server/ nutrition_db MCP server (tools + resources + prompts over core/)
app/ FastAPI backend + minimal web UI (form, plan, catch-up, progress chart)
data/ food_catalog.json (fallback), nutrition_cache.json, state.json (runtime)
evals/ plan-quality eval harness + SCORECARD.md (python -m evals)
docs/ DECISIONS.md (design tradeoffs & roadmap)
tests/ pytest suite (targets, planner, adjuster, allergens, service, evals)Testing & evals
uv run pytest -q # 34 tests
uv run ruff check .
uv run python -m evals # regenerate evals/SCORECARD.mdTests run the real engine in offline mode (deterministic via the catalog) and use small fakes to exercise the LLM path without a network call.
Plan-quality evals (evals/, scorecard: evals/SCORECARD.md)
score generated plans across a golden set of profiles (goals × diets × allergies) on calorie
adherence, 100% allergen safety, protein adequacy, diet compliance, and variety. CI gates the
non-negotiables - measuring a non-deterministic LLM system, not just unit-testing pure functions.
Data & limits
Be clear-eyed about what this does and doesn't guarantee:
Macro source. Authoritative macros come from API Ninjas only when your key returns them. On the free tier
calories/proteinare premium-gated, so values fall back to the curated ~29-food catalog (data/food_catalog.json) or an Atwater (4/4/9) estimate. The bundled catalog is what makes offline mode work."On target" means calories. Days are reconciled to the calorie target (±10%); protein/carb/fat are shown as guidance and a day is flagged when protein runs low, but macros aren't enforced.
Allergens. Typed allergies are expanded to ingredient keywords (
core/allergens.py) and excluded from catalog, LLM-proposed, and catch-up foods - but it's best-effort keyword matching, not a medical guarantee. Verify ingredients yourself.Not medical advice. Estimates only; not for pregnancy, medical conditions, or disordered eating. Single-user, local state; no accounts or sync.
Provenance
This started as an MCP nutrition benchmark server and grew into a standalone product. All code here is original work by harmehak0173; it has no dependency on the original benchmark framework.
License
MIT © 2026 harmehak0173 - see LICENSE.
Available Tools
6 toolsadjust_daily_caloriesB
Compare a day's logged intake to target; if under, suggest catch-up foods / roll shortfall into tomorrow.
Inputs: date, profile, remaining_meals.
compute_targetsB
Compute daily calorie + macro targets from a profile (Mifflin-St Jeor BMR -> TDEE -> goal).
Inputs: profile (required).
generate_weekly_meal_planB
Generate a 7-day meal plan of concrete foods (LLM-proposed, API-Ninjas-grounded, reconciled to targets).
Inputs: profile (required), days.
get_current_conditionsA
Fetch current temperature and humidity for a city via OpenWeather.
Inputs: city (required).
get_food_nutrientsA
Look up macros (calories/protein/carbs/fat/fiber/sugar) for a food query via API Ninjas (cached).
Inputs: query (required).
log_daily_intakeC
Record foods eaten on a date (default today) and return running totals.
Inputs: foods (required), date.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose, from computing targets to logging intake and generating meal plans. The weather tool is unrelated but still unique.
All tool names follow a consistent verb_noun pattern in snake_case, making them predictable and easy to understand.
With 6 tools, the server is well-scoped for nutrition tracking without being overwhelming or underwhelming.
Core workflows are covered (targets, food lookup, logging, planning), but missing update/delete for logs and the weather tool is extraneous.
Maintenance
Related MCP Connectors
Weekly meal plans, recipes, grocery list with Kroger checkout, and USDA-based calorie tracking.
Your AI assistant logs your meals and workouts, then plans your week from what you did.
Meal plans, USDA-based nutrition and Instacart groceries for every diet in your household.
Calorie and macro diary your AI fills in: log meals from text or photos, refine later, track goals.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables users to log meals, track daily and weekly calorie intake, and manage diet records. Supports both local and network modes for flexible meal logging across devices.-
- FlicenseBqualityDmaintenanceEnables AI agents to generate budget-disciplined, allergy-safe weekly meal plans, shopping lists, and meal swaps using a fully local deterministic engine.20-
- FlicenseNot gradedqualityBmaintenanceEnables AI assistants to search recipes, compose nutritionally balanced meals, optimize weekly meal plans based on macro targets for family members, and generate consolidated grocery lists from a personal recipe database.-
- AlicenseNot gradedqualityCmaintenanceEnables AI-driven weekly meal planning with structured recipes, cooking steps, and grocery lists.2MIT