@trainheroic-unofficial/athlete-mcp 3.4.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/server.mjs +83 -7
  2. package/package.json +3 -3
package/dist/server.mjs CHANGED
@@ -271,6 +271,15 @@ const athleteWorkoutNoteObject = z.object({
271
271
  rpe: z.number().int().min(1).max(10).optional()
272
272
  });
273
273
  const athleteWorkoutNoteArgsSchema = athleteWorkoutNoteObject.refine((v) => v.notes !== void 0 || v.rpe !== void 0, { message: "Provide notes and/or rpe" });
274
+ /**
275
+ * Args for the athlete per-exercise note write (the "Add exercise note" box on the exercise
276
+ * screen — band color, etc.). `savedWorkoutSetExerciseId` is the slot id from athlete_log_targets.
277
+ * Empty `notes` clears the note. Distinct from {@link athleteWorkoutNoteArgsSchema} (session note).
278
+ */
279
+ const athleteExerciseNoteArgsSchema = z.object({
280
+ savedWorkoutSetExerciseId: idArgSchema,
281
+ notes: z.string()
282
+ });
274
283
  const presentedNullNumber = z.number().nullable();
275
284
  const presentedNullString = z.string().nullable();
276
285
  /** Flattened exercise within a presented workout: prescriptions, logged results, units. */
