--- name: healthmd-cli description: Safely install and use the Health.md CLI and MCP server to query user-authorized health data, chart typed metrics, inspect sleep and workouts, export scoped or complete public/authorized Apple Health or Health Connect data, and recover durable jobs on macOS, Linux, or Windows. Use for consumer workflows, not Health.md development. compatibility: Requires matching `healthmd` and `healthmd-mcp` binaries plus an explicitly compatible Health.md mobile build. Direct typed queries and canonical extraction currently require iPhone; Android supports provider-native raw and generated-file exports. Live work requires Direct CLI Access and the selected phone to be available. --- # Health.md CLI Use the standalone `healthmd` command. Health.md for Mac is not required. ```text agent/user → healthmd on macOS, Linux, or Windows ← authenticated encrypted Manual IP or Tailscale connection → foreground Health.md mobile app → HealthKit or Health Connect → bounded typed results, canonical data, or generated files ``` The CLI listens on the computer; the phone connects to the displayed address. It can keep an unavailable request waiting while the user opens Health.md. Published alpha.7 binaries send one best-effort APNs notification when the selected iPhone has enrolled wake material; alpha.6 binaries were wait-only. Android and unenrolled phones remain wait-only. A notification can restore user presence but never authorizes background health access or bypasses app activity, permissions, protected-data controls, quotas, or OS background limits. The CLI is direct-only and has no backend option; it never requires or contacts the Health.md Mac app. Do not add `--transport nearby`. ## Authorization and privacy first Treat the user's request as authority only for its stated device, operation, metrics/categories, dates, sources, detail, destination, and disclosure level. Ask before widening any of them. - Default to the smallest useful date and metric scope. - Get explicit approval before pairing, returning health values in chat, using `--all`, requesting lossless records, enabling `--allow-partial`, writing generated files, changing trust, or deleting state. - Use a user-approved private absolute path outside a repository for health artifacts. Do not assume a synced or shared folder is private. - Pairing QR images and fallback codes contain short-lived secrets. Render them only to the user; never transcribe, reconstruct, upload, or log them. - Local stdio means Health.md itself needs no health-data cloud. It does **not** guarantee local model inference: the MCP host or model provider may process returned values under its own policies. - Do not diagnose, recommend treatment, infer causation, or label a result healthy, harmful, better, or worse. Preserve exact metric IDs, statistics, units, dates/timezone, source, coverage, missingness, evidence, and limitations. - Never merge HealthKit HRV SDNN with Health Connect or WHOOP HRV RMSSD. ## Verify release compatibility The `0.1.0-alpha.7` package is an explicitly unqualified public preview. Physical QA has confirmed basic iPhone and Android connectivity, but no public CLI/mobile pair has completed and retained the full release qualification matrix yet. Its source snapshot contains these exact counterparts: | Mobile source | Protocol | Exact counterpart in the release snapshot | Portable operations | |---|---|---|---| | iPhone exports | v1 | iOS 3.4.0 (build 202609032318) | status, raw, extract, files, resume, cancel | | iPhone typed queries | v1 + query v3 | iOS 3.4.0 (build 202609032318) | the export operations plus fixed typed query tools | | Android exports | v2 | Android 1.9.0 (`versionCode 38`) | status, provider-native raw, files, resume, cancel | | Android typed queries | unavailable | not implemented | do not claim support | The unqualified protocol floors remain iOS 3.0.3 and Android 1.5.4 (`versionCode 25`), but protocol implementation and basic connectivity are not release qualification. Check the exact package and mobile build before live work. Do not claim App Store or Play Store compatibility from a marketing version alone. Authoritative ledger: ## Install or verify ```bash healthmd --version healthmd --help ``` On macOS or Linux, install the matching preview binaries together: ```bash brew install CodyBontecou/tap/healthmd ``` For Windows or direct archive installation, use the exact `healthmd-cli/v` GitHub Release—not repository `/releases/latest`—and follow that release's checksum, Sigstore, and publisher-verification instructions. Do not mix `healthmd` and `healthmd-mcp` versions. Authorized preview testers may build the exact tag from source: ```bash git clone https://github.com/CodyBontecou/health-md.git cd health-md git checkout healthmd-cli/v0.1.0-alpha.7 cd apps/cli cargo install --locked --path crates/healthmd-cli ``` Do not use `apps/apple/scripts/healthmd`; it runs the legacy Swift compatibility client. Linux requires an unlocked freedesktop Secret Service provider such as GNOME Keyring or KWallet. The CLI never falls back to plaintext credentials. ## Bound unfamiliar commands Use the CLI's non-network discovery mode instead of guessing required flags. These commands exit successfully with `healthmd.cli_guidance/1`, `status: guidance`, and `request_sent: false` without opening credentials or contacting a phone: ```bash healthmd export healthmd extract healthmd query healthmd query healthmd_sleep_sessions healthmd resume healthmd cancel healthmd direct healthmd mcp ``` A selected query operation returns its complete `input_schema`, JSON examples, and an `argv` array. Malformed or runtime failures return `healthmd.cli_error/1` with `help_command` and bounded `next_actions`; follow those fields instead of scraping `message` or retrying blindly. On macOS/Linux use non-interactive execution and a hard process timeout: ```bash NO_COLOR=1 TERM=dumb timeout 15 healthmd --version