# health4ai [Health: Active]

**Category:** 🧬 Biology & Bioinformatics  
**Repository:** https://github.com/jefflitt1/health4ai  
**GitHub Stars:** 12  
**Views:** 11  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/health4ai

## Description
Query your Apple Health data from your own Supabase/Postgres via local MCP.

## Tools
Capabilities this server exposes over MCP:

- **get_health_summary** — Overview of key metrics for the past N days
- **get_sleep** — Per-night sleep breakdown with REM, Deep, Core stages. One source per night: Oura > Apple Watch > Whoop > Garmin > Withings > whichever other source (iPhone included) has the most stage records
- **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 (same one-source-per-night rule as `get_sleep`), 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

## Claude Desktop Quick Installation
No generated config for this server: it installs through its own setup steps.

The project's own setup steps (from https://github.com/jefflitt1/health4ai), copied verbatim. Follow them in order; they are not an mcpServers config.

1. Install:

```sh
git clone https://github.com/jefflitt1/health4ai.git
```

2. Configure:

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

3. Add to your MCP client:

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

## Documentation

## What health4ai does

health4ai makes Apple Health data available to MCP-compatible AI clients through a database you create and control. The iOS app reads HealthKit data and synchronizes it to your Supabase project. The local MCP server then queries that data using purpose-built tools rather than requiring an AI client to access HealthKit directly.

Supported data includes sleep stages, HRV, heart rate, workouts, VO₂ max, and more than 150 other HealthKit metric types. The server can return recent summaries, raw time-series records, long-term monthly aggregates, threshold-based searches, personal statistics, and comparisons between date ranges.

Sleep results select one source per night using this order: Oura, Apple Watch, Whoop, Garmin, Withings, then another source with the most stage records. The same source-selection rule is used in recovery briefs.

## How it works

The data path is:

`iPhone HealthKit → your Supabase project → local MCP server → AI client`

The iOS app uses HealthKit background observation and scheduled background tasks to sync records. A Supabase Edge Function receives the ingest requests, while the MCP process connects to the project's Postgres database using its pooler connection string. The server is run locally over standard input/output, so an MCP client launches the Python process directly.

The database and backend belong to the user. health4ai does not run a separate hosted backend or retain access to the health records.

## Setup and configuration

Create a Supabase project and execute the supplied schema in its SQL editor. Deploy the `healthkit-ingest` Edge Function with the Supabase CLI, create a Supabase Auth user, and install the health4ai iOS app from the App Store. In the app, provide the project URL and anon key, sign in with the created user, and start synchronization.

From the repository checkout, copy `mcp-server/.env.example` to `mcp-server/.env` and set:

- `DATABASE_URL`: the Supabase project's pooler PostgreSQL connection string, using the database password rather than an API key.
- `HEALTHKIT_USER_ID`: the UID of the Supabase Auth user whose records the server should query.

Configure the MCP client to run `python /path/to/health4ai/mcp-server/main.py` with those environment variables. Claude Desktop, Claude Code, Cursor, and local Ollama workflows using an MCP client such as mcphost are shown usage paths.

## Tools and capabilities

- `get_health_summary` returns key metrics for a requested number of recent days.
- `get_sleep` reports nightly duration and REM, Deep, and Core stages.
- `get_hrv_trend` provides daily SDNN HRV with rolling comparisons and a trend.
- `get_daily_snapshot` gathers records for one date.
- `get_workouts` lists workout type, duration, distance, and calories.
- `query_metric` retrieves raw time-series data for a HealthKit metric type.
- `get_long_term_trend` produces monthly aggregates across multiple years.
- `get_coaching_brief` combines recovery, sleep, training load, and fitness indicators.
- `search_records` finds days when a metric crossed a threshold.
- `get_metric_stats` calculates min, max, mean, and percentiles for a personal baseline.
- `compare_periods` compares a metric across two date ranges.

## Limitations and notes

Supabase is required for the supported backend; plain Postgres installations such as Neon or a local Docker database are not supported. The iOS app does not sign users up, so the Auth user must be created in the Supabase dashboard first.

HealthKit can return an empty result both when no samples exist and when a permission was not shared. Tools that can be empty include a `data_status` block: `never_recorded` indicates that the metric has never produced a sample, while `empty_window` indicates a gap in the requested period despite data elsewhere. Check Health sharing permissions and re-import when appropriate.

The iOS component requires iOS 17 or newer, and the project identifies Python 3.11 or newer as its runtime requirement. The project is licensed under MIT.

_Full upstream README: https://allmcps.com/mcp/health4ai/readme_

