DEV Community

Cover image for Nutrition Maxing CLI- log foods with macros into your Notion workspace through MCP
Avro Dotter
Avro Dotter

Posted on

Nutrition Maxing CLI- log foods with macros into your Notion workspace through MCP

Notion MCP Challenge Submission 🧠

Nutrition Maxing CLI - Notion MCP Challenge Submission

This is a submission for the Notion MCP Challenge

What I Built

Nutrition Maxing CLI - A natural language-powered nutrition logging system that transforms how users track their daily meals and macronutrients. Instead of manually entering food data, users simply tell the CLI what they ate, and it intelligently parses multi-item meals, estimates accurate macros, and syncs everything to their Notion database.

Key Features

Natural Language Meal Logging

  • Just say "I ate 3 eggs and toast" and it parses into separate entries
  • Supports meal format: "Lunch: rice, dal, curry, vegetables"
  • Recognizes meal types: Breakfast, Morning Snacks, Lunch, Evening Snacks, Dinner

Accurate Macro Estimation

  • Uses IFCT 2017 (Indian Food Composition Tables) for Indian dishes
  • Uses USDA FoodData Central for global foods
  • Automatically calculates: Protein, Carbs, Fat, Fiber, Calories
  • Distinguishes between dairy types (whole milk vs skim)

⚑ Interactive REPL Experience

  • Animated spinner showing real-time status: "Analyzing..." β†’ "Logging..." β†’ "Done"
  • Welcome screen with guidance
  • Persistent command history
  • One-off and interactive modes

Notion Database Integration

  • Logs each food item as a separate Notion page
  • Tracks full macro breakdown per item
  • Links to daily calorie summaries
  • Auto-generates day pages with macro goals

Technical Stack

  • Framework: TypeScript/Node.js CLI
  • AI: Groq llama-3.1-8b-instant (agentic loop)
  • MCP: Model Context Protocol for Notion integration
  • UI: Chalk (terminal colors) + Readline (interactive input)
  • Database: Notion (food logs + calorie tracking)

Video Demo

My video demo

Example flow:

  1. User runs notion β†’ Welcome screen displays
  2. User types: "Lunch: 250g rice, 2 bowls dal, curry"
  3. Spinner animates with status updates
  4. Response shows 3 separate logged items with macros
  5. Data instantly synced to Notion

Show us the code

Repository: nutrition-maxing-cli on GitHub

Project Structure

apps/notion-cli/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ groq-agent.ts          # Agentic loop with Groq
β”‚   β”œβ”€β”€ mcp-client.ts          # Notion MCP communication
β”‚   β”œβ”€β”€ repl.ts                # Interactive CLI interface
β”‚   β”œβ”€β”€ cli.ts                 # Entry point
β”‚   β”œβ”€β”€ ui.ts                  # Terminal UI components
β”‚   └── styled-input.ts        # Styled input handler
β”œβ”€β”€ dist/                      # Compiled JavaScript
β”œβ”€β”€ package.json
└── tsconfig.json

nutrition-mcp/
β”œβ”€β”€ index.js                   # MCP server with 3 nutrition tools
└── package.json
Enter fullscreen mode Exit fullscreen mode

Key Files

[groq-agent.ts] - Core agentic loop

  • System prompt with IFCT 2017 + USDA standards
  • Multi-item meal parsing logic
  • Tool calling orchestration
  • Status update callbacks for real-time UI

[nutrition-mcp/index.js] - Notion MCP Server

  • log_food: Save meal entries with macros
  • get_daily_nutrition: Retrieve foods for a date
  • get_daily_calories: Get calorie summary + goals

[repl.ts]) - Interactive Interface

  • Animated spinner (braille characters)
  • Real-time status sync from AI agent
  • Multi-turn interaction loop

How I Used Notion MCP

The Integration Challenge

Integrating with Notion requires more than just an API key. You need:

  1. Proper database structure (fields, relations, types)
  2. Reliable tool calling for data persistence
  3. Real-time feedback during async operations
  4. Accurate data matching (food entries to daily summaries)

How MCP Solved This

The Model Context Protocol provided:

1. Abstraction Layer

User Message β†’ Groq AI β†’ MCP Tool Calls β†’ Notion API
Enter fullscreen mode Exit fullscreen mode

Instead of the AI directly hitting Notion's REST API (which requires object/array construction), MCP tools handle all the complexity:

  • Proper field type conversion (strings, numbers, relations)
  • Automatic page creation with correct schema
  • Relation management (linking food entries to daily pages)

2. Agentic Capabilities
The MCP server acts as an intelligent tool executor that:

  • Validates parameters before sending to Notion
  • Handles multi-step operations (create day page β†’ create food entries β†’ link relations)
  • Provides structured responses for the AI to reason about
  • Retries gracefully on failures

3. Real-time Status Feedback

// Agent can now report what it's doing at each step
onStatusUpdate?.("Analyzing your input...");
onStatusUpdate?.("Calling AI model...");
onStatusUpdate?.("Executing log_food...");
onStatusUpdate?.("Finalizing response...");
Enter fullscreen mode Exit fullscreen mode

This transforms the user experience from opaque delays to transparent progress.

What It Unlocks

Without MCP: AI would need to construct complex Notion page objects, manage database IDs, handle page relations - bloating the system prompt and error handling.

With MCP:

  • AI focuses on nutrition intelligence (macro estimation, meal parsing)
  • MCP handles all Notion complexity
  • System prompt stays clean and focused
  • Easy to extend with new tools (hydration tracking, supplements, etc.)
  • Decoupled architecture - can swap backends

Example: Multi-Item Meal Logging

User says: "Lunch: 250g rice, 2 bowls dal, curry"

AI Flow (via MCP):

  1. Parse into 3 items
  2. Estimate macros using IFCT 2017
  3. Call MCP log_food for each item:
   log_food(food_name="250g cooked rice", protein="7", carbs="56", fat="2", ...)
   log_food(food_name="2 bowls arhar dal", protein="24", carbs="42", fat="2", ...)
   log_food(food_name="curry", protein="8", carbs="12", fat="15", ...)
Enter fullscreen mode Exit fullscreen mode
  1. MCP automatically:
    • Creates 3 food log pages in Notion
    • Finds or creates the day's calorie summary page
    • Links all 3 entries to the correct day
    • Updates macro rollups

Result: Clean architecture where AI and Notion are perfectly decoupled.


Submission Summary

This project demonstrates how Model Context Protocol elegantly solves the integration challenge between AI and Notion. By abstracting Notion operations into typed, validated tools, we enable the AI to focus on domain intelligence (nutrition) while MCP handles infrastructure concerns (database schema, relations, types).

The result: A delightful user experience where complex meal logging feels instant and effortless.

Technologies Used: TypeScript, Groq API, Model Context Protocol, Notion API

Status: Ready for personal nutrition tracking

Top comments (0)