This is an MCP server to chat with Apple Health data. I built it because I'm working on (yet another) personal trainer tool that keeps track of my workout goals, etc. and does scheduling for me. Part of that is weekly check-ins. I thought pairing those check-ins with sensor data could be useful, so here we are.
It seems there isn't a way to automate access to Apple Health data, so this relies on an iOS app that can quickly/easily export key data to CSV. So the process at the moment is to export the data every Sunday before doing a check-in. More steps than I'd like, but in practice isn't a big lift.
Under the hood this is mostly a thin wrapper around duckdb.
There's a video of it in action here: https://x.com/realtron/status/1947710791521591514
This was quite straightforward once you understand the permissions. I wonder why the OP didn’t do this and was instead using a simple health export CSV?
The main concern I had with releasing this or turning it into a tool was data security.
I have been swimming 1500m x 365 days of the year for the last 7 years. My use case was to build a personalised dashboard for my daily swimming and heart rate data to track detailed progress beyond what Apple offers. Having the ability to query this data with AI could be quite useful, rather than relying on manual reports.
But I'd like to revisit it because it would be a natural fit to just put the personal trainer flow directly in an app.
I would like to go back to this though and add it as an integration option.
I mean, it's been vetted by Apple, right? If they did their job then it should be fine. This isn't the Play Store you're dealing with; it's the App Store. I kinda dig the "simple utility app that does one job well" format, tbh.
We have a REST API with python client lib (https://fulcradynamics.github.io/developer-docs/), an MCP server (https://fulcradynamics.github.io/developer-docs/mcp-server/), and did some experiments with ChatGPT actions as well (https://www.fulcradynamics.com/chatgpt).
It doesn't have the simplicity of a plain export to duckdb/sqlite, but it definitely helps solve a lot of the sharing/collaboration problems.
My general belief around data agents is to offload as much as possible to SQL.
Would love to chip in on the discussion around this topic.
For getting Apple Health data into duckdb, I’ve used this in the past: https://github.com/dogsheep/healthkit-to-sqlite. (You can load the SQLite database directly in duckdb.)
@_neil, any reason not to use this instead? duckdb over a .db file is a more straightforward approach
I think supporting the native Apple Health export feature would be a good idea. It just takes longer than the CSV export, so I started there. I would imagine the native export has more data, though, which might be nice.
People use it to track sensitive information, like reproductive and mental health data, that should only be exported very intentionally.
I haven't experimented with MCP too much because I have some reservations about it, but I decided to go MCP-first for this to see how it feels to prototype around it. My typical flow would have been to go sqlite+sveltekit.
if RubyLLM.with_tools(...).ask("Do my health metrics indicate I am stressed?") model = 'claude-4-opus' else model = 'claude-4-sonnet' end
I have a proof of concept here that turns the Apple Health export xml file into a timeseries .parquet that you can then load into clickhouse or duckdb.
I love the use of a notebook as an updating dashboard here. One of my demos before this MCP server was an evidence.dev dashboard.
All that said, I’ll try to add some examples to the readme.
Looking at the code (and "for the future..." note about LLM generated queries), you cannot ask arbitrary questions? Is that correct?
I work on an iOS health app, and I'd love to try integrating this. It'd help eliminate the step of having to manually export to a CSV every Sunday.
Feel free to shoot me an email if you want to collaborate!
I’ve found good value in making purpose-build MCP servers like that with the general model: Data<>DuckDB<>MCP<>LLM With verbose description for the LLM of an “sql” tool endpoint for it to use to explore.
https://github.com/AgentDank/screentime-mcp
It's pretty crazy what it can do! I'll put examples once I can scrub personal info. But it has browsing history too. Sensitive data, so please be careful!!
This morning I kept pushing and started getting Claude into an human-agentic loop of suggesting MCP tool description and pre-flight SQL changes (for views). I'd ask it a some MCP queries, have it examine the SQL mistakes (e.g. CoreData vs UNIX timestamps, tricky queries), then evolved it. Since the endpoint is SQL, it can generate SQL to generate better SQL....
I had some human intelligence in that (and surely at the outset), but right now mostly I'm building and restarting Claude Desktop, then prompting:
"i have integrated those changes. examine my habits of concurrent browsing. identify statistical patterns in the timing and correlation of the destinations. after you do that, look at the issues you had and present new tool descriptions and sql migration. test the sql migrations before final presentation"
Tool Desc: https://github.com/AgentDank/screentime-mcp/blob/main/intern...
SQL Migration : https://github.com/AgentDank/screentime-mcp/blob/main/intern...
The best approach we've found to tracking specific app use time is to have our app publish App Intents, and then tell users to trigger those intents with shortcuts. It's fairly effective, but very clunky to set up and has to be done app by app..
Does it include health records (eg from Epic)?