Apple Health → Claude (MCP connector)
A private, single-user MCP server that lets Claude query all of your Apple Health data. It runs entirely on Cloudflare's free tier and doesn't need a Mac.
export.zip ──(Python CLI: parse → plan → upload)──┐
├─► POST /ingest ─► Cloudflare Worker ─► D1 (SQLite)
iPhone Shortcut @23:00 (last 36 h, per type) ──────┘ │
claude.ai custom connector ◄── OAuth (password) ── /mcp (Streamable HTTP) ◄──┘
| Piece | What it is |
|---|
src/index.ts | OAuthProvider (@cloudflare/workers-oauth-provider): dynamic client registration, PKCE, single-user password page; /ingest behind a Bearer token |
src/tools.ts | 11 MCP tools via createMcpHandler from the Agents SDK. McpAgent is now deprecated in the SDK, so this uses its stateless successor: no Durable Object needed |
src/ingest.ts | One INSERT … SELECT FROM json_each(?) per type per request; idempotent upserts |
migrations/0001_init.sql | Generic schema: new types need no migration |
cli/health_import.py | Stdlib-only streaming importer (iterparse), resumable, daily write budget |
docs/SHORTCUT.md | Nightly Shortcut + automation, and which types Shortcuts can and can't read |
plugin/, .claude-plugin/ | Claude Code plugin + marketplace (connects to your server, adds a health-review skill) |
test/ | Synthetic export.zip generator and an end-to-end OAuth + MCP smoke test |
Free-tier limits (checked 2026-11-26) and how the design fits them
| Limit (Workers Free) | Value | Design response |
|---|
| D1 rows written / day | 100,000 (index writes count extra) | health_samples is WITHOUT ROWID with PK (type, start_ts, id), so 1 row written per sample and no secondary index. The CLI keeps a per-UTC-day budget (default 90k) from real rows_written and resumes the next day |
| D1 rows read / day | 5,000,000 | Every query is a PK range scan; list_data_types reads a small type_stats table, never COUNT(*) |
| D1 storage | 500 MB per DB, 5 GB per account | High-frequency types are stored as hourly buckets (sum/mean + min/max/count); routes are downsampled to ≤300 points |
| D1 queries per Worker call | 50 | ≤40 types per request, one statement each, run in a single batch |
| Bound params per query | 100 | Rows go in as one JSON string param (json_each) |
| Worker CPU / request | 10 ms | No hashing; the CLI sends ≤1,000 pre-aggregated rows per request |
| Worker requests / day | 100,000 | A full backfill uses ~1 request per 1,000 rows |
Daily limits reset at 00:00 UTC (05:30 IST). Nothing here costs money. Don't upgrade to Workers Paid; if you hit a limit, the CLI just stops and resumes the next day.
Expected row counts
Run plan on your own export: it prints exact per-type numbers before anything is uploaded. As a rough guide for ~5 years of Apple Watch + iPhone:
| raw records in export.xml | rows stored in D1 |
|---|
| Heart rate, steps, energy, distance, exercise/stand minutes, audio, walking metrics… (≈20 high-frequency types, 2 sources) | 5–15 million | ≈ 600–900k (hourly buckets) |
| Sleep stages, RHR, HRV, SpO₂, weight, VO₂max, nutrition… (raw) | 100–300k | same |
| Workouts / routes / ring days | ~1–2k / ~500 / ~1,800 | same |
| Total | | ≈ 0.8–1.2 M rows → 9–14 days of backfill at 90k/day, ~80–120 MB |
The upload goes newest-first, so recent months become queryable on day 1. Use parse --since 2023-01-01 if you only want recent history.
Setup (PowerShell, Windows)
Prerequisites: Node 20+, Python 3.9+, and a free Cloudflare account. Click Use this template on GitHub (or clone the repo) to get your own copy:
git clone https://github.com/NiksheyYadav/apple-health-mcp
cd apple-health-mcp
npm install
copy wrangler.example.toml wrangler.toml
wrangler.toml is git-ignored, so your database IDs never get committed.