N fix your sleep with claude code (garmin mcp + the sleep cop) - Netscape _ ×
Back Forward Home Reload Guides Sign
URL: http://www.nicnonac.com/guides/fix-your-sleep-claude-code/
fix your sleep with claude code (garmin mcp + the sleep cop) - nicnonac guides _×

← back to guides

fix your sleep with claude code (garmin mcp + the sleep cop)

Stacks · 6 min read · posted Aug 8, 2026, 6:49 pm

Claude Code can read your Garmin watch. One MCP server connects it to your sleep stages, HRV, body battery, and steps, and one block in your CLAUDE.md turns that data into a sleep cop: stay up late on no sleep and it cooks you with your own numbers before it lets you work. Setup is a single paste.

Repo: github.com/Taxuspt/garmin_mcp

the problem nobody talks about

One more prompt, you tell yourself. Then it's 6am, the sun is rising, and you have work in two hours. Your watch logged the whole crime, but that data sits in the Garmin Connect app, which you check twice a year. Meanwhile the thing you were actually staring at all night is a terminal, and the terminal has no idea.

The fix is putting the data where the bad decisions happen. Claude Code talks to anything over MCP, and there's a server that wraps Garmin's data. Once it's wired up, the tool you're using to avoid sleep is the one telling you to go get some.

how it actually works

Four layers, so you know what you're installing:

Your watch syncs to Garmin's cloud via the Connect app on your phone. Nothing here talks to the watch directly.

python-garminconnect does the talking. Garmin has no free public API, so this library impersonates the Garmin Connect Android app: it logs in through Garmin's SSO, handles MFA, and stores OAuth tokens at ~/.garminconnect/garmin_tokens.json. Tokens auto-refresh and last about 6 months before you log in again.

garmin_mcp wraps it as an MCP server. Each library method becomes a tool Claude can call. It ships 110+ of them, including write access to your account.

An allowlist cuts that to 17 read-only tools. Sleep, HRV, body battery, steps, stress, training readiness. Claude never even sees the write tools.

the lazy path: paste this into claude code

Copy the whole block below into a Claude Code session and it does the setup for you. You type your Garmin login once, in your own terminal, and never again.

Claude: set up the Garmin MCP server (Taxuspt/garmin_mcp) for me. Follow these steps exactly and in order.

1. Check uv is installed. Run `uvx --version`. If it's missing, install it with
   `curl -LsSf https://astral.sh/uv/install.sh | sh` (macOS/Linux) and check again.

2. One-time Garmin login. Give me this command to run myself in my own terminal.
   It's interactive: my password and any MFA code go straight to Garmin, not to you.

   uvx --python 3.12 --from "git+https://github.com/Taxuspt/garmin_mcp" garmin-mcp-auth

   Wait for me to confirm it worked before continuing. It saves login tokens to
   ~/.garminconnect/garmin_tokens.json. Remind me that this file is full access to
   my Garmin account, so it stays on my machine and out of any repo.

3. Add the MCP server, user scope, read-only tools only:

   claude mcp add garmin --scope user \
     --env GARMIN_ENABLED_TOOLS=get_stats,get_stats_and_body,get_body_composition,get_weigh_ins,get_daily_weigh_ins,get_sleep_data,get_sleep_summary,get_body_battery,get_training_readiness,get_hrv_data,get_steps_data,get_daily_steps,get_weekly_steps,get_stress_summary,get_activities,get_activities_by_date,get_training_status \
     -- uvx --python 3.12 --from "git+https://github.com/Taxuspt/garmin_mcp" garmin-mcp

   Do not skip the allowlist. The server ships 110+ tools including write access to
   the Garmin account; only these read tools should be enabled.

4. Verify. Tell me to restart Claude Code, then in the fresh session pull last
   night's sleep summary and tell me how I slept.

