myfitnesspal-mcp
A Model Context Protocol (MCP) server that connects AI assistants to your MyFitnessPal data, enabling reading food diaries, nutrition goals, weight measurements, and more via MFP's web scraping.
README
mfp-mcp
A Model Context Protocol (MCP) server that connects AI assistants to your MyFitnessPal data. Lets Claude read your food diary, nutrition goals, weight measurements, and more.
MFP has no official API - this uses the myfitnesspal Python library which scrapes the website using browser cookies.
Quick start
# Install
git clone https://github.com/jevy/myfitnesspal-mcp.git
cd myfitnesspal-mcp
uv sync --extra browser
# Authenticate (must be logged into MFP in your browser first)
mfp-mcp auth --from-browser chrome
# Verify
mfp-mcp auth-status
# Start the server
mfp-mcp serve
Adding to Claude Code
Run mfp-mcp config to get the JSON snippet, or add this to your Claude Code project settings (.claude/settings.json):
{
"mcpServers": {
"myfitnesspal": {
"command": "/path/to/your/.venv/bin/mfp-mcp",
"args": ["serve"]
}
}
}
Replace the path with the output of which mfp-mcp after installing.
Tools
| Tool | Description | Inputs |
|---|---|---|
mfp_get_diary |
Get food diary for a single date | date (YYYY-MM-DD) |
mfp_get_nutrition_summary |
Get nutrition totals across a date range (max 31 days) | start_date, end_date |
mfp_get_goals |
Get calorie and macro goals | none |
mfp_get_measurements |
Get body measurements (weight, body fat, etc.) over time | measurement?, start_date?, end_date? |
mfp_get_profile |
Get user profile and preferences | none |
mfp_search_food |
Search the MFP food database | query |
mfp_get_food_details |
Get full nutrition for a food item | mfp_id |
mfp_auth_status |
Check whether authentication is valid | none |
mfp_refresh_auth |
Re-extract cookies from browser | browser? (auto/chrome/firefox/safari/edge) |
CLI reference
mfp-mcp auth --from-browser <browser> Authenticate (extract + store cookies)
mfp-mcp auth-status Check stored credential validity
mfp-mcp auth-clear Remove stored credentials
mfp-mcp config Output Claude Code MCP config JSON
mfp-mcp serve Start stdio MCP server
mfp-mcp help Show help
Authentication
MFP requires browser cookies for access. The auth command extracts cookies from your browser and stores them securely.
# Auto-detect browser
mfp-mcp auth --from-browser auto
# Specific browser
mfp-mcp auth --from-browser chrome
mfp-mcp auth --from-browser firefox
mfp-mcp auth --from-browser safari
You must be logged into myfitnesspal.com in the browser first.
How authentication works
Credentials are stored using a layered system (checked in order):
- Environment variable (
MFP_COOKIES) - for CI/testing - System keyring - macOS Keychain, GNOME Keyring, etc.
- Encrypted file -
~/.config/myfitnesspal-mcp/credentials.enc
The encrypted file uses AES-256-GCM with a key derived via PBKDF2-HMAC-SHA256 (600,000 iterations) bound to machine-specific identifiers. File permissions are set to 600 (owner-only).
Cookie values are never logged, never included in error messages, and never returned to Claude. Multiple layers of defence prevent accidental leakage:
repr=Falseon all cookie fields- Custom
__repr__implementations that mask values - Result sanitisation before returning tool responses
Architecture
src/mfp_mcp/
├── cli.py # CLI entry point
├── server.py # stdio MCP server, tool registration
├── auth/
│ ├── storage.py # Unified credential storage (env → keyring → file)
│ ├── keyring.py # System keyring backend
│ ├── encrypted.py # AES-256-GCM file backend
│ ├── browser.py # Browser cookie extraction
│ └── validator.py # Cookie validation via NextAuth session
├── client/
│ ├── mfp.py # Async wrapper around myfitnesspal library
│ └── models.py # Pydantic response models
└── tools/
├── _validation.py # Pydantic input validation
├── diary.py # mfp_get_diary
├── nutrition.py # mfp_get_nutrition_summary
├── goals.py # mfp_get_goals
├── measurements.py # mfp_get_measurements
├── food.py # mfp_search_food, mfp_get_food_details
├── profile.py # mfp_get_profile
├── auth_status.py # mfp_auth_status
└── refresh_auth.py # mfp_refresh_auth
Technical notes
MFP WAF workaround
The upstream myfitnesspal library's __init__ hits /user/auth_token which MFP's WAF now blocks (HTTP 403). This server works around the issue by:
- Creating the library's
Clientobject without calling__init__(viaobject.__new__()) - Setting up the HTTP session manually with plain
requests(cloudscraper also gets blocked) - Getting the username from MFP's NextAuth session endpoint (
/api/auth/session) - The HTML scraping methods (
get_date,get_measurements) continue to work normally
Rate limiting
Requests to MFP are throttled to one every 500ms with a lock to prevent concurrent requests. This is conservative to avoid triggering MFP's rate limits.
Development
# Install with dev dependencies
uv sync --extra dev --extra browser
# Run tests
pytest
# Lint
ruff check src/ tests/
Requirements
- Python 3.12+
- A MyFitnessPal account with an active browser session
- uv for dependency management
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。