@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
package/LICENSE ADDED
@@ -0,0 +1,37 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Brian Gao
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+ This software is NOT affiliated with WHOOP, Inc. "WHOOP" is a trademark of
24
+ WHOOP, Inc. This is a community-built tool that interacts with Whoop's private
25
+ iOS API surface via reverse engineering of the iOS app's network traffic.
26
+
27
+ Use of this software is contrary to Whoop's Terms of Use, Section 4 — specifically
28
+ Section 4(v) (prohibition on reverse engineering) and Section 4(iii) (prohibition
29
+ on web scraping / data extraction, "even if the Account owner gives permission").
30
+ It is not illegal, but it is not permitted by the user agreement you accepted
31
+ when activating your Whoop Membership. Whoop reserves the right under Section 21
32
+ to suspend or terminate access to the Services and your Membership for material
33
+ breaches of the Agreement.
34
+
35
+ Use this software at your own discretion. The authors disclaim any responsibility
36
+ for account suspensions, terminations, lost data, or other consequences resulting
37
+ from Whoop enforcing its Terms of Use.
package/README.md ADDED
@@ -0,0 +1,587 @@
1
+ <p align="center">
2
+ <img src="assets/banner.svg" alt="totem — 48 tools, 47 microservices, 311 endpoints" width="820">
3
+ </p>
4
+
5
+ <p align="center">
6
+ <i><b>Totem</b> gives Claude (or any MCP-compatible AI) <b>full read + write access to your wearable data.</b> Today it speaks <b>Whoop</b> — every metric, through Whoop's private iOS API.</i>
7
+ </p>
8
+
9
+ <p align="center">
10
+ <a href="#remote-hosting"><img src="https://img.shields.io/badge/Claude_Code-a855f7?style=for-the-badge" alt="Claude Code"></a>
11
+ <a href="#claude-desktop-config"><img src="https://img.shields.io/badge/Claude_Desktop-7c3aed?style=for-the-badge" alt="Claude Desktop"></a>
12
+ <img src="https://img.shields.io/badge/ChatGPT_Desktop-10a37f?style=for-the-badge" alt="ChatGPT Desktop">
13
+ <img src="https://img.shields.io/badge/Codex-000000?style=for-the-badge" alt="Codex">
14
+ <img src="https://img.shields.io/badge/Gemini_CLI-4285f4?style=for-the-badge" alt="Gemini CLI">
15
+ <img src="https://img.shields.io/badge/Any_MCP_1.x_Client-262626?style=for-the-badge" alt="any MCP 1.x client">
16
+ </p>
17
+
18
+ <p align="center">
19
+ <img src="https://img.shields.io/badge/tools-48-9ca3af?style=flat-square" alt="tools">
20
+ <img src="https://img.shields.io/badge/TypeScript-6.0-3178c6?style=flat-square&logo=typescript&logoColor=white" alt="typescript">
21
+ <img src="https://img.shields.io/badge/Node-24%2B-339933?style=flat-square&logo=node.js&logoColor=white" alt="node">
22
+ <img src="https://img.shields.io/badge/MCP-1.x%2B-9ca3af?style=flat-square" alt="mcp">
23
+ <img src="https://img.shields.io/badge/deploy-Fly%20%7C%20Docker%20%7C%20Railway-9ca3af?style=flat-square" alt="deploy">
24
+ </p>
25
+
26
+ <p align="center">
27
+ <video src="https://github.com/user-attachments/assets/b0101d7d-24ad-4341-a88c-dc6fae075f6e" controls muted width="820"></video>
28
+ </p>
29
+ <p align="center">
30
+ <sub>▶ 2-min demo — the full <code>totem cloud</code> flow: install → Whoop login → Fly deploy → Claude connector → first query.</sub>
31
+ </p>
32
+
33
+ 48 tools, structured zod-validated outputs, bundled catalogs (372 exercises, 308 behaviors, 203 sports, 311 endpoints), write-safety harness, automatic Cognito token refresh, session-scoped catalog gate. TypeScript 6, Node 24, 233 tests.
34
+
35
+ > **Totem is becoming a universal wearables bridge.** Whoop is the first adapter — every metric, fully wired. Fitbit, Apple Watch, and Garmin are in progress ([contributors welcome](CONTRIBUTING.md)). The MCP + projection layer is device-agnostic; an adapter just maps its source into the same shared schemas, so everything below applies to whatever you wear.
36
+
37
+ > *Note: this works through Whoop's private iOS API rather than the public OAuth API. That isn't what Whoop's terms allow — see the [FAQ](#faq) if you want the full picture before installing.*
38
+
39
+ ---
40
+
41
+ ## Table of contents
42
+
43
+ 1. [Get Started](#get-started)
44
+ 2. [Why this exists](#why-this-exists)
45
+ 3. [What it does](#what-it-does)
46
+ 4. [Architecture](#architecture)
47
+ 5. [The 48 tools](#the-48-tools)
48
+ 6. [Authentication](#authentication)
49
+ 7. [Write-safety harness](#write-safety-harness)
50
+ 8. [Bundled catalogs](#bundled-catalogs)
51
+ 9. [Configuration](#configuration)
52
+ 10. [Remote hosting](#remote-hosting)
53
+ - [Deploying to Hugging Face Spaces (free hosting)](#deploying-to-hugging-face-spaces-free-hosting)
54
+ 11. [The `totem` CLI](#the-totem-cli)
55
+ 12. [Privacy + security](#privacy--security)
56
+ 13. [Troubleshooting](#troubleshooting)
57
+ 14. [Comparison to alternatives](#comparison-to-alternatives)
58
+ 15. [FAQ](#faq)
59
+ 16. [Disclaimers](#disclaimers)
60
+ 17. [Acknowledgments](#acknowledgments)
61
+
62
+ **Other root-level docs:** [`TOOLS.md`](TOOLS.md) (full per-tool reference) · [`WHOOP.md`](WHOOP.md) (full API reference) · [`CHANGELOG.md`](CHANGELOG.md) · [`CONTRIBUTING.md`](CONTRIBUTING.md) · [`SECURITY.md`](SECURITY.md) · [`LICENSE`](LICENSE)
63
+
64
+ ---
65
+
66
+ ## Get Started
67
+
68
+ **Prerequisites:** Node 24+ and a Whoop account (any membership tier).
69
+
70
+ ```bash
71
+ git clone https://github.com/thebriangao/totem.git
72
+ cd totem && npm install && npx tsc && npm link
73
+ ```
74
+
75
+ That puts `totem` on your PATH (the one-time `npx tsc` builds it; after that every workflow is a `totem` command — there are no `npm run` scripts). Now run **one guided command** — each handles Whoop login (SMS included), setup, and connecting to Claude from end to end. Pick how you want to run it:
76
+
77
+ ### ★ Recommended — `totem cloud`
78
+
79
+ Deploys the server to a host and connects it to Claude on **web, desktop, and mobile**, synced across every device on your account. One command walks through:
80
+
81
+ 1. **Whoop login** — email + password, plus the SMS code if your account has MFA. Tokens are saved locally and pushed to the host.
82
+ 2. **Pick a host** — Fly (automated + tested), Railway, Google Cloud Run, or your own server (guided Docker steps).
83
+ 3. **Secrets** — generates `MCP_AUTH_TOKEN` and asks you to choose a connector password.
84
+ 4. **Deploy + verify** — sets env, deploys, confirms `/health` and the OAuth endpoints are live.
85
+ 5. **Connect** — prints ready-to-paste setup for **claude.ai, ChatGPT, Claude Code (remote), and Cursor / Windsurf / any HTTP MCP client** (URL + password for the OAuth connectors, a bearer-token block for the rest), and opens claude.ai's connector page.
86
+
87
+ ```bash
88
+ totem cloud
89
+ ```
90
+
91
+ ### Local only — `totem local`
92
+
93
+ Runs the server on this machine over stdio — no hosting, this device only. Walks through Whoop login → build → wiring it into the client you pick: **Claude Desktop, Claude Code, Cursor, VS Code (Copilot), Gemini CLI, Codex CLI, or Windsurf** — it writes the right config to the right path automatically (or prints a universal block for any other MCP client). Restart the client and you're set.
94
+
95
+ ```bash
96
+ totem local
97
+ ```
98
+
99
+ ### Keeping it alive
100
+
101
+ Whoop's tokens expire roughly every 30 days. When they do, re-run the same command — it re-logs you in and (if you deployed) pushes the new tokens to your server:
102
+
103
+ ```bash
104
+ totem auth
105
+ ```
106
+
107
+ Silent if your account has no SMS MFA; prompts for the code if it does. Pushes fresh tokens to your deployment automatically.
108
+
109
+ ### Check it works
110
+
111
+ Ask Claude: *"how am I doing today on whoop?"* — you should get structured recovery / sleep / strain back.
112
+
113
+ > Prefer to wire everything up by hand? The guided commands just automate the steps documented in [The `totem` CLI](#the-totem-cli), [Remote hosting](#remote-hosting), and [Configuration](#configuration). Stuck? See [Troubleshooting](#troubleshooting).
114
+
115
+ ---
116
+
117
+ ## Why this exists
118
+
119
+ Whoop ships two APIs:
120
+
121
+ - The **public developer API** at [`developer.whoop.com`](https://developer.whoop.com/api/) is OAuth2, read-only, and exposes **13 endpoints** under 6 scopes. You get recovery score, sleep stage totals, workout strain, body measurements (3 fields), and HRV/RHR per cycle. No journal, no Strength Trainer, no Whoop Coach, no hypnogram, no stress monitor, no trends, no writes, nothing else. Numeric `sport_id` was removed 2025-09-01.
122
+ - The **private iOS API** is what the actual Whoop app uses — `api.prod.whoop.com` behind AWS Cognito. **311 distinct operations across 47 microservices**, including everything missing from above.
123
+
124
+ This MCP wraps the iOS surface.
125
+
126
+ ### What the iOS API has that the public OAuth doesn't
127
+
128
+ | Capability | Tool |
129
+ |---|---|
130
+ | HRV / RHR / respiratory / VO2 / weight time-series (25 metrics × up to 4 windows) | `whoop_trend` |
131
+ | Hypnogram (per-stage sleep timeline) + full stage breakdown (ms + %) + in-sleep HR | `whoop_sleep` |
132
+ | Strength Trainer — every set, every workout, full 372-exercise catalog, PRs | `whoop_lift_*` (8 tools) |
133
+ | 308-behavior Journal + behavior impact analysis | `whoop_journal*` (5 tools) |
134
+ | Stress monitor (intraday timeline) | `whoop_stress, whoop_live_stress` |
135
+ | Whoop Coach AI chat | `whoop_coach_ask` |
136
+ | Smart Alarm (read + 4 write modes) | `whoop_smart_alarm*` |
137
+ | HR zones (read + configure max HR / 5 custom zones) | `whoop_hr_zones*` |
138
+ | Compare-windows, sleep coach, calendar grid, performance assessment | `whoop_compare`, `whoop_sleep_need`, `whoop_calendar`, `whoop_performance_assessment` |
139
+ | Live HR / activity state / live stress | `whoop_live_*` (3 tools) |
140
+ | Community leaderboards, hidden metrics, women's health (cycle / symptoms / MCI) | `whoop_leaderboard`, `whoop_hidden_metric`, `whoop_cycle*` |
141
+ | **14 write tools** — log workouts, journal entries, profile edits, smart-alarm config | various |
142
+
143
+ If recovery + sleep totals + workout list is enough for you, use the public OAuth API. If anything in the table is interesting, you need this. The iOS API was discovered via mitmproxy — full methodology in [`WHOOP.md`](WHOOP.md).
144
+
145
+ ---
146
+
147
+ ## What it does
148
+
149
+ The MCP runs as a local Node process. It speaks **Model Context Protocol** over stdio (or HTTP for remote deployments), registers 48 tools at startup, and waits for tool calls from a connected MCP client.
150
+
151
+ When a tool is called:
152
+
153
+ 1. Authenticates via the cached Cognito access token (auto-refreshes if expired)
154
+ 2. Issues HTTP requests to `api.prod.whoop.com`
155
+ 3. Walks the response to extract a flat domain object (the **projection** step)
156
+ 4. Validates the projected object against a zod schema (catches Whoop API drift)
157
+ 5. Returns the structured JSON to the MCP client
158
+
159
+ Writes follow the same path plus a **preview gate**: every write tool defaults `confirm: false`, returning a preview of what would be sent. Claude must explicitly re-call with `confirm: true` to fire.
160
+
161
+ See [The 48 tools](#the-48-tools) for the full per-tool reference.
162
+
163
+ ---
164
+
165
+ ## Architecture
166
+
167
+ ```
168
+ Claude Desktop / Code ──stdio──▶ src/server.ts ──▶ 48 tool handlers
169
+ │
170
+ ┌──────────────────┼──────────────────┐
171
+ ▼ ▼ ▼
172
+ schemas (zod) projections (raw→flat) whoop/client
173
+ │
174
+ ▼ HTTPS
175
+ api.prod.whoop.com
176
+ ```
177
+
178
+ ### Three layers per tool
179
+
180
+ Every tool is a schema + projection + handler:
181
+
182
+ - **`src/schemas/<tool>.ts`** — zod schema. The contract Claude sees. Used at runtime to validate the projection's output before returning.
183
+ - **`src/projections/<tool>.ts`** — pure function turning Whoop's raw BFF response into a flat object. All the "Whoop puts this data over there, not where you'd expect" knowledge lives here. Tested against captured fixtures.
184
+ - **`src/tools/v2/<tool>.ts`** — ~25-100 lines. Registers the tool, parses input args, calls the client, runs the projection, validates with zod, returns.
185
+
186
+ Almost no logic in the tool file. That's all in the projection — which makes the codebase highly testable (projections are pure transformations, tested against `tests/fixtures/*.json` without hitting the network).
187
+
188
+ ### Shape drift handling
189
+
190
+ When Whoop changes a response shape, the projection emits unexpected data, zod's `.parse()` fails, and the MCP throws `WhoopProjectionError` instead of silently returning malformed data to Claude. Fix: use `whoop_raw` + `whoop_endpoints` to capture the new shape, update the projection, update the fixture, ship.
191
+
192
+ > **Recent example:** in May 2026, Whoop migrated recovery + strain deep-dives from `GRAPHING_CARD` tiles (keyed by `content.title` like `"RECOVERY"`) to `SCORE_GAUGE` + `CONTRIBUTORS_TILE` items with stable `content.id` keys (`RECOVERY_SCORE_GAUGE`, `CONTRIBUTORS_TILE_HRV`). Other deep-dives still use the old card-based shape. The escape-hatch tools made the migration trivial to debug.
193
+
194
+
195
+ ---
196
+
197
+ ## The 48 tools
198
+
199
+ Compact summary. **Full per-tool reference (input shape · source endpoints · output shape · notes) → [`TOOLS.md`](TOOLS.md).** Tools marked ⚠️ are writes (default `confirm: false`, preview-first). Tools marked 🔒 are gated — the catalog tool in the same group must be called once per session before they'll run.
200
+
201
+ | Group | Tools |
202
+ |---|---|
203
+ | **Snapshots & profile** (4) | `whoop_today` · `whoop_day` · `whoop_profile` · `whoop_calendar` |
204
+ | **Deep dives** (3) | `whoop_recovery` · `whoop_sleep` · `whoop_strain` |
205
+ | **Trends** (2) | `whoop_trend` · `whoop_compare` |
206
+ | **Stress + sleep coach** (2) | `whoop_stress` · `whoop_sleep_need` |
207
+ | **Live** (3) | `whoop_live_hr` · `whoop_live_state` · `whoop_live_stress` |
208
+ | **Activities** (5) | `whoop_workouts` · `whoop_workout` · `whoop_sports_catalog` · `whoop_activity_create` ⚠️🔒 · `whoop_activity_delete` ⚠️ |
209
+ | **Strength reads** (6) | `whoop_lift_prs` · `whoop_lift_exercise` 🔒 · `whoop_lift_progression` 🔒 · `whoop_lift_history` · `whoop_lift_library` · `whoop_lift_catalog` |
210
+ | **Strength writes** (3) | `whoop_lift_log` ⚠️🔒 · `whoop_lift_template_save` ⚠️🔒 · `whoop_lift_custom_exercise` ⚠️🔒 |
211
+ | **Journal** (5) | `whoop_journal` · `whoop_journal_catalog` · `whoop_behavior_impact` · `whoop_journal_log` ⚠️🔒 · `whoop_journal_autopop` ⚠️ |
212
+ | **Women's health** (3) | `whoop_cycle` · `whoop_cycle_log` ⚠️ · `whoop_symptom_log` ⚠️🔒 |
213
+ | **Coach + performance** (2) | `whoop_coach_ask` ⚠️ · `whoop_performance_assessment` |
214
+ | **Smart alarm** (2) | `whoop_smart_alarm` · `whoop_smart_alarm_set` ⚠️ |
215
+ | **Social** (2) | `whoop_leaderboard` · `whoop_communities` |
216
+ | **Settings** (4) | `whoop_hr_zones` · `whoop_hr_zones_set` ⚠️ · `whoop_profile_update` ⚠️ · `whoop_hidden_metric` ⚠️ |
217
+ | **Escape hatch** (2) | `whoop_raw` · `whoop_endpoints` |
218
+
219
+ **Total: 48** (32 reads + 14 writes + 2 escape hatches). For each tool's input args, source endpoint(s), and output shape, see [`TOOLS.md`](TOOLS.md).
220
+
221
+ ---
222
+
223
+ ## Authentication
224
+
225
+ Whoop's iOS app uses **AWS Cognito** routed through a Whoop-owned proxy (`/auth-service/v3/whoop/`). The proxy fills in `ClientId` + `SECRET_HASH` server-side — no IPA extraction needed.
226
+
227
+ **Bootstrap once** (email + password + SMS MFA code if your account has it on) → tokens written to `.env`. **After that, it's hands-off**: access tokens auto-refresh every 24h via the refresh token; refresh token lives ~30 days. Single-flight refresh gate prevents thundering-herd refreshes when concurrent tool calls all see a stale token at the same time.
228
+
229
+ Auth requests impersonate the iOS AWS Swift SDK (the proxy 403s a Node-style User-Agent), and data requests carry the **WHOOP iOS app's own identity headers** (`user-agent: iOS`, the `x-whoop-*` device set, a per-install identifier) so the traffic blends with the legitimate app rather than standing out — see [`WHOOP.md` → Headers for data requests](WHOOP.md) for the full set and the reasoning.
230
+
231
+ **Error classes** (`src/whoop/errors.ts`):
232
+
233
+ | Error | When | Behavior |
234
+ |---|---|---|
235
+ | `WhoopAuthExpiredError` | 401 from Whoop | TokenManager refreshes on next call |
236
+ | `WhoopApiError` | 4xx with body | Description surfaced to caller |
237
+ | `WhoopServerError` | 5xx | Transient — retry |
238
+ | `WhoopProjectionError` | Projection output failed zod parse | Whoop changed shape — fix the projection |
239
+
240
+ When refresh-token lifetime expires (~30 days), re-run `totem auth`. It auto-detects local vs deployed and, for a deployment, pushes the new tokens to it. Brand-new SMS code (if your account has MFA), fresh 30-day window.
241
+
242
+ ---
243
+
244
+ ## Write-safety harness
245
+
246
+ Every write tool defaults `confirm: false`. The first call returns a **preview** of what would execute. Claude must explicitly re-call with `confirm: true` to fire the actual request. Without the gate, a hallucinated "log my workout" could create garbage activities on your account.
247
+
248
+ The preview shape (lives in `src/whoop/write_safety.ts`):
249
+
250
+ ```json
251
+ {
252
+ "preview": true,
253
+ "will_execute": {
254
+ "method": "POST",
255
+ "path": "/weightlifting-service/v2/weightlifting-workout/activity",
256
+ "body_summary": {
257
+ "exercise_count": 3, "set_count": 12,
258
+ "exercise_list": [{"name": "BENCHPRESS_BARBELL", "set_count": 5}, ...]
259
+ }
260
+ },
261
+ "set_confirm_true_to_run": true
262
+ }
263
+ ```
264
+
265
+ Claude reads this back to you, you confirm, Claude re-calls with `confirm: true`, the actual POST fires. Every write tool's output schema is a `withPreview(ReceiptSchema)` discriminated union — preview or receipt, never both.
266
+
267
+ ---
268
+
269
+ ## Bundled catalogs
270
+
271
+ Four datasets compiled into the MCP at build time (not fetched at runtime):
272
+
273
+ | Catalog | Entries | Catalog tool | Use |
274
+ |---|---:|---|---|
275
+ | `behaviors.ts` | 308 | `whoop_journal_catalog` | Journal behavior validation |
276
+ | `exercises.ts` | 372 | `whoop_lift_catalog` | Strength Trainer exercises |
277
+ | `sports.ts` | 203 | `whoop_sports_catalog` | `sport_id` ↔ name |
278
+ | `endpoints.ts` | 311 | `whoop_endpoints` | API path search |
279
+
280
+ **Session-scoped gate**: tools that take IDs from sports/exercises/behaviors refuse to run until the corresponding catalog tool has been called once per session. Keeps ~14k tokens out of the system prompt. AI calling e.g. `whoop_activity_create` first gets `{error: "Must call whoop_sports_catalog first…"}`.
281
+
282
+ ---
283
+
284
+ ## Configuration
285
+
286
+ ### Environment variables
287
+
288
+ | Variable | Required | Description |
289
+ |---|---|---|
290
+ | `WHOOP_EMAIL` | yes | Your Whoop login email |
291
+ | `WHOOP_PASSWORD` | yes (bootstrap only) | Your Whoop login password (used only during bootstrap) |
292
+ | `WHOOP_IOS_BEARER_TOKEN` | yes | Cognito access token (24h, auto-refreshed) |
293
+ | `WHOOP_COGNITO_REFRESH_TOKEN` | yes | Cognito refresh token (~30d) |
294
+ | `WHOOP_USER_ID` | no | Your Whoop user ID — used by `whoop_profile`, `whoop_leaderboard`. Avoids one bootstrap call per session. |
295
+ | `WHOOP_TIMEZONE` | no | IANA timezone (e.g., `America/Los_Angeles`). If unset, auto-detected from your Whoop profile and refreshed hourly. Set explicitly to override. |
296
+ | `WHOOP_INSTALLATION_ID` | no (auto) | The per-install device identifier sent as `x-whoop-installation-identifier`. Generated once and written to `.env` on first run — don't set it by hand. |
297
+ | `WHOOP_TOKEN_STORE` | no | `envfile` (default — persists refreshed tokens back to `.env`) or `memory` (for read-only filesystems; re-bootstrap every ~30 days). |
298
+
299
+ ### Claude Desktop config
300
+
301
+ ```json
302
+ {
303
+ "mcpServers": {
304
+ "whoop": {
305
+ "command": "/opt/homebrew/bin/node",
306
+ "args": ["/absolute/path/to/totem/dist/server.js"]
307
+ }
308
+ }
309
+ }
310
+ ```
311
+
312
+ The MCP loads `.env` from the repo root (relative to `server.js`). Use absolute paths — Claude Desktop doesn't inherit shell `PATH`.
313
+
314
+ ---
315
+
316
+ ## Remote hosting
317
+
318
+ The MCP also speaks HTTP — deploy once, use from multiple devices. Same 48 tools, same auto-refresh, behind a bearer-token gate at a URL.
319
+
320
+ ```bash
321
+ # 1. Local bootstrap (Cognito needs an interactive MFA prompt)
322
+ totem auth
323
+
324
+ # 2. Build + deploy via the shipped Dockerfile (Fly/Railway/Render/VPS — all work)
325
+ docker build -t totem .
326
+
327
+ # 3. Run with env: WHOOP_EMAIL, WHOOP_IOS_BEARER_TOKEN, WHOOP_COGNITO_REFRESH_TOKEN,
328
+ # MCP_TRANSPORT=http, MCP_AUTH_TOKEN=$(openssl rand -hex 32)
329
+ ```
330
+
331
+ ### Deploying to Hugging Face Spaces (free hosting)
332
+
333
+ [Hugging Face Spaces](https://huggingface.co/spaces) provides **free Docker hosting** — a zero-cost alternative to Fly or Railway. Connecting to **claude.ai web and Claude mobile** as a custom connector requires a **Claude Pro plan**, but the server itself runs for free on HuggingFace.
334
+
335
+ > **Note:** HuggingFace Spaces routes all external traffic through port **7860** only, but this repo's Dockerfile defaults to `3000`. The server reads `PORT` from the environment, so just set `PORT=7860` as a Space variable (step 2 below) — no Dockerfile edit needed, and it'll listen on the right port.
336
+
337
+ #### Step-by-step
338
+
339
+ **1. Create a new Space**
340
+
341
+ - Go to [huggingface.co/new-space](https://huggingface.co/new-space)
342
+ - Select **Docker** as the Space SDK
343
+ - Set the **visibility to Public** — HuggingFace Spaces must be public for Claude's connector to reach the `/mcp` endpoint
344
+
345
+ **2. Add your secrets via the Space Settings UI**
346
+
347
+ In your Space → **Settings → Variables and Secrets**, add the following. The token values go in as **Secrets** (hidden, never shown in logs); `PORT` and `PUBLIC_URL` aren't sensitive, so they can be plain **Variables**:
348
+
349
+ | Secret name | Where to find the value |
350
+ |---|---|
351
+ | `WHOOP_EMAIL` | Your Whoop account email |
352
+ | `WHOOP_IOS_BEARER_TOKEN` | From `totem auth` on your local machine (written to `.env`) |
353
+ | `WHOOP_COGNITO_REFRESH_TOKEN` | From `totem auth` on your local machine (written to `.env`) |
354
+ | `WHOOP_USER_ID` | From `.env` after running `totem auth` |
355
+ | `MCP_AUTH_TOKEN` | Generate one with `openssl rand -hex 32` (or reuse the value from `.env.deploy` if you ran a deploy flow) |
356
+ | `AUTH_PASSWORD` | A password you'll type once when adding the Claude connector |
357
+ | `PUBLIC_URL` | Your Space's public URL — e.g. `https://<your-hf-username>-<your-space-name>.hf.space` |
358
+ | `PORT` | `7860` — HuggingFace's required port. Without this the container listens on 3000 and is unreachable. |
359
+
360
+ > **Tip:** The `WHOOP_*` token values come from your local `.env` after running `totem auth`. `MCP_AUTH_TOKEN` you generate yourself (`openssl rand -hex 32`).
361
+
362
+ **3. Push your code to the Space**
363
+
364
+ Clone this repo and add your HuggingFace Space as a remote, then push:
365
+
366
+ ```bash
367
+ git clone https://github.com/thebriangao/totem
368
+ cd totem
369
+
370
+ # Add your HuggingFace Space as a remote
371
+ git remote add hf https://huggingface.co/spaces/<your-hf-username>/<your-space-name>
372
+
373
+ # Push the main branch
374
+ git push hf main
375
+ ```
376
+
377
+ HuggingFace will automatically build and run the Docker container. Watch the **Logs** tab in your Space to confirm it starts up and `/health` returns 200.
378
+
379
+ **4. Connect to Claude**
380
+
381
+ Once the Space is running, go to **claude.ai → Settings → Connectors → Add custom connector**:
382
+
383
+ - **MCP Server URL:** `https://<your-hf-username>-<your-space-name>.hf.space/mcp`
384
+ - Claude will open an OAuth flow — enter the `AUTH_PASSWORD` you set in your Space secrets
385
+
386
+ > `MCP_AUTH_TOKEN` is used internally as the bearer token + JWT signing secret. You do **not** type it into Claude's connector UI — that field uses the OAuth `AUTH_PASSWORD` flow instead.
387
+
388
+ **5. Re-authenticate when tokens expire (~30 days)**
389
+
390
+ Whoop's Cognito tokens expire roughly every 30 days. Re-run `totem auth` on your local machine, then update `WHOOP_IOS_BEARER_TOKEN` and `WHOOP_COGNITO_REFRESH_TOKEN` in your Space's Secrets UI. The Space will restart automatically and pick up the new tokens.
391
+
392
+ **Claude Desktop** doesn't natively speak remote MCP — bridge through stdio with [`mcp-remote`](https://www.npmjs.com/package/mcp-remote):
393
+
394
+ ```json
395
+ { "mcpServers": { "whoop": {
396
+ "command": "npx",
397
+ "args": ["-y", "mcp-remote", "https://your-app.fly.dev/mcp",
398
+ "--header", "Authorization:Bearer your-mcp-auth-token"]
399
+ }}}
400
+ ```
401
+
402
+ **Claude Code** speaks remote MCP natively: `claude mcp add whoop --url ... --header ...`.
403
+
404
+ **claude.ai web + Claude mobile app** can't use a bearer token — their custom-connector UI only supports OAuth. The server includes an OAuth 2.1 + PKCE authorization server for exactly this. Enable it by setting two extra env vars:
405
+
406
+ ```bash
407
+ AUTH_PASSWORD=<a password you'll type once when adding the connector>
408
+ PUBLIC_URL=https://your-app.fly.dev # your server's public origin (the OAuth issuer)
409
+ ```
410
+
411
+ Then in Claude: **Settings → Connectors → Add custom connector**, paste `https://your-app.fly.dev/mcp`, and Claude walks the OAuth flow. It pops a small password page (served by your server) — enter `AUTH_PASSWORD`, approve, done. The connector then syncs across every device logged into your Claude account (web, desktop, mobile). The password gate means a stranger who finds your URL still can't connect without it. `MCP_AUTH_TOKEN` doubles as the JWT signing secret; leave `AUTH_PASSWORD` unset to disable this path.
412
+
413
+ All of the above is what `totem cloud` automates for you — the manual steps here are for reference or hand-rolling.
414
+
415
+ **When Cognito expires (~30 days)**: `totem auth` from your Mac. Silent if your account has no SMS MFA; prompts for the code if it does. Auto-detects your deployment and pushes the new tokens to it (Fly/Railway/Cloud Run/custom), ~10s restart. Requires being at a machine with the repo + the platform CLI.
416
+
417
+ **Security**: bearer-token and OAuth paths both gate `/mcp`. Generate the token random (`openssl rand -hex 32`), HTTPS only, never commit, rotate if leaked. OAuth access/refresh tokens are stateless signed JWTs (survive restarts); auth codes are one-time + 60s-lived; PKCE S256 is enforced. `/health` is the only path without auth.
418
+
419
+ ---
420
+
421
+ ## The `totem` CLI
422
+
423
+ `totem` is the single entry point for everything — there are no `npm run` scripts. It works from any directory (it resolves its own install path), so `totem deploy` from `~/Desktop` does the same thing as `cd totem && fly deploy`.
424
+
425
+ ```bash
426
+ # One-time, after cloning:
427
+ npm install && npx tsc && npm link # the only npm steps; `npx tsc` does the first build
428
+
429
+ totem # banner + full command list
430
+ ```
431
+
432
+ Commands by group:
433
+
434
+ | Group | Commands |
435
+ |---|---|
436
+ | **Get started** | `cloud` ★ (guided server deploy + Claude connect) · `local` (guided local setup) |
437
+ | **Setup** | `auth` (log in + save tokens — re-run to re-auth; auto-detects local vs deployed and pushes new tokens to your deployment) |
438
+ | **Deployed** | `deploy` · `update` (interactive version picker + auto-update) · `logs` · `status` · `ping` |
439
+ | **Local dev** | `start [--http]` · `dev` · `dev:http` · `build` · `test` · `typecheck` |
440
+ | **Inspect** | `info` · `tools` · `config <stdio\|http>` |
441
+ | **Help** | `help` · `version` (+ `--help`, `-v` aliases) |
442
+
443
+ Most people only ever need the two **Get started** commands plus `auth` (to re-auth when tokens expire). The rest are for power users — `totem ping` ("is my deploy alive"), `totem logs`, `totem start` (drop-in for `node dist/server.js`), etc.
444
+
445
+ **Staying current — `totem update`.** An interactive updater. Run it and you get a version picker — every release, newest first, with dates and notes pulled from GitHub Releases. The newest is the default; pick anything older and it warns you what you'd be behind on (you can always run it again to go forward). After you choose, it applies the change with a guided, animated build — git installs fast-forward `main` (or check out the pinned tag), reinstall deps, and rebuild; npm installs reinstall the chosen version — then redeploys to your existing host and health-checks `/health`. A clean working tree is required (it won't clobber local edits), and a failed deploy leaves your live server untouched.
446
+
447
+ After a successful update to the latest it offers **auto-update**. Turn it on and a background job (launchd on macOS, cron on Linux) checks for new releases every 6 hours and applies them the same way — pull, build, redeploy, health-check — logging to `.totem-autoupdate.log`. There's no push channel to your machine, so it's a scheduled poll, not instant. Toggle it directly anytime:
448
+
449
+ ```bash
450
+ totem update # interactive: pick a version, then optionally enable auto-update
451
+ totem update --auto on # turn auto-update on (and pull the newest now)
452
+ totem update --auto off # turn it off
453
+ totem update --check # non-interactive: print installed-vs-latest + auto state
454
+ ```
455
+
456
+ Versions are sourced from the places that already host them — git tags + GitHub Releases for git installs, the npm registry for global installs — so there's nothing extra to maintain. Auto-update is opt-in and only ever moves you to **released** versions (every release is CI-gated), never bleeding-edge `main`.
457
+
458
+ ---
459
+
460
+ ## Privacy + security
461
+
462
+ - **Credentials live in `.env` on your machine.** Email, password, access token, refresh token — never leave your filesystem. Claude can't read them (it doesn't have filesystem access unless you wire in a filesystem MCP).
463
+ - **The only outbound traffic is HTTPS to `api.prod.whoop.com`.** No telemetry, no analytics, no third-party servers. The MCP is open source — every line that touches your data is auditable.
464
+ - **Write safety**: every write tool defaults to `confirm: false`. The preview shape includes what would be sent. You see it in chat before any mutation. To go further, remove specific writes from `src/tools/register.ts` or use Claude Desktop's "always require approval" setting.
465
+ - **Hardened in 1.2.3**: token files are written `0600`, your account password is wiped from `.env` after login, OAuth tokens are audience-bound and signed with a key derived from `MCP_AUTH_TOKEN`, the HTTP server sends anti-clickjacking + CSP headers, the connector-password gate has a global brute-force ceiling, and deploy secrets are pushed over stdin (not argv). Full detail in [`SECURITY.md`](SECURITY.md) and [`CHANGELOG.md`](CHANGELOG.md).
466
+
467
+ ---
468
+
469
+ ## Troubleshooting
470
+
471
+ **"AUTH FAIL: Cognito InitiateAuth failed (400)"**
472
+ > Wrong email or password. Double-check `.env`.
473
+
474
+ **"AUTH FAIL: Cognito MFA challenge missing Session token"**
475
+ > The InitiateAuth response was malformed (unusual). Re-run `totem auth` — Cognito occasionally drops sessions.
476
+
477
+ **"MFA verification did not return tokens"**
478
+ > You entered the wrong SMS code (or it timed out). Codes expire after ~3 minutes.
479
+
480
+ **"WhoopAuthExpiredError" after every call**
481
+ > Your refresh token has expired (>30 days since last login). Re-run `totem auth` — it logs you back in, saves the tokens locally, and (if you deployed) auto-detects your host and pushes the new tokens to it in one step. If your account has MFA you'll get a fresh SMS code on your phone to type in the terminal.
482
+
483
+ **"WhoopServerError: 502" / "503" / "504"**
484
+ > Whoop's servers are having issues. Retry in 30 seconds.
485
+
486
+ **Claude says it doesn't see any whoop tools**
487
+ > Check `claude_desktop_config.json` paths are absolute. Restart Claude Desktop fully (quit, then reopen).
488
+ > Check the MCP server runs without errors: `totem dev` — it should start silently and wait on stdin.
489
+
490
+ **"WhoopApiError: 422 on /profile-service/v1/profile"**
491
+ > Your `whoop_profile_update` body is too partial. Send most fields (gender from {MALE,FEMALE,NON_BINARY} only, birthday as YYYY-MM-DD or ISO datetime, country ISO-2). If `country=US`, also send `state` — Whoop returns 400 `"AdminDivision (state) must be set for US"` otherwise.
492
+
493
+ **"Whoop API error 409 on /weightlifting-service/v2/weightlifting-workout/activity"**
494
+ > Time window conflicts with an existing workout. Use a different range.
495
+
496
+ **"WhoopProjectionError for whoop_X"**
497
+ > Whoop changed a response shape. Capture the new response (e.g. via `whoop_raw`), inspect, update the projection.
498
+
499
+ **Tests fail after `git pull`**
500
+ > Pull may have updated captured fixtures. Run `totem test` again to see what changed. If projections need updating, that's the work.
501
+
502
+ **`totem build` (or `npx tsc`) fails with "Top-level await is currently not supported with the 'cjs' output format"**
503
+ > You're using an old Node. Upgrade to Node 24+.
504
+
505
+ **"Error: ENOENT: no such file or directory, open '.env'"**
506
+ > Create `.env` at the repo root (or wherever `dist/server.js` is being run from — the MCP loads `.env` relative to the entry).
507
+
508
+ **"Cannot find module '@modelcontextprotocol/sdk/server/mcp.js'"**
509
+ > Run `npm install`.
510
+
511
+ **"AbortError: This operation was aborted"**
512
+ > A request to Whoop's API took longer than 30s. Either Whoop is slow or your network is slow. Retry.
513
+
514
+ ---
515
+
516
+ ## Comparison to alternatives
517
+
518
+ | Approach | Pros | Cons |
519
+ |---|---|---|
520
+ | **This MCP** | Full iOS API surface (48 total: 32 reads + 14 writes + 2 escape hatches), writes supported, structured outputs, auto-refresh, write-safety, session-scoped catalog gate | Unsupported by Whoop (see [FAQ](#faq) for what that means); reverse-engineered (Whoop could break it at any time); local install required |
521
+ | Whoop's public OAuth API | Official, supported, 6 webhook events, scoped permissions | Only 13 endpoints; read-only; no journal/strength/stress/coach/smart-alarm/trends/hypnogram; numeric `sport_id` removed 2025-09-01; 429s exist |
522
+ | HealthKit-based scraper | Bypass Whoop entirely; uses Apple's data sync | Loses Whoop-specific data (recovery score, journal, coach); requires iOS device involvement |
523
+ | Direct mitmproxy capture | See everything | Manual, not programmable, doesn't scale |
524
+ | Whoop iOS app + screenshots → Claude | Works without code | Painful, slow, no writes |
525
+
526
+ This MCP is the only option for **programmatic write access** to your Whoop data right now.
527
+
528
+ ---
529
+
530
+ ## FAQ
531
+
532
+ **Q: Is this supported by Whoop?**
533
+ A: No. This MCP works through Whoop's private iOS API, which isn't a public surface they intend for third-party tools. Whoop's terms reserve the right to take action against accounts they catch using unsupported integrations — realistically that means suspending API access or terminating the membership. The author has used the MCP heavily for weeks without issue, and traffic patterns look similar to normal app usage, but there's no guarantee. If losing your Whoop account would be a problem for you, don't use this.
534
+
535
+ **Q: Why not use Whoop's public OAuth API instead?**
536
+ A: It's 13 endpoints, all read-only, no journal, no strength, no stress, no coach, no smart alarm, no trends beyond a single recovery score per day. Whoop also pulled numeric `sport_id` past 2025-09-01 (now `sport_name` strings only). If you only need recovery score + sleep stage totals + workout list, the OAuth API is the right answer.
537
+
538
+ **Q: Will this work with the Whoop 4.0 vs 5.0 strap?**
539
+ A: Yes — the API doesn't care which strap you have. It cares about your account.
540
+
541
+ **Q: What about Whoop 6.0?**
542
+ A: When it launches and the iOS app updates, the api version may bump from 7 to 8. The MCP's `constants.ts` may need an update. Worst case, projections break and you fix them.
543
+
544
+ **Q: Can I run this on a server / cloud / always-on?**
545
+ A: Sure. The MCP doesn't care where it runs. Just make sure your `.env` survives restarts.
546
+
547
+ **Q: Can I share this MCP with my friends?**
548
+ A: Each user needs their own `.env` with their own Whoop credentials. Don't share tokens.
549
+
550
+ **Q: Is there an HTTP transport instead of stdio?**
551
+ A: Yes — set `MCP_TRANSPORT=http` to expose the MCP over Streamable HTTP behind a bearer-token + OAuth 2.1 gate (since v1.1.0). See [Remote hosting](#remote-hosting). stdio stays the default for local Claude Desktop / Claude Code.
552
+
553
+ **Q: Does this support Claude's Computer Use API?**
554
+ A: It's MCP-compatible — anything that speaks MCP can talk to it.
555
+
556
+ **Q: Why TypeScript instead of Python?**
557
+ A: The MCP SDK is most mature in TypeScript. Also Whoop's API responses are heavily nested — zod is genuinely the best validation library for that shape work.
558
+
559
+ **Q: Why Node 24 specifically?**
560
+ A: Uses `import.meta.dirname` (added in 20.11), modern `fetch`, native ESM, `AbortController`. Node 18 might work; 16 won't.
561
+
562
+ **Q: How long did this take?**
563
+ A: ~3 weeks of evening/weekend work for v1, plus another week to rewrite as v2 with proper projections and the write-safety harness.
564
+
565
+ **Q: Will you maintain this?**
566
+ A: Best-effort. PRs welcome.
567
+
568
+ ---
569
+
570
+ ## Disclaimers
571
+
572
+ - **Not affiliated with Whoop.** "WHOOP" is a trademark of WHOOP, Inc. Community-built tool that interacts with surfaces Whoop has not published. See the [FAQ](#faq) for the practical implications.
573
+ - **No warranty, use at your own discretion.** The API surface is reverse-engineered — Whoop can change response shapes at any time. The zod schemas surface drift as `WhoopProjectionError` instead of silent corruption.
574
+ - **Respect rate limits.** Single-digit RPS in normal use. Don't be the person who triggers a backend alert that gets every user of this MCP banned.
575
+ - **Don't share tokens.** Your `.env` is yours. Don't commit it, don't paste it anywhere.
576
+
577
+ ---
578
+
579
+ ## Acknowledgments
580
+
581
+ - **WHOOP** for building a fitness platform worth reverse-engineering
582
+ - **Anthropic** for [MCP](https://modelcontextprotocol.io) and [Claude](https://claude.ai)
583
+ - **mitmproxy** for being the tool that made discovery possible
584
+ - **The TypeScript + zod community** for making strict validation pleasant
585
+ - The various API consumers + bloggers who documented bits of Whoop's private API over the years
586
+
587
+ This is open source under the terms in `LICENSE`. Contributions welcome.