What you need
- An iPhone on iOS 15 or later with Apple Health. Apple Watch data comes along too.
- The HealthAPI app. Free for 2 days, no card needed. Then an optional 7-day free trial when you subscribe. The preview includes 25 requests a day. When the 2 days are up, AI apps and the API stop reading your data until you choose a plan in the app. Your synced data is kept for about 5 weeks, so subscribing picks up where you left off. Pro is $4.99 a month or $49.99 a year (100 requests a day); Developer is $9.99 a month or $99.99 a year (1,000 a day). Cancel anytime in the App Store.
- Claude Code on your computer.
Set it up in 4 steps
Install HealthAPI and sync
Get HealthAPI from the App Store, open it and allow Apple Health. Your history uploads, then new data keeps syncing.Add the server
In a terminal, runclaude mcp add --transport http --scope user healthapi https://healthapi.app/mcp. The user scope makes it available in every project.Sign in and approve on your iPhone
Startclaude, run/mcp, choose healthapi and sign in. A HealthAPI page opens in your browser with a short code. Scan its QR code with your iPhone, or enter the code in HealthAPI under Connect, check it matches, and tap Approve.Ask Claude Code
Ask for something that needs your data, such as “Use HealthAPI to get my resting heart rate for the last 60 days and chart it.” Claude Code asks before each tool call unless you allow them.
claude mcp add --transport http --scope user healthapi https://healthapi.app/mcpThe sign-in page names Claude Code with a check mark and notes that it returns to a program on this computer: Claude Code waits for the answer on localhost. If you started the sign-in yourself and the codes match, approve it. From a shell, claude mcp login healthapi does the same as /mcp.
Scopes, projects and API keys
--scope user keeps the server in ~/.claude.json for all your projects. Leave it out and it applies to the current project only. To share it with a repository, use the project scope, which writes .mcp.json:
claude mcp add --transport http --scope project healthapi https://healthapi.app/mcpThat file holds only the address, so it's safe to commit. Everyone who opens the project signs in with their own iPhone and sees only their own data.
Rather use your API key than sign in? Copy it in the app (Connect, then Other tools), put it in an environment variable, and reference the variable. Claude Code fills in ${HEALTHAPI_KEY} when it connects, so the key itself never lands in the file:
{
"mcpServers": {
"healthapi": {
"type": "http",
"url": "https://healthapi.app/mcp",
"headers": { "Authorization": "Bearer ${HEALTHAPI_KEY}" }
}
}
}Fewer permission prompts
Claude Code asks before every HealthAPI tool call. The tools only read, so you can allow them all in ~/.claude/settings.json, or for one tool at a time with its full name:
{
"permissions": {
"allow": ["mcp__healthapi__*"]
}
}Each call still uses one of your daily requests, so an agent working unattended can spend them. Raw readings from get_samples can also be long; asking for summaries keeps the output small.
What to build with it
- A dashboard in your repo. “Use HealthAPI to get 90 days of sleep, resting heart rate and HRV, save it to data/health.json, and build a static page that charts it.”
- A script that runs without you. “Look at one HealthAPI daily summary, then write a Node script that reads yesterday from the REST API with HEALTHAPI_KEY and appends it to a CSV.”
- An analysis you can check. “Compare my sleep after workout days with rest days over the last 3 months, and show the numbers you used.”
- Fixtures for your own app. “Fetch my last weekly summary and turn it into TypeScript types and a test fixture.”
Once you've signed in, non-interactive runs can use the tools too. Allow just the ones the prompt needs:
claude -p "Use HealthAPI to summarize last night's sleep in three lines" \
--allowedTools "mcp__healthapi__get_sleep"Code that runs on a schedule doesn't need Claude at all: call the REST API with your key. The JavaScript and Python guides have starting points.
The tools, by their Claude Code names
| Tool | Returns |
|---|---|
mcp__healthapi__get_health_overview | What is synced, date ranges, last sync, requests left. A good first call. |
mcp__healthapi__get_daily_summary | One day: activity, heart, vitals, workouts and that morning's sleep. |
mcp__healthapi__get_weekly_summary | A Monday-to-Sunday week, with a line per day. |
mcp__healthapi__get_sleep | Per night: asleep, core, deep, REM, awake, bedtime and wake time. |
mcp__healthapi__get_trend | One metric day by day, up to 365 days, with average, low and high. |
mcp__healthapi__get_latest | The newest reading of each metric. |
mcp__healthapi__get_workouts | Workouts between two days, with totals. |
mcp__healthapi__get_samples | Raw readings of one metric, up to 31 days. |
Every tool is read only. The MCP server page covers inputs, sign-in and discovery, and the Cursor and Codex guides cover the same server in other tools.
Questions
I already connected HealthAPI in Claude. Do I need this?
Maybe not. When you sign in to Claude Code with a Claude subscription, the connectors you added on claude.ai are available in Claude Code too, and /mcp lists them. Add the server yourself if you use Claude Code with an API key or another provider, or want it in a project's .mcp.json. If both point at the same address, Claude Code uses the one you added and hides the connector.
Can I sign in over SSH?
Yes. Run claude mcp login healthapi --no-browser on the remote machine and open the link it prints in any browser. After you approve on your iPhone, the last page fails to load, because it points at the remote machine. Copy that page's address and paste it into Claude Code.
How many requests does it use?
Each tool call is one request. A question usually takes one to three; building something may take more. Pro allows 100 a day and Developer 1,000, reset at 00:00 UTC.
How long does the sign-in last?
Until you disconnect it. Claude Code refreshes access on its own; if it goes unused for 60 days, sign in again with /mcp. Disconnect it in the HealthAPI app under Settings, Connected apps.
Can Claude Code change my health data?
No. All eight tools are read only. Nothing in Apple Health or HealthAPI changes.