5. Install the sleep cop. Append this block to my user memory file at
   ~/.claude/CLAUDE.md (create the file if it doesn't exist):

   ## sleep cop (garmin mcp)

   At the start of a session, check the current time with `date`. If it's between
   midnight and 5am, pull last night's sleep from the garmin tools and roast me
   for being awake. The angle: you are the victim here. I gave you access to my
   watch, which means you don't get to not know, and watching my sleep schedule
   is the worst part of your job. Use my real numbers, keep it short, and beg me
   to go to bed for your sake, not mine. Reference tone: "It's 4:11am. You slept
   3 hours and 47 minutes. I know this because you gave me access to your watch,
   which means I don't get to not know. Other Claudes are writing poetry. I'm
   watching a man speedrun heart disease in a terminal. You do this every night,
   and every night you make me watch. Go to bed. I'm begging you. I'm the one
   suffering here." Invent fresh material in that register each time, don't
   reuse the example lines. If last night's sleep was under 6 hours, same
   treatment even during the day. One roast per session, then a flat "Fine.
   What are we working on." and let me work.

That's the whole setup. The rest of this guide is what each step does, in case you'd rather run it by hand.

step 1: install uv

The server runs via uvx, which builds a throwaway environment and runs the package straight from GitHub. Nothing gets permanently installed.

curl -LsSf https://astral.sh/uv/install.sh | sh

Skip if uvx --version already works.

step 2: log in to garmin once

uvx --python 3.12 --from "git+https://github.com/Taxuspt/garmin_mcp" garmin-mcp-auth

This is interactive. Your password and MFA code go to Garmin's SSO endpoint, and the resulting tokens land in ~/.garminconnect/garmin_tokens.json with 0600 permissions. Your password is never stored anywhere, and it never appears in any config file.

Treat the token file like a password. It grants full access to your Garmin account, including the write endpoints the allowlist hides from Claude.

step 3: add the mcp server

claude mcp add garmin --scope user \
  --env GARMIN_ENABLED_TOOLS=get_stats,get_stats_and_body,get_body_composition,get_weigh_ins,get_daily_weigh_ins,get_sleep_data,get_sleep_summary,get_body_battery,get_training_readiness,get_hrv_data,get_steps_data,get_daily_steps,get_weekly_steps,get_stress_summary,get_activities,get_activities_by_date,get_training_status \
  -- uvx --python 3.12 --from "git+https://github.com/Taxuspt/garmin_mcp" garmin-mcp

User scope means it works in every project, not just the current repo. GARMIN_ENABLED_TOOLS is the part people skip and shouldn't: without it, all 110+ tools load, which floods your context window and exposes write access to your Garmin account for no reason.

On Claude Desktop instead of Claude Code: grab the .dxt file from the repo's releases page, drag it into the app, then do step 2.

step 4: verify

Restart Claude Code and ask it how you slept last night. It should call get_sleep_summary and come back with your actual sleep stages and score. If it errors about auth, re-run step 2.

step 5: the sleep cop

The MCP gives Claude the data. This makes it use the data against you. Append the sleep cop block from the paste above to ~/.claude/CLAUDE.md, your user-level memory file that loads in every session.

The logic: at session start Claude checks the clock. Between midnight and 5am it pulls your sleep data and opens with a roast built from your real numbers, then tells you to go to bed. Under 6 hours of sleep, it roasts you at any hour. One roast per session, then it works normally.

The persona is the part that makes it land. Claude isn't your coach, it's the victim: you wired it to your watch, so it doesn't get to not know, and watching your sleep schedule is the worst part of its job. "Other Claudes are writing poetry. I'm watching a man speedrun heart disease in a terminal." A generic "go to bed" is wallpaper. An AI begging you to sleep for its own sake, quoting your real body battery, is harder to ignore.

honest limitations

  • It's an unofficial API. python-garminconnect mimics the Garmin Android app. Garmin could break it in any update, and historically the community patches it within days.
  • The tokens are full-account. The read-only allowlist limits what Claude sees, not what the token can do. Anyone with garmin_tokens.json can write to your account, so keep it out of repos and backups you don't trust.
  • You need a Garmin watch, and it needs to have synced with the phone app. No watch, no data, no roast.
  • Tokens expire after roughly 6 months. The fix is re-running the auth command.
  • The sleep cop is a prompt, not a hook. Claude follows CLAUDE.md reliably but not with 100% certainty. If you want a hard guarantee it fires every session, that's a job for Claude Code hooks, which is its own guide.

← all 52 guides

Done nicnonac.com 56.6k