Skip to content

mairabies/Healthmaxxing

Repository files navigation

NutriLens MCP

Model Context Protocol for Nutrition, Meals, and Scheduling

NutriLens MCP is an AI context engine that combines nutrition data, restaurant search, calendar availability, and weather to help users make informed meal and exercise decisions. It fetches live data from multiple APIs and returns concise, actionable context.

Features

  • MacroAnalyzer: Nutrition data lookup from USDA, Open Food Facts, and Edamam
  • MealPlanner: Find nearby restaurants with menu analysis that match macro targets
  • TimeAdvisor: Schedule recommendations based on calendar and weather
  • SummaryEngine: Intelligent summarization using OpenRouter or Gemini

Quick Start

Installation

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Create .env file and add API keys (see below)
cp .env.example .env

API Keys

Required:

Optional:

  • OPENROUTER_API_KEY or GEMINI_API_KEY - For better summaries
  • USDA_API_KEY - For enhanced nutrition data
  • GOOGLE_CALENDAR_CLIENT_ID/SECRET/REFRESH_TOKEN - For calendar integration

Running

# Terminal 1: Start server
python server.py

# Terminal 2: Start Streamlit app
streamlit run streamlit_app.py

Visit http://localhost:8501 to use the interface.

Example Prompts

1. Multi-Source Integration

"I have 40g protein and <20g fat left. What should I eat for lunch near me today?"

Combines: macros + location + meal planning + time

2. Calendar & Weather Integration

"Plan tomorrow's meals around my gym schedule. I need 150g protein total and want to exercise when the weather is good."

Combines: calendar + weather + macros + meal planning

3. Restaurant-Specific Query

"I'm at a restaurant in San Francisco. What dish here fits my remaining macros (30g protein, <15g fat) and when should I eat it based on my calendar?"

Combines: location + restaurant search + macros + calendar

4. Comprehensive Restaurant Exploration

"Find me 3 restaurants near me that serve high-protein, low-carb meals. Show me specific dishes and their macros."

Shows: restaurant exploration + menu analysis + nutrition matching

5. Complex Multi-Factor Query

"I'm in New York and need lunch. I have 40g protein left, want to stay under 600 calories, and prefer to eat when it's not raining. What are my options?"

Combines: location + macros + weather + meal planning

How It Works

  1. Intent Detection: Analyzes query to determine which modules to call
  2. Parallel Execution: Fetches data from multiple APIs simultaneously
  3. Data Aggregation: Combines results into unified context
  4. Intelligent Summarization: Compresses to concise, actionable response

Data Sources

  • USDA FoodData Central: Official nutrition database
  • Open Food Facts: Community nutrition data
  • Google Maps Places: Restaurant search and menu data
  • Google Calendar: Personal schedule (optional)
  • OpenWeatherMap: Weather forecasts
  • OpenRouter/Gemini: LLM summarization

Technical Details

  • Error Handling: Graceful degradation when APIs fail
  • Caching: Reduces API calls (nutrition: 2h, restaurants: 30min, weather: 30min)
  • Validation: Input sanitization and data validation
  • Retry Logic: Exponential backoff for transient failures

Project Structure

Health_mcp/
├── mcp/
│   ├── macro_analyzer.py      # Nutrition lookup
│   ├── meal_planner.py         # Restaurant search & menu analysis
│   ├── time_advisor.py         # Scheduling with calendar & weather
│   ├── summary_engine.py       # LLM summarization
│   ├── query_processor.py     # Intent detection
│   ├── context_builder.py     # Orchestration
│   └── utils.py                # Utilities
├── server.py                   # FastAPI server
├── streamlit_app.py            # Web interface
└── requirements.txt            # Dependencies

API Documentation

When the server is running, visit http://localhost:8000/docs for interactive API documentation.


Built with: FastAPI, Streamlit, Google APIs, OpenWeatherMap, USDA FoodData Central

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages