apple-health-fly-mcp
Provides tools for querying Apple Health data, including daily steps, heart rate, sleep analysis, workouts, body metrics, and nutrition, from exported Apple Health data.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@apple-health-fly-mcpwhat was my average heart rate during my workout yesterday?"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Apple Health MCP Server
An MCP server that exposes Apple Health data as tools queryable by LLMs (Claude, Copilot, etc.).
Architecture
exportación.xml (Apple Health)
│
▼
preprocess.py ──► data/*.parquet (run locally on Mac)
│
▼ (sync_to_fly.sh, over plain HTTPS)
Fly.io: fjcabello-apple-health-mcp
├─ wrapper.py (FastMCP app + api_key ASGI gate, port 8080)
└─ /data volume (persistent, 1GB) ─ loaded by server.py
│
▼
apple-health-fly-mcp-worker (Cloudflare Worker, OAuth gateway)
│
https://apple-health-fly-mcp-worker.fjcabello.workers.dev/mcpThe server loads Parquet files at startup (~1-2 s) and caches them in memory. If they are not found, it falls back to parsing the XML directly. server.py is never modified for deployment concerns — wrapper.py wraps it with the api_key auth gate and the admin sync endpoints (see "Deploy to Fly.io" below).
Related MCP server: Apple Health MCP Server
Requirements
Python 3.11+
pyarrow(for Parquet support)
pip install -r requirements.txt
pip install pyarrowrequirements.txt
mcp[cli]>=1.0.0
lxml>=5.0.0
pandas>=2.0.0
pyarrow>=15.0.0
uvicorn>=0.30.0Data update workflow
1. Export from iPhone
Health → profile → Export All Health Data → produces a ZIP containing exportación.xml. Unzip it so the file lands at ../apple_health_export/exportación.xml (relative to this repo), or pass a custom path.
2. Sync to Fly.io
cd ~/Personal/apple_health/apple_health_mcp
./sync_to_fly.shThis single script:
Runs
preprocess.py(XML →data/*.parquet, ~20-25 files, one per metric type)Uploads every Parquet file to the Fly volume via
PUT /admin/upload/<filename>?api_key=...(plain HTTPS — SSH/SFTP tunnels to Fly are blocked on this network)Calls
POST /admin/reload?api_key=...to clear the in-memory cache, so the next tool call picks up the fresh data — no machine restart needed
Both /admin/* routes require the API_KEY Fly secret as a query param (see wrapper.py). The key is read from .fly_secret_local (gitignored) or the environment.
3. Automated sync via Health Auto Export
Instead of manually exporting the Apple Health ZIP, the Health Auto Export
iOS app can push data automatically via a webhook, which upserts directly into
the Parquet files on the Fly volume (no XML/preprocess step needed). This is
defined in server.py (ingest_app) and wired into wrapper.py's router.
Endpoint (calls Fly directly, not through the Cloudflare Worker):
POST https://fjcabello-apple-health-mcp.fly.dev/ingest
GET https://fjcabello-apple-health-mcp.fly.dev/ingest/inspect (last payload received, for debugging)Authentication: header x-api-key: <secret> or query param ?api_key=<secret>, checked against the INTERNAL_SECRET Fly secret (kept equal to API_KEY for simplicity — set both with the same value). This is intentionally separate from the Cloudflare Worker's OAuth, since the iOS app can only set a header, not go through the OAuth flow.
Configure one automation per data type in Health Auto Export (the app only allows one data type per automation): Health Metrics, Workouts, etc. — pick the metrics listed in config.py → HK_TYPE_MAP. Format JSON, export version v2, incremental date range, header x-api-key set to the shared secret.
Each /ingest call upserts only the metrics/workouts present in that payload (dedup by startDate, or startDate + activityType for workouts) and clears the in-memory cache so the next MCP tool call reloads fresh data — no restart needed.
Deploy to Fly.io
The server runs as a Docker container on Fly.io (app fjcabello-apple-health-mcp, region ams), fronted by wrapper.py (an ASGI router that gates /mcp and /admin/* behind API_KEY, and forwards /ingest* to server.py's own-auth ingest_app — mirrors the proxy.cjs pattern in garmin-connect-mcp). Parquet files live on a persistent Fly volume mounted at /data, not baked into the image.
First-time setup
fly auth login
fly apps create fjcabello-apple-health-mcp
fly volumes create apple_health_data --region ams --size 1 --app fjcabello-apple-health-mcp
fly secrets set API_KEY=$(openssl rand -hex 32) --app fjcabello-apple-health-mcp
fly secrets set INTERNAL_SECRET=<same value as API_KEY> --app fjcabello-apple-health-mcpContinuous deployment
.github/workflows/deploy.yml auto-deploys to Fly.io on every push to main, using a FLY_API_TOKEN repo secret (fly tokens create deploy --app fjcabello-apple-health-mcp).
Why CI instead of
fly deploylocally: on this network, Fly's remote "depot" builder and SSH/SFTP tunnels hang indefinitely / fail the WebSocket handshake (corporate SSL/proxy inspection). Deploying from a GitHub-hosted runner avoids this entirely.
Seeding / updating data
See "Data update workflow" above — use ./sync_to_fly.sh, not SSH.
Running locally (development)
python server.py
# Listens on http://0.0.0.0:8001/mcpOptional environment variables:
Variable | Default | Description |
|
| Directory containing |
|
| XML fallback path |
Available MCP tools
Tool | Description |
| Overview of all available data types, record counts and date ranges |
| Daily step counts |
| Heart rate per day (mean / min / max) |
| Daily resting heart rate |
| Sleep analysis by stage (Core, Deep, REM, Awake) |
| Workout sessions, filterable by type and date |
| Weight (kg), BMI, body fat %, lean body mass |
| Active/basal energy burned, distance, flights climbed |
| Nutritional intake (calories, protein, carbs, fat) |
| Generic query for any available metric |
All tools accept optional start_date and end_date parameters in YYYY-MM-DD format.
Available metrics for query_health_data
steps, heart_rate, resting_hr, active_energy, basal_energy, distance_walk, distance_cycling, flights_climbed, sleep, body_mass, bmi, body_fat, lean_body_mass, walking_speed, walking_steadiness, dietary_energy, dietary_protein, dietary_carbs, dietary_fat
Cloud access (OAuth)
The Cloudflare Worker adds OAuth 2.0 authentication for remote access from Claude.ai or VS Code.
Public URL: https://apple-health-fly-mcp-worker.fjcabello.workers.dev/mcp
VS Code configuration
// .vscode/mcp.json
{
"servers": {
"apple-health-cloud": {
"type": "http",
"url": "https://apple-health-fly-mcp-worker.fjcabello.workers.dev/mcp"
}
}
}Worker source
See fjcabello/apple-health-fly-mcp-worker (../apple-health-fly-worker/ in the local workspace). Same multi-MCP OAuth gateway pattern as garmin-connect-mcp's mcp-oauth-gateway.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityAmaintenanceAn MCP server that allows users to query and analyze their Apple Health data using SQL and natural language, utilizing DuckDB for fast and efficient health data analysis.93412557MIT
- AlicenseAqualityCmaintenanceA Model Context Protocol server that enables seamless interaction between LLM-based agents and Apple Health data, allowing users to query, analyze, and manage health records through natural language commands.27248MIT
- AlicenseAqualityAmaintenanceAn MCP server that enables AI agents to query Apple Health data (190+ metrics) in natural language, including trends, comparisons, and structured exports.72882MIT
- Alicense-qualityBmaintenanceHosted MCP server that syncs health data from Apple Health, Fitbit, Oura, and Google Health Connect, enabling Claude and ChatGPT to query workouts, sleep, nutrition, and recovery in plain English with interactive charts.MIT
Related MCP Connectors
Hosted MCP server exposing US hospital procedure cost data to AI assistants
MCP server for Withings health data — sleep, activity, heart, and body metrics.
MCP server for Argo RPG Platform — connects AI assistants to campaign data via OAuth2
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/fjcabello/apple-health-fly-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server