How do I set up HealthSQL?
Install the HealthSQL app on your iPhone and allow Health access, then run one command on your Mac: curl -fsSL https://healthsql.app/install | sh. It installs healthsql, builds your Health database from iCloud Drive and prints how to connect each agent.
HealthSQL is an iPhone app and a command-line tool that copy your whole Apple Health record into a local SQLite database on your computer, so AI agents can query it with SQL or MCP. An agent can do the Mac part for you. Give it this line:
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.The agent follows https://healthsql.app/agents.md, the same steps as below, written for an agent.
What you need
- An iPhone with iOS 18 or later.
- A Mac signed in to the same Apple Account as the iPhone, with iCloud Drive on.
- Python 3.9 or later on the Mac. If
python3is missing,xcode-select --installinstalls it. - An agent: Claude Code, Codex, Claude Desktop, Cursor or another MCP client.
1. Install the iPhone app
Install HealthSQL from the App Store (it is not there yet; this page will link to it at launch). Open it and tap Allow Health access. Allow every category. On iOS 27, choose All Recorded Data and Future Data: with "Past 30 Days" the app gets only the last 30 days.
Keep the screen open until the first export ends. A long history takes a few minutes. When it is done, the app shows In your iCloud Drive and a record count.
2. Install the command on your Mac
curl -fsSL https://healthsql.app/install | shThis saves one file, ~/.local/bin/healthsql, and runs healthsql setup. The script is short; read it before you run it if you like. To do the same by hand:
mkdir -p ~/.local/bin && curl -fsSL https://healthsql.app/healthsql -o ~/.local/bin/healthsql && chmod +x ~/.local/bin/healthsql && ~/.local/bin/healthsql setupIf ~/.local/bin is not on your PATH, the script says so. Use the full path, or add the folder to your shell profile.
3. Read what setup says
healthsql setup waits up to two minutes for the iPhone's files to come down from iCloud Drive, builds the database at ~/Library/Application Support/HealthSQL/health.db and prints JSON. "ok": true means the database is built and current. If not, problem says the one thing to do: see troubleshooting.
The first build reads your whole history. Millions of records take a few minutes.
4. Connect your agent
An agent with a shell, such as Claude Code or Codex, can use healthsql now. To give it the tools over MCP in every session, register the server with your client:
healthsql connect claude-codeUse codex, claude-desktop or cursor in place of claude-code. healthsql connect with no name lists the clients it finds on this Mac. Restart a desktop app after you connect it. Every client, and any other MCP client: Apple Health MCP server.
5. Ask a question
healthsql
healthsql query "SELECT day, steps, resting_hr, hrv_ms, asleep_min FROM daily ORDER BY day DESC LIMIT 7"The first command describes what your database holds. The second shows your last seven days. Or ask your agent: "What does my last week look like?"
Make the export automatic
Without a purchase, the iPhone app exports each time you open it. With the one $7.99 purchase, Health wakes the app when there is new data and the export runs by itself, after the next time you unlock the phone: iOS lets no app read Health while the iPhone is locked. On the Mac there is nothing to schedule. Each healthsql command reads the new files first.
Troubleshooting
Every healthsql answer has a problem field. When it is not null, it names what is wrong and the one act that clears it. These are all the problems the command reports, word for word ("N" stands for a number):
| The command says | What it means | What to do |
|---|---|---|
| No export folder at ~/Library/Mobile Documents/iCloud~dkbuilds~HealthSQL/Documents. Install HealthSQL on the iPhone, open it and allow Health access. This computer must be signed in to the same Apple Account, with iCloud Drive on; the folder then appears by itself, in about a minute. | The iPhone app's folder has not reached this Mac. | Check that the app is installed and has Health access, and that the Mac uses the same Apple Account with iCloud Drive on. Wait a minute, then run healthsql setup again. |
| The iPhone has not exported yet. Open HealthSQL on the iPhone and keep it open until the first export ends. | The app is installed but has not finished its first export. | Open the app and keep it open until it shows a record count. |
N files from the iPhone are not in the database yet. Run healthsql sync. | More files are waiting than one query reads in 45 seconds, as after the first export or a long gap. | Run healthsql sync. It reads them all, however long it takes. |
| N files are still downloading from iCloud Drive. Ask again in a minute. | iCloud Drive is still bringing files to this Mac. | Ask again in a minute. |
| The iPhone last synced N days ago. Open HealthSQL on the iPhone; it can only read Health while the phone is unlocked. | The phone has not exported for more than 3 days. | Open HealthSQL on the iPhone. With the purchase, unlocking the phone is enough. |
| This program may not read iCloud Drive. Allow it in System Settings, Privacy & Security, Files and Folders (or Full Disk Access), for the app that runs this command. Then run it again. | macOS keeps the app that runs healthsql (Terminal, your editor or your agent's app) out of iCloud Drive. | System Settings, Privacy & Security, Files and Folders: allow iCloud Drive for that app. Then run the command again. |
Two messages come before the command exists:
- "healthsql needs Python 3.9 or later" from the install script: run
xcode-select --install, then run the install command again. - "command not found: healthsql":
~/.local/binis not on your PATH. Run~/.local/bin/healthsql, or add the folder to your PATH.
A SQL error ends with a hint to run healthsql, which lists every view and column. The schema reference has the same list.
Questions
How long does setup take?
The commands take a minute or two. The first export on the iPhone, and the first build on the Mac, take a few minutes more for a long history.
Can I start over?
Yes. The database is a copy: delete ~/Library/Application Support/HealthSQL/health.db and run healthsql sync, and it is built again from the files in iCloud Drive.
How do I remove it?
Delete ~/.local/bin/healthsql and the folder ~/Library/Application Support/HealthSQL. Remove the MCP entry from your client (in Claude Code: claude mcp remove healthsql --scope user). Delete the app on the iPhone, and remove its data from iCloud in your Apple Account's iCloud storage settings.