Automate Your Apple Health Export for AI Agents, No More Manual export.xml

The minute you export Apple Health by hand, your data is already stale. Here's how to make export a background job that writes clean JSON, and feed it live to any AI agent over MCP.

By MetricBridge · Updated 21 September 2026 · ~7 min read

Quick answer. Tapping Export All Health Data in the Health app gives you a multi-gigabyte XML snapshot that is stale the moment it finishes and still has to be parsed before any agent can read it. MetricBridge replaces that with a background export: the iOS app reads your Apple Health read-only and writes 190 metrics as clean JSON to a destination you choose, on a schedule, with no manual step. Add its zero-dependency MCP server and your agent queries today's numbers, not last month's export.

Why manual export.xml is a dead end for agents

The manual flow is seductive because it looks complete. You tap, Apple grinds for a while, you get a file. But look at what you actually end up with:

  • It is huge. An export.xml can run past 1.7 GB for a multi-year HealthKit history, and larger exports have crashed naive parsers outright.
  • It is XML, not JSON. LLMs and most data tooling want structured records with units and types. XML means a parse step with DTD fixes before anything useful happens.
  • It is a snapshot. The data you exported on Tuesday is wrong by Friday. Any trend or comparison your agent draws is anchored to a dead point in time.
  • It is manual. An automated system must be re-run by hand every time you want fresh data. That is a job for a cron, not for you.

Agents are at their best when the data is fresh and the schema is predictable. A manual XML dump fails both tests. The whole point of automation is to remove the human from the loop so the numbers your agent reasons over are always current.

What automation actually changes

The export becomes a background job that keeps a small JSON file current, not a one-off dump. You pick a destination and turn it on once. From there, the app writes incrementally:

  • iCloud Drive so the file syncs to your Mac with zero setup.
  • A local folder on your iPhone or on a machine you sync onward with Dropbox, Google Drive, OneDrive, or Syncthing.
  • Your LAN, over HTTP or WebSocket, which is clean across a Tailscale network.
  • A webhook you run, token-authenticated, for non-MCP tools like ChatGPT.

The output is .health-cache.json, a tidy structured file keyed by metric, with units and metadata already attached. There is also an hourly health-intraday.json that refreshes today's hour-by-hour window, so intraday questions in the evening actually reflect the day you just lived.

One number that matters. This background export carries the full 190-metric set, including the ones most people never think to export manually: running dynamics, cycling power, workout intervals, and logged health events. That breadth is what lets an agent answer a genuinely cross-cutting question instead of a narrow HRV lookup.

Feed it to your agent over MCP

The export is only half the job. The other half is giving your agent a live, read-only handle on that JSON. MetricBridge ships an open-source zero-dependency MCP server, health-export-mcp on npm, with 14 tools and 22 prompts. Zero dependencies means no Docker, no Python environment, no cloud bridge. It reads your export folder and makes zero network calls of its own.

Add it to any MCP client by pointing it at the server and the folder holding your JSON. For Claude Code, that is one command:

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"

Then ask your agent normally. It decides which of the 14 tools to call: get_health_metrics for daily values, get_trends for a window against the prior one, compare_periods for an A/B across two dates, get_intraday for today's hour-by-hour, and get_mcp_status to confirm the source and its latest data date.

Verify it before you trust it. Always run get_mcp_status first. It reports the resolved data folder, the metric count, and the lastDataDate. If that date is not today, the export is not running; the agent is looking at stale data without telling you.

Here is the difference automation makes in practice. With a manual dump, your agent answers from a frozen copy. With the background export plus the MCP server, the same question is answered from the file that was refreshed this morning:

You: Compare my HRV this week against last week.

Agent: [calls get_trends -> metric: hrv, window: 7d]
       Your HRV averaged 61 ms this week, up 4.4% from 58 ms last week.
       Resting heart rate dropped from 56 to 55 bpm. Both are a deviation
       from your own recent baseline, not a diagnosis.

Export is only half the product

Automation solves the plumbing, but a plain JSON feed is not an answer. MetricBridge also answers questions on the iPhone itself. Ask "why is my sleep trending down this month" and the on-device engine computes the answer locally, then renders it as a provenance card: the headline number in large type, an inline chart, and a strip showing exactly which samples, date range, and computation produced it. You can check the work instead of taking an AI summary on faith.

Because the answer engine runs on the phone, no health data needs to reach a server to get a plain-language read. The MCP server is the developer surface for your own agents; the on-device chat is the consumer surface. Both rest on the same read-only, local-first foundation.

Make your Apple Health export a background job, not a chore

190 metrics as clean JSON on a schedule, 14 read-only MCP tools for your agents, and on-device answers with provenance. One-time $24.99, no subscription.

Frequently asked questions

Can I export Apple Health data to JSON instead of by hand?

Yes. The MetricBridge iOS app reads Apple Health read-only and writes 190 metrics as clean JSON on a background schedule to a destination you choose: iCloud Drive, a local folder, your LAN, or a webhook. Once you turn on background export, fresh data lands without touching the Health app's Export All Health Data flow.

Why is manual export.xml a poor fit for AI agents?

Apple's export can produce a file over 1.7 GB that is stale the instant it is generated and still needs a parse step out of XML before any agent can read it. The iOS 16+ export also has known parse errors that break common Python and R tools. JSON written incrementally avoids all three problems.

How does the export reach my AI agent?

The app writes a small JSON file to a folder you can read, then the zero-dependency health-export-mcp server reads that folder and exposes 14 read-only MCP tools. Claude, Cursor, Claude Code, DuckDB-based tools, or any MCP client can query your live numbers in plain language.

Does background export send my data anywhere?

No. You pick the destination and it stays on hardware you control. The MCP server makes zero network calls and has zero dependencies. There is no account and no server in the path.

Is there more to it than just export?

Yes. MetricBridge also answers questions about your Apple Health data on the iPhone, and every answer shows a provenance card with the exact samples, date range, and computation behind the number. A single $24.99 one-time unlock covers export, the MCP tools, the on-device chat, and the Weekly Health Brief. There is no subscription.

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