Add legacy MCP tools for recent and saved food collections#1
Open
tomerh2001 wants to merge 1 commit into
Open
Conversation
Owner
|
~1,000 lines of new logic covering HTML parsing, write operations, and entry ID matching with no tests. The PR description mentions manual verification against a live session, which is great for smoke testing, but I'd like to see at least unit tests for the pure functions before merging:
These don't need a live MFP session and would catch regressions if MFP changes their HTML structure. |
Owner
|
Thanks for the contribution — the code quality here is solid. The A few things I'd like addressed before approving:
Happy to re-review once those are addressed. |
sgrimbly
added a commit
to sgrimbly/myfitnesspal-mcp-python
that referenced
this pull request
Jun 8, 2026
Port the legacy add-page AJAX collections (PR AdamWalt#1 by tomerh2001, adapted): - mfp_get_recent_foods, mfp_get_frequent_foods, mfp_get_my_foods - Fetch via POST /food/load_{recent,most_used,my_foods} with meal/base_index/ page params; these endpoints require X-Requested-With plus the page csrf-token meta as X-CSRF-Token (without the params the server returns 406). - Parse the favorite rows into {name, food_id, default_serving, weight_id}. food_id is the classic /food/add id; My Foods are private and do not appear in mfp_search_food, so this is the only way to reach them. Also ignore .DS_Store.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why
Newer account routes such as
/food/mine,/meal/mine, and/food/newcan redirect to/account/logoutin this environment even while diary reads and authenticated API token fetches still work. That made simple account-level food list requests slow and brittle to answer manually.This change gives the MCP first-class tools for those queries and documents the non-obvious legacy path that still behaves reliably.
Notes
I attempted to create a tracking issue in the fork first to follow the normal fork flow, but GitHub Issues are disabled on this repository, so there was no issue to link.
Verification
python -m py_compile src/mfp_mcp/server.pymfp_get_recent_foods,mfp_get_frequent_foods, andmfp_get_my_foodslocally against a live authenticated session