healthsql
Reads Apple Health records exported by the companion iPhone app and exposes daily totals, sleep stages, workouts, raw samples, and ring data through SQL-queryable views.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@healthsql How did my sleep and resting heart rate trend over the last two weeks?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
HealthSQL
Your whole Apple Health record as a local SQLite database, so that an AI agent on your computer can answer questions about your body. The agent queries it with SQL, from a shell or as an MCP server.
Apple Health lives on the iPhone. Apple gives it no way to a computer except a manual export, and that export is out of date the day you make it. HealthSQL has two parts:
An iPhone app that copies every Health record to its own folder in your iCloud Drive and keeps the copy current.
healthsql, this repository. One Python file that reads that folder and builds the database. Claude Code, Codex, Claude Desktop, Cursor, and any other agent that has a shell or speaks MCP can then query it.
Watch, ring, scale → Health on the iPhone → the HealthSQL app → your iCloud Drive → healthsql → your agentThere is no server and no account. Your Apple Account is the only link between the phone and the computer: iCloud Drive carries the files.
Guides and the full reference are at healthsql.app.
The iPhone app is with Apple for review. Until it is in the App Store, you can try the command on the sample data in this repository: see Try it without an iPhone.
Install
curl -fsSL https://healthsql.app/install | shThis saves one file to ~/.local/bin/healthsql and then starts healthsql setup, which checks the computer, builds the database, and prints how to connect each agent. It needs Python 3.9 or later and nothing else. On a Mac, xcode-select --install gives you Python.
You can read the code before you use it. It is healthsql.py: one file, standard library only.
With uv or pipx:
uv tool install git+https://github.com/declankra/healthsqlpipx install git+https://github.com/declankra/healthsqlThe computer must be signed in to the same Apple Account as the iPhone, with iCloud Drive on. The first build reads your whole history, so a record of millions of samples takes a few minutes.
Related MCP server: Mi Fitness Data Bridge
Connect your agent
An agent that has a shell needs nothing more: it can call healthsql and read the answer.
For MCP, the command registers itself with the client you name:
healthsql connect claude-code # or: codex, claude-desktop, cursorFor any other MCP client, add a stdio server whose command is the full path to healthsql and whose one argument is mcp:
{
"mcpServers": {
"healthsql": { "command": "/Users/you/.local/bin/healthsql", "args": ["mcp"] }
}
}HealthSQL is in the MCP registry as io.github.declankra/healthsql.
The server has two tools:
Tool | What it does |
| Says what the database holds: when the iPhone last synced, each view with its columns, example queries, and every metric with its unit and date range. The agent calls it once. |
| Takes one read-only SQL statement and returns the rows as JSON. |
You can also give the whole setup to your agent. Tell it:
Set up HealthSQL on this computer so you can read my Apple Health data. Follow https://healthsql.app/agents.md and tell me what my record covers when you are done.Ask in SQL
healthsql # start here: the views, their columns, examples, every metric
healthsql query "SELECT day, steps, resting_hr, hrv_ms, asleep_min FROM daily ORDER BY day DESC LIMIT 7"
healthsql query --csv "SELECT * FROM daily" > daily.csv
healthsql status # is the feed alive, and what to do if it is not
healthsql sync # read every waiting file from the iPhone nowEach command first reads the files that are new, so an answer is as fresh as the phone's last sync. Every answer is JSON and says how fresh it is:
{"rows":[{"day":"2026-11-30","steps":1200,"active_kcal":1150.0,"hr_avg":151.21,"asleep_min":420.0}],
"truncated":false,"phone_synced":"2026-11-30T14:17:30-08:00"}The views:
View | One row for each | Use it for |
| day | Any question about a day or a trend: steps, distance, energy, heart rate, HRV, weight, sleep and more, side by side. |
| metric and day | Apple Health's own total for every metric it holds, with |
| night of sleep | Time asleep and in each stage, from one source. |
| night and source | A watch compared with a ring, or a source other than the one |
| sleep stage interval | The stages of a night, minute by minute. |
| workout | Activity, minutes, distance, heart rate, and the whole record as JSON. |
| raw measurement | A value at a time of day, or one source's own numbers. |
| day | Move, Exercise and Stand, with the goals. |
Under the views is one table, records, with every record the phone sent: quantities, categories, workouts, GPS routes, State of Mind entries, ECG summaries.
What it is careful about
Daily totals are Apple Health's own. A watch, a phone and a ring each record the same walk, so a sum of the raw step samples counts it two or three times. Only Health knows which source counts for which minute. The iPhone app asks Health for each day's total, the number the Health app shows, and
dailyanddayshold those numbers.Every answer says how fresh it is.
phone_syncedis the phone's last export. When something is wrong (the phone went quiet, files are still downloading, Health refused a type), there is oneproblemline that names what you must do.Unknown is not zero. A day that has no total has no row.
A night comes from one source. If a watch and a ring both recorded it,
nightspicks the one with sleep stages andnights_by_sourceshows both.Units do not depend on the phone's region. Lengths are meters, mass is kg, energy is kcal, temperature is degC, and a percent is a 0-1 fraction.
Deletions carry over. A record deleted on the phone leaves the database.
Queries cannot change anything. The database opens read-only for every query.
Privacy
The command makes no network requests. It reads the files in your iCloud Drive folder and writes one database file on your computer (on a Mac:
~/Library/Application Support/HealthSQL/health.db). You can delete that file at any time; the next command builds it again.The rows your agent reads enter its context, so they go to the model provider that agent uses. With a local model they go nowhere.
What the iPhone app does is in the privacy policy.
Limits
iOS lets no app read Health while the iPhone is locked. New data arrives after you next unlock the phone.
Not in the export: clinical records, medications, vision prescriptions, ECG voltages, heartbeat series, audiograms.
We test on macOS. The command also knows where iCloud for Windows keeps the folder, but that path is not tested yet.
HealthSQL is not a medical device, and an agent is not a doctor.
Try it without an iPhone
The repository has a small sample export: one made-up day, written by the app in the iOS Simulator.
git clone https://github.com/declankra/healthsql && cd healthsql
export HEALTHSQL_EXPORT_DIR="$PWD/testdata/export" HEALTHSQL_DB=/tmp/healthsql-sample.db
python3 healthsql.py
python3 healthsql.py query "SELECT day, activity, minutes, meters, avg_hr FROM workouts"
python3 healthsql.py mcp # an MCP server on stdin and stdoutThe sample is from 30 November 2026. Because that is more than three days ago, each answer has a problem line that says the iPhone last synced some days ago. That is what you would see for a real phone that stopped exporting.
In this repository
healthsql.py: the command.test_healthsql.py: its behavior checks. Runpython3 -m unittest.FORMAT.md: the files the iPhone app writes. Any program can read them.testdata/: the sample export.
Feedback
If HealthSQL cannot do what you need, or a number looks wrong, write to contact@dkbuilds.co or open an issue. A person reads every message.
License
MIT. Copyright (c) 2026 dkBuilds LLC.
Available Tools
2 toolshealth_overviewApple Health: what is availableARead-only
What the user's Apple Health database holds: when their iPhone last synced, each view with its columns and when to use it, example queries, and every metric with its unit and date range. Call this first, once.
Inputs: no named parameters.
health_queryApple Health: run SQLARead-only
Run one read-only SQLite query on the user's Apple Health database and get rows as JSON (at most 2000; aggregate or LIMIT). Start from the daily view (one row per day: steps, energy, resting heart rate, HRV, sleep, weight and more), nights for sleep, workouts for training. health_overview lists every view and column.
Inputs: sql (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools occupy clearly separate phases: health_overview is a one-time schema/metric discovery call, while health_query executes SQL. The descriptions explicitly sequence them ('Call this first, once' vs 'Run one read-only SQLite query'), leaving no room for misselection.
Both names follow a strict `health_<noun>` snake_case pattern, and the nouns (overview, query) accurately reflect each tool's role. No mixed conventions or stray verbs.
Two tools is on the thin side, but for a read-only SQL interface the discovery+execute pair is a legitimate minimal design rather than a gap. A third convenience tool (e.g. saved/favorite queries or a metric catalog) could add value but is not required.
Arbitrary read-only SQL over documented views means any analytical question is answerable, and health_overview prevents dead ends by exposing every view, column, and metric. Write operations and any result-export or pagination helpers are absent, though read-only scope appears intentional for a personal health database.
Maintenance
Related MCP Connectors
Ask Claude, ChatGPT or Cursor about your Apple Health data: workouts, sleep, food. Read-only.
Read-only Apple Health data synced from your iPhone: sleep, heart rate, HRV, workouts and trends.
Your Apple Health data, food diary and lifts, for ChatGPT, Claude and Gemini. Approved on iPhone.
Read-only health data: sleep, HRV recovery, macros, micros, workouts, lift trends, and plans.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceLoads Apple Health export data into a local SQLite database and exposes tools to query health metrics and workout records via natural language.3MIT
- AlicenseAqualityAmaintenanceProvides local MCP tools to query your own Xiaomi Mi Fitness health data (sleep, workouts, heart rate, etc.) stored in a local SQLite database, enabling AI assistants to access personal health records without exposing credentials.1781AGPL 3.0
- AlicenseNot gradedqualityBmaintenanceEnables AI agents to read your own Apple Health data through a self-hosted SQLite mirror, allowing them to query health metrics, workouts, meals, and strength logs without sending data to the cloud.73 PyPI5MIT
- AlicenseNot gradedqualityNot gradedmaintenanceEnables AI clients to read-only query synced Apple Health data through tools for current status, detailed sleep or metric records, and 7/14/30-day trends.MIT