Skip to main content
Glama
ai-mcp-garage

MyFitnessPal MCP Server

get_daily_meals

Retrieve detailed meal breakdowns with foods, servings, and calories from MyFitnessPal for any date to track nutrition intake.

Instructions

Get detailed meal-by-meal breakdown with all foods, servings, and calories.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNo

Implementation Reference

  • The main handler function for the 'get_daily_meals' tool. It is decorated with @mcp.tool, which registers it in the FastMCP server. The function parses the date, fetches the day's data using MyFitnessPalClient, iterates through meals and entries to build a detailed markdown summary of meals, foods, servings, calories, and macros, and returns it wrapped in text_response.
    @mcp.tool
    def get_daily_meals(date: Optional[str] = None):
        """
        Get detailed meal-by-meal breakdown with all foods, servings, and calories.
        
        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)
            
            output = f"# Meals for {target_date.strftime('%B %d, %Y')}\n\n"
            
            if not day.meals:
                output += "No meals logged for this day.\n"
            else:
                for meal in day.meals:
                    meal_totals = meal.totals
                    meal_calories = meal_totals.get('calories', 0)
                    
                    output += f"## {meal.name}\n"
                    output += f"**Total**: {meal_calories:.0f} kcal"
                    
                    # Show meal macros
                    meal_carbs = meal_totals.get('carbohydrates', 0)
                    meal_fat = meal_totals.get('fat', 0)
                    meal_protein = meal_totals.get('protein', 0)
                    output += f" ({meal_carbs:.0f}C / {meal_fat:.0f}F / {meal_protein:.0f}P)\n\n"
                    
                    if meal.entries:
                        for entry in meal.entries:
                            nutrition = entry.nutrition_information
                            
                            output += f"- **{entry.name}**\n"
                            output += f"  - Serving: {entry.quantity} {entry.unit}\n"
                            output += f"  - Calories: {nutrition.get('calories', 0):.0f} kcal\n"
                            output += f"  - Macros: "
                            output += f"{nutrition.get('carbohydrates', 0):.0f}C / "
                            output += f"{nutrition.get('fat', 0):.0f}F / "
                            output += f"{nutrition.get('protein', 0):.0f}P\n"
                        output += "\n"
                    else:
                        output += "No foods logged in this meal.\n\n"
            
            return text_response(output)
            
        except Exception as e:
            return text_response(f"Error retrieving meals: {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