Skip to main content
Glama
ai-mcp-garage

MyFitnessPal MCP Server

get_daily_summary

Retrieve daily nutrition overview including calories consumed and remaining, macro breakdown, water intake, and goal progress from MyFitnessPal data.

Instructions

Get daily nutrition overview: calories consumed/remaining, macro breakdown, water, and goals.

Args: date: Date in YYYY-MM-DD format (defaults to today)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNo

Implementation Reference

  • The handler function decorated with @mcp.tool that implements the get_daily_summary tool. It fetches daily nutrition data from MyFitnessPal, computes summaries for calories, macros, exercise, water, and formats as markdown.
    @mcp.tool
    def get_daily_summary(date: Optional[str] = None):
        """
        Get daily nutrition overview: calories consumed/remaining, macro breakdown, water, and goals.
        
        Args:
            date: Date in YYYY-MM-DD format (defaults to today)
        """
        try:
            target_date = parse_date(date)
            client = get_client()
            
            # Fetch day data
            day = client.get_day(target_date)
            
            totals = day.totals
            goals = day.goals
            
            # Extract key nutrients
            calories = totals.get('calories', 0)
            carbs = totals.get('carbohydrates', 0)
            fat = totals.get('fat', 0)
            protein = totals.get('protein', 0)
            
            # Goals
            calorie_goal = goals.get('calories', 0)
            carb_goal = goals.get('carbohydrates', 0)
            fat_goal = goals.get('fat', 0)
            protein_goal = goals.get('protein', 0)
            
            # Water (library returns milliliters)
            water_ml = day.water
            water_oz = water_ml / 29.5735  # Convert ml to oz
            water_cups = water_ml / 236.588  # Convert ml to cups
            
            # Exercise summary
            exercises = day.exercises
            total_exercise_calories = 0
            total_exercise_minutes = 0
            exercise_count = 0
            
            for exercise in exercises:
                for entry in exercise.entries:
                    exercise_count += 1
                    nutrition = entry.nutrition_information
                    total_exercise_calories += nutrition.get('calories burned', 0)
                    minutes = nutrition.get('minutes')
                    if minutes:
                        total_exercise_minutes += minutes
            
            # Format output
            output = f"""# Daily Summary for {target_date.strftime('%B %d, %Y')}
    
    ## Calories
    - **Consumed**: {calories:.0f} kcal
    - **Goal**: {calorie_goal:.0f} kcal
    - **Remaining**: {calorie_goal - calories:.0f} kcal
    
    ## Macronutrients
    - **Carbohydrates**: {carbs:.0f}g / {carb_goal:.0f}g
    - **Fat**: {fat:.0f}g / {fat_goal:.0f}g
    - **Protein**: {protein:.0f}g / {protein_goal:.0f}g
    
    ## Exercise
    - **Activities**: {exercise_count}
    - **Duration**: {total_exercise_minutes:.0f} minutes
    - **Calories Burned**: {total_exercise_calories:.0f} kcal
    
    ## Water Intake
    - **Amount**: {water_oz:.0f} oz ({water_cups:.1f} cups, {water_ml:.0f} ml)
    
    ## Status
    - **Day Complete**: {'Yes' if day.complete else 'No'}
    - **Meals Logged**: {len(day.meals)}
    """
            
            return text_response(output)
            
        except Exception as e:
            return text_response(f"Error retrieving daily summary: {str(e)}")

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ai-mcp-garage/mcp-myfitnesspal'

If you have feedback or need assistance with the MCP directory API, please join our Discord server