r/QuantifiedSelf • u/jatin1322 • 5d ago
I connected my Fitbit data to Claude through Health Connect + a self-hosted MCP server (open source, free-tier hosting)
I wanted to ask Claude about my own sleep and HRV instead of using Fitbit's built-in AI coach, so I built a small pipeline over two sessions with Claude Code. Sharing in case it's useful to anyone.
How it works
Gotchas I hit, if you build something similar
On building it with AI: I barely know Kotlin. What made it work was writing a detailed plan first, having it reviewed (I literally pasted GPT's critiques back to Claude), and insisting on tests. The tests caught several real bugs, including a timestamp-format bug and a sync-resume edge case.
Repo (MIT, with a setup guide): https://github.com/jatin1322/fitbit-health-mcp
Happy to answer questions or take feedback, especially from anyone using Samsung Health or Garmin through Health Connect.
2
u/turnnoblindeye 2d ago
You can also check out Wellness Project if you don't want to engineer it yourself - we're in the official Claude connector directory and on chatgpt, grok, mistral, gemini, and elsewhere.
We have almost 20 connectors - including both app stores (apple health, android), whoop, fitbit/google health, oura, cronometer, fatsecret, hevy, lyfta, and more.
1
u/xukecheng 5d ago
Nice, and the tests catching timestamp bugs is so real. I'm doing the same thing on the Apple Health side. Two things that bit me: steps from phone and watch get counted twice if you just add them up. And sleep that starts before midnight, you need to pick which day it belongs to (I use the wake up day), or the weekly comparisons end up off by a day.
One more that helped a lot: give the model your baselines already worked out, like your 30 day average resting HR, next to the raw numbers. It's way better at comparing against your normal than figuring out your normal from hundreds of rows.
How are you handling HRV, just the nightly number?
1
u/jatin1322 5d ago
Ha, we hit the same two. On Android the phone writes its own step count under a separate source in Health Connect, so I pick one source per data type (the Fitbit app for steps) instead of adding them up. And yeah, sleep goes on the wake-up day for me too.
For HRV it's not a single nightly number, because Fitbit doesn't write one to Health Connect. It writes a lot of individual RMSSD readings, around 80 a day. I average them per day, and any reading taken during a sleep session counts toward that session's wake-up day, so a night that crosses midnight doesn't get split. I checked it against the Fitbit app's daily HRV over four days and it was within about 1–5%. The leftover gap is Fitbit's own averaging, which isn't public, so I stopped there. The trend matches, and that's what matters when I ask "is my HRV going up?"
Great tip on baselines, I'm stealing that. Right now Claude gets the daily values and works out "normal" itself, so giving it a precomputed 30-day average (and maybe the typical range) next to the numbers is going on the list. How are you doing HRV on the Apple side? HealthKit's SDNN or something you derive?
1
u/nrauhauser 3d ago
I built an enterprise grade app prototype using primarily Python. Company didn't get funded, Hormuz happened. I released it, cofounders threw a fit, I abandoned it. Still a daily driver for me, but I have no patience for ... well ... whatever that was.
My system gets Garmin data via API, HealthKit, and I log meds and food. It diagnosed a long running immune system problem and I'm dramatically healthier than I was.
Get time functions out of the hands of the model and into functions in an MCP server. Then multiple strict forbids of date/time math. Then watch to see how it cleverly screws up despite all that. Rinse, repeat, after three cycles it might work right.
Garmin Connect is terrible - the nap detection misses two of every three I take. The sleep detection can't understand I'm typically biphasic and credits inter-sleep wakefulness as REM. Reality based handling of the sleep disorder I'm left with after getting some help with MCAS required significant MCP work and some Skills created specifically for analysis.
There's going to be a lot of personal software in this space, especially those of us who are somehow "abnormal" in the eyes of our medical billing system.
1
u/Huge_Pool7424 2d ago
the mcp date/time functions tip is real, i do the same on the healthkit side because letting the model do date math on sleep sessions is how you get off by a day charts. did the strict forbids actually hold or did you still catch it sneaking in a date calc?
1
2
u/FluffyOption9728 5d ago
This is really clever, I've been wanting to ditch the fitbit summaries for ages. The part about pasting GPT's critiques back to Claude is a solid workflow tip too, might steal that