# Polar Health Data (self-hosted)

A self-hosted server that syncs Polar health data into PostgreSQL and exposes it to your agent over MCP: sleep, HRV, workouts, personal baselines.

- MCP server · `type=mcp` · Claude Code, Codex, Cursor, GitHub Copilot, Windsurf (Devin Desktop), Cline, Zed · ★ 24
- Author: StuMason
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/StuMason/polar-flow-server
- Updated: 2026-10-19
- HTML: https://affpapa.org/en/nevibecode/mcp/polar-health-data-self-hosted

## What it does

Polar's API shows you roughly the last 28-30 days. This server pulls everything it can reach and keeps it in your own PostgreSQL, with no cloud sitting in between. Thirteen endpoints feed it: sleep stages, nightly recharge, daily activity, exercises, cardio load, SleepWise, SpO2, ECG, body and skin temperature. Baselines are recomputed per person using rolling averages and IQR anomaly bounds, so a question about whether something is normal gets answered against your own history.

The MCP server is built into the main process at `/mcp` and speaks streamable HTTP. Ten tools cover a one-shot assessment, sleep, recovery, activity, workouts, seven biosensing streams, baselines and sync control. With `BASE_URL` set, the server acts as its own OAuth 2.1 authorization server: user-scoped tokens, refreshed automatically and revocable from settings. Headless clients can authenticate with an API key instead.

You will need PostgreSQL plus `ENCRYPTION_KEY`, a 32-byte Fernet key used to encrypt stored tokens. Polar credentials come from the AccessLink admin console, and the redirect URI has to point at `/admin/oauth/callback` on your instance. The stack is Litestar with SQLAlchemy 2.0 and the polar-flow SDK. Dashboard assets are vendored, so it renders on a LAN without CDN access.

## Requirements
- Needs: Docker
- Environment variables: `DATABASE_URL`, `POLAR_CLIENT_ID`, `POLAR_CLIENT_SECRET`, `BASE_URL` — keys and tokens: ask the human for the values, never commit them or put them in shared files.

## Install

### Claude Code (native platform)

**Install**
- The MCP registry has no launch command for it: see the repository README

## When to use it
- keep Polar history past the 28-30 day window
- compare overnight HRV against your own normal
- ask an agent whether today calls for hard training
- pull sleep, load and SpO2 into one store
- connect a health server through OAuth

## Example prompts
- Add my `polar-health` MCP server at `https://your-server/mcp` and list the tools it exposes
- Compare last night's HRV to my baseline and tell me if a hard session makes sense today
- Chart my skin temperature over the past week against its baseline

## Similar
- [REA](https://affpapa.org/en/nevibecode/mcp/rea.md) — MCP server · ★ 386989
- [GitHub](https://affpapa.org/en/nevibecode/mcp/github.md) — MCP server · ★ 33918
- [Netdata](https://affpapa.org/en/nevibecode/mcp/netdata.md) — MCP server · ★ 81115
- [browser-use](https://affpapa.org/en/nevibecode/mcp/browser-use.md) — MCP server · ★ 119160
- [Codebase Memory](https://affpapa.org/en/nevibecode/mcp/codebase-memory.md) — MCP server · ★ 47392
- [mcp-server](https://affpapa.org/en/nevibecode/mcp/mcp-server.md) — MCP server · ★ 43872

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
