<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jeff Littell</title>
    <description>The latest articles on DEV Community by Jeff Littell (@jglitt).</description>
    <link>https://dev.to/jglitt</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3991704%2Fb4d874b5-1855-4876-8ddf-667ee49c2f55.jpg</url>
      <title>DEV Community: Jeff Littell</title>
      <link>https://dev.to/jglitt</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jglitt"/>
    <language>en</language>
    <item>
      <title>How to give Claude Code access to your Apple Health data</title>
      <dc:creator>Jeff Littell</dc:creator>
      <pubDate>Fri, 19 Jun 2026 02:01:09 +0000</pubDate>
      <link>https://dev.to/jglitt/how-to-give-claude-code-access-to-your-apple-health-data-3p76</link>
      <guid>https://dev.to/jglitt/how-to-give-claude-code-access-to-your-apple-health-data-3p76</guid>
      <description>&lt;p&gt;Apple has no HealthKit REST API. Claude's native Apple Health connector only works on claude.ai web, not Claude Code. Here's how to fix that.&lt;/p&gt;




&lt;h2&gt;
  
  
  The constraint
&lt;/h2&gt;

&lt;p&gt;Apple's privacy design is the core issue. HealthKit data never leaves your device through a server-side API. There's no endpoint you can call from a script, a cloud function, or an AI agent. All HealthKit access goes through an on-device iOS app that the user has explicitly granted permission.&lt;/p&gt;

&lt;p&gt;That's actually good for privacy. But it creates a real problem if you want to query your health data from Claude Code, Cursor, or any MCP client running outside the claude.ai web interface.&lt;/p&gt;

&lt;p&gt;The existing workarounds have limits. Health Auto Export is a solid app, but its MCP server works over local TCP. Your Claude Code session on a Mac Studio can't reach it if your phone is on a different network, or if you're on a VPN. The built-in Apple Health connector in claude.ai is great for the web UI but doesn't expose anything to Claude Code or any other MCP client.&lt;/p&gt;

&lt;p&gt;The only real solution is to build your own sync layer: an iOS app that reads HealthKit and pushes to a database you control, plus an MCP server that Claude can talk to.&lt;/p&gt;

&lt;p&gt;That's what health4.ai is.&lt;/p&gt;




&lt;h2&gt;
  
  
  What health4.ai does
&lt;/h2&gt;

&lt;p&gt;The architecture is straightforward:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;iPhone (HKObserverQuery) → Your Postgres database → FastMCP server → Any AI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The iOS app registers &lt;code&gt;HKObserverQuery&lt;/code&gt; observers for every HealthKit metric type. When Apple Health receives new data (a completed workout, a new HRV reading, a sleep session), the observer fires and queues a sync. &lt;code&gt;BGTaskScheduler&lt;/code&gt; handles periodic background delivery. On first launch, a bulk backfill exports your entire HealthKit history — mine was around 5.6 million rows.&lt;/p&gt;

&lt;p&gt;Data lands in a simple EAV schema: one row per &lt;code&gt;HKSample&lt;/code&gt;, with &lt;code&gt;metric_type&lt;/code&gt;, &lt;code&gt;value&lt;/code&gt;, &lt;code&gt;unit&lt;/code&gt;, &lt;code&gt;started_at&lt;/code&gt;, &lt;code&gt;ended_at&lt;/code&gt;, &lt;code&gt;source_device&lt;/code&gt;, and a &lt;code&gt;metadata&lt;/code&gt; JSONB column. New metric types never require a schema migration.&lt;/p&gt;

&lt;p&gt;The MCP server is a Python FastMCP process running locally. It reads directly from Postgres (your credentials, your database) and exposes 11 tools that any MCP client can call.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You own the data.&lt;/strong&gt; health4.ai never receives or stores your health data. It flows from your iPhone to your Postgres database — you choose the provider.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step-by-step setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Clone the repo
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/jefflitt1/health4ai.git
&lt;span class="nb"&gt;cd &lt;/span&gt;health4ai
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Set up your Postgres database
&lt;/h3&gt;

