Vital Relay
Enables AI assistants to query a user's Apple Health data via HealthKit on their iPhone, including health overviews, metric series, workouts, sleep data, available metrics, and custom metric computation.
Click on "Deploy 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., "@Vital Relayhow did I sleep last night?"
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.
Vital Relay — relay server
The open-source half of Vital Relay: a remote MCP server that lets AI assistants (Claude, ChatGPT, Cursor, Claude Code, any MCP client) ask about a user's Apple Health data — answered live by the user's iPhone, passed through this server's memory and never stored.
AI client ──MCP (Streamable HTTP)──▶ relay (this repo, RAM only) ──WebSocket / push──▶ iPhone app (HealthKit)The iPhone app is a separate, closed-source product. This repository exists so that anyone can verify what the relay does with health data (nothing, beyond forwarding it) and run their own.
What is stored, what is not
Where | What | |
✅ stored | SQLite ( | random device id + hash of its secret; AI connections (label, self-reported client name, hash of the token, timestamps); optional APNs token; Pro expiry; landing-page waitlist emails |
⏳ in memory only | process RAM | open phone sockets; tool calls waiting for the phone (≤ 40 s); answers not yet collected by the AI (≤ 10 min, handed out once, then dropped) |
❌ never | — | health data on disk, tool arguments or answers in logs, accounts, names, emails of app users, analytics, third-party requests |
📝 logged | stdout (JSON) | method, path (MCP secrets replaced by |
Health data is visible to this server in plain text while it is forwarded (TLS terminates here; the AI provider needs plain text). That is exactly why the code is public.
Related MCP server: Apple Health AI Bridge MCP Server
How a request flows
The user creates a connection in the app → gets a secret MCP URL (
/mcp/rly_…) or bearer token for one AI.The AI calls a tool, e.g.
get_sleep. The relay validates arguments and ranges, then:app open → forwards the call over the phone's WebSocket and waits up to 40 s;
app closed + push enabled → sends a visible notification (“Claude asks for: Sleep · last 7 nights”); the user approves with Face ID and the phone posts the answer;
otherwise → tells the AI the phone is offline.
The phone checks that AI's permissions, reads HealthKit, optionally shows the user the computed answer, and replies with a receipt id (
#a4f2) that matches an entry in the phone's ledger.If the phone is slower than 40 s, the AI gets
request_idand collects the answer withget_pending_result.
MCP tools
health_overview · get_metric_series · list_workouts · get_workout · get_sleep · list_available_metrics ·
define_metric · list_custom_metrics · compute_custom_metric · delete_custom_metric · relay_status ·
get_pending_result — schemas in src/tools.ts.
Custom metrics use a small declarative formula language (src/formula.ts); no code is ever sent to
the phone.
Run it
npm i
npm run dev # http://localhost:8083 (landing page + API + /mcp)
npm test # formula language testsNo iPhone? Use the simulator — it registers a device, creates a connection and answers with synthetic data:
npm run sim -- --server http://localhost:8083 # prints the MCP URL and a `claude mcp add …` command
npm run probe -- <MCP URL> # calls every tool like an AI client wouldSelf-host
cp .env.example .env # set PUBLIC_URL
docker compose up -d --build # listens on 127.0.0.1:8083Put a TLS reverse proxy in front (deploy/nginx.example.conf). Requirements:
do not log request paths under
/mcp(they contain connection secrets);WebSocket upgrade for
/v1/ws;read timeout ≥ 60 s for
/mcp(tool calls may wait for the phone).
Then in the app: Settings → Relay server → your URL.
Push notifications (approve requests while the app is closed) need your own Apple Developer account, an APNs key and your own build of the app — the hosted relay at the app's default address has them; a self-hosted relay works in live mode (app open) out of the box.
Env | Default | |
|
| base URL shown in MCP URLs |
|
| |
|
| |
|
| how long a tool call waits for the phone |
|
| how long an uncollected answer stays in RAM |
| empty | push (optional) |
|
| name used in messages to the AI |
Phone protocol
JSON over WebSocket (GET /v1/ws, Authorization: Bearer <device token>), contract in
src/protocol.ts. REST: POST /v1/devices, GET|POST|DELETE /v1/connections,
PUT /v1/push-token, POST /v1/answers, DELETE /v1/devices/me.
Security
See SECURITY.md. Please report vulnerabilities privately.
License
AGPL-3.0. If you run a modified relay as a service, publish your changes — that keeps “nothing stored” verifiable for everyone.
This server cannot be deployed
Maintenance
Related MCP Connectors
- SomviaOAuthapp.somvia
Apple Health training load, recovery, HRV and workout detail for Claude, ChatGPT and any MCP client.
MCP server for Withings health data — sleep, activity, heart, and body metrics.
Your Apple Health data, food diary and lifts, for ChatGPT, Claude and Gemini. Approved on iPhone.
Private health and fitness analytics through a secure remote MCP connection.
Related MCP Servers
- AlicenseAqualityAmaintenanceOpen-source MCP server for MetricBridge (formerly Health Export AI). 16 tools and 22 prompts let any MCP agent query 190 Apple Health metrics from files on your own machine. The server is read-only, has zero dependencies and makes zero network calls.16389 npm8MIT
- AlicenseAqualityAmaintenanceRead-only MCP server that exposes Apple Health data (steps, workouts, sleep, etc.) from a local SQLite store, allowing AI agents to query health metrics without sending data to hosted services.927Apache 2.0
- AlicenseAqualityAmaintenanceHosted 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.732MIT
- AlicenseNot gradedqualityCmaintenanceAn MCP server that gives AI read-only access to Apple Health data through shortcuts and Cloudflare, enabling queries of current stats, detailed records, and trends.MIT