DEV Community

Philip D'Souza
Philip D'Souza

Posted on

How to Export Apple Health to JSON for AI Agents

Apple Health holds years of your steps, sleep, heart rate and workouts. The built-in export is one giant export.xml, often hundreds of megabytes, and it is the wrong shape for any LLM.

Here is the pipeline that works: get the data out as clean JSON, then let an agent query it on demand.

Why the default export fails for AI

  • export.xml is one flat file with millions of rows. The model burns its context parsing rows instead of reasoning about your health.
  • CSV is flat too, and loses the units, time ranges and record structure an agent needs.
  • What an LLM wants is the opposite: small, per-metric JSON with units and ranges already structured, plus a live connection so it can request just the slice it needs.

Get 190 metrics out as JSON

MetricBridge reads Apple Health read-only and turns HealthKit into 190 clean JSON metrics across activity, heart, sleep, body and workouts. You choose where the JSON lands: iCloud Drive, a synced folder (Dropbox, Google Drive, OneDrive, Syncthing, Nextcloud, rclone), your local network, or a webhook. Local-first, no account, no third-party server.

Wire it to an agent with MCP

health-export-mcp is a free, MIT-licensed, zero-dependency MCP server on npm. MCP is the open standard that lets AI clients call tools, so instead of pasting a file your agent gets live read-only tools. Drop this into your client config and restart it:

{
  "mcpServers": {
    "health-export-mcp": {
      "command": "npx",
      "args": ["-y", "health-export-mcp"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

Then ask Claude, ChatGPT or Cursor things like "how has my HRV trended this month?" or "compare my deep sleep on weeks I trained".

Full guide, including the five prompts to try first: https://www.healthexport.dev/blog/export-apple-health-to-json-with-ai?utm_source=devto&utm_medium=social&utm_campaign=exp-20261004-hea179-json-ai

Top comments (0)