Local-First Health Analytics with Claude Code

Claude Code can write and run real analysis scripts against your Apple Health data (correlations, custom aggregates, charts) without any of it leaving your machine. This guide is for developers and quantified-self users who want programmatic, repeatable analysis of their own health data, not a fixed chat template.

By MetricBridge · Published 1 August 2026 · ~9 min read

What does "local-first health analytics" actually mean?

It means the whole path (your exported Apple Health data, the code that analyses it, and the results) stays on hardware you control. Nothing is uploaded to a server to get an answer. A local agent reads a local file (or calls a local tool) and computes the result on the same machine.

That is a different model from most "AI health" tools, which ask you to hand over a copy of your data so their server can process it. Local-first flips who runs the computation: you do, on your own machine, using an agent you already trust with your code.

Why use Claude Code specifically for this?

Claude Code is Anthropic's coding agent: it runs in your terminal, reads and writes files, and executes code, not just chat replies. That combination is what makes it useful for health data specifically: it can call the same read-only Apple Health tools a chat client can, but it can also turn the result into a script, a chart, or a CSV saved to disk, and rerun that script whenever fresh data lands.

A chat-only client can tell you a number. An agent with a file system and code execution can build you a reusable analysis.

How do you set up Claude Code to read your Apple Health data?

Three steps, and the second one is a single command:

  1. Export your data. Install MetricBridge on iOS, grant Apple Health read-only access, and choose a destination. iCloud Drive is the simplest, since macOS syncs it automatically.
  2. Register the MCP server with Claude Code. Let the CLI write its own config:
    claude mcp add health-export \
      -e HEALTH_DATA_DIR="/Users/you/Library/Mobile Documents/iCloud~ai~healthexport~app/Documents" \
      -- node "/Users/you/.health-export-mcp/server.mjs"
    Verify with claude mcp list. Full client-by-client instructions live in Connect Apple Health to Claude via MCP.
  3. Ask Claude Code to check the connection. In a new session: "Call get_mcp_status on the health-export server and tell me what it reports." A healthy response confirms the server can see your exported data.

You don't need to write the config by hand. MetricBridge publishes an open Agent Skill. Paste "Read https://healthexport.dev/SKILL.md and set up MetricBridge for me" into Claude Code and it patches its own MCP config and verifies the connection.

What can Claude Code do with your data that a chat app can't?

It can turn a question into a script instead of a single answer, then run that script and show you the actual numbers behind the result. In practice that covers three things a fixed chat UI generally doesn't:

  • Custom statistics. Pearson correlation between two metrics, a rolling 7-day average, a weekday-vs-weekend split: anything expressible as code, not just the handful of aggregates a product's UI happens to expose.
  • Reusable output. A saved .py or .js file you can rerun next month against fresh data, rather than a chat message that evaporates.
  • Combining sources. Joining your Apple Health export with a separate CSV (training log, symptom diary, work calendar), something a closed chat app has no way to ingest.

The MCP server supplies the data through 14 read-only tools (get_mcp_status, list_metrics, get_health_metrics, get_trends, compare_periods, get_structured_export, get_intraday, query_health_data, list_events, get_profile, get_workouts, get_sleep_sessions, get_cycle_context, and correlate_metrics), documented in full on the MCP server reference. Claude Code decides which of these to call, then writes ordinary code around the result.

Worked example: does your HRV actually track your sleep duration?

An illustrative session, start to finish. You ask a real analytical question, not a lookup. The shape of the exchange is what matters here. The numbers you get back are your own, and will not match anyone else's:

You: Pull my HRV and sleep duration for the last 90 days from health-export,
     compute the correlation between them, and plot it.

Claude Code: [calls list_metrics → checks `days` and `firstDate` for both series]
             [calls get_health_metrics → heart_rate_variability, 90d]
             [calls get_health_metrics → sleep_analysis, 90d]
             [writes analyze_hrv_sleep.py: aligns both series by date,
              computes Pearson r with scipy, renders a scatter plot]
             [runs the script]

             Pearson r over the nights where both readings exist, with the
             n it actually found, plus a scatter plot saved to
             hrv_vs_sleep.png, computed from your own data, on your own
             machine.

