Command Palette

Search for a command to run...

UnylyUnyly
Весь каталог

Health4AI

БесплатноНе проверен

Apple HealthKit → PostgreSQL sync + MCP server for Claude Code, Cursor, and Ollama. Open-source iOS app with reliable background sync (HKObserverQuery). 11 tool

GitHubEmbed

Описание

Apple HealthKit → PostgreSQL sync + MCP server for Claude Code, Cursor, and Ollama. Open-source iOS app with reliable background sync (HKObserverQuery). 11 tools covering health summary, sleep, HRV trends, workouts, daily snapshots, metric stats, period comparison, and coaching briefs. Supports Supabase, Neon, and self-hosted Postgres. Privacy-first: your data goes to your own database.

README

health4.ai logo

Ask your AI about your sleep, HRV, recovery, and fitness — in plain language.
Free iOS app · Your own database · Works with any MCP client

Website MIT License iOS 17+ Python 3.11+ FastMCP Any Postgres


What it does

iPhone HealthKit → Your Postgres database → MCP server → Any AI

Apple Health holds years of your biometric data — sleep stages, HRV, heart rate, workouts, VO₂ max, and 150+ other metrics. health4.ai makes all of it queryable from Claude, ChatGPT, Cursor, Ollama, or any MCP-compatible client via 8 purpose-built tools.

You control the data. It syncs to a Postgres database you configure — Supabase, Neon, or a local Docker container. health4.ai never stores or has access to your health data.


Why it exists

Problem health4.ai fix
Apple has no HealthKit server API — all access requires an on-device app Native iOS app with HKObserverQuery + BGTaskScheduler background sync
Health Auto Export only works on the same WiFi Your data lands in Postgres — queryable from any AI, anywhere
The claude.ai Apple Health connector doesn't reach Claude Code CLI or Cursor Standard MCP (stdio) — one config block works everywhere
Most solutions require a managed cloud service Bring your own Postgres: Supabase, Neon, or fully local

Demo

Demo video coming. Here's what a typical conversation looks like:

You:     How was my recovery this week? Anything standing out?

