Skip to main content
Glama

get_daily_macros

Retrieve your daily macro and micronutrient breakdown from MyFitnessPal for any date to track nutrition intake and monitor dietary goals.

Instructions

Get comprehensive macro and micronutrient breakdown with all tracked nutrients.

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNo

Implementation Reference

  • The handler function implementing the get_daily_macros tool. It retrieves daily totals and goals from MyFitnessPal, formats a comprehensive macronutrient and micronutrient breakdown in markdown, using helper functions parse_date and get_client.
    @mcp.tool def get_daily_macros(date: Optional[str] = None): """ Get comprehensive macro and micronutrient breakdown with all tracked nutrients. 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 output = f"# Macros & Nutrients for {target_date.strftime('%B %d, %Y')}\n\n" # Macronutrients output += "## Macronutrients\n" def format_nutrient(name: str, display_name: str, unit: str = "g"): value = totals.get(name, 0) goal = goals.get(name, 0) if goal > 0: return f"- **{display_name}**: {value:.0f}{unit} / {goal:.0f}{unit} ({value/goal*100:.0f}%)\n" else: return f"- **{display_name}**: {value:.0f}{unit}\n" output += format_nutrient('calories', 'Calories', 'kcal') output += format_nutrient('carbohydrates', 'Carbohydrates') output += format_nutrient('protein', 'Protein') output += format_nutrient('fat', 'Fat') # Fat breakdown if available if 'saturated fat' in totals: output += f" - Saturated: {totals.get('saturated fat', 0):.1f}g\n" if 'polyunsaturated fat' in totals: output += f" - Polyunsaturated: {totals.get('polyunsaturated fat', 0):.1f}g\n" if 'monounsaturated fat' in totals: output += f" - Monounsaturated: {totals.get('monounsaturated fat', 0):.1f}g\n" if 'trans fat' in totals: output += f" - Trans: {totals.get('trans fat', 0):.1f}g\n" output += format_nutrient('fiber', 'Fiber') output += format_nutrient('sugar', 'Sugar') output += "\n" # Micronutrients output += "## Micronutrients\n" if 'sodium' in totals: output += format_nutrient('sodium', 'Sodium', 'mg') if 'potassium' in totals: output += format_nutrient('potassium', 'Potassium', 'mg') if 'cholesterol' in totals: output += format_nutrient('cholesterol', 'Cholesterol', 'mg') if 'vitamin a' in totals: output += format_nutrient('vitamin a', 'Vitamin A', '%') if 'vitamin c' in totals: output += format_nutrient('vitamin c', 'Vitamin C', '%') if 'calcium' in totals: output += format_nutrient('calcium', 'Calcium', '%') if 'iron' in totals: output += format_nutrient('iron', 'Iron', '%') return text_response(output) except Exception as e: return text_response(f"Error retrieving macros: {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