&lt;p&gt;Pick the backend that fits you and run the schema:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Supabase (free tier works fine):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;psql &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$DATABASE_URL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;lt; web/public/schema.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Neon (serverless Postgres):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;psql &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="nv"&gt;$DATABASE_URL&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &amp;lt; web/public/schema.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Local Docker:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;--name&lt;/span&gt; health4ai-postgres &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;yourpassword &lt;span class="nt"&gt;-p&lt;/span&gt; 5432:5432 postgres:16
psql &lt;span class="s2"&gt;"postgresql://postgres:yourpassword@localhost:5432/postgres"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &amp;lt; web/public/schema.sql
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Install the iOS app
&lt;/h3&gt;

&lt;p&gt;TestFlight link: &lt;strong&gt;coming soon&lt;/strong&gt; — the app is in review. Sign in with your Postgres connection details and tap &lt;strong&gt;Start Sync&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Configure the MCP server
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp &lt;/span&gt;mcp-server/.env.example mcp-server/.env
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Edit &lt;code&gt;mcp-server/.env&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DATABASE_URL=postgresql://...    # your Postgres connection string
HEALTHKIT_USER_ID=your_user_id   # any string to identify your data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Install dependencies:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd &lt;/span&gt;mcp-server &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; pip &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-r&lt;/span&gt; requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5. Add it to Claude Code
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"mcpServers"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"health4ai"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"command"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"python"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"args"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"/path/to/health4ai/mcp-server/main.py"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"DATABASE_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"postgresql://..."&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"HEALTHKIT_USER_ID"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"your_user_id"&lt;/span&gt;&lt;span class="w"&gt;
      &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Restart Claude Code. Run &lt;code&gt;/mcp&lt;/code&gt; to confirm. You should see &lt;code&gt;health4ai&lt;/code&gt; with 11 tools listed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Works with Cursor too&lt;/strong&gt; — same config block in &lt;code&gt;~/.cursor/mcp.json&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fully local with Ollama:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;mcphost &lt;span class="nt"&gt;--model&lt;/span&gt; ollama/llama3.2 &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--mcp-server&lt;/span&gt; &lt;span class="s2"&gt;"health4ai:python /path/to/health4ai/mcp-server/main.py"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your data and the model both stay on-device. Nothing leaves your machine.&lt;/p&gt;




&lt;h2&gt;
  
  
  What you can ask
&lt;/h2&gt;

&lt;p&gt;Here are prompts that work well, along with which tool they trigger:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"How did I sleep this week?"&lt;/strong&gt; → &lt;code&gt;get_sleep&lt;/code&gt; — per-night breakdown with Core, Deep, and REM stage durations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Is my HRV trending up or down this month?"&lt;/strong&gt; → &lt;code&gt;get_hrv_trend&lt;/code&gt; — daily SDNN averages, 7-day rolling comparison, trend direction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Give me a full health summary for the last 14 days."&lt;/strong&gt; → &lt;code&gt;get_health_summary&lt;/code&gt; — steps, HRV, resting HR, sleep, workouts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"What does yesterday look like?"&lt;/strong&gt; → &lt;code&gt;get_daily_snapshot&lt;/code&gt; — everything recorded that day.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Is 42ms HRV good or bad for me?"&lt;/strong&gt; → &lt;code&gt;get_metric_stats&lt;/code&gt; — your personal baseline: min/max/mean, percentiles, good/poor-day thresholds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Did my sleep improve after I started lifting?"&lt;/strong&gt; → &lt;code&gt;compare_periods&lt;/code&gt; — compare any metric between two date ranges with delta, % change, and a plain-English verdict.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;"Show me my resting heart rate trend over the past 2 years."&lt;/strong&gt; → &lt;code&gt;get_long_term_trend&lt;/code&gt; — transparently switches to pre-aggregated monthly buckets beyond 180 days, so it's fast and complete regardless of data volume.&lt;/p&gt;




&lt;h2&gt;
  
  
  GitHub
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/jefflitt1/health4ai" rel="noopener noreferrer"&gt;https://github.com/jefflitt1/health4ai&lt;/a&gt; — MIT licensed. PRs welcome.&lt;/p&gt;

&lt;p&gt;If you set it up and run into anything, open an issue. The main thing still pending is the public TestFlight link. Everything else is working.&lt;/p&gt;

</description>
      <category>healthkit</category>
      <category>mcp</category>
      <category>ios</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
