Skip to main content

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:

  1. An iPhone app that copies every Health record to its own folder in your iCloud Drive and keeps the copy current.
  2. 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 agent

There 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 on the App Store: HealthSQL: AI Health Export. To try the command first, without an iPhone, use the sample data in this repository: see Try it without an iPhone.

Install

curl -fsSL https://healthsql.app/install | sh

This 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.

Install the package from PyPI with uv or pipx:

uv tool install healthsql
pipx install healthsql

The 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.

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, cursor

For 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"] }
  }
}

The official MCP Registry lists HealthSQL as io.github.declankra/healthsql. Clients with uv can launch it with uvx healthsql mcp. Glama lists the tools and their inputs.

The server has two tools:

Tool What it does
health_overview 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.
health_query 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 now

Each 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
daily day Any question about a day or a trend: steps, distance, energy, heart rate, HRV, weight, sleep and more, side by side.
days metric and day Apple Health's own total for every metric it holds, with sum for a metric that adds up and avg, min, max for one that does not.
nights night of sleep Time asleep and in each stage, from one source.
nights_by_source night and source A watch compared with a ring, or a source other than the one nights chose.
sleep sleep stage interval The stages of a night, minute by minute.
workouts workout Activity, minutes, distance, heart rate, and the whole record as JSON.
samples raw measurement A value at a time of day, or one source's own numbers.
rings 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 daily and days hold those numbers.
  • Every answer says how fresh it is. phone_synced is the phone's last export. When something is wrong (the phone went quiet, files are still downloading, Health refused a type), there is one problem line 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, nights picks the one with sleep stages and nights_by_source shows 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 stdout

The 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

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.

Metadata

Release files for healthsql 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for healthsql 0.1.2
File Size Uploaded Provenance Actions
healthsql-0.1.2.tar.gz 19.0 kB With provenance Details for healthsql-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for healthsql 0.1.2
File Interpreter ABI Platform Actions
healthsql-0.1.2-py3-none-any.whl Python 3 none any Details for healthsql-0.1.2-py3-none-any.whl

Total release size: 38.4 kB

Release files / healthsql-0.1.2.tar.gz

Download URL healthsql-0.1.2.tar.gz
Size 19.0 kB
Tags Source
SHA-256 checksum
How to use checksums
c7a3a9b3f07a054f581e03a7614d9771a09b1e87a81c790766bf8f6f1aadcaf5
BLAKE2b-256 checksum
How to use checksums
fa71d207043a451c7ff1e2e85998c1ec50e0165adaf185f38e85b036f34455d3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Release files / healthsql-0.1.2-py3-none-any.whl

Download URL healthsql-0.1.2-py3-none-any.whl
Size 19.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
63c67e8c8a5e8e598173cfcf75aca01306a3f3ca8f22c4dd16a6160ea802d61f
BLAKE2b-256 checksum
How to use checksums
fe153c5f4eabe0a8324a7e1270275374862173ef59fd4788f9e5f09ee2f4d68b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

Security for healthsql 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for healthsql-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 1, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page