Repository navigation
fix(mcp): the read tools answer the question that was asked - #355
Merged
Merged
Conversation
Seven places where an MCP answer was confidently wrong. - "What are my PRs?": estimate_1rm's PR table scanned the rows itself with the rule from before DuarteSantos8#212. A one-arm set is one row carrying both sides, so its `r` is L+R; 8+8 reps read as 16, over the 12-rep cap, and a dumbbell curl had a 1RM and no line in the table. An assistance machine, which the app keeps out of every estimate (DuarteSantos8#232), was listed. prTable now asks bestSetOf per entry, as the per-exercise answer does. - "How many workouts in March?": list_workouts' total_count is all-time and the list stops at 25 without saying so. New matching_count (in the from/to range) and truncated. total_count keeps its meaning. - A made-up exercise_id read "No completed sets logged for this exercise", because exOr's miss is a placeholder, not null. It now says no exercise with that id exists and sets exercise.unknown. A deleted custom with logged sets keeps the real answer. An empty exercise_id, which fell through to the whole PR table, is now invalid params. - 2026-02-30 passed the date regex and new Date() rolled it to March 2, so preview_session answered for March 2 while echoing February 30. Every date argument now has to round-trip through the calendar, so an impossible date is a -32602 before any handler runs. - `to` is documented as "Defaults to today" in list_workouts and get_bodyweight and had no default. A row dated in the future (another device with a wrong clock) was listed first and became `latest`. - muscle_balance's "last 7 days" was an instant 7x24h back. A workout with no clock (an import, a hand-added session) counts at local noon, so the week covered 8 dates and the month 31. The window is now whole local days counting today: 7 dates, and 30. - Its cutoff_iso was toISOString(), a UTC date: a day off from the date the filter used in the evening west of Greenwich and in the morning east of it. It is a local date now, like every other date in the API. 11 new tests in mcp/test/tools.test.js (now 74). 10 fail against the old tools.js; the eleventh checks a real leap day still gets through. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Owner
|
Merged and released in v1.3.10, thanks @kurktchiev! https://github.com/DuarteSantos8/openGym/releases/tag/v1.3.10 |
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.
Seven places where an MCP answer was wrong and gave no sign of it. All in mcp/src/tools.js.
"What are my PRs?"
prTablescanned the rows itself with the rule from before #212. A one-armset is one row carrying both sides, so its
ris L+R. A dumbbell curl logged 8+8 read as 16 reps,over the 12-rep cap, and got no estimate. A row with one side still unchecked was not
done, thoughthe finished side is completed work. So the exercise had a 1RM in the per-exercise answer and no
line in the table. The table also listed assistance machines, which the app keeps out of every
estimate (#232).
prTablenow callsbestSetOfper entry, the same reading the per-exercise answerand the app use.
"How many workouts in March?"
list_workoutsreturnstotal_count, which is all-time andcounted before the from/to filter, and a list cut at 25 with nothing saying so. 25 rows and a total
of 340 say nothing about the 40 in March. New fields:
matching_count(in the range asked for) andtruncated.total_countkeeps its meaning.A made-up exercise id read as "never trained".
exOr's miss is a placeholder, not null, so atypo'd
exercise_idgot "No completed sets logged for this exercise". It now says no exercise withthat id exists and sets
exercise.unknown. A deleted custom exercise with logged sets keeps the realanswer. An empty
exercise_idfell through to the whole PR table; it is now rejected as invalidparams.
2026-02-30 was answered as March 2. The date regex let it through and
new Date()rolled itover, so
preview_sessionanswered for March 2 while echoing "2026-02-30" back. Every date argument(
list_workouts,get_workout,get_bodyweight,preview_session) now has to round-trip throughthe calendar, so an impossible date is a -32602 before any handler runs. 2024-02-29 passes,
2025-02-29 does not.
tohad no default.list_workoutsandget_bodyweightdocument it as "Defaults to today". Arow dated in the future (another device with a wrong clock) was listed first as the newest session
and became
latestin the body-weight summary. It now falls back to the local today; asking for afuture range explicitly still returns the row.
"Last 7 days" covered 8 dates.
muscle_balancecut off at an instant 7×24 h back. A workoutwith no clock (an import, a hand-added session) counts at local noon, so noon seven days ago was
still inside the window: 8 dates for a week, 31 for a month. The window is now whole local days
counting today, 7 and 30.
Its
cutoff_isowas a UTC date.toISOString().slice(0, 10)gave a date a day off from the onethe filter used, in the evening west of Greenwich and in the morning east of it. It is local now,
like every other date the API reports.
11 new tests in mcp/test/tools.test.js, which now has 74, all passing. 10 of the 11 fail against the
old tools.js; the eleventh checks that real dates, including a leap day, still get through. The
date and empty-id tests drive the real
McpServerover an in-memory transport, because what theytest is what zod does before a handler runs. The cutoff test runs in Asia/Tokyo, where the UTC and
local dates differ.
check:node-loadableis clean.Overlaps:
bestSetOfover its exposures) and conflicts with thisin five places in tools.js and two in tools.test.js. Whichever lands second needs a rebase.
its write tools take (
isoDatein mcp/src/write-tools.js); the two could share one.🤖 Generated with Claude Code