Skip to main content
Glama
thesaaspreneur

MyFitnessPal MCP

README.md
# MyFitnessPal MCP

A [Model Context Protocol](https://modelcontextprotocol.io) server that lets Claude (or any MCP client) **read and write your MyFitnessPal account** — food diary, custom foods, saved meals, recipes, exercise, measurements, water, and nutrition goals.

MyFitnessPal has no public API, so this drives the same private endpoints its own web and mobile apps use, authenticated with your existing browser session (no password stored). **33 tools**, covering the full create/read/update/delete surface — not just logging.

> **Credit where it's due.** This builds on [**@AdamWalt/myfitnesspal-mcp-python**](https://github.com/AdamWalt/myfitnesspal-mcp-python) (MIT), whose browser-cookie + macOS-Keychain authentication is the foundation everything here stands on. This project keeps that foundation, fixes a couple of its stated limitations (MyFitnessPal *does* support editing foods in place), and adds a large set of new capabilities. Thank you, Adam.

---

## What you can do

| Area | Capabilities | Tools |
|---|---|---|
| **Food diary** | read a day, add, **edit an entry**, remove, **bulk-log across many days** | `mfp_get_diary`, `mfp_add_food_to_diary`, `mfp_remove_food_from_diary`, `mfp_bulk_log` |
| **Foods** | search, details, create custom, **edit in place**, delete, list your own | `mfp_search_food`, `mfp_get_food_details`, `mfp_create_custom_food`, `mfp_edit_food`, `mfp_delete_custom_food`, `mfp_list_own_foods` |
| **Saved meals** | list, **create** from foods, **log to the diary**, delete | `mfp_list_meals`, `mfp_create_meal`, `mfp_log_meal`, `mfp_delete_meal` |
| **Recipes** | **create** a multi-ingredient recipe with computed per-portion nutrition | `mfp_create_recipe` |
| **Exercise** | read, **search the database**, **log**, delete a day's entries | `mfp_get_exercises`, `mfp_search_exercises`, `mfp_log_exercise`, `mfp_delete_exercises` |
| **Goals** | read, set the 4 macros, **or set deep per-nutrient goals** | `mfp_get_goals`, `mfp_set_goals`, `mfp_set_nutrient_goals` |
| **Diary settings** | **choose tracked nutrients** (e.g. show Fiber), **rename meal slots** | `mfp_set_tracked_nutrients`, `mfp_rename_meals` |
| **Measurements** | read weight/body history, log a measurement | `mfp_get_measurements`, `mfp_set_measurement` |
| **Water** | read, set | `mfp_get_water`, `mfp_set_water` |
| **Fasting** | log, update, delete a fasting window | `mfp_log_fast`, `mfp_update_fast`, `mfp_delete_fast` |
| **Reports** | nutrition trends over a date range | `mfp_get_report` |

**Bold** items are additions over the original project.

### Stability tiers

Each write tool is labelled in its docstring:

- **`[stable]`** — rides MyFitnessPal's structured JSON APIs (food editing, nutrient goals, diary settings, diary entries). These have consistent request/response shapes.
- **`[legacy]`** — uses MyFitnessPal's older server-rendered flows (saved-meal "Remember a Meal", exercise search-and-add). These work today but are more likely to change if MyFitnessPal retires its classic site.

---

## Install

Requires **Python 3.10–3.12** (an upstream dependency, `lxml`, has no wheels for 3.13+ yet).

```bash
git clone https://github.com/thesaaspreneur/myfitnesspal-mcp
cd myfitnesspal-mcp
python3.12 -m venv .venv && source .venv/bin/activate
pip install -e .
```

## Authentication

There is **no password to configure**. Log in to MyFitnessPal in any Chromium-based browser — **Chrome, Arc, Edge, Brave, Vivaldi, Opera, or Dia** — and the server discovers your session automatically on macOS via each browser's Keychain "Safe Storage" entry. On first use, macOS shows a one-time prompt ("… wants to use your keychain"); click **Always Allow**. Sessions are cached to `~/.mfp_mcp/cookies.json` and last ~30 days.

> **Safari is not supported** — macOS blocks other apps from reading Safari's cookies. Use a Chromium browser.

## Use with Claude Desktop

Add to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "myfitnesspal": {
      "command": "/absolute/path/to/myfitnesspal-mcp/.venv/bin/python",
      "args": ["-m", "mfp_mcp.server"]
    }
  }
}
```

Restart Claude Desktop, then try: *"What did I log for lunch yesterday?"* or *"Create a recipe called Overnight Oats from 80g oats, 200g milk, and 15g honey, 2 portions."*

---

## Design

```
src/mfp_mcp/
├── server.py         # MCP tool definitions (auth, base tools, and the extended tools)
└── capabilities.py   # the extended capability logic, reverse-engineered from MFP's
                      #   web + legacy apps and verified with live create/edit/delete cycles
```

`capabilities.py` is a plain Python module you can import and call directly, independent of MCP.

## A note on the unofficial API

MyFitnessPal does not publish an API, and this tool uses private endpoints intended for their own clients. It's meant for **managing your own account** — the same actions you could take by hand in the app. Automating a third-party service may be contrary to its Terms of Service; use it thoughtfully, at your own risk, and don't hammer their servers. No credentials leave your machine.

## Contributing

Issues and PRs welcome. The food-in-place-edit fix here is also being offered back upstream to the original project.

## License

MIT — see [LICENSE](LICENSE). Original work © Adam; extended capabilities © thesaaspreneur.

TDQS

A3.6/5.0

Scored across 33 tools

Disambiguation4/5

Most tools target distinct resources (diary, foods, meals, exercises, water, measurements, goals, fasting), and descriptions are detailed enough to prevent confusion. A few near-boundary pairs exist—mfp_set_goals vs mfp_set_nutrient_goals and mfp_create_meal vs mfp_create_recipe vs mfp_create_custom_food—but their descriptions clarify the differences.

Naming Consistency4/5

The overwhelming majority follow the mfp_verb_noun pattern with clear verbs like get, set, create, delete, log, and search. Minor deviations include refresh_browser_cookies (no mfp_ prefix) and bulkier constructions like mfp_add_food_to_diary / mfp_remove_food_from_diary and the slightly odd mfp_bulk_log, but the overall pattern remains predictable.

Tool Count2/5

At 33 tools, this server exceeds the 25+ threshold that indicates a bloated surface, even for a broad fitness-tracking domain. The toolset covers many features, but the count is heavy and includes legacy-tagged tools, settings tweaks, and maintenance operations that could likely be consolidated.

Completeness4/5

The server offers unusually deep coverage: diary CRUD, custom food CRUD, meals, recipes, exercises, water, measurements, goals, and fasting. Minor gaps exist—diary entries can be added/removed but not updated in place, and fasting entries cannot be listed—but agents can work around these in most workflows.

Maintenance

ActivityMaintained
ResponsivenessNo issues