Vitals for AI Server
README.md
# Vitals for AI server
The server behind the [Vitals for AI](https://nagakaze.com/health/) iPhone app. The app sends
encrypted daily summaries of your Apple Health data here, and this server answers ChatGPT,
Claude and other AI apps over a remote MCP endpoint with sign-in (OAuth).
Most people use the hosted service and never need this repository. Run your own copy if you
want your health data to stay on infrastructure you control.
## What you need
- A Cloudflare account. The free plan is enough for one person.
- A GitHub account, if you use the deploy button: it copies this repository into your account.
- The Vitals for AI app from the App Store.
A step-by-step guide with the app side included: <https://nagakaze.com/health/self-host>
## Deploy
[](https://deploy.workers.cloudflare.com/?url=https://github.com/mengchangfeng/vitals-for-ai-server)
The button copies this repository into your GitHub account, creates the database and
key-value store, and deploys. Keep the default names on the setup page; it asks for no
secrets. When it finishes, your server has an address like
`https://vitals-for-ai.<your-subdomain>.workers.dev`, shown on the Worker's page in the
Cloudflare dashboard.
Or from a terminal:
```bash
git clone https://github.com/mengchangfeng/vitals-for-ai-server && cd vitals-for-ai-server
npm install
npx wrangler login
npm run deploy
```
This needs Node.js 22.12 or later. `wrangler.official.jsonc` and `npm run deploy:official` are
for the hosted service at health.nagakaze.com; ignore them.
To check the result, open `<your address>/v1/meta` in a browser. It should show:
```json
{"service":"vitals-for-ai","api_version":1,"single_user":true,"claimed":false}
```
## Point the app at it
1. In the app, open **Settings › Server** and choose **Custom**.
2. Enter your server's address, for example `https://vitals-for-ai.example.workers.dev`,
and confirm.
3. Sign in with Apple. The first person to sign in becomes the owner of the server.
4. Add connections as usual. The address to give an AI app is your server's address followed
by `/mcp`.
Switching servers does not move anything. Data and connections on the server you left stay
there until you switch back or delete that account.
## Settings
These live under `vars` in `wrangler.jsonc`. Change them in that file, in your copy of the
repository, and deploy again; values edited only in the dashboard are replaced by the next
deploy.
| Name | Default | Meaning |
|---|---|---|
| `SINGLE_USER` | `"true"` | Only the first person to sign in can use the server. Set to `"false"` to share it with family. |
| `APPLE_BUNDLE_ID` | `com.nagakaze.health` | Sign-in tokens must come from the App Store app. Leave as is. |
| `PUBLIC_HOST` | unset | If you add a custom domain, set this to the bare host, such as `health.example.com`, and every other address stops answering. Remove it and deploy again to undo. |
## Updating
Bring the latest changes into your copy and deploy again:
```bash
git remote add upstream https://github.com/mengchangfeng/vitals-for-ai-server # once
git pull upstream main
git push # button deploys: Cloudflare redeploys when your GitHub copy changes
npm run deploy # terminal deploys
```
The database updates itself on first use.
The app checks the server's version (`GET /v1/meta`) and tells you when the server is too old.
## What this server can see
Be clear about what running it means:
- Summaries are stored encrypted. The key is created on the iPhone and is not stored here.
- Approving a connection gives that connection a copy of the key, encrypted so that only the
holder of the connection's token can open it. While answering a request the server decrypts
the categories you shared, in memory. This is not end-to-end encryption.
- Whoever controls the Cloudflare account controls the server. Protect that account with
two-factor sign-in.
- Leave `DEV_AUTH_SECRET` unset. It enables a sign-in route meant only for local testing.
## Develop
```bash
npm run dev # local server on http://localhost:8787
node scripts/e2e.mjs # plays phone, browser and AI client against it
npm run typecheck
```
Local testing needs a `.dev.vars` file:
```
DEV_AUTH_SECRET=local-dev-secret
SINGLE_USER=false
```
## Licence
MIT. Vitals for AI is made by Dongfeng Li, publishing as Nagakaze. Report security problems
privately to support@nagakaze.com.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues