How do I connect Apple Health to Claude Code?

Updated

Install the HealthSQL app on your iPhone, then ask Claude Code to set up the Mac side: it runs curl -fsSL https://healthsql.app/install | sh and can then query your Health data with healthsql query. To have the same data as MCP tools in every session, it also runs healthsql connect claude-code.

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. Claude Code reads a SQLite database on your Mac; nothing goes through a third-party server.

Let Claude Code do the setup

Install the iPhone app and let it finish its first export (setup, step 1). Then paste this into Claude Code:

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.

agents.md is written for an agent. Claude Code checks with you that the iPhone part is done, installs the command, reads what healthsql setup reports, can register itself over MCP, and ends with the dates your record covers, when the phone last synced, and a few facts from your last week. If something is wrong, it tells you the one thing to do.

Shell or MCP

Claude Code can use your Health data both ways. Pick one; both read the same database.

ShellMCP
How Claude reads itRuns healthsql and healthsql query "..." with its shell toolCalls health_overview and health_query
SetupNothing after the installhealthsql connect claude-code (once)
Best forScripts, files and charts: Claude can pipe rows into Python or save themHaving the tools in every session and every project, with no command to discover

healthsql connect claude-code runs this, which you can also run yourself:

claude mcp add --scope user healthsql -- ~/.local/bin/healthsql mcp

--scope user makes it available in every project. Start a new Claude Code session to load it.

If macOS blocks iCloud Drive

The first time, macOS may keep the app that runs Claude Code (Terminal, iTerm, VS Code or another) out of iCloud Drive. The command then says:

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.

Allow iCloud Drive for that app in System Settings, Privacy & Security, Files and Folders, and run the command again. Every other message and its fix: troubleshooting.

Prompts to try

Claude reads daily numbers from the daily view, which holds Apple Health's own totals. The rules it follows are in the schema reference.

Questions

Does Claude Code have Apple Health built in?

No. As of November 2026, Anthropic's Apple Health connection works only in the Claude iPhone app (Anthropic help page). Claude Code reads Health data through a tool on your Mac, such as HealthSQL. More: Claude and Apple Health.

Does it work when Claude Code runs on another machine?

Only where the database is. healthsql reads the files iCloud Drive brings to your Mac, so Claude Code must run on that Mac.

How fresh is the data Claude sees?

As fresh as the iPhone's last export. Every answer carries phone_synced, and Claude Code can tell you the time. If the phone has not exported for more than 3 days, the answer also has a problem line.

Does it work with Codex too?

Yes: healthsql connect codex. Any agent with a shell can also run healthsql directly.