@thebriangao/totem 1.4.4

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 (405) hide show
  1. package/.dockerignore +23 -0
  2. package/.env.example +66 -0
  3. package/CHANGELOG.md +283 -0
  4. package/CONTRIBUTING.md +149 -0
  5. package/Dockerfile +53 -0
  6. package/LICENSE +37 -0
  7. package/README.md +587 -0
  8. package/SECURITY.md +79 -0
  9. package/TOOLS.md +429 -0
  10. package/WHOOP.md +2673 -0
  11. package/assets/banner.svg +38 -0
  12. package/dist/cli/index.js +589 -0
  13. package/dist/cli/index.js.map +1 -0
  14. package/dist/cli/setup.js +1127 -0
  15. package/dist/cli/setup.js.map +1 -0
  16. package/dist/cli/ui.js +512 -0
  17. package/dist/cli/ui.js.map +1 -0
  18. package/dist/cli/update.js +465 -0
  19. package/dist/cli/update.js.map +1 -0
  20. package/dist/data/behaviors.js +2777 -0
  21. package/dist/data/behaviors.js.map +1 -0
  22. package/dist/data/endpoints.js +320 -0
  23. package/dist/data/endpoints.js.map +1 -0
  24. package/dist/data/exercises.js +4863 -0
  25. package/dist/data/exercises.js.map +1 -0
  26. package/dist/data/sports.js +212 -0
  27. package/dist/data/sports.js.map +1 -0
  28. package/dist/lib/concurrency.js +27 -0
  29. package/dist/lib/concurrency.js.map +1 -0
  30. package/dist/lib/dates.js +29 -0
  31. package/dist/lib/dates.js.map +1 -0
  32. package/dist/lib/format.js +22 -0
  33. package/dist/lib/format.js.map +1 -0
  34. package/dist/lib/stats.js +32 -0
  35. package/dist/lib/stats.js.map +1 -0
  36. package/dist/lib/timezone.js +249 -0
  37. package/dist/lib/timezone.js.map +1 -0
  38. package/dist/lib/walk.js +396 -0
  39. package/dist/lib/walk.js.map +1 -0
  40. package/dist/projections/behavior_impact.js +96 -0
  41. package/dist/projections/behavior_impact.js.map +1 -0
  42. package/dist/projections/calendar.js +33 -0
  43. package/dist/projections/calendar.js.map +1 -0
  44. package/dist/projections/communities.js +105 -0
  45. package/dist/projections/communities.js.map +1 -0
  46. package/dist/projections/cycle.js +81 -0
  47. package/dist/projections/cycle.js.map +1 -0
  48. package/dist/projections/hr_zones.js +35 -0
  49. package/dist/projections/hr_zones.js.map +1 -0
  50. package/dist/projections/journal.js +56 -0
  51. package/dist/projections/journal.js.map +1 -0
  52. package/dist/projections/leaderboard.js +37 -0
  53. package/dist/projections/leaderboard.js.map +1 -0
  54. package/dist/projections/lift_exercise.js +22 -0
  55. package/dist/projections/lift_exercise.js.map +1 -0
  56. package/dist/projections/lift_history.js +133 -0
  57. package/dist/projections/lift_history.js.map +1 -0
  58. package/dist/projections/lift_library.js +71 -0
  59. package/dist/projections/lift_library.js.map +1 -0
  60. package/dist/projections/lift_progression.js +138 -0
  61. package/dist/projections/lift_progression.js.map +1 -0
  62. package/dist/projections/lift_prs.js +20 -0
  63. package/dist/projections/lift_prs.js.map +1 -0
  64. package/dist/projections/live_hr.js +19 -0
  65. package/dist/projections/live_hr.js.map +1 -0
  66. package/dist/projections/live_state.js +23 -0
  67. package/dist/projections/live_state.js.map +1 -0
  68. package/dist/projections/live_stress.js +11 -0
  69. package/dist/projections/live_stress.js.map +1 -0
  70. package/dist/projections/performance_assessment.js +15 -0
  71. package/dist/projections/performance_assessment.js.map +1 -0
  72. package/dist/projections/profile.js +59 -0
  73. package/dist/projections/profile.js.map +1 -0
  74. package/dist/projections/recovery.js +131 -0
  75. package/dist/projections/recovery.js.map +1 -0
  76. package/dist/projections/sleep.js +256 -0
  77. package/dist/projections/sleep.js.map +1 -0
  78. package/dist/projections/sleep_need.js +32 -0
  79. package/dist/projections/sleep_need.js.map +1 -0
  80. package/dist/projections/smart_alarm.js +45 -0
  81. package/dist/projections/smart_alarm.js.map +1 -0
  82. package/dist/projections/strain.js +128 -0
  83. package/dist/projections/strain.js.map +1 -0
  84. package/dist/projections/stress.js +86 -0
  85. package/dist/projections/stress.js.map +1 -0
  86. package/dist/projections/today.js +129 -0
  87. package/dist/projections/today.js.map +1 -0
  88. package/dist/projections/trend.js +149 -0
  89. package/dist/projections/trend.js.map +1 -0
  90. package/dist/projections/workout.js +161 -0
  91. package/dist/projections/workout.js.map +1 -0
  92. package/dist/projections/workouts.js +37 -0
  93. package/dist/projections/workouts.js.map +1 -0
  94. package/dist/schemas/calendar.js +12 -0
  95. package/dist/schemas/calendar.js.map +1 -0
  96. package/dist/schemas/coach.js +11 -0
  97. package/dist/schemas/coach.js.map +1 -0
  98. package/dist/schemas/communities.js +51 -0
  99. package/dist/schemas/communities.js.map +1 -0
  100. package/dist/schemas/compare.js +15 -0
  101. package/dist/schemas/compare.js.map +1 -0
  102. package/dist/schemas/escape.js +18 -0
  103. package/dist/schemas/escape.js.map +1 -0
  104. package/dist/schemas/journal.js +69 -0
  105. package/dist/schemas/journal.js.map +1 -0
  106. package/dist/schemas/leaderboard.js +25 -0
  107. package/dist/schemas/leaderboard.js.map +1 -0
  108. package/dist/schemas/live.js +26 -0
  109. package/dist/schemas/live.js.map +1 -0
  110. package/dist/schemas/performance.js +12 -0
  111. package/dist/schemas/performance.js.map +1 -0
  112. package/dist/schemas/primitives.js +29 -0
  113. package/dist/schemas/primitives.js.map +1 -0
  114. package/dist/schemas/profile.js +39 -0
  115. package/dist/schemas/profile.js.map +1 -0
  116. package/dist/schemas/recovery.js +27 -0
  117. package/dist/schemas/recovery.js.map +1 -0
  118. package/dist/schemas/settings.js +26 -0
  119. package/dist/schemas/settings.js.map +1 -0
  120. package/dist/schemas/sleep.js +38 -0
  121. package/dist/schemas/sleep.js.map +1 -0
  122. package/dist/schemas/sleep_need.js +15 -0
  123. package/dist/schemas/sleep_need.js.map +1 -0
  124. package/dist/schemas/smart_alarm.js +36 -0
  125. package/dist/schemas/smart_alarm.js.map +1 -0
  126. package/dist/schemas/strain.js +24 -0
  127. package/dist/schemas/strain.js.map +1 -0
  128. package/dist/schemas/strength.js +170 -0
  129. package/dist/schemas/strength.js.map +1 -0
  130. package/dist/schemas/stress.js +16 -0
  131. package/dist/schemas/stress.js.map +1 -0
  132. package/dist/schemas/today.js +38 -0
  133. package/dist/schemas/today.js.map +1 -0
  134. package/dist/schemas/trend.js +50 -0
  135. package/dist/schemas/trend.js.map +1 -0
  136. package/dist/schemas/womens_health.js +23 -0
  137. package/dist/schemas/womens_health.js.map +1 -0
  138. package/dist/schemas/workouts.js +50 -0
  139. package/dist/schemas/workouts.js.map +1 -0
  140. package/dist/scripts/cognito_bootstrap.js +278 -0
  141. package/dist/scripts/cognito_bootstrap.js.map +1 -0
  142. package/dist/server-http.js +221 -0
  143. package/dist/server-http.js.map +1 -0
  144. package/dist/server.js +74 -0
  145. package/dist/server.js.map +1 -0
  146. package/dist/tools/register.js +117 -0
  147. package/dist/tools/register.js.map +1 -0
  148. package/dist/tools/v2/activity_create.js +64 -0
  149. package/dist/tools/v2/activity_create.js.map +1 -0
  150. package/dist/tools/v2/activity_delete.js +26 -0
  151. package/dist/tools/v2/activity_delete.js.map +1 -0
  152. package/dist/tools/v2/behavior_impact.js +36 -0
  153. package/dist/tools/v2/behavior_impact.js.map +1 -0
  154. package/dist/tools/v2/calendar.js +28 -0
  155. package/dist/tools/v2/calendar.js.map +1 -0
  156. package/dist/tools/v2/coach_ask.js +117 -0
  157. package/dist/tools/v2/coach_ask.js.map +1 -0
  158. package/dist/tools/v2/communities.js +60 -0
  159. package/dist/tools/v2/communities.js.map +1 -0
  160. package/dist/tools/v2/compare.js +67 -0
  161. package/dist/tools/v2/compare.js.map +1 -0
  162. package/dist/tools/v2/cycle.js +23 -0
  163. package/dist/tools/v2/cycle.js.map +1 -0
  164. package/dist/tools/v2/cycle_log.js +43 -0
  165. package/dist/tools/v2/cycle_log.js.map +1 -0
  166. package/dist/tools/v2/day.js +32 -0
  167. package/dist/tools/v2/day.js.map +1 -0
  168. package/dist/tools/v2/endpoints.js +28 -0
  169. package/dist/tools/v2/endpoints.js.map +1 -0
  170. package/dist/tools/v2/hidden_metric.js +28 -0
  171. package/dist/tools/v2/hidden_metric.js.map +1 -0
  172. package/dist/tools/v2/hr_zones.js +24 -0
  173. package/dist/tools/v2/hr_zones.js.map +1 -0
  174. package/dist/tools/v2/hr_zones_set.js +51 -0
  175. package/dist/tools/v2/hr_zones_set.js.map +1 -0
  176. package/dist/tools/v2/journal.js +26 -0
  177. package/dist/tools/v2/journal.js.map +1 -0
  178. package/dist/tools/v2/journal_autopop.js +19 -0
  179. package/dist/tools/v2/journal_autopop.js.map +1 -0
  180. package/dist/tools/v2/journal_catalog.js +44 -0
  181. package/dist/tools/v2/journal_catalog.js.map +1 -0
  182. package/dist/tools/v2/journal_log.js +78 -0
  183. package/dist/tools/v2/journal_log.js.map +1 -0
  184. package/dist/tools/v2/leaderboard.js +79 -0
  185. package/dist/tools/v2/leaderboard.js.map +1 -0
  186. package/dist/tools/v2/lift_catalog.js +47 -0
  187. package/dist/tools/v2/lift_catalog.js.map +1 -0
  188. package/dist/tools/v2/lift_custom_exercise.js +108 -0
  189. package/dist/tools/v2/lift_custom_exercise.js.map +1 -0
  190. package/dist/tools/v2/lift_exercise.js +31 -0
  191. package/dist/tools/v2/lift_exercise.js.map +1 -0
  192. package/dist/tools/v2/lift_history.js +39 -0
  193. package/dist/tools/v2/lift_history.js.map +1 -0
  194. package/dist/tools/v2/lift_library.js +22 -0
  195. package/dist/tools/v2/lift_library.js.map +1 -0
  196. package/dist/tools/v2/lift_log.js +95 -0
  197. package/dist/tools/v2/lift_log.js.map +1 -0
  198. package/dist/tools/v2/lift_progression.js +30 -0
  199. package/dist/tools/v2/lift_progression.js.map +1 -0
  200. package/dist/tools/v2/lift_prs.js +21 -0
  201. package/dist/tools/v2/lift_prs.js.map +1 -0
  202. package/dist/tools/v2/lift_template_save.js +83 -0
  203. package/dist/tools/v2/lift_template_save.js.map +1 -0
  204. package/dist/tools/v2/live_hr.js +21 -0
  205. package/dist/tools/v2/live_hr.js.map +1 -0
  206. package/dist/tools/v2/live_state.js +21 -0
  207. package/dist/tools/v2/live_state.js.map +1 -0
  208. package/dist/tools/v2/live_stress.js +22 -0
  209. package/dist/tools/v2/live_stress.js.map +1 -0
  210. package/dist/tools/v2/performance_assessment.js +38 -0
  211. package/dist/tools/v2/performance_assessment.js.map +1 -0
  212. package/dist/tools/v2/profile.js +28 -0
  213. package/dist/tools/v2/profile.js.map +1 -0
  214. package/dist/tools/v2/profile_update.js +66 -0
  215. package/dist/tools/v2/profile_update.js.map +1 -0
  216. package/dist/tools/v2/raw.js +43 -0
  217. package/dist/tools/v2/raw.js.map +1 -0
  218. package/dist/tools/v2/recovery.js +31 -0
  219. package/dist/tools/v2/recovery.js.map +1 -0
  220. package/dist/tools/v2/sleep.js +23 -0
  221. package/dist/tools/v2/sleep.js.map +1 -0
  222. package/dist/tools/v2/sleep_need.js +21 -0
  223. package/dist/tools/v2/sleep_need.js.map +1 -0
  224. package/dist/tools/v2/smart_alarm.js +24 -0
  225. package/dist/tools/v2/smart_alarm.js.map +1 -0
  226. package/dist/tools/v2/smart_alarm_set.js +94 -0
  227. package/dist/tools/v2/smart_alarm_set.js.map +1 -0
  228. package/dist/tools/v2/sports_catalog.js +26 -0
  229. package/dist/tools/v2/sports_catalog.js.map +1 -0
  230. package/dist/tools/v2/strain.js +23 -0
  231. package/dist/tools/v2/strain.js.map +1 -0
  232. package/dist/tools/v2/stress.js +23 -0
  233. package/dist/tools/v2/stress.js.map +1 -0
  234. package/dist/tools/v2/symptom_log.js +72 -0
  235. package/dist/tools/v2/symptom_log.js.map +1 -0
  236. package/dist/tools/v2/today.js +30 -0
  237. package/dist/tools/v2/today.js.map +1 -0
  238. package/dist/tools/v2/trend.js +26 -0
  239. package/dist/tools/v2/trend.js.map +1 -0
  240. package/dist/tools/v2/workout.js +23 -0
  241. package/dist/tools/v2/workout.js.map +1 -0
  242. package/dist/tools/v2/workouts.js +32 -0
  243. package/dist/tools/v2/workouts.js.map +1 -0
  244. package/dist/whoop/build_lift_body.js +67 -0
  245. package/dist/whoop/build_lift_body.js.map +1 -0
  246. package/dist/whoop/client.js +84 -0
  247. package/dist/whoop/client.js.map +1 -0
  248. package/dist/whoop/cognito.js +110 -0
  249. package/dist/whoop/cognito.js.map +1 -0
  250. package/dist/whoop/constants.js +4 -0
  251. package/dist/whoop/constants.js.map +1 -0
  252. package/dist/whoop/device.js +103 -0
  253. package/dist/whoop/device.js.map +1 -0
  254. package/dist/whoop/errors.js +42 -0
  255. package/dist/whoop/errors.js.map +1 -0
  256. package/dist/whoop/init_timezone.js +62 -0
  257. package/dist/whoop/init_timezone.js.map +1 -0
  258. package/dist/whoop/installation.js +62 -0
  259. package/dist/whoop/installation.js.map +1 -0
  260. package/dist/whoop/json_out.js +9 -0
  261. package/dist/whoop/json_out.js.map +1 -0
  262. package/dist/whoop/oauth_provider.js +297 -0
  263. package/dist/whoop/oauth_provider.js.map +1 -0
  264. package/dist/whoop/session_state.js +34 -0
  265. package/dist/whoop/session_state.js.map +1 -0
  266. package/dist/whoop/token_manager.js +60 -0
  267. package/dist/whoop/token_manager.js.map +1 -0
  268. package/dist/whoop/token_store.js +47 -0
  269. package/dist/whoop/token_store.js.map +1 -0
  270. package/dist/whoop/types.js +82 -0
  271. package/dist/whoop/types.js.map +1 -0
  272. package/dist/whoop/write_safety.js +23 -0
  273. package/dist/whoop/write_safety.js.map +1 -0
  274. package/package.json +66 -0
  275. package/src/cli/index.ts +597 -0
  276. package/src/cli/setup.ts +1106 -0
  277. package/src/cli/ui.ts +505 -0
  278. package/src/cli/update.ts +442 -0
  279. package/src/data/behaviors.ts +2784 -0
  280. package/src/data/endpoints.ts +319 -0
  281. package/src/data/exercises.ts +4868 -0
  282. package/src/data/sports.ts +218 -0
  283. package/src/lib/concurrency.ts +28 -0
  284. package/src/lib/dates.ts +35 -0
  285. package/src/lib/format.ts +27 -0
  286. package/src/lib/stats.ts +35 -0
  287. package/src/lib/timezone.ts +269 -0
  288. package/src/lib/walk.ts +418 -0
  289. package/src/projections/behavior_impact.ts +98 -0
  290. package/src/projections/calendar.ts +46 -0
  291. package/src/projections/communities.ts +135 -0
  292. package/src/projections/cycle.ts +85 -0
  293. package/src/projections/hr_zones.ts +43 -0
  294. package/src/projections/journal.ts +55 -0
  295. package/src/projections/leaderboard.ts +49 -0
  296. package/src/projections/lift_exercise.ts +29 -0
  297. package/src/projections/lift_history.ts +140 -0
  298. package/src/projections/lift_library.ts +70 -0
  299. package/src/projections/lift_progression.ts +138 -0
  300. package/src/projections/lift_prs.ts +23 -0
  301. package/src/projections/live_hr.ts +21 -0
  302. package/src/projections/live_state.ts +28 -0
  303. package/src/projections/live_stress.ts +13 -0
  304. package/src/projections/performance_assessment.ts +19 -0
  305. package/src/projections/profile.ts +71 -0
  306. package/src/projections/recovery.ts +133 -0
  307. package/src/projections/sleep.ts +276 -0
  308. package/src/projections/sleep_need.ts +36 -0
  309. package/src/projections/smart_alarm.ts +70 -0
  310. package/src/projections/strain.ts +131 -0
  311. package/src/projections/stress.ts +95 -0
  312. package/src/projections/today.ts +166 -0
  313. package/src/projections/trend.ts +149 -0
  314. package/src/projections/workout.ts +168 -0
  315. package/src/projections/workouts.ts +36 -0
  316. package/src/schemas/calendar.ts +13 -0
  317. package/src/schemas/coach.ts +11 -0
  318. package/src/schemas/communities.ts +56 -0
  319. package/src/schemas/compare.ts +17 -0
  320. package/src/schemas/escape.ts +21 -0
  321. package/src/schemas/journal.ts +80 -0
  322. package/src/schemas/leaderboard.ts +26 -0
  323. package/src/schemas/live.ts +31 -0
  324. package/src/schemas/performance.ts +13 -0
  325. package/src/schemas/primitives.ts +35 -0
  326. package/src/schemas/profile.ts +40 -0
  327. package/src/schemas/recovery.ts +28 -0
  328. package/src/schemas/settings.ts +30 -0
  329. package/src/schemas/sleep.ts +40 -0
  330. package/src/schemas/sleep_need.ts +16 -0
  331. package/src/schemas/smart_alarm.ts +40 -0
  332. package/src/schemas/strain.ts +25 -0
  333. package/src/schemas/strength.ts +189 -0
  334. package/src/schemas/stress.ts +17 -0
  335. package/src/schemas/today.ts +39 -0
  336. package/src/schemas/trend.ts +53 -0
  337. package/src/schemas/womens_health.ts +26 -0
  338. package/src/schemas/workouts.ts +55 -0
  339. package/src/scripts/cognito_bootstrap.ts +249 -0
  340. package/src/server-http.ts +241 -0
  341. package/src/server.ts +85 -0
  342. package/src/tools/register.ts +120 -0
  343. package/src/tools/v2/activity_create.ts +74 -0
  344. package/src/tools/v2/activity_delete.ts +33 -0
  345. package/src/tools/v2/behavior_impact.ts +39 -0
  346. package/src/tools/v2/calendar.ts +33 -0
  347. package/src/tools/v2/coach_ask.ts +131 -0
  348. package/src/tools/v2/communities.ts +65 -0
  349. package/src/tools/v2/compare.ts +83 -0
  350. package/src/tools/v2/cycle.ts +28 -0
  351. package/src/tools/v2/cycle_log.ts +51 -0
  352. package/src/tools/v2/day.ts +37 -0
  353. package/src/tools/v2/endpoints.ts +32 -0
  354. package/src/tools/v2/hidden_metric.ts +33 -0
  355. package/src/tools/v2/hr_zones.ts +29 -0
  356. package/src/tools/v2/hr_zones_set.ts +57 -0
  357. package/src/tools/v2/journal.ts +31 -0
  358. package/src/tools/v2/journal_autopop.ts +26 -0
  359. package/src/tools/v2/journal_catalog.ts +48 -0
  360. package/src/tools/v2/journal_log.ts +84 -0
  361. package/src/tools/v2/leaderboard.ts +92 -0
  362. package/src/tools/v2/lift_catalog.ts +48 -0
  363. package/src/tools/v2/lift_custom_exercise.ts +117 -0
  364. package/src/tools/v2/lift_exercise.ts +35 -0
  365. package/src/tools/v2/lift_history.ts +52 -0
  366. package/src/tools/v2/lift_library.ts +28 -0
  367. package/src/tools/v2/lift_log.ts +102 -0
  368. package/src/tools/v2/lift_progression.ts +34 -0
  369. package/src/tools/v2/lift_prs.ts +26 -0
  370. package/src/tools/v2/lift_template_save.ts +89 -0
  371. package/src/tools/v2/live_hr.ts +26 -0
  372. package/src/tools/v2/live_state.ts +26 -0
  373. package/src/tools/v2/live_stress.ts +27 -0
  374. package/src/tools/v2/performance_assessment.ts +44 -0
  375. package/src/tools/v2/profile.ts +33 -0
  376. package/src/tools/v2/profile_update.ts +76 -0
  377. package/src/tools/v2/raw.ts +50 -0
  378. package/src/tools/v2/recovery.ts +36 -0
  379. package/src/tools/v2/sleep.ts +28 -0
  380. package/src/tools/v2/sleep_need.ts +26 -0
  381. package/src/tools/v2/smart_alarm.ts +29 -0
  382. package/src/tools/v2/smart_alarm_set.ts +103 -0
  383. package/src/tools/v2/sports_catalog.ts +32 -0
  384. package/src/tools/v2/strain.ts +28 -0
  385. package/src/tools/v2/stress.ts +28 -0
  386. package/src/tools/v2/symptom_log.ts +78 -0
  387. package/src/tools/v2/today.ts +35 -0
  388. package/src/tools/v2/trend.ts +31 -0
  389. package/src/tools/v2/workout.ts +28 -0
  390. package/src/tools/v2/workouts.ts +37 -0
  391. package/src/whoop/build_lift_body.ts +84 -0
  392. package/src/whoop/client.ts +118 -0
  393. package/src/whoop/cognito.ts +150 -0
  394. package/src/whoop/constants.ts +3 -0
  395. package/src/whoop/device.ts +106 -0
  396. package/src/whoop/errors.ts +41 -0
  397. package/src/whoop/init_timezone.ts +64 -0
  398. package/src/whoop/installation.ts +58 -0
  399. package/src/whoop/json_out.ts +9 -0
  400. package/src/whoop/oauth_provider.ts +377 -0
  401. package/src/whoop/session_state.ts +41 -0
  402. package/src/whoop/token_manager.ts +76 -0
  403. package/src/whoop/token_store.ts +45 -0
  404. package/src/whoop/types.ts +89 -0
  405. package/src/whoop/write_safety.ts +30 -0