Claude:  Your recovery this week was mixed but trending positive.
         • HRV averaged 58ms (Tue–Thu strong at 64–68ms; Monday low at 44ms after Saturday's long run)
         • Sleep averaged 7h 12m — Wednesday and Thursday were your best nights (7h 40m+)
         • Resting HR dropped from 54bpm Monday to 49bpm Friday — a good sign
         Recommendation: today looks like a solid day for a moderate-intensity session.

Quick start

Choose your Postgres backend first:

Supabase (free tier available)
# 1. Create a project at supabase.com
# 2. Run the schema
psql "$DATABASE_URL" < web/public/schema.sql
# or use the Supabase dashboard SQL editor
Neon (serverless Postgres)
# 1. Create a project at neon.tech
# 2. Run the schema
psql "$DATABASE_URL" < web/public/schema.sql
Local Docker
docker run -d \
  --name health4ai-postgres \
  -e POSTGRES_PASSWORD=yourpassword \
  -p 5432:5432 \
  postgres:16
psql "postgresql://postgres:yourpassword@localhost:5432/postgres" \
  < web/public/schema.sql

Then set up the MCP server:

git clone https://github.com/jefflitt1/health4ai.git
cd health4ai

cp mcp-server/.env.example mcp-server/.env

Edit mcp-server/.env:

DATABASE_URL=postgresql://...    # your Postgres connection string
HEALTHKIT_USER_ID=your_user_id   # any string to identify your data

Add to your AI client:

Claude Code / Claude Desktop
{
  "mcpServers": {
    "health4ai": {
      "command": "python",
      "args": ["/path/to/health4ai/mcp-server/main.py"],
      "env": {
        "DATABASE_URL": "postgresql://...",
        "HEALTHKIT_USER_ID": "your_user_id"
      }
    }
  }
}
Cursor

Same block → ~/.cursor/mcp.json

Ollama (fully local — no data leaves your machine)

Pair with mcphost or mcp-client-for-ollama:

mcphost --model ollama/llama3.2 \
  --mcp-server "health4ai:python /path/to/health4ai/mcp-server/main.py"

Your health data and the model both stay on your hardware — nothing leaves your machine.

Install the iOS app: TestFlight link coming at App Store launch. Sign in with your database credentials and tap Start Sync.


MCP tools

Tool What it answers
get_health_summary Overview of key metrics for the past N days
get_sleep Per-night sleep breakdown with REM, Deep, Core stages
get_hrv_trend Daily HRV (SDNN) with rolling comparison and trend
get_daily_snapshot Everything recorded for a specific date
get_workouts Recent workouts with type, duration, distance, calories
query_metric Raw time-series for any HealthKit metric type
get_long_term_trend Monthly aggregates over years (raw + summary tiers)
get_coaching_brief Recovery status, sleep quality, training load, fitness markers
search_records Find days where a metric crossed a threshold
get_metric_stats Personal baseline: min/max/mean/percentiles
compare_periods Compare a metric between two date ranges

Architecture

┌─────────────────────────────────────────────────────────────┐
│  iPhone                                                      │
│  HKObserverQuery + BGTaskScheduler                          │
│  → continuous background sync                               │
└──────────────────────────┬──────────────────────────────────┘
                           │ HTTPS
                           ▼
┌─────────────────────────────────────────────────────────────┐
│  Your Postgres database (Supabase / Neon / local Docker)    │
│  healthkit_metrics · healthkit_daily_summaries              │
│  v_healthkit_daily_quantity (unified view)                  │
└──────────────────────────┬──────────────────────────────────┘
                           │ SQL (service-role key, server-side only)
                           ▼
┌─────────────────────────────────────────────────────────────┐
│  FastMCP server  (mcp-server/main.py)                       │
│  11 tools · stdio transport                                  │
└──────────────────────────┬──────────────────────────────────┘
                           │ MCP
                           ▼
              Claude · ChatGPT · Cursor · Ollama · any client

Data tiers: queries within the last 30 days return raw samples; older data transparently switches to pre-aggregated daily summaries — so long-term trend queries stay fast regardless of data volume.


Repo structure

health4ai/
├── ios/                         # Swift/SwiftUI iOS app (iOS 17+)
│   └── Health4AI/               # HealthKit sync engine, auth, settings
├── mcp-server/
│   ├── main.py                  # FastMCP server entry point
│   ├── tools.py                 # 11 tool implementations
│   └── .env.example             # Required environment variables
├── web/
│   ├── public/schema.sql        # Portable Postgres schema (all backends)
│   └── src/                     # Astro marketing site
├── scripts/
│   ├── import_health_export.py  # One-time XML backfill from Apple Health export
│   └── summarize_historical.py  # Backfill daily summaries table
└── docs/
    └── SETUP.md                 # Detailed setup guide

Privacy

Your health data goes directly from your iPhone to your Postgres database. health4.ai never receives, stores, or has access to it. The MCP server runs locally with your own credentials — your data never touches our infrastructure.

See the Privacy Policy for full details.


Contributing

MIT licensed. PRs welcome.

Good first areas: additional metric aggregations, multi-user support with JWT/RLS, Android, and more MCP client integration guides.

License

MIT — see LICENSE.

from github.com/jefflitt1/health4ai

Установка Health4AI

У этого сервера нет опубликованного пакета — он собирается из исходников. Открой репозиторий и следуй инструкции в README.

▸ github.com/jefflitt1/health4ai

FAQ

Health4AI MCP бесплатный?

Да, Health4AI MCP бесплатный — установка в пару кликов через Unyly без оплаты.

Нужен ли API-ключ для Health4AI?

Нет, Health4AI работает без API-ключей и переменных окружения.

Health4AI — hosted или self-hosted?

Доступен hosted-вариант: Unyly запускает сервер в облаке, локальная установка не обязательна.

Как установить Health4AI в Claude Desktop, Claude Code или Cursor?

Открой Health4AI на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.

Похожие MCP

Compare Health4AI with

Не уверен что выбрать?

Найди свой стек за 60 секунд

Автор?

Embed-бейдж для README

Похожее

Все в категории data