@@ -278,6 +287,7 @@ const athleteWorkoutExerciseSchema = z.object({
278
287
  exerciseId: presentedNullNumber,
279
288
  title: z.string(),
280
289
  instruction: presentedNullString,
290
+ notes: presentedNullString,
281
291
  units: z.array(presentedNullString),
282
292
  prescribed: z.array(z.string()),
283
293
  performed: z.array(z.string())
@@ -387,6 +397,7 @@ z.array(rosterActivityRowSchema);
387
397
  const presentedExerciseSessionSchema = z.object({
388
398
  date: z.string(),
389
399
  abr: presentedNullString,
400
+ notes: presentedNullString,
390
401
  estimated1RM: presentedNullNumber,
391
402
  sets: z.array(z.object({
392
403
  setNumber: z.number(),
@@ -523,6 +534,7 @@ const logSetTargetOutputSchema = z.object({
523
534
  savedWorkoutSetExerciseId: z.number(),
524
535
  title: z.string(),
525
536
  units: z.array(nullableString),
537
+ notes: nullableString,
526
538
  prescribed: z.array(z.string()),
527
539
  performed: z.array(z.string())
528
540
  }))
@@ -597,6 +609,10 @@ const athleteWorkoutNoteOutputSchema = z.object({
597
609
  notes: z.string(),
598
610
  rpe: nullableNumber
599
611
  });
612
+ const athleteExerciseNoteOutputSchema = z.object({
613
+ savedWorkoutSetExerciseId: z.number(),
614
+ notes: z.string()
615
+ });
600
616
  const workoutReadExerciseOutputSchema = z.object({
601
617
  order: z.number(),
602
618
  title: z.string(),
@@ -1397,6 +1413,16 @@ function performedSlotsByExerciseId(sets) {
1397
1413
  }
1398
1414
  return map;
1399
1415
  }
1416
+ /** Per-exercise athlete notes keyed by the prescription template id (`workout_set_exercise_id`). */
1417
+ function notesByTemplateId(sets) {
1418
+ const map = /* @__PURE__ */ new Map();
1419
+ for (const { exercises } of sets) for (const ex of exercises) {
1420
+ const id = coerceInt(ex.workout_set_exercise_id);
1421
+ const notes = str(ex.notes);
1422
+ if (id !== null && notes !== null) map.set(id, notes);
1423
+ }
1424
+ return map;
1425
+ }
1400
1426
  /** Align an exercise's prescribed slots with the slots the athlete logged, per set index. */
1401
1427
  function mergeExercise(prescribed, performed, meta) {
1402
1428
  const indices = [.../* @__PURE__ */ new Set([...prescribed.keys(), ...performed.keys()])].sort((a, b) => a - b);
@@ -1410,7 +1436,7 @@ function mergeExercise(prescribed, performed, meta) {
1410
1436
  };
1411
1437
  }
1412
1438
  /** A prescription block, each exercise aligned with the slots the athlete logged against it. */
1413
- function mergePrescriptionBlock(set, performedById) {
1439
+ function mergePrescriptionBlock(set, performedById, notesById) {
1414
1440
  const exercises = Array.isArray(set.workoutSetExercises) ? set.workoutSetExercises : [];
1415
1441
  return {
1416
1442
  order: coerceInt(set.order) ?? 0,
@@ -1424,6 +1450,7 @@ function mergePrescriptionBlock(set, performedById) {
1424
1450
  exerciseId: coerceInt(ex.exercise_id),
1425
1451
  title: typeof ex.title === "string" ? ex.title : "",
1426
1452
  instruction: str(ex.instruction),
1453
+ notes: id !== null ? notesById.get(id) ?? null : null,
1427
1454
  units: exerciseUnits(ex.param_1_type, ex.param_2_type)
1428
1455
  });
1429
1456
  })
@@ -1440,6 +1467,7 @@ function mergeSavedBlock(set, exercises) {
1440
1467
  exerciseId: coerceInt(ex.exercise_id),
1441
1468
  title: typeof ex.exercise_title === "string" ? ex.exercise_title : "",
1442
1469
  instruction: str(ex.instruction),
1470
+ notes: str(ex.notes),
1443
1471
  units: exerciseUnits(ex.param_1_type, ex.param_2_type)
1444
1472
  }))
1445
1473
  };
@@ -1458,7 +1486,8 @@ function mergeAthleteWorkout(raw) {
1458
1486
  const prescriptionSets = (Array.isArray(workout.workoutSets) ? workout.workoutSets : []).filter(isRecord);
1459
1487
  const logged = savedSets(saved);
1460
1488
  const performedById = performedSlotsByExerciseId(logged);
1461
- const blocks = prescriptionSets.map((s) => mergePrescriptionBlock(s, performedById)).sort((a, b) => a.order - b.order);
1489
+ const notesById = notesByTemplateId(logged);
1490
+ const blocks = prescriptionSets.map((s) => mergePrescriptionBlock(s, performedById, notesById)).sort((a, b) => a.order - b.order);
1462
1491
  const prescribedIds = /* @__PURE__ */ new Set();
1463
1492
  for (const s of prescriptionSets) {
1464
1493
  const exs = Array.isArray(s.workoutSetExercises) ? s.workoutSetExercises : [];
@@ -1504,6 +1533,7 @@ function toStringExercise(ex) {
1504
1533
  exerciseId: ex.exerciseId,
1505
1534
  title: ex.title,
1506
1535
  instruction: ex.instruction,
1536
+ notes: ex.notes,
1507
1537
  units: ex.units,
1508
1538
  prescribed: sideStrings(ex.sets, (s) => s.prescribed),
1509
1539
  performed: sideStrings(ex.sets, (s) => s.performed)
@@ -1598,6 +1628,7 @@ function presentLogTargets(list) {
1598
1628
  savedWorkoutSetExerciseId: id,
1599
1629
  title: exerciseTitle(ex),
1600
1630
  units: exerciseUnits(ex.param_1_type, ex.param_2_type),
1631
+ notes: str(ex.notes),
1601
1632
  prescribed: prescribedStrings(ex),
1602
1633
  performed: performedStrings(ex)
1603
1634
  };
@@ -1665,6 +1696,7 @@ function presentExerciseHistory(detail) {
1665
1696
  sessions: (detail.history ?? []).map((h) => ({
1666
1697
  date: h.dateCompleted,
1667
1698
  abr: h.abr ?? null,
1699
+ notes: str(h.notes),
1668
1700
  estimated1RM: h.bestEstimated1RM ?? null,
1669
1701
  sets: (h.sets ?? []).map((s) => ({
1670
1702
  setNumber: s.setNumber,
@@ -2253,6 +2285,28 @@ async function setAthleteWorkoutNote(client, args) {
2253
2285
  };
2254
2286
  }
2255
2287
  //#endregion
2288
+ //#region ../js/src/athlete-exercise-note.ts
2289
+ /**
2290
+ * PUT /1.0/athlete/savedworkoutsetexercise/{id} — set the athlete's per-exercise note (the
2291
+ * "Add exercise note" box on the exercise screen). A notes-only body leaves logged reps/weight
2292
+ * untouched. Empty `notes` clears the note. GET on that path 405s; the range read and exercise
2293
+ * history both echo the stored string. Coach-visible.
2294
+ */
2295
+ async function setAthleteExerciseNote(client, args) {
2296
+ const savedWorkoutSetExerciseId = coerceInt(args.savedWorkoutSetExerciseId);
2297
+ if (savedWorkoutSetExerciseId === null) throw new Error(`Invalid savedWorkoutSetExerciseId ${String(args.savedWorkoutSetExerciseId)}.`);
2298
+ const res = await client.request("PUT", `/1.0/athlete/savedworkoutsetexercise/${savedWorkoutSetExerciseId}`, { body: {
2299
+ id: savedWorkoutSetExerciseId,
2300
+ notes: args.notes
2301
+ } });
2302
+ if (!res.ok) throw new Error(`Set exercise note failed (HTTP ${res.status}).`);
2303
+ const data = isRecord(res.data) ? res.data : {};
2304
+ return {
2305
+ savedWorkoutSetExerciseId,
2306
+ notes: typeof data.notes === "string" ? data.notes : args.notes
2307
+ };
2308
+ }
2309
+ //#endregion
2256
2310
  //#region ../core/src/history.ts
2257
2311
  /**
2258
2312
  * Trim a presented exercise history's session time-series to an inclusive YYYY-MM-DD window.
@@ -2332,9 +2386,9 @@ function registerProfileTools(server, ctx, whoami, userId) {
2332
2386
  return jsonResult(await fetchLeaderboard(ctx.client, toId(workoutId), opts));
2333
2387
  }));
2334
2388
  }
2335
- const ATHLETE_WORKOUTS_DESC = "Workouts on the AUTHENTICATED user's own athlete calendar in an inclusive YYYY-MM-DD window, flattened to blocks/exercises. When a coach account calls this, it returns the coach's own training schedule — not a roster athlete's. To inspect a roster athlete use athlete_saved_workouts (or athlete_training for a month overview); to verify a coach-published team session from the calendar side use workout_read. Each exercise carries both its `prescribed` sets (what the program called for) and `performed` sets (what the athlete actually logged); each workout has a top-level `logged` flag. Session `notes` and `rpe` are the athlete's own note/RPE on that workout (null when unset), distinct from coach `instruction`. Use `performed`/`logged` to tell what was recorded or done. That is the reliable signal: a session can hold logged sets while the API's own completion flags stay 0, and an empty `performed` means nothing was logged for that exercise. For 'did I record anything / what did I do', set loggedOnly:true to return only sessions with logged sets (it keeps whole sessions that have any logged set, so individual exercises inside can still show empty `performed`; it also shrinks a large result); limit returns the most recent N workouts (newest first). For a high-level overview ('what's on my schedule this week', 'what have I been training lately') set summary:true to get one compact row per session (date, program, title, logged flag, and exerciseCount/performedCount — read performedCount against exerciseCount, e.g. 1 of 12 logged) instead of every set — a multi-program week of full detail is large, so prefer summary first, then re-query a single day without it to drill into that day's sets. For 'what's my next workout', query a forward window from today; if it comes back empty, the most recent session is likely yesterday's still-unlogged one, so widen the window backward a day or two. Both filters apply to the presented view, not raw. raw:true returns the untouched API objects. This is a date-windowed fetch, NOT an aggregate: for lifetime totals (all-time session count, total volume, first/last logged date) call athlete_profile instead of summing windows — a multi-year range here can time out. Narrow the window if the result is truncated.";
2336
- const ATHLETE_LOG_TARGETS_DESC = "The savedWorkoutSetId + savedWorkoutSetExerciseId that athlete_log_set needs, read straight off your scheduled/logged workouts in an inclusive YYYY-MM-DD window — no raw needed. This is the self-service path for logging into a COACH-SCHEDULED workout: read the ids here, then pass them to athlete_log_set. The default view is COMPACT: one row per saved set, each carrying its program/programId, the savedWorkoutSetId, and every exercise's savedWorkoutSetExerciseId with prescribed/performed values. When several workouts fall on the same day (you're on more than one program), narrow to one with program (a case-insensitive title substring, e.g. 'bodybuilding' — no id lookup needed), or programId/teamId if you have the id. raw:true returns the untouched API objects, but that blob is large and can be truncated when several workouts share a date — prefer the program filter + the default view. For reading what you actually did (not the log ids), use athlete_workouts.";
2337
- const ATHLETE_EXERCISE_HISTORY_DESC = "Per-exercise PRs and the dated session time-series (sets performed, estimated 1RM). The returned `sessions` run all-time, newest first; pass since/until (YYYY-MM-DD, inclusive) to keep only sessions in that window — use it for 'last 3 months' / 'this year' questions so the result stays small. estimated1RM is a formula off the session's best set and reads high when a session mixes a heavy single with high-rep backdown work, so treat it as approximate, not a logged single. `liftPRs` are always all-time and ignore since/until, but each carries the date it was set, so filter those dates yourself to answer 'PRs set this year'. Set raw:true for the untouched API object. Get the exercise id from athlete_exercises.";
2389
+ const ATHLETE_WORKOUTS_DESC = "Workouts on the AUTHENTICATED user's own athlete calendar in an inclusive YYYY-MM-DD window, flattened to blocks/exercises. When a coach account calls this, it returns the coach's own training schedule — not a roster athlete's. To inspect a roster athlete use athlete_saved_workouts (or athlete_training for a month overview); to verify a coach-published team session from the calendar side use workout_read. Each exercise carries both its `prescribed` sets (what the program called for) and `performed` sets (what the athlete actually logged); each workout has a top-level `logged` flag. Session `notes` and `rpe` are the athlete's own note/RPE on that workout (null when unset), distinct from coach `instruction`. Each exercise may also carry `notes` (the per-exercise box on the exercise screen; null when unset). Use `performed`/`logged` to tell what was recorded or done. That is the reliable signal: a session can hold logged sets while the API's own completion flags stay 0, and an empty `performed` means nothing was logged for that exercise. For 'did I record anything / what did I do', set loggedOnly:true to return only sessions with logged sets (it keeps whole sessions that have any logged set, so individual exercises inside can still show empty `performed`; it also shrinks a large result); limit returns the most recent N workouts (newest first). For a high-level overview ('what's on my schedule this week', 'what have I been training lately') set summary:true to get one compact row per session (date, program, title, logged flag, and exerciseCount/performedCount — read performedCount against exerciseCount, e.g. 1 of 12 logged) instead of every set — a multi-program week of full detail is large, so prefer summary first, then re-query a single day without it to drill into that day's sets. For 'what's my next workout', query a forward window from today; if it comes back empty, the most recent session is likely yesterday's still-unlogged one, so widen the window backward a day or two. Both filters apply to the presented view, not raw. raw:true returns the untouched API objects. This is a date-windowed fetch, NOT an aggregate: for lifetime totals (all-time session count, total volume, first/last logged date) call athlete_profile instead of summing windows — a multi-year range here can time out. Narrow the window if the result is truncated.";
2390
+ const ATHLETE_LOG_TARGETS_DESC = "The savedWorkoutSetId + savedWorkoutSetExerciseId that athlete_log_set needs, read straight off your scheduled/logged workouts in an inclusive YYYY-MM-DD window — no raw needed. This is the self-service path for logging into a COACH-SCHEDULED workout: read the ids here, then pass them to athlete_log_set. The default view is COMPACT: one row per saved set, each carrying its program/programId, the savedWorkoutSetId, and every exercise's savedWorkoutSetExerciseId with prescribed/performed values and any per-exercise `notes`. When several workouts fall on the same day (you're on more than one program), narrow to one with program (a case-insensitive title substring, e.g. 'bodybuilding' — no id lookup needed), or programId/teamId if you have the id. raw:true returns the untouched API objects, but that blob is large and can be truncated when several workouts share a date — prefer the program filter + the default view. For reading what you actually did (not the log ids), use athlete_workouts.";
2391
+ const ATHLETE_EXERCISE_HISTORY_DESC = "Per-exercise PRs and the dated session time-series (sets performed, estimated 1RM). The returned `sessions` run all-time, newest first; pass since/until (YYYY-MM-DD, inclusive) to keep only sessions in that window — use it for 'last 3 months' / 'this year' questions so the result stays small. estimated1RM is a formula off the session's best set and reads high when a session mixes a heavy single with high-rep backdown work, so treat it as approximate, not a logged single. Each session may carry `notes` (the per-exercise athlete note). `liftPRs` are always all-time and ignore since/until, but each carries the date it was set, so filter those dates yourself to answer 'PRs set this year'. Set raw:true for the untouched API object. Get the exercise id from athlete_exercises.";
2338
2392
  const ATHLETE_EXERCISES_DESC = "The exercises the athlete has logged (id + title + positional units). Call with no arguments to get the athlete's complete catalog, which often runs to several hundred entries; leave limit off when you want the whole list, since a no-q call returns everything by default. Pass q to free-text search by name (returns the top ranked matches, capped by limit, default 20). Use a returned id with athlete_exercise_history, athlete_personal_records, or athlete_exercise_stats (all of which require an exercise id). If a no-q result comes back wrapped with a __truncated marker, you passed a limit smaller than the catalog and are seeing a partial list; re-call without limit for all of it. A common name returns several variants (e.g. plain 'Bench Press' id 1162 vs 'BARBELL BENCH PRESS'); each variant keeps its own separate history and PR board, so prefer the plain canonical entry, and if a PR or trend looks incomplete, the work may be split across variants, so check the others.";
2339
2393
  function runAthleteWorkouts(ctx, args) {
2340
2394
  return attempt(async () => {
@@ -2507,7 +2561,7 @@ function registerSessionTools(server, ctx) {
2507
2561
  function registerWorkoutNoteTool(server, ctx) {
2508
2562
  server.registerTool("athlete_workout_note", {
2509
2563
  title: "Set your session note or RPE",
2510
- description: "Athlete-facing write: set the free-text note (and/or session RPE 1–10) on a workout. This is the note box on the workout screen, not the coach's Instructions. programWorkoutId is the `id` from athlete_workouts for that date. Pass notes (empty string clears) and/or rpe; a notes-only write leaves rpe untouched and vice versa. Visible to your coach. Requires confirmation (elicitation or confirm:true).",
2564
+ description: "Athlete-facing write: set the free-text note (and/or session RPE 1–10) on a workout. This is the note box on the workout screen, not the coach's Instructions and not the per-exercise note (use athlete_exercise_note for that). programWorkoutId is the `id` from athlete_workouts for that date. Pass notes (empty string clears) and/or rpe; a notes-only write leaves rpe untouched and vice versa. Visible to your coach. Requires confirmation (elicitation or confirm:true).",
2511
2565
  inputSchema: {
2512
2566
  ...athleteWorkoutNoteObject.shape,
2513
2567
  confirm: z.boolean().optional()
@@ -2526,6 +2580,27 @@ function registerWorkoutNoteTool(server, ctx) {
2526
2580
  return jsonResult(await setAthleteWorkoutNote(ctx.client, patch));
2527
2581
  }));
2528
2582
  }
2583
+ /** Set the athlete's per-exercise note on a saved slot (coach-visible). */
2584
+ function registerExerciseNoteTool(server, ctx) {
2585
+ server.registerTool("athlete_exercise_note", {
2586
+ title: "Set a per-exercise note",
2587
+ description: "Athlete-facing write: set the free-text note on one exercise in a workout (the 'Add exercise note' box on the exercise screen). Use this for things the weight field cannot hold, such as which band you used. Distinct from athlete_workout_note, which writes the session-level note. savedWorkoutSetExerciseId is the slot id from athlete_log_targets. Empty notes clears the note. Visible to your coach. Requires confirmation (elicitation or confirm:true).",
2588
+ inputSchema: {
2589
+ ...athleteExerciseNoteArgsSchema.shape,
2590
+ confirm: z.boolean().optional()
2591
+ },
2592
+ outputSchema: toolOutputSchema(athleteExerciseNoteOutputSchema),
2593
+ annotations: DESTRUCTIVE
2594
+ }, ({ savedWorkoutSetExerciseId, notes, confirm }, extra) => attempt(async () => {
2595
+ const patch = athleteExerciseNoteArgsSchema.parse({
2596
+ savedWorkoutSetExerciseId,
2597
+ notes
2598
+ });
2599
+ const blocked = confirmGate(extra, `Set the exercise note on slot ${toId(patch.savedWorkoutSetExerciseId)}? This is visible to your coach.`, confirm);
2600
+ if (blocked) return blocked;
2601
+ return jsonResult(await setAthleteExerciseNote(ctx.client, patch));
2602
+ }));
2603
+ }
2529
2604
  /** Map validated logSession exercises to the SDK's SessionExercise[] (ids coerced, slots trimmed). */
2530
2605
  function mapSessionExercises(exercises) {
2531
2606
  return exercises.map((e) => {
@@ -2678,12 +2753,13 @@ function registerAthleteTrainingTools(server, ctx) {
2678
2753
  registerLogTargetsTool(server, ctx);
2679
2754
  registerSessionTools(server, ctx);
2680
2755
  registerWorkoutNoteTool(server, ctx);
2756
+ registerExerciseNoteTool(server, ctx);
2681
2757
  registerLogTool(server, ctx);
2682
2758
  registerSwapTool(server, ctx);
2683
2759
  }
2684
2760
  //#endregion
2685
2761
  //#region package.json
2686
- var version = "3.4.0";
2762
+ var version = "3.5.0";
2687
2763
  //#endregion
2688
2764
  //#region src/server.ts
2689
2765
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trainheroic-unofficial/athlete-mcp",
3
- "version": "3.4.0",
3
+ "version": "3.5.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,8 +21,8 @@
21
21
  "dependencies": {
22
22
  "@modelcontextprotocol/server": "2.0.0",
23
23
  "zod": "^4.4.3",
24
- "@trainheroic-unofficial/core": "3.4.0",
25
- "@trainheroic-unofficial/js": "3.4.0"
24
+ "@trainheroic-unofficial/core": "3.5.0",
25
+ "@trainheroic-unofficial/js": "3.5.0"
26
26
  },
27
27
  "devDependencies": {
28
28
  "@types/node": "^26.3.0",