Skip to content

Open-source gym & body-weight tracker, now in the App Store (iPhone + Apple Watch) and as an Android APK. Plan routines, log workouts, see which muscles are trained, import from Strong/Hevy/FitNotes. Self-host it or use it on the phone alone.

MCP: get_routine reports a pyramid's planned weight per set (#445)

Duarte Santosab65a9ebfa9d
diff --git a/mcp/src/tools.js b/mcp/src/tools.js
index 6b014b03c..c087bc947 100644
--- a/mcp/src/tools.js
+++ b/mcp/src/tools.js
@@ -122,7 +122,7 @@ export const listRoutines = {
/** get_routine — the full exercise list for one routine, including set/rep targets. */
export const getRoutine = {
name: 'get_routine',
- description: 'Get the full exercise list for a single routine (the same view the routine editor shows). Returns mode (reps/time/cardio), set/rep/weight targets (a `pyramid` list of per-set rep targets, \'max\' meaning as many reps as possible, when the exercise uses pyramid sets), superset links, any per-exercise custom increment or Epley deload factor, and each exercise\'s own rest in seconds (absent means it inherits the global rest timer). Use routine_id from list_routines.',
+ description: 'Get the full exercise list for a single routine (the same view the routine editor shows). Returns mode (reps/time/cardio), set/rep/weight targets (a `pyramid` list of per-set rep targets, \'max\' meaning as many reps as possible, when the exercise uses pyramid sets, with `pyramid_rest_sec` and `pyramid_weight` per set where planned, 0 meaning the exercise\'s rest or last time\'s weight), superset links, any per-exercise custom increment or Epley deload factor, and each exercise\'s own rest in seconds (absent means it inherits the global rest timer). Use routine_id from list_routines.',
schema: { routine_id: z.string().min(1) },
handler: ({ routine_id }) => {
const S = getState()
@@ -154,6 +154,8 @@ export const getRoutine = {
pyramid: mode === 'reps' && Array.isArray(cfg.pyramid) && cfg.pyramid.length ? cfg.pyramid : undefined,
// Each pyramid set's own rest in seconds, 0 meaning the exercise's rest.
pyramid_rest_sec: mode === 'reps' && Array.isArray(cfg.pyramid) && cfg.pyramid.length && Array.isArray(cfg.pyramidRest) && cfg.pyramidRest.length ? cfg.pyramidRest : undefined,
+ // Each pyramid set's own planned weight (#445), 0 meaning it starts from that set last time.
+ pyramid_weight: mode === 'reps' && Array.isArray(cfg.pyramid) && cfg.pyramid.length && Array.isArray(cfg.pyramidWeight) && cfg.pyramidWeight.length ? cfg.pyramidWeight : undefined,
sec: mode === 'time' ? (cfg.sec || 0) : undefined,
min: mode === 'cardio' ? (cfg.min || 0) : undefined,
speed: mode === 'cardio' ? (cfg.speed || 0) : undefined,
diff --git a/mcp/test/tools.test.js b/mcp/test/tools.test.js
index f32c7c19d..34abba829 100644
--- a/mcp/test/tools.test.js
+++ b/mcp/test/tools.test.js
@@ -143,6 +143,15 @@ describe('get_routine', () => {
expect(r.exercises[0]).toMatchObject({ pyramid: [12, 8, 6, 'max', 12], policy: 'off', summary: '12 · 8 · 6 · Max · 12' })
})
+ test('reports a pyramid\'s planned weight per set, and leaves it out when none is planned (#445)', () => {
+ const cfg = S.routines[0].ex[0]
+ Object.assign(cfg, { mode: 'reps', sets: 3, reps: 12, weight: 0, pyramid: [12, 8, 6], pyramidWeight: [40, 0, 60] })
+ delete cfg.repsMin
+ expect(call('get_routine', { routine_id: S.routines[0].id }).exercises[0].pyramid_weight).toEqual([40, 0, 60])
+ delete cfg.pyramidWeight
+ expect(call('get_routine', { routine_id: S.routines[0].id }).exercises[0].pyramid_weight).toBeUndefined()
+ })
+
test('reports an exercise\'s own rest, and leaves it out when it inherits the timer', () => {
S.routines[0].ex[0].restSec = 180
delete S.routines[0].ex[1]?.restSec