A Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with your MyFitnessPal data, including food diary, exercises, body measurements, nutrition goals, and water intake.
| Tool | Type | Description |
|---|---|---|
mfp_get_diary |
Read | Get food diary entries for any date |
mfp_search_food |
Read | Search the MyFitnessPal food database |
mfp_get_food_details |
Read | Get detailed nutrition info for a food item |
mfp_add_food_to_diary |
Write | Add a food item to your diary for a specific meal and date |
mfp_get_measurements |
Read | Get weight/body measurement history |
mfp_set_measurement |
Write | Log a new weight or body measurement |
mfp_get_exercises |
Read | Get logged exercises (cardio & strength) |
mfp_get_goals |
Read | Get daily nutrition goals |
mfp_set_goals |
Write | Update daily nutrition goals |
mfp_get_water |
Read | Get water intake for a date |
mfp_set_water |
Write | Log water intake for a date |
mfp_get_report |
Read | Get nutrition reports over a date range |
refresh_browser_cookies |
Utility | Extract and save session cookies from browser |
MyFitnessPal has no public API. Reads here are scraped from the website via
python-myfitnesspal, and diary
writes go through MFP's internal v2 JSON API — the same one their web client uses,
authenticated with your existing session token.
That interface is undocumented and was determined by observing the web client. It works today,
but MyFitnessPal can change it without notice. They have already done so once: this server
originally posted to /food/diary/{user}/add, which now returns 404, leaving food logging
broken. If logging starts failing, that is the most likely cause.
-
Python 3.10–3.12 (check with
python3 --version)Not 3.13+:
lxml, pulled in bymyfitnesspal, has no wheels for it and fails to build against the 3.14 C API. On macOS,brew install python@3.12. -
pip 21.3+ (for pyproject.toml support; upgrade with
pip install --upgrade pip) -
MyFitnessPal account
-
One of the following for authentication:
- Recommended (macOS): any Chromium-based browser (Arc, Chrome, Edge, Brave, Vivaldi, Opera, ...) with an active MyFitnessPal login session — the MCP auto-discovers the session on next call
- Firefox with an active MyFitnessPal login session (via the
browser_cookie3fallback) - Legacy: your MFP username/email and password (see caveats below — MFP's NextAuth backend rejects the form-POST flow, so credential auth only works while cached cookies remain valid)
This MCP supports multiple authentication methods:
| Method | Setup | Persistence |
|---|---|---|
| Chromium browser auto-discovery (macOS, recommended) | Log into myfitnesspal.com in any Chromium-based browser (Arc, Chrome, Edge, Brave, Vivaldi, Opera, ...). The MCP auto-detects installed browsers via the macOS keychain and uses whichever one is logged in. | Until browser session expires (cached for 30 days in ~/.mfp_mcp/cookies.json) |
| Encrypted credentials (legacy) | Add encrypted MFP_USERNAME and MFP_PASSWORD to Claude Desktop config; set MFP_SECRET_KEY outside the config (for example via shell env or OS keychain) |
Form login no longer works against MFP's NextAuth backend — only useful if cached cookies are still valid |
| Plain credentials (legacy) | Add MFP_USERNAME and MFP_PASSWORD to Claude Desktop config |
Same as above — form login flow is deprecated |
| Browser cookies (browser_cookie3 fallback) | Log into myfitnesspal.com in Chrome or Firefox via the default profile paths | Until browser session expires |
Note: MyFitnessPal migrated their authentication to NextAuth, so the legacy form-POST
authenticate_with_credentialspath almost always fails for fresh logins. The Chromium auto-discovery path is the reliable way to get a session on macOS — just log in via any modern browser and the MCP picks it up automatically on the next call.
# Clone the repository
git clone https://github.com/YOUR_USERNAME/myfitnesspal-mcp-python.git
cd myfitnesspal-mcp-python
# Create virtual environment (use python3.10+ on macOS/Linux)
python3 -m venv venv
# On macOS, you may need to specify version: python3.12 -m venv venv
# Activate virtual environment
source venv/bin/activate # macOS/Linux
# On Windows: .\venv\Scripts\activate
# Upgrade pip (required for pyproject.toml support)
pip install --upgrade pip
# Install the package in editable mode
pip install -e .pip install mfp-mcpNote: Option 2 requires the package to be published to PyPI. For now, use Option 1.
After installation, verify the server can start:
# With venv activated
python -m mfp_mcp.serverYou should see the server waiting for input (it communicates via stdio). Press Ctrl+C to stop.
To test authentication (optional):
MFP_USERNAME="your_email" MFP_PASSWORD="your_password" python -c "
from mfp_mcp.server import get_mfp_client
client = get_mfp_client()
print('Authentication successful!')
"| OS | Config File Location |
|---|---|
| macOS | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Windows | %APPDATA%\Claude\claude_desktop_config.json |
If the file doesn't exist, create it. Add or merge the following configuration:
Encrypt your credentials before storing them in the config file. See Encrypted Credentials for setup instructions.
⚠️ Security note: Encryption only provides meaningful protection ifMFP_SECRET_KEYis stored separately from the config file (e.g., set in your shell profile or OS keychain). Storing the key alongside the encrypted values in the same config file means anyone who obtains the config can still decrypt your credentials.
macOS Example (with key set separately in your shell environment):
{
"mcpServers": {
"myfitnesspal": {
"command": "/Users/yourname/myfitnesspal-mcp-python/venv/bin/python",
"args": ["-m", "mfp_mcp.server"],
"env": {
"MFP_USERNAME": "gAAAAAB...<encrypted_email>",
"MFP_PASSWORD": "gAAAAAB...<encrypted_password>"
}
}
}
}macOS Example:
{
"mcpServers": {
"myfitnesspal": {
"command": "/Users/yourname/myfitnesspal-mcp-python/venv/bin/python",
"args": ["-m", "mfp_mcp.server"],
"env": {
"MFP_USERNAME": "your_email@example.com",
"MFP_PASSWORD": "your_password"
}
}
}
}Windows Example:
{
"mcpServers": {
"myfitnesspal": {
"command": "C:\\Users\\YourName\\myfitnesspal-mcp-python\\venv\\Scripts\\python.exe",
"args": ["-m", "mfp_mcp.server"],
"env": {
"MFP_USERNAME": "your_email@example.com",
"MFP_PASSWORD": "your_password"
}
}
}
}macOS Example:
{
"mcpServers": {
"myfitnesspal": {
"command": "/Users/yourname/myfitnesspal-mcp-python/venv/bin/python",
"args": ["-m", "mfp_mcp.server"]
}
}
}
⚠️ Important: Use full absolute paths to the Python executable in your virtual environment. Replaceyourname/YourNamewith your actual username.
After saving the config file, completely quit and restart Claude Desktop for the changes to take effect.
In Claude Desktop, you should see a hammer icon (🔨) indicating MCP tools are available. Try asking:
"Show my MyFitnessPal diary for today"
The MCP server supports four authentication methods, tried in this order:
Set MFP_USERNAME and MFP_PASSWORD in your Claude Desktop config's env
section. You can store them as plain text or encrypted (see below).
⚠️ Note: MyFitnessPal migrated to a NextAuth backend, so the form-POST flow this method uses no longer produces a session cookie. Credential auth only succeeds while~/.mfp_mcp/cookies.jsonstill holds a valid session from a previous browser login — after that, this method silently falls through to the browser cookie paths below. Prefer the Chromium auto-discovery method on macOS.
"env": {
"MFP_USERNAME": "your_email@example.com",
"MFP_PASSWORD": "your_password"
}Instead of storing plain-text credentials, you can encrypt them using Fernet symmetric encryption from the cryptography library. The server decrypts them at runtime using MFP_SECRET_KEY.
⚠️ Important: For encryption to be meaningful,MFP_SECRET_KEYmust be kept outside the Claude Desktop config file. The server resolves it in this order:
MFP_SECRET_KEYenvironment variable (shell profile, not the Claude config)- OS keychain — service
mfp-mcp, accountMFP_SECRET_KEY(recommended)
Step 1 — Generate and store the key in one command:
npm install
npm run store-keystore-key generates a Fernet-compatible key, stores it in the OS keychain (mfp-mcp / MFP_SECRET_KEY), and prints the key so you can use it in Step 2. See Key Management CLI for all available flags.
Step 2 — Encrypt your credentials:
from cryptography.fernet import Fernet
key = b"abc123XYZ...==" # your key from Step 1
f = Fernet(key)
encrypted_user = f.encrypt(b"your_email@example.com").decode()
encrypted_pass = f.encrypt(b"your_password").decode()
print("MFP_USERNAME:", encrypted_user)
print("MFP_PASSWORD:", encrypted_pass)Step 3 — Add only the encrypted values to your Claude Desktop config:
"env": {
"MFP_USERNAME": "gAAAAAB...<encrypted>",
"MFP_PASSWORD": "gAAAAAB...<encrypted>"
}The key stays in the keychain — it never touches the config file.
Alternative: shell profile (simpler, still outside the Claude config):
# Add to ~/.zshrc or ~/.bashrc — do NOT put this in claude_desktop_config.json
export MFP_SECRET_KEY="abc123XYZ...=="If MFP_SECRET_KEY is not found in the environment or keychain, the server treats MFP_USERNAME and MFP_PASSWORD as plain text (backward compatible).
After successful authentication, session cookies are saved to ~/.mfp_mcp/cookies.json. These persist for 30 days, so you won't need to re-authenticate frequently.
If no credentials are provided and stored cookies are absent or expired, the
server scans the macOS keychain for <Browser> Safe Storage entries to find
every installed Chromium-based browser, then tries each one's cookies
database until it finds a valid MyFitnessPal session token.
This works out of the box with Arc, Chrome, Edge, Brave, Vivaldi, Opera, Chromium, and any other Chromium-derived browser. You only need to be logged into myfitnesspal.com in one of them.
The first successful extraction is persisted to ~/.mfp_mcp/cookies.json,
so subsequent calls skip the discovery step until the session expires.
You can also force a specific browser via the refresh_browser_cookies
MCP tool:
refresh_browser_cookies(browser="arc") # or "chrome", "edge", "brave", ...
refresh_browser_cookies(browser="auto") # scan everything (default)
refresh_browser_cookies(browser="firefox") # via browser_cookie3
A final fallback uses browser_cookie3
to read Chrome or Firefox cookies from the default profile paths. Useful on
Linux/Windows or if the macOS auto-discovery path can't access your
keychain.
Your MyFitnessPal credentials in the Claude Desktop config are stored locally on your machine. The config file is only readable by your user account. Options to harden this further:
The strongest option. The ciphertext lives in the config; the key never does. See Encrypted Credentials.
Still separates key from ciphertext, though the key is on disk.
Storing MFP_PASSWORD in your MCP client config puts your MyFitnessPal password in plaintext
on disk, readable by anything running as your user. It is convenient — the server can
re-authenticate indefinitely — but it is a real tradeoff, not a formality.
Prefer browser-cookie auth if you would rather not store the password: log into myfitnesspal.com and the server reads the session from your browser. The cost is that MFP sessions expire, so you will occasionally need to log in again.
Files this server writes to ~/.mfp_mcp/ (directory mode 0700):
| File | Contents | Mode |
|---|---|---|
cookies.json |
Session cookies — full account access, treat as a password | 0600 |
Note that this server can modify your diary — adding food entries and updating goals, measurements, and water.
Once configured, you can interact with your MyFitnessPal data through Claude:
"Show me what I ate today"
"Get my food diary for 2026-01-05"
"What meals did I log yesterday?"
"Log a grilled chicken breast, 6 oz, for lunch"
"Add 2 cups of oatmeal to breakfast"
"Show my weight history for the past 30 days"
"Log my weight as 232.5 pounds"
"What's my weight trend this month?"
"Search MyFitnessPal for chicken breast"
"Find nutrition info for Greek yogurt"
"Look up calories in a banana"
"Compare my nutrition goals to what I actually ate today"
"Am I on track with my protein intake?"
"How many calories do I have left today?"
"What exercises did I log today?"
"Show my workout from yesterday"
"Show my calorie intake over the past week"
"What's my average protein intake this week?"
"Generate a nutrition report for January"
scripts/store-key.ts is a one-time setup tool that generates and stores MFP_SECRET_KEY in your OS keychain (macOS Keychain, Windows Credential Vault, Linux Secret Service). Node.js 18+ is required.
npm install| Command | What it does |
|---|---|
npm run store-key |
Generate a new Fernet key and store it in the keychain |
npm run store-key -- --key <val> |
Store an existing key instead of generating one |
npm run store-key -- --overwrite |
Replace a key that is already stored |
npm run store-key -- --show |
Print the currently stored key |
npm run store-key -- --delete |
Remove the stored key from the keychain |
✅ MFP_SECRET_KEY stored in OS keychain
service : mfp-mcp
account : MFP_SECRET_KEY
source : generated
Your key (use this to encrypt MFP_USERNAME / MFP_PASSWORD):
abc123XYZ...==
Next — encrypt your credentials with Python:
from cryptography.fernet import Fernet
f = Fernet(b"abc123XYZ...==")
print("MFP_USERNAME:", f.encrypt(b"your_email@example.com").decode())
print("MFP_PASSWORD:", f.encrypt(b"your_password").decode())
myfitnesspal-mcp-python/
├── Dockerfile # Container deployment
├── package.json # Node tooling (store-key CLI)
├── tsconfig.json # TypeScript config for scripts/
├── pyproject.toml # Python package configuration
├── README.md # This file
├── scripts/
│ └── store-key.ts # One-time key management CLI
└── src/
└── mfp_mcp/
├── __init__.py # Package initialization
└── server.py # MCP server implementation
# Clone and enter directory
git clone https://github.com/YOUR_USERNAME/myfitnesspal-mcp-python.git
cd myfitnesspal-mcp-python
# Create virtual environment (Python 3.10+ required)
python3 -m venv venv
source venv/bin/activate
# Upgrade pip and install with dev dependencies
pip install --upgrade pip
pip install -e ".[dev]"pytestblack src/
isort src/
ruff check src/mypy src/
⚠️ Note: Docker deployment requires mounting your browser's cookie database for authentication.
# Build the image
docker build -t mfp-mcp .
# Run with Chrome cookies mounted (Linux example)
docker run -it --rm \
-v ~/.config/google-chrome:/root/.config/google-chrome:ro \
mfp-mcpProblem: Python is not in PATH or you need to specify version.
Solutions:
- On macOS/Linux, use
python3instead ofpython - Check your version:
python3 --version(must be 3.10+) - If needed, install Python 3.12 via Homebrew:
brew install python@3.12 - Then create venv with:
python3.12 -m venv venv
Problem: Your pip version is too old to support pyproject.toml builds.
Solution: Upgrade pip first:
pip install --upgrade pip
pip install -e .Problem: The server can't authenticate with your credentials or read browser cookies.
Solutions:
- Easiest (macOS): Log into myfitnesspal.com in any Chromium-based browser (Arc, Chrome, Edge, Brave, ...). The MCP will auto-discover the session on the next call.
- Force a refresh: Call the
refresh_browser_cookiestool —autoscans every browser, or pass a specific name (arc,chrome,edge,brave,vivaldi,opera,firefox). - If using credentials: Double-check your MFP_USERNAME and MFP_PASSWORD
in the config. Note that the legacy form-login flow no longer works
against MFP's NextAuth backend — credentials are only useful while
~/.mfp_mcp/cookies.jsonstill holds a valid session. - Try logging out and back in to MyFitnessPal in your browser.
- Clear
~/.mfp_mcp/cookies.jsonand let the auto-discovery rebuild it. - On macOS, the auto-discovery path reads each browser's
Safe Storagepassword from your login keychain. On the very first run, macOS shows a dialog: " wants to use information stored in your keychain" — click Always Allow. If Claude Desktop is spawning the MCP headlessly in the background, this dialog can be easy to miss; if auto-discovery returns "no browser had a session", bring Claude Desktop to the foreground and retry so the prompt is visible. Once approved, the key is cached and the prompt won't repeat.
Problem: Package not installed or wrong Python environment.
Solutions:
- Ensure you're using the correct Python from your virtual environment
- Reinstall the package:
pip install -e . - Verify the path in your Claude Desktop config points to the venv Python:
/path/to/project/venv/bin/python # macOS/Linux C:\path\to\project\venv\Scripts\python.exe # Windows
Problem: MCP server not connecting.
Solutions:
- Check the config file syntax (must be valid JSON - use a JSON validator)
- Use absolute paths in the configuration (no
~or relative paths) - Restart Claude Desktop completely (Cmd+Q on macOS, then relaunch)
- Check Claude Desktop logs:
- macOS:
~/Library/Logs/Claude/ - Windows:
%APPDATA%\Claude\logs\
- macOS:
Problem: Authentication works but no data returned.
Solutions:
- Verify you have data logged in MyFitnessPal for the requested date
- Check the date format (YYYY-MM-DD)
- Try a recent date where you know you have entries
Problem: VS Code/Cursor Python extension bug with venv prompt.
Solutions:
- Update the Python extension in VS Code/Cursor
- Or manually fix the venv activate script - change line ~70 in
venv/bin/activate:# Change from: PS1="("'(venv) '") ${PS1:-}" # To: PS1="(venv) ${PS1:-}"
Get food diary for a specific date.
date(optional): YYYY-MM-DD format, defaults to todayresponse_format: "markdown" or "json"
Search the MyFitnessPal food database.
query(required): Search termlimit(optional): Max results (default 10, max 50)response_format: "markdown" or "json"
Get detailed nutrition for a food item.
mfp_id(required): MyFitnessPal food ID from search resultsresponse_format: "markdown" or "json"
Add a food item to your diary for a specific meal and date.
mfp_id(required): MyFitnessPal food ID from search results (usemfp_search_foodfirst)meal(optional): Meal name - "Breakfast", "Lunch", "Dinner", or "Snacks" (default: "Breakfast")date(optional): YYYY-MM-DD format (default: today)quantity(optional): Number of servings (default: 1.0)unit(optional): Unit/serving size description (e.g., "1 cup", "100g")
Example workflow:
- Use
mfp_search_foodto find a food item and get itsmfp_id - Use
mfp_add_food_to_diarywith themfp_idto add it to your diary
Get body measurement history.
measurement(optional): "Weight", "Body Fat", "Waist", etc.start_date(optional): YYYY-MM-DD (default 30 days ago)end_date(optional): YYYY-MM-DD (default today)response_format: "markdown" or "json"
Log a body measurement for today.
measurement(optional): Type (default "Weight")value(required): Numeric value
Get exercise log for a date.
date(optional): YYYY-MM-DD (default today)response_format: "markdown" or "json"
Get daily nutrition goals.
date(optional): YYYY-MM-DD (default today)response_format: "markdown" or "json"
Update nutrition goals.
calories(optional): Daily calorie goalprotein(optional): Daily protein in gramscarbohydrates(optional): Daily carbs in gramsfat(optional): Daily fat in grams
Get water intake for a date.
date(optional): YYYY-MM-DD (default today)
Log water intake for a date.
cups(required): Number of cups of water (e.g., 2.5 for 2.5 cups). Note: MyFitnessPal uses cups as the unit (1 cup = ~237ml)date(optional): YYYY-MM-DD format (default: today)
Get nutrition report over a date range.
report_name(optional): "Net Calories", "Protein", "Fat", "Carbs"start_date(optional): YYYY-MM-DD (default 7 days ago)end_date(optional): YYYY-MM-DD (default today)response_format: "markdown" or "json"
- Encrypted Credentials: Credentials can be stored as Fernet-encrypted ciphertext in your config.
MFP_SECRET_KEYis resolved at runtime from the environment variable first, then the OS keychain (mfp-mcp/MFP_SECRET_KEY). See Encrypted Credentials for setup. - OS Keychain: Storing
MFP_SECRET_KEYin the native keychain (macOS Keychain, Windows Credential Vault, Linux Secret Service) means the decryption key never touches the config file or any backup. - Plain Credentials: If
MFP_SECRET_KEYis absent from both environment and keychain,MFP_USERNAMEandMFP_PASSWORDare used as-is (backward compatible). - Session Cookies: After successful authentication, session cookies are cached in
~/.mfp_mcp/cookies.json(restricted permissions) for 30 days. - Browser Cookies: As a fallback, the server can read your browser cookies to authenticate with MyFitnessPal.
- Local Only: The server runs locally on your machine via stdio transport. No data is sent to any third-party servers.
- No External Transmission: Your MyFitnessPal data is only transmitted between your computer and MyFitnessPal's servers (myfitnesspal.com).
MIT License - See LICENSE file for details.
- python-myfitnesspal - The underlying library for MyFitnessPal access
- MCP Python SDK - Model Context Protocol framework
- Anthropic - Claude and the MCP specification