๐Ÿ“ฆ linares222 / mcp-myfitnesspal

A simple MCP Server to Pull data from MyFitnessPal

โ˜… 0 stars โ‘‚ 4 forks ๐Ÿ‘ 0 watching โš–๏ธ MIT License
๐Ÿ“ฅ Clone https://github.com/linares222/mcp-myfitnesspal.git
HTTPS git clone https://github.com/linares222/mcp-myfitnesspal.git
SSH git clone git@github.com:linares222/mcp-myfitnesspal.git
CLI gh repo clone linares222/mcp-myfitnesspal
Loading files...
๐Ÿ“„ README.md

MyFitnessPal MCP Server

A FastMCP server that retrieves your MyFitnessPal nutrition data through the Model Context Protocol.

Quick Start

Local Development

  • Prerequisites: Python 3.12+, uv, MyFitnessPal account
  • Install dependencies: uv sync
  • Log into MyFitnessPal in your browser (Chrome, Firefox, Safari, or Edge)
  • Test the server: uv run python test_client.py

Deployment (Server/Docker)

For environments without a browser:

  • Export cookies from your local browser:
uv run python export_cookies.py

  • Deploy with the generated .env file - no browser needed!
See Deployment Guide for Docker, systemd, and cloud deployment options.

Features

  • Daily nutrition summary (calories, macros, water)
  • Detailed meal-by-meal breakdown
  • Exercise tracking (cardio + strength)
  • Macro & micronutrient analysis
  • Water intake monitoring
  • Date range summaries with trends

Configuration

Add to your MCP client config (e.g., .cursor/mcp.json):

{
  "mcpServers": {
    "myfitnesspal": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--directory", "/path/to/mfp-mcp", "python", "main.py"]
    }
  }
}

Documentation

How It Works

Uses the python-myfitnesspal library (GitHub version) which:

  • Extracts cookies from your browser automatically
  • Scrapes MyFitnessPal website for data
  • No credentials stored in files
  • Works with Chrome, Firefox, Safari, and Edge

Cookie Authentication

Browser-based (default):

  • Automatically extracts cookies from your local browser
  • Works out of the box if you're logged into MyFitnessPal
Environment variable (for Docker/servers):
  • Set MFP_COOKIES environment variable with exported cookies
  • Use export_cookies.py utility to extract cookies beforehand:
uv run python export_cookies.py
  • Perfect for environments without browser access (Docker containers, remote servers, etc.)
  • Cookies expire after ~30 days, re-export when needed

Project Structure

mfp-mcp/
โ”œโ”€โ”€ docs/              # All documentation
โ”œโ”€โ”€ myfitnesspal/      # External library (GitHub)
โ”œโ”€โ”€ main.py            # FastMCP server
โ”œโ”€โ”€ api_client.py      # Client wrapper
โ”œโ”€โ”€ utils.py           # Helper functions
โ”œโ”€โ”€ test_client.py     # Test script
โ””โ”€โ”€ pyproject.toml     # Dependencies

Requirements

  • Python 3.12+
  • uv package manager
  • Active MyFitnessPal session in browser
  • fastmcp 2.12+
  • lxml, browser-cookie3, measurement

License

For personal use and educational purposes. Respect MyFitnessPal's Terms of Service.

Credits

  • python-myfitnesspal: https://github.com/coddingtonbear/python-myfitnesspal
  • FastMCP: https://github.com/jlowin/fastmcp