Note the first call: list_metrics returns days, firstDate and lastDate per metric, so the agent checks how much history it actually has before asking for a 90-day window, and tells you if the file is shallower than the question.

Nothing here required copying a CSV into a chat window or trusting a black-box "insight." The script is on disk, the statistics are standard, and you can open analyze_hrv_sleep.py yourself and check every line. Ask a follow-up ("now split that by whether I trained that day") and Claude Code extends the same script rather than starting over.

How does this compare to cloud-upload AI health apps and manual spreadsheets?

The short version: local-first analytics trades a polished one-tap interface for programmable, repeatable, and fully local computation. The table below is a factual comparison of the three common approaches, not a ranking of specific products.

Local-first via Claude Code (MCP)Cloud-upload AI health appsManual export.xml + spreadsheet
Where your data goesStays on your machine; only what you explicitly ask about enters the conversationUploaded to a third-party server for processingStays on your machine. You do the analysis by hand
Custom analysis (e.g. correlate two metrics)Yes: the agent writes and runs real codeUsually limited to the app's built-in insight templatesYes, but you write every formula yourself
Reusable / rerun tomorrow with fresh dataYes: the same script runs again against new exportsYes, if you keep re-uploadingNo: manual re-export and rework each time
Account requiredNoUsually yesNo
Ongoing costOne purchase for MetricBridge, plus your existing Claude Code planOften a monthly subscriptionFree, but your time
Best forDevelopers and power users who want programmatic, repeatable analysisPeople who want a polished, guided chat interfaceA one-off question, no tooling wanted

Is my data actually safe running through Claude Code?

The MCP server itself makes no network calls: it is a small, zero-dependency Node script that reads your local export folder and returns tool results over stdio. It was built and is intended to be short enough to read in one sitting; the full source is on GitHub under the MIT licence, so you can verify that yourself rather than take it on faith. What Claude does with the data once it's in a conversation follows Anthropic's normal handling for Claude Code. Read their documentation if that distinction matters for your use case. Nothing is ever sent to MetricBridge's servers, because there are none in this path.

Common questions

What does "local-first health analytics" mean?

It means the entire path (your Apple Health export, the analysis code, and the results) stays on hardware you control. No health file is uploaded to a server to get an answer; a local agent reads local data and computes locally.

Do I need to know how to code to use Claude Code for this?

No. You describe what you want in plain English ("correlate my HRV with sleep duration over the last 90 days") and Claude Code writes and runs the script itself. Reading the code it produces helps you trust the result, but it is not required.

How is this different from asking Claude Desktop the same question?

Both can call the same read-only MCP tools to fetch your data. Claude Code additionally has a file system and a code execution environment, so it can write a script, run it, iterate on the output, and save a chart or CSV to disk: steps a chat-only client cannot do on its own.

Does my health data ever leave my machine?

The MCP server itself makes no network calls and only reads from the local export you point it at. Text you send to Claude as part of a conversation follows Anthropic's normal data handling for that product; nothing is uploaded to MetricBridge's servers, because there are none in this path.

What does this cost?

MetricBridge is one purchase, after a 7-day free trial, with everything included, no subscription and no account. The App Store shows the current price. The MCP server is free and MIT-licensed. Claude Code is billed separately by Anthropic under your existing plan.

Can Claude Code use my Apple Watch workout and GPS data too?

Yes, for any of the 190 metrics MetricBridge exports, including workouts. Route data (GPX) is not part of the JSON export, so route-level mapping is outside what the MCP tools currently expose.

Give Claude Code something real to analyse

190 metrics, 14 read-only MCP tools, fully local. Free 7-day trial. No account, nothing on our servers.

MetricBridge · Apple Health → your AI agent, privately. · Home · Privacy · Terms · Support