{"_id":"@aion-health/pc","name":"@aion-health/pc","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@aion-health/pc","version":"0.1.0","description":"Aion on your computer — background sync of your health data from the phone bridge, an MCP server for AI clients, and a direct CLI","bin":{"aion-health":"src/index.ts"},"main":"src/index.ts","type":"module","publishConfig":{"access":"public"},"scripts":{"prepack":"node -e \"require('fs').copyFileSync('../LICENSE', 'LICENSE')\"","typecheck":"tsc --noEmit","test":"AION_MIRROR_ENCRYPTION=off bun test src/","start:bun":"bun run src/index.ts","build:bun":"mkdir -p bin && bun build --compile src/index.ts --define __AION_MCP_VERSION__=\"\\\"$npm_package_version\\\"\" --outfile bin/aion-health-bun"},"keywords":["mcp","cli","health","fhir","claude","claude-code","ai","aion"],"homepage":"https://github.com/BionicLightIndustries/aion-foundation","repository":{"type":"git","url":"git+https://github.com/BionicLightIndustries/aion-foundation.git","directory":"pc"},"license":"PolyForm-Noncommercial-1.0.0","engines":{"bun":">=1.1.0"},"dependencies":{"@aion-health/bridge-protocol":"^0.1.0","@modelcontextprotocol/sdk":"^1.29.0","bonjour-service":"^1.4.4","env-paths":"^4.0.0","ws":"^8.18.0","zod":"^4.2.1"},"devDependencies":{"@medplum/fhirtypes":"^5.0.14","@types/bun":"^1.3.14","@types/ws":"^8.5.14","typescript":"^5.7.0"},"gitHead":"0aa99ef5b76a702eb6479e6cc1f2ae871d721d75","_id":"@aion-health/pc@0.1.0","bugs":{"url":"https://github.com/BionicLightIndustries/aion-foundation/issues"},"_nodeVersion":"26.8.1","_npmVersion":"11.19.0","dist":{"integrity":"sha512-7TC53WhIQb6BR0yFzuU4UsTuVIjllTT3j0Otj1MJUZYKRgF82iwZjVUjALmZPoRMzs0YF+CsJYvBU9N/Oh/zbg==","shasum":"fecad116e110f3ba0113b8734e10ac2c89999fd0","tarball":"https://registry.npmjs.org/@aion-health/pc/-/pc-0.1.0.tgz","fileCount":36,"unpackedSize":251474,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIEA9nbhaoJIVSeCaJXrLAr58U5nLgsLw4aIh3Hu0oKZGAiEA94AF2RvW7c7WFo8lab1MQtBkysKXD16G0IkMPakv9A0="}]},"_npmUser":{"name":"rishi.graham","email":"rishi.graham@blihealth.com"},"directories":{},"maintainers":[{"name":"rishi.graham","email":"rishi.graham@blihealth.com"},{"name":"easpencer1","email":"easpencer@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pc_0.1.0_1789091148430_0.14428603747033963"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-11T01:45:48.238Z","0.1.0":"2026-09-11T01:45:48.583Z","modified":"2026-09-11T01:45:48.889Z"},"maintainers":[{"name":"rishi.graham","email":"rishi.graham@blihealth.com"},{"name":"easpencer1","email":"easpencer@gmail.com"}],"description":"Aion on your computer — background sync of your health data from the phone bridge, an MCP server for AI clients, and a direct CLI","homepage":"https://github.com/BionicLightIndustries/aion-foundation","keywords":["mcp","cli","health","fhir","claude","claude-code","ai","aion"],"repository":{"type":"git","url":"git+https://github.com/BionicLightIndustries/aion-foundation.git","directory":"pc"},"bugs":{"url":"https://github.com/BionicLightIndustries/aion-foundation/issues"},"license":"PolyForm-Noncommercial-1.0.0","readme":"# @aion-health/pc\n\nAion on your computer: keeps an encrypted mirror of your phone's health data in sync in the background, serves it to [Claude Code](https://claude.ai/code) (and other MCP clients) via the **Aion local FHIR bridge**, and gives you a direct CLI. Everything stays on your local network — no cloud, no servers, no data leaving your home.\n\n> Source-available under PolyForm-Noncommercial-1.0.0 — free for personal and non-commercial use. Commercial use requires a license from Bionic Light Industries.\n\n## How it works\n\n```\nYour phone (Aion app)\n    ↕  WebSocket on local WiFi (port 8420, ws)\nYour PC (this package: sync daemon + MCP server + CLI)\n    ↕  stdio\nClaude Code / Cursor / Windsurf / …\n```\n\nClaude gets tools to query your FHIR health records (vitals, labs, conditions, medications, and more) and can reason about them directly.\n\nA background sync daemon (installed by setup) keeps an encrypted mirror of your\nhealth data on the PC current whenever the phone's bridge is reachable, so\nqueries work whether or not the phone is — a mirror-served result carries a\n`[MIRROR]` banner stating how fresh it is.\n\n**Requires [Bun](https://bun.sh).** The server runs its TypeScript entry directly under Bun and reads the local mirror via `bun:sqlite`. Launching with `bunx` uses the Bun you already have; the [one-line installer](https://github.com/BionicLightIndustries/aion-foundation) sets Bun up for you if it's missing.\n\n---\n\n## Quickstart\n\n`npm run setup` at the aion-foundation repo root ends by running this wizard. To run it again —\nafter a rebuild, or if you skipped that step:\n\n```bash\nnpm install   # at the repo root — the workspace installs pc's dependencies\nbun run src/index.ts setup\n```\n\nThe wizard auto-detects installed clients (Claude Code, Claude Desktop, Cursor, Windsurf, Gemini CLI, Zed), finds your phone (over USB or WiFi), and writes the right config for each, plus prints manual snippets for Continue.dev and OpenAI Codex.\n\n### Without a checkout\n\n```bash\nbunx @aion-health/pc setup\n```\n\nBun fetches and runs the package on demand, nothing to install first.\n\nCommands below are written `bunx @aion-health/pc …`; from a checkout the equivalent is `bun run src/index.ts …`. Every message telling you to re-run something prints the form that matches how you launched it.\n\n---\n\n## Prerequisites\n\n1. **Aion app** installed on your phone, with data synced\n2. Phone and PC on the **same WiFi network** (or connected over USB — see below)\n3. Bridge running: it starts by itself when the app opens, and the **home screen** shows it running\n4. The **6-digit pairing code** shown in the app\n\n---\n\n## .mcp.json reference\n\nAfter running `setup`, your AI client uses this config automatically. To configure manually:\n\n```json\n{\n  \"mcpServers\": {\n    \"aion-health\": {\n      \"command\": \"bunx\",\n      \"args\": [\"@aion-health/pc\"]\n    }\n  }\n}\n```\n\nFrom a checkout, `command` is `bun` and `args` is `[\"run\", \"<repo>/pc/src/index.ts\"]`. For the bundled-binary launch method, `command` is the absolute path to the executable and `args` is empty.\n\nA client entry is just the launch command — nothing in it can go stale:\n\n- The pairing code lives once in this package's config file, written by\n  `setup`/`repair`; `AION_PAIRING_CODE` in an entry's `env` block overrides it\n  for that client.\n- The server locates your phone at launch: first a USB port-forward on\n  `localhost:8420`, then LAN discovery (Bonjour/mDNS, the ARP cache, and a TCP\n  subnet scan). `AION_BRIDGE_URL` in `env` pins an explicit address instead.\n\n---\n\n## Available tools\n\n| Tool                  | Description                                                             |\n|-----------------------|-------------------------------------------------------------------------|\n| `fhir_summary`        | Counts of all FHIR resources by type — call first                       |\n| `fhir_query`          | Query a resource type with the full predicate surface                   |\n| `fhir_get`            | Fetch a single resource by type + id                                    |\n| `fhir_record`         | Record a new Observation                                                |\n| `export_health_data`  | Full FHIR R4 Bundle export                                              |\n| `health_audit`        | Recent bridge audit log                                                 |\n\n---\n\n## Background sync daemon\n\nThe PC-side mirror is maintained by a small daemon, not by the MCP server: it\nconnects whenever the phone's bridge is reachable and pulls a fresh snapshot\nafter each burst of changes, regardless of whether any AI client is running.\nThe MCP server only reads the mirror, and mirror-served tool results state\nwhether the daemon is keeping it current.\n\nA bridge coming up is normally noticed within seconds (a persistent mDNS\nwatch hears the announcement). Where multicast is blocked, cheap probes of\nUSB-localhost and the last-known address run at least every 15 seconds, and\na full LAN discovery every 5 minutes.\n\nSetup offers to install it. Manually:\n\n```bash\nbunx @aion-health/pc daemon install     # register as a login service and start it\nbunx @aion-health/pc daemon status      # registration, live state, last sync\nbunx @aion-health/pc daemon uninstall   # stop and deregister\nbunx @aion-health/pc daemon run         # run in the foreground (debugging)\n```\n\nPer platform, `install` registers a LaunchAgent (macOS), a systemd user\nservice (Linux), or a logon Scheduled Task with a Run-key fallback (Windows) —\nper-user, no elevation, restarted on failure. Where no credential store is\navailable for the mirror key, `install --unencrypted-mirror` explicitly opts\ninto a plaintext mirror.\n\nWithout the daemon, the mirror only updates when you run\n`bunx @aion-health/pc snapshot` yourself.\n\n## CLI subcommands\n\n```bash\nbunx @aion-health/pc setup      # Interactive setup wizard\nbunx @aion-health/pc repair     # Update the pairing code after a bridge restart\nbunx @aion-health/pc daemon     # Background sync daemon (install/status/uninstall/run)\nbunx @aion-health/pc discover   # Locate the phone, print its URL\nbunx @aion-health/pc export     # Write a FHIR Bundle to stdout or --output file\n```\n\nIt also doubles as a direct-to-bridge CLI (uses `AION_BRIDGE_URL` + `AION_PAIRING_CODE`, no server needed):\n\n```bash\nbunx @aion-health/pc summary                                   # counts by type\nbunx @aion-health/pc query Observation --category vital-signs --limit 20\nbunx @aion-health/pc query Condition --json > conditions.json  # raw FHIR\nbunx @aion-health/pc get Observation obs-123\nbunx @aion-health/pc count Observation\nbunx @aion-health/pc audit --limit 30\n```\n\nUSB mode (no WiFi): `bunx @aion-health/pc setup --usb`, with `iproxy 8420 8420` (iOS) or `adb forward tcp:8420 tcp:8420` (Android) running.\n\n---\n\n## Security posture\n\nEverything runs on your own local network — the bridge is not reachable from\nthe internet, and no data is sent to any server. Within that network:\n\n- **Access control:** every connection must authenticate with the 6-digit\n  pairing code shown on the phone before any data is served.\n- **Transport:** the bridge speaks plain `ws://` on your LAN. Traffic is not\n  encrypted in transit — devices on your own WiFi could observe it, and one\n  that captures the pairing code as a client authenticates could gain query\n  access of its own. If your home network is not a place you'd pass sensitive\n  papers around, don't run the bridge on it.\n- **At rest:** the PC-side mirror is encrypted (AES-256-GCM). The key is a\n  random 32 bytes generated on first use and kept in the platform credential\n  store, under service `aion-health-mirror`, account `mirror`:\n  - macOS: the login Keychain\n  - Windows: a DPAPI-protected file, `mirror.key.dpapi`, next to the config below\n  - Linux: the Secret Service keyring, via `secret-tool`\n\n  Nothing removes the key or the mirror; `daemon uninstall` stops the daemon\n  and leaves both in place.\n\nTBD: whether proper TLS with trust-on-first-use certificate pinning is worth\nthe added complexity — it needs dependable cross-platform key and certificate\nstorage (Keychain, credential managers, …) on every OS the client supports,\nplus a re-pairing flow whenever the phone's certificate rotates. Punted until\nthe value clearly outweighs the complexity cost.\n\n## Where things live\n\nThe mirror is one SQLite file, and the pairing code sits in a small config\nfile. `daemon status` prints the mirror path.\n\n| | Mirror | Config |\n|---|---|---|\n| macOS | `~/Library/Caches/aion-health/mirror.db` | `~/Library/Preferences/aion-health/config.json` |\n| Linux | `~/.cache/aion-health/mirror.db` | `~/.config/aion-health/config.json` |\n| Windows | `%LOCALAPPDATA%\\aion-health\\Cache\\mirror.db` | `%APPDATA%\\aion-health\\Config\\config.json` |\n\n`AION_MIRROR_PATH` overrides the mirror location. The mirror lives in a cache\ndirectory, so a cleanup tool may remove it; the next sync rebuilds it from the\nphone.\n\n---\n\n## Build a standalone binary\n\n```bash\nnpm install         # at the repo root, if not already done\nbun run build:bun   # compiles a standalone Bun binary → bin/\n```\n\n`bun build --compile` embeds the Bun runtime and the whole server, so the binary\nruns on a machine with no Bun or `node_modules` present.\n\n---\n\n## Development\n\nThe WebSocket transport + discovery is this package's own `src/bridge-client`\nmodule. The store contract and the wire protocol come from\n`@aion-health/bridge-protocol`, an ordinary dependency — inside this repo the\nnpm workspace links it to package source. Bun runs the TypeScript entry\n(`src/index.ts`) directly, so there is no build step for local use —\n`npm install` at the repo root once, then `bun run src/index.ts setup`.\n\n## License\n\nSource-available under PolyForm-Noncommercial-1.0.0. Free for personal\nand non-commercial use. Commercial use requires a license from Bionic Light Industries.\n","readmeFilename":"README.md","_rev":"1-36b5d6959f9d606bbd4d3789d756d865"}