Apple Health HRV and Sleep Trends in Your AI Agent: Visualize, Compare, Decide
HRV and sleep are the two Apple Health signals worth reading together, and the hardest to eyeball. Here is how to pull both into Claude, Cursor or any MCP client: the tools it calls, the config, and the output you get back.
By MetricBridge · Published 5 November 2026 · ~10 min read
AI-assisted, human reviewed. How we use AI
Quick answer: give your agent read-only tools over your own Apple Health export with the MetricBridge MCP server, then ask a trend question in plain language. The agent calls get_trends, compare_periods or correlate_metrics and returns numbers with the date range they cover. HRV and sleep compare cleanly because both are recorded nightly, so "this week versus last week" is two tool calls and a sentence, not a spreadsheet.
Why HRV and sleep are the pair that matters
Most Apple Health metrics are noise on their own. Steps are cumulative, so a big Tuesday only means you walked. HRV and sleep are different. Both are recorded while you sleep, both move with recovery, and both are read against your own baseline rather than a population average. A single HRV reading of 52 ms says very little. The same 52 ms sitting well below your own recent range is the interesting part.
That is why a trend question beats a snapshot, and why the agent needs your history instead of a pasted number. Seven and a half hours of sleep means one thing after a normal week and something else after four short nights in a row. The comparison is the signal.
What you need before you start
MetricBridge on your iPhone. Grant Apple Health read-only, turn on export, and pick a destination. iCloud Drive is the simplest choice: the OS syncs the folder to your Mac with no extra setup. The app writes all 194 metrics into one local JSON file, including per-night sleep sessions with stages and HRV samples.
Node.js 18 or later on the machine where your agent runs. The MCP server is a single command with no dependencies to install.
Install the server in one line. On a Mac there is no environment variable to set:
claude mcp add health-export -- npx -y health-export-mcp
On Windows or Linux, point it at the export folder with HEALTH_DATA_DIR:
HEALTH_DATA_DIR="/Users/you/export-folder" npx -y health-export-mcp
The server is stdio only, MIT-licensed, and makes zero network calls. It never writes to Apple Health; the only two tools that write anything are add_event and remove_event, and they touch a file beside your export. For the full client-by-client walkthrough, see connecting Apple Health to Claude over MCP.
The tools that answer a trend question
You do not call tools yourself. You ask a question and the agent picks. These are the ones it reaches for on an HRV and sleep task, from the server's 22 tools (20 read-only, plus the two event writers) and 23 prompts:
get_mcp_status: confirms the server is up and the export folder was found
get_freshness: how current the export is, and whether it has gone stale
list_metrics: which of the 194 metrics are present in your file
get_health_metrics: raw values for one metric over a date range
get_trends: week-over-week and month-over-month math for a metric
compare_periods: A against B, for example this week against last
correlate_metrics: the relationship between two metrics over the same window, such as HRV and sleep duration
get_sleep_sessions: per-night sessions with stages and naps, not just a nightly total
get_intraday: within-day samples when you want the shape of a night
resolve_metric: the canonical name and unit for whatever you called it
Spelling is not a problem. Say "resting heart rate", "RHR" or "resting_hr" and resolve_metric maps it to the same canonical metric with the right unit. You never have to memorise our names.
A worked example: HRV against sleep, week over week
Once the server is connected you just ask. A representative run looks like this, with the tool calls and the reply:
`You: Compare my HRV and my sleep this week to last week.
Is there a pattern?
Agent: [get_freshness] data through 2026-11-04
[resolve_metric] "HRV" -> hrv (ms)
[compare_periods] hrv: last 7d vs prior 7d
[compare_periods] sleep: last 7d vs prior 7d
[correlate_metrics] hrv vs sleep_duration, 14d
HRV averaged 54.8 ms this week, up 6.1% from 51.6 ms last week.
Both figures sit inside your recent range, so this is a normal
week-to-week move for you, not a deviation from your baseline.
Sleep averaged 7h 22m, up 19 minutes. On the nights you slept
more than 7h 30m, your next-night HRV ran above your 14-day
average. Across the 14 days, longer sleep and higher next-night
HRV move together (r = 0.41). That is an association in your
own data, not a cause.`
Three things to notice. The agent checked freshness first, so you can trust the window it used. It reported the change and, crucially, whether that change is a deviation from your own baseline. And it labelled the correlation as an association, not a cause.
That last line is the honest reading of two metrics that move together over 14 days. A correlation between sleep and next-night HRV is the kind of thing a wellness tool should describe and a medical tool should not diagnose. MetricBridge is the first kind, and every number here is general-wellness information, not medical advice. The app publishes how it computes baselines in the methods.
How to visualise it, not just read it
A terminal agent will happily give you numbers and an ASCII sparkline if you ask for one. For a real chart, the reliable route is to have the agent hand the series to whatever draws on your machine:
`You: Export hrv and sleep_duration, daily, for the last 30 days
as a CSV I can plot.
Agent: [get_health_metrics] hrv, 2026-10-06..2026-11-04
[get_health_metrics] sleep_duration, same window
[writes hrv-sleep-30d.csv] 30 rows: date,hrv_ms,sleep_h`
Because the data is a local file, anything on your computer can read it: a notebook, a spreadsheet, gnuplot, or the Mac app if you would rather see the same export drawn for you.
If you would rather ask on the phone than on a laptop, the same HRV and sleep questions are answered by the on-device Ask in the app, each with a provenance card that shows the samples, the date range and the computation behind the number. See where your data goes when you ask in the app.
Frequently asked
Does the agent need my whole Apple Health history?
No. Your agent queries a date range at a time, and a 30-day window is one tool call. Backfilling to your first Apple Watch matters mainly when you want a personal baseline older than the last few weeks.
Can two agents read the same export at once?
Yes. The server reads your folder and does not write to your data, so Claude, Cursor and anything else can each run their own copy against the same file. Only the two event tools write, and they write to their own file.
What if the numbers look stale?
Ask the agent to call get_freshness. It reports when the export was last written. If it lags, check that background export is on in the app and that iCloud Drive or your synced folder has finished uploading.
Is a correlation between sleep and HRV medical advice?
No. The agent reports associations in your own data and flags each change against your personal baseline. It does not diagnose, treat or monitor anything. Wellness information only.
Ask your own sleep and HRV questions
194 metrics as local JSON, a zero-dependency MCP server, and on-device answers that show their working.
Start my 7-day free trial (https://apps.apple.com/app/apple-store/id6784185201?pt=129083290&ct=blog&mt=8&ppid=221531d9-aa54-41ed-ad67-6128263b81f2)
Install the MCP server
Where it goes: the app reads Apple Health read-only and writes JSON to a folder you pick. Nothing reaches us or a cloud AI. Price: $24.99 one time after a 7-day free trial, not a subscription.
Related reading
→ Connect Apple Health to Claude (and any MCP agent): step by step
→ Query your Apple Health data with ChatGPT and Cursor
→ Pass-through vs answer-on-device: two designs for health AI
→ Sync to a server you own: the self-hosted receiver pattern
→ Methods: how every number is calculated
→ The MCP server: 22 tools (20 read-only), 23 prompts and every client config
→ MetricBridge: product overview & setup
Top comments (0)