How mason-levyy/myfitnesspal-mcp works
This repository is an MCP server that lets an AI client read and change a user’s MyFitnessPal diary. The main workflow is: a client invokes a server tool, food searches can be ranked into a draft and confirmed for logging, and the server reads or writes MyFitnessPal before returning results. Diary summaries and trends use a local SQLite cache; sync fills it from MyFitnessPal. Authentication uses a browser session cookie, with optional headless-browser refresh. Some tool and helper wiring is inferred from the README where source excerpts are incomplete.
Main entry points: server.py MCP tools · mfp_client.py MFP client · food_logging.py Food logging · sync.py Diary sync
Components 13
Diary operations
- Food logging
src/myfitnesspal_mcp/food_logging.py - Food ranking
src/myfitnesspal_mcp/food_ranking.py - Diary operations
src/myfitnesspal_mcp/diary.py
Cache and analysis
- Diary sync
src/myfitnesspal_mcp/sync.py - Local cache
src/myfitnesspal_mcp/store.py
Session management
- MFP client
src/myfitnesspal_mcp/mfp_client.py - Cookie auth
src/myfitnesspal_mcp/auth.py - Configuration
src/myfitnesspal_mcp/config.py - Session refresh
src/myfitnesspal_mcp/refresh.py
Other components
- MCP client
- MyFitnessPal
Connections 23
- MCP client → MCP tools: invokes tools
- CLI entry → MCP tools: starts server
- MCP tools → Food logging: handles food tools
- MCP tools → Diary operations: handles diary tools
- MCP tools → Diary sync: syncs diary
- MCP tools → Local cache: reads and writes
- MCP tools → MFP client: gets session client
- MCP tools → Session refresh: retries auth failures
- Food logging → Food ranking: ranks candidates
- Food logging → Local cache: uses pins and drafts
- Food logging → Diary operations: logs food
- Diary operations → MyFitnessPal: reads and writes diary
- Diary sync → Diary operations: fetches notes
- Diary sync → MFP client: fetches diary data
- Diary sync → Local cache: updates cache
- MFP client → Cookie auth: loads cookies
- MFP client → MyFitnessPal: authenticates requests
- Cookie auth → MFP client: validates cookie
- Cookie auth → Configuration: locates cookie file
- Session refresh → MyFitnessPal: refreshes session
- Session refresh → Cookie auth: saves refreshed cookies
- Session refresh → MFP client: resets client
- Local cache → Configuration: locates database