@@ -0,0 +1,117 @@
1
+ import { z } from "zod";
2
+ import { randomUUID } from "node:crypto";
3
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import type { WhoopClient } from "../../whoop/client.js";
5
+ import { LiftCustomExerciseOut } from "../../schemas/strength.js";
6
+ import { preview } from "../../whoop/write_safety.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { EXERCISES_BY_ID } from "../../data/exercises.js";
9
+ import { gateError } from "../../whoop/session_state.js";
10
+
11
+ const PATH = "/weightlifting-service/v2/custom-exercise";
12
+
13
+ export function registerLiftCustomExercise(server: McpServer, client: WhoopClient): void {
14
+ server.tool(
15
+ "whoop_lift_custom_exercise",
16
+ "WRITE: create a custom Strength Trainer exercise based on an existing official one. Requires calling whoop_lift_catalog first.",
17
+ {
18
+ name: z.string(),
19
+ push_core_name: z.string().describe("exercise_id of the official exercise this is based on."),
20
+ muscle_groups: z
21
+ .array(z.enum(["ARMS", "BACK", "CHEST", "CORE", "FULL_BODY", "LEGS", "OTHER", "SHOULDERS"]))
22
+ .min(1)
23
+ .describe("Whoop's API only accepts these 8 muscle groups. There is no GLUTES/HAMSTRINGS/QUADS/BICEPS/TRICEPS — use LEGS or ARMS."),
24
+ equipment: z.enum(["MACHINE", "DUMBBELL", "BARBELL", "BODY", "OTHER", "KETTLEBELL"]).default("OTHER"),
25
+ movement_pattern: z
26
+ .enum([
27
+ "SQUAT",
28
+ "HINGE",
29
+ "HORIZONTAL_PRESS",
30
+ "VERTICAL_PRESS",
31
+ "HORIZONTAL_PULL",
32
+ "VERTICAL_PULL",
33
+ "LUNGE",
34
+ "JUMP",
35
+ "OTHER",
36
+ ])
37
+ .default("OTHER")
38
+ .describe("Whoop's API rejects OLYMPIC_LIFT, ROTATION, GAIT, CARRY despite them being plausible — use OTHER for those."),
39
+ // Write-side enum differs from the read catalog (whoop_lift_catalog returns
40
+ // LEFT/RIGHT): the create-exercise POST requires the UNILATERAL_* form.
41
+ laterality: z
42
+ .enum(["BILATERAL", "UNILATERAL_LEFT", "UNILATERAL_RIGHT", "ALTERNATING"])
43
+ .default("BILATERAL"),
44
+ volume_input_format: z.enum(["REPS", "TIME"]).default("REPS"),
45
+ exercise_type: z.enum(["STRENGTH", "POWER"]).default("STRENGTH"),
46
+ instructions: z.array(z.string()).default([]),
47
+ trackable: z.boolean().default(true),
48
+ confirm: z.boolean().default(false),
49
+ },
50
+ async (args) => {
51
+ const gate = gateError("exercises", "whoop_lift_catalog");
52
+ if (gate) return { content: [{ type: "text", text: JSON.stringify(gate, null, 2) }], isError: true };
53
+ const linked = EXERCISES_BY_ID.get(args.push_core_name);
54
+ if (!linked) {
55
+ return {
56
+ content: [
57
+ {
58
+ type: "text",
59
+ text: jsonOut({
60
+ error: `push_core_name ${args.push_core_name} not in catalog`,
61
+ hint: "Use whoop_lift_catalog to find a valid exercise_id",
62
+ }),
63
+ },
64
+ ],
65
+ isError: true,
66
+ };
67
+ }
68
+ const newId = randomUUID().toUpperCase();
69
+ const body = {
70
+ created_at: "",
71
+ updated_at: "",
72
+ exercise_id: newId,
73
+ laterality: args.laterality,
74
+ exercise_type: args.exercise_type,
75
+ push_core_name: args.push_core_name,
76
+ training_types: [],
77
+ custom_exercise_info: {
78
+ linked_exercise: {
79
+ name: linked.name,
80
+ exercise_id: linked.exercise_id,
81
+ image_url: `https://dh6o7n168ts9.cloudfront.net/exercises/${linked.exercise_id}.jpg`,
82
+ },
83
+ },
84
+ trackable: args.trackable,
85
+ movement_pattern: args.movement_pattern,
86
+ instructions: args.instructions,
87
+ equipment: args.equipment,
88
+ name: args.name,
89
+ volume_input_format: args.volume_input_format,
90
+ muscle_groups: args.muscle_groups,
91
+ };
92
+ if (!args.confirm) {
93
+ return {
94
+ content: [
95
+ {
96
+ type: "text",
97
+ text: jsonOut(
98
+ preview("POST", PATH, {
99
+ name: args.name,
100
+ push_core_name: args.push_core_name,
101
+ will_create_id: newId,
102
+ }),
103
+ ),
104
+ },
105
+ ],
106
+ };
107
+ }
108
+ await client.post(PATH, body);
109
+ const out = LiftCustomExerciseOut.parse({
110
+ created: true as const,
111
+ exercise_id: newId,
112
+ name: args.name,
113
+ });
114
+ return { content: [{ type: "text", text: jsonOut(out) }] };
115
+ },
116
+ );
117
+ }
@@ -0,0 +1,35 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftExerciseOut } from "../../schemas/strength.js";
5
+ import { projectLiftExercise } from "../../projections/lift_exercise.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { gateError } from "../../whoop/session_state.js";
9
+
10
+ export function registerLiftExercise(server: McpServer, client: WhoopClient): void {
11
+ server.tool(
12
+ "whoop_lift_exercise",
13
+ "Single exercise composite: metadata + recent sessions (sets with reps/weight/medal) + PRs. Requires calling whoop_lift_catalog first.",
14
+ {
15
+ exercise_id: z.string().describe("Exercise code (upper-snake) or UUID from whoop_lift_catalog."),
16
+ },
17
+ async ({ exercise_id }) => {
18
+ const gate = gateError("exercises", "whoop_lift_catalog");
19
+ if (gate) return { content: [{ type: "text", text: JSON.stringify(gate, null, 2) }], isError: true };
20
+ const [info, history, prs] = await Promise.all([
21
+ client.get(`/weightlifting-service/v1/exercise/${exercise_id}`),
22
+ client.get(`/weightlifting-service/v3/exercise/${exercise_id}/exercise_history`),
23
+ client.get(`/weightlifting-service/v3/exercise/${exercise_id}/personal_records`),
24
+ ]);
25
+ try {
26
+ const projected = projectLiftExercise({ info, history, prs });
27
+ const out = LiftExerciseOut.parse(projected);
28
+ return { content: [{ type: "text", text: jsonOut(out) }] };
29
+ } catch (e) {
30
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_exercise", e);
31
+ throw e;
32
+ }
33
+ },
34
+ );
35
+ }
@@ -0,0 +1,52 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftHistoryOut } from "../../schemas/strength.js";
5
+ import { projectLiftHistory } from "../../projections/lift_history.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { rangeFromDays } from "../../lib/dates.js";
9
+ import { runPaced } from "../../lib/concurrency.js";
10
+
11
+ export function registerLiftHistory(server: McpServer, client: WhoopClient): void {
12
+ server.tool(
13
+ "whoop_lift_history",
14
+ "Recent strength workouts with per-exercise aggregates (set count, total reps, tonnage, medals). It does NOT include individual set reps/weights — for those use whoop_lift_exercise, which returns every set for one exercise across your history.",
15
+ {
16
+ limit: z.number().int().min(1).max(20).default(10),
17
+ end_date: z.iso.date().optional(),
18
+ },
19
+ async ({ limit, end_date }) => {
20
+ const endDate = end_date ? new Date(end_date) : new Date();
21
+ const start = rangeFromDays(60, endDate).start;
22
+ const end = endDate.toISOString();
23
+ const workouts = await client.get<{ records?: { id: string; sport_name?: string }[] }>(
24
+ "/developer/v2/activity/workout",
25
+ { start, end, limit: 25 },
26
+ );
27
+ // Whoop's /developer/v2/activity/workout returns internal sport names like
28
+ // "weightlifting_msk" (Strength Trainer), "weightlifting", "powerlifting".
29
+ // None of these contain "strength" so we match by the broader pattern.
30
+ const strengthIds = (workouts.records ?? [])
31
+ .filter((r) => r.sport_name && /weight|strength|powerlift/i.test(r.sport_name))
32
+ .slice(0, limit)
33
+ .map((r) => r.id);
34
+ // Up to 20 detail calls — paced (≤3 at a time, small jitter) instead of a
35
+ // single simultaneous burst.
36
+ const details = await runPaced(
37
+ strengthIds.map((id) =>
38
+ () => client.get(`/core-details-bff/v1/cardio-details`, { activityId: id }).catch(() => ({})),
39
+ ),
40
+ { concurrency: 3, jitterMaxMs: 150 },
41
+ );
42
+ const projected = projectLiftHistory({ workouts, details });
43
+ try {
44
+ const out = LiftHistoryOut.parse(projected);
45
+ return { content: [{ type: "text", text: jsonOut(out) }] };
46
+ } catch (e) {
47
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_history", e);
48
+ throw e;
49
+ }
50
+ },
51
+ );
52
+ }
@@ -0,0 +1,28 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftLibraryOut } from "../../schemas/strength.js";
5
+ import { projectLibraryList, projectLibrarySingle } from "../../projections/lift_library.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+
9
+ export function registerLiftLibrary(server: McpServer, client: WhoopClient): void {
10
+ server.tool(
11
+ "whoop_lift_library",
12
+ "Your saved Strength Trainer templates. Pass template_id for full detail of one; omit for the list.",
13
+ { template_id: z.number().int().optional() },
14
+ async ({ template_id }) => {
15
+ const projected =
16
+ template_id !== undefined
17
+ ? projectLibrarySingle(await client.get(`/weightlifting-service/v2/workout-template/${template_id}`))
18
+ : projectLibraryList(await client.get("/weightlifting-service/v3/workout-library"));
19
+ try {
20
+ const out = LiftLibraryOut.parse(projected);
21
+ return { content: [{ type: "text", text: jsonOut(out) }] };
22
+ } catch (e) {
23
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_library", e);
24
+ throw e;
25
+ }
26
+ },
27
+ );
28
+ }
@@ -0,0 +1,102 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftLogOut } from "../../schemas/strength.js";
5
+ import { preview } from "../../whoop/write_safety.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { buildExerciseGroups } from "../../whoop/build_lift_body.js";
9
+ import { gateError } from "../../whoop/session_state.js";
10
+
11
+ const PATH = "/weightlifting-service/v2/weightlifting-workout/activity";
12
+
13
+ export function registerLiftLog(server: McpServer, client: WhoopClient): void {
14
+ server.tool(
15
+ "whoop_lift_log",
16
+ "WRITE: log a finished strength workout — pass exercises, each with sets (reps and/or weight in kg and/or time_seconds). Call whoop_lift_catalog first to get valid exercise_ids; preview unless confirm:true.",
17
+ {
18
+ name: z.string().optional(),
19
+ start: z.iso.datetime({ offset: true }).optional(),
20
+ end: z.iso.datetime({ offset: true }).optional(),
21
+ exercises: z.array(z.object({
22
+ exercise_id: z.string(),
23
+ sets: z.array(z.object({
24
+ reps: z.number().int().min(0),
25
+ weight: z.number().min(0).optional(),
26
+ time_seconds: z.number().int().min(0).optional(),
27
+ strap_location: z.enum(["LEFT", "RIGHT", "BOTH"]).default("LEFT"),
28
+ })).min(1),
29
+ })).min(1),
30
+ confirm: z.boolean().default(false),
31
+ },
32
+ async ({ name, start, end, exercises, confirm }) => {
33
+ const gate = gateError("exercises", "whoop_lift_catalog");
34
+ if (gate) return { content: [{ type: "text", text: JSON.stringify(gate, null, 2) }], isError: true };
35
+ const endTs = end ? new Date(end).getTime() : Date.now();
36
+ const startTs = start ? new Date(start).getTime() : endTs - 30 * 60 * 1000;
37
+ const { workout_groups, set_count, unknown_exercises } = buildExerciseGroups(exercises, startTs);
38
+ if (unknown_exercises.length > 0) {
39
+ return {
40
+ content: [
41
+ {
42
+ type: "text",
43
+ text: jsonOut({
44
+ error: "Unknown exercise IDs",
45
+ unknown_exercises,
46
+ hint: "Use whoop_lift_catalog or whoop_lift_custom_exercise",
47
+ }),
48
+ },
49
+ ],
50
+ isError: true,
51
+ };
52
+ }
53
+ // Whoop's body wants an IANA zone name. Prefer WHOOP_TIMEZONE when it's an
54
+ // IANA name (cloud hosts run in UTC, so the system zone would mislabel the
55
+ // logged workout); else fall back to the system zone (correct for local
56
+ // stdio use). Never send a bare numeric offset.
57
+ const tzEnv = process.env.WHOOP_TIMEZONE;
58
+ const timezone = tzEnv && tzEnv.includes("/") ? tzEnv : Intl.DateTimeFormat().resolvedOptions().timeZone;
59
+ const body = {
60
+ name: name ?? new Date(endTs).toISOString().slice(0, 10),
61
+ during: `['${new Date(startTs).toISOString()}','${new Date(endTs).toISOString()}')`,
62
+ timezone,
63
+ scaled_msk_strain_score: 0,
64
+ msk_total_volume_kg: 0,
65
+ msk_intensity_percent: 0,
66
+ raw_msk_strain_score: 0,
67
+ workout_groups,
68
+ };
69
+ if (!confirm) {
70
+ return {
71
+ content: [
72
+ {
73
+ type: "text",
74
+ text: jsonOut(
75
+ preview("POST", PATH, {
76
+ exercise_count: exercises.length,
77
+ set_count,
78
+ exercise_list: exercises.map((e) => ({ name: e.exercise_id, set_count: e.sets.length })),
79
+ }),
80
+ ),
81
+ },
82
+ ],
83
+ };
84
+ }
85
+ const receipt = await client.post<{ id: string }>(PATH, body);
86
+ const projected = {
87
+ logged: true as const,
88
+ activity_id: receipt.id,
89
+ exercise_count: exercises.length,
90
+ set_count,
91
+ total_volume_kg: null,
92
+ };
93
+ try {
94
+ const out = LiftLogOut.parse(projected);
95
+ return { content: [{ type: "text", text: jsonOut(out) }] };
96
+ } catch (e) {
97
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_log", e);
98
+ throw e;
99
+ }
100
+ },
101
+ );
102
+ }
@@ -0,0 +1,34 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftProgressionOut } from "../../schemas/strength.js";
5
+ import { projectLiftProgression } from "../../projections/lift_progression.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { todayIso } from "../../lib/dates.js";
9
+ import { gateError } from "../../whoop/session_state.js";
10
+
11
+ export function registerLiftProgression(server: McpServer, client: WhoopClient): void {
12
+ server.tool(
13
+ "whoop_lift_progression",
14
+ "Multi-window volume trend for a single exercise: 30-day, 6-month, year segments with avg volume + change % + per-session points. Requires calling whoop_lift_catalog first.",
15
+ {
16
+ exercise_id: z.string().describe("From whoop_lift_catalog."),
17
+ end_date: z.iso.date().optional(),
18
+ },
19
+ async ({ exercise_id, end_date }) => {
20
+ const gate = gateError("exercises", "whoop_lift_catalog");
21
+ if (gate) return { content: [{ type: "text", text: JSON.stringify(gate, null, 2) }], isError: true };
22
+ const d = end_date ?? todayIso();
23
+ const raw = await client.get(`/progression-service/v3/exercise/${exercise_id}`, { endDate: d });
24
+ const projected = projectLiftProgression(raw, exercise_id, d);
25
+ try {
26
+ const out = LiftProgressionOut.parse(projected);
27
+ return { content: [{ type: "text", text: jsonOut(out) }] };
28
+ } catch (e) {
29
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_progression", e);
30
+ throw e;
31
+ }
32
+ },
33
+ );
34
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftPrsOut } from "../../schemas/strength.js";
5
+ import { projectLiftPrs } from "../../projections/lift_prs.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+
9
+ export function registerLiftPrs(server: McpServer, client: WhoopClient): void {
10
+ server.tool(
11
+ "whoop_lift_prs",
12
+ "All Strength Trainer personal records: per-exercise top weight, units, date, medal.",
13
+ {},
14
+ async () => {
15
+ const raw = await client.get("/weightlifting-service/v3/prs");
16
+ const projected = projectLiftPrs(raw);
17
+ try {
18
+ const out = LiftPrsOut.parse(projected);
19
+ return { content: [{ type: "text", text: jsonOut(out) }] };
20
+ } catch (e) {
21
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_prs", e);
22
+ throw e;
23
+ }
24
+ },
25
+ );
26
+ }
@@ -0,0 +1,89 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiftTemplateSaveOut } from "../../schemas/strength.js";
5
+ import { preview } from "../../whoop/write_safety.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { buildExerciseGroups, type InputExercise } from "../../whoop/build_lift_body.js";
9
+ import { gateError } from "../../whoop/session_state.js";
10
+
11
+ const PATH = "/weightlifting-service/v3/workout-template";
12
+
13
+ export function registerLiftTemplateSave(server: McpServer, client: WhoopClient): void {
14
+ server.tool(
15
+ "whoop_lift_template_save",
16
+ "WRITE: create or save-as a Strength Trainer workout template from exercises whose sets can specify reps and/or weight (kg) and/or time_seconds. Call whoop_lift_catalog first for valid exercise_ids; preview unless confirm:true.",
17
+ {
18
+ name: z.string(),
19
+ base_template_key: z.number().int().optional().describe("If provided, saves as derivative of an existing template."),
20
+ exercises: z.array(z.object({
21
+ exercise_id: z.string(),
22
+ sets: z.array(z.object({
23
+ // All optional — a template set can prescribe just reps, just weight,
24
+ // a time, or nothing. Omit the keys you don't need.
25
+ reps: z.number().int().nullable().optional(),
26
+ weight: z.number().nullable().optional(),
27
+ time_seconds: z.number().int().nullable().optional(),
28
+ })).min(1),
29
+ })).min(1),
30
+ confirm: z.boolean().default(false),
31
+ },
32
+ async ({ name, base_template_key, exercises, confirm }) => {
33
+ const gate = gateError("exercises", "whoop_lift_catalog");
34
+ if (gate) return { content: [{ type: "text", text: JSON.stringify(gate, null, 2) }], isError: true };
35
+ const inputExercises: InputExercise[] = exercises.map((e) => ({
36
+ exercise_id: e.exercise_id,
37
+ sets: e.sets.map((s) => ({
38
+ reps: s.reps ?? 0,
39
+ weight: s.weight ?? undefined,
40
+ time_seconds: s.time_seconds ?? undefined,
41
+ })),
42
+ }));
43
+ const { workout_groups, unknown_exercises } = buildExerciseGroups(inputExercises, 0);
44
+ if (unknown_exercises.length > 0) {
45
+ return {
46
+ content: [
47
+ {
48
+ type: "text",
49
+ text: jsonOut({
50
+ error: "Unknown exercise IDs",
51
+ unknown_exercises,
52
+ hint: "Use whoop_lift_catalog or whoop_lift_custom_exercise",
53
+ }),
54
+ },
55
+ ],
56
+ isError: true,
57
+ };
58
+ }
59
+ const body: Record<string, unknown> = { name, workout_groups };
60
+ if (base_template_key !== undefined) body.workout_template_key = base_template_key;
61
+ if (!confirm) {
62
+ return {
63
+ content: [
64
+ {
65
+ type: "text",
66
+ text: jsonOut(
67
+ preview("POST", PATH, { name, exercise_count: exercises.length, base_template_key }),
68
+ ),
69
+ },
70
+ ],
71
+ };
72
+ }
73
+ const receipt = await client.post<{ workout_template_key?: number; id?: number }>(PATH, body);
74
+ const projected = {
75
+ created: true as const,
76
+ template_id: receipt.workout_template_key ?? receipt.id ?? 0,
77
+ name,
78
+ exercise_count: exercises.length,
79
+ };
80
+ try {
81
+ const out = LiftTemplateSaveOut.parse(projected);
82
+ return { content: [{ type: "text", text: jsonOut(out) }] };
83
+ } catch (e) {
84
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_lift_template_save", e);
85
+ throw e;
86
+ }
87
+ },
88
+ );
89
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiveHrOut } from "../../schemas/live.js";
5
+ import { projectLiveHr } from "../../projections/live_hr.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+
9
+ export function registerLiveHr(server: McpServer, client: WhoopClient): void {
10
+ server.tool(
11
+ "whoop_live_hr",
12
+ "Current heart rate from the strap. Returns is_recording:false + last-known BPM if not actively streaming. Check last_updated_at for staleness.",
13
+ {},
14
+ async () => {
15
+ const raw = await client.get("/health-tab-bff/v1/health-tab");
16
+ const projected = projectLiveHr(raw);
17
+ try {
18
+ const out = LiveHrOut.parse(projected);
19
+ return { content: [{ type: "text", text: jsonOut(out) }] };
20
+ } catch (e) {
21
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_live_hr", e);
22
+ throw e;
23
+ }
24
+ },
25
+ );
26
+ }
@@ -0,0 +1,26 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiveStateOut } from "../../schemas/live.js";
5
+ import { projectLiveState } from "../../projections/live_state.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+
9
+ export function registerLiveState(server: McpServer, client: WhoopClient): void {
10
+ server.tool(
11
+ "whoop_live_state",
12
+ "Are you currently in a tracked workout, sleep, or idle? Returns sport name + start time if active.",
13
+ {},
14
+ async () => {
15
+ const raw = await client.get("/activities-service/v1/user-state");
16
+ const projected = projectLiveState(raw);
17
+ try {
18
+ const out = LiveStateOut.parse(projected);
19
+ return { content: [{ type: "text", text: jsonOut(out) }] };
20
+ } catch (e) {
21
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_live_state", e);
22
+ throw e;
23
+ }
24
+ },
25
+ );
26
+ }
@@ -0,0 +1,27 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { LiveStressOut } from "../../schemas/live.js";
5
+ import { projectLiveStress } from "../../projections/live_stress.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { todayIso } from "../../lib/dates.js";
9
+
10
+ export function registerLiveStress(server: McpServer, client: WhoopClient): void {
11
+ server.tool(
12
+ "whoop_live_stress",
13
+ "Current stress level (terse). Cheaper than whoop_stress if you just want the latest reading.",
14
+ {},
15
+ async () => {
16
+ const raw = await client.get(`/health-service/v2/stress-bff/${todayIso()}`);
17
+ const projected = projectLiveStress(raw);
18
+ try {
19
+ const out = LiveStressOut.parse(projected);
20
+ return { content: [{ type: "text", text: jsonOut(out) }] };
21
+ } catch (e) {
22
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_live_stress", e);
23
+ throw e;
24
+ }
25
+ },
26
+ );
27
+ }
@@ -0,0 +1,44 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { PerformanceAssessmentOut } from "../../schemas/performance.js";
5
+ import { projectPerformanceAssessment } from "../../projections/performance_assessment.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+ import { getTimezone, zonedParts } from "../../lib/timezone.js";
9
+
10
+ // "now" as a wall-clock timestamp in the USER's timezone with the user's offset
11
+ // (e.g. "2026-05-27T13:05:00-0700"). Uses the configured WHOOP_TIMEZONE / profile
12
+ // TZ rather than the server's offset — `getTimezoneOffset()` returns 0 on a UTC
13
+ // host like Fly, which produced wrong local times before.
14
+ function localIsoNow(): string {
15
+ const now = new Date();
16
+ const p = zonedParts(now, getTimezone());
17
+ const pad = (n: number): string => String(n).padStart(2, "0");
18
+ // Offset = (the wall-clock components read as if UTC) minus the real instant.
19
+ const asUtc = Date.UTC(p.year, p.month - 1, p.day, p.hour, p.minute, p.second);
20
+ const offsetMin = Math.round((asUtc - now.getTime()) / 60000);
21
+ const sign = offsetMin >= 0 ? "+" : "-";
22
+ const abs = Math.abs(offsetMin);
23
+ return `${p.year}-${pad(p.month)}-${pad(p.day)}T${pad(p.hour)}:${pad(p.minute)}:${pad(p.second)}${sign}${pad(Math.floor(abs / 60))}${pad(abs % 60)}`;
24
+ }
25
+
26
+ export function registerPerformanceAssessment(server: McpServer, client: WhoopClient): void {
27
+ server.tool(
28
+ "whoop_performance_assessment",
29
+ "Whoop's performance assessment for a period — recoveries logged vs required, whether an assessment is due, and the next assessment window. period: WEEK or MONTH (default MONTH).",
30
+ { period: z.enum(["WEEK", "MONTH"]).default("MONTH") },
31
+ async ({ period }) => {
32
+ const ts = localIsoNow();
33
+ const raw = await client.get(`/coaching-service/v1/performance-assessment/${period}/data/${ts}`);
34
+ const projected = projectPerformanceAssessment(raw, period);
35
+ try {
36
+ const out = PerformanceAssessmentOut.parse(projected);
37
+ return { content: [{ type: "text", text: jsonOut(out) }] };
38
+ } catch (e) {
39
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_performance_assessment", e);
40
+ throw e;
41
+ }
42
+ },
43
+ );
44
+ }
@@ -0,0 +1,33 @@
1
+ import { z } from "zod";
2
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
+ import type { WhoopClient } from "../../whoop/client.js";
4
+ import { ProfileOut } from "../../schemas/profile.js";
5
+ import { projectProfile } from "../../projections/profile.js";
6
+ import { WhoopProjectionError } from "../../whoop/errors.js";
7
+ import { jsonOut } from "../../whoop/json_out.js";
8
+
9
+ export function registerProfile(server: McpServer, client: WhoopClient): void {
10
+ server.tool(
11
+ "whoop_profile",
12
+ "Static account + body data: name, email, height, weight, max HR, resting HR, hidden metrics, stealth mode.",
13
+ {},
14
+ async () => {
15
+ const userId = process.env.WHOOP_USER_ID;
16
+ const bootstrapQuery = userId ? { accountType: "users", id: userId } : {};
17
+ const [bootstrap, hidden_body_comp, hidden_healthspan, stealth] = await Promise.all([
18
+ client.get("/users-service/v2/bootstrap", bootstrapQuery),
19
+ client.get("/users-service/v1/hidden-metrics/BODY_COMP").catch(() => null),
20
+ client.get("/users-service/v1/hidden-metrics/HEALTHSPAN").catch(() => null),
21
+ client.get("/users-service/v1/stealth-mode").catch(() => null),
22
+ ]);
23
+ try {
24
+ const projected = projectProfile({ bootstrap, hidden_body_comp, hidden_healthspan, stealth });
25
+ const out = ProfileOut.parse(projected);
26
+ return { content: [{ type: "text", text: jsonOut(out) }] };
27
+ } catch (e) {
28
+ if (e instanceof z.ZodError) throw new WhoopProjectionError("whoop_profile", e);
29
+ throw e;
30
+ }
31
+ },
32
+ );
33
+ }