
Polar Health Data (self-hosted)
io.github.StuMason由 GitHub 账号 StuMason 发布v1.6.2更新于 Oct 24, 2026
Self-hosted Polar health analytics with a built-in MCP server: sleep, HRV, workouts, baselines.
概览
自托管的 Polar 健康数据分析服务器,内置 MCP 端点,让助手读取你的睡眠、HRV、训练记录和个人基线。
- 可以做什么
- 获取一次性健康评估与训练准备度结论
- 读取睡眠、恢复、夜间充电、活动与训练记录
- 查询连续心率、血氧、ECG、皮肤温度等生物传感数据流
- 将数值与个人基线对比,发现模式与异常
- 触发并控制从 Polar AccessLink 同步数据
- 适用场景
- 适合佩戴 Polar 设备、希望把完整历史保存在自己的 PostgreSQL 而非 Polar 仅 28-30 天窗口内,并想让助手基于这些数据回答训练与恢复问题的人。
- 运行要求
- 以自托管 Docker 容器(或从源码)运行,需要 PostgreSQL 数据库(DATABASE_URL)。需要 Polar AccessLink OAuth 凭据 POLAR_CLIENT_ID 与 POLAR_CLIENT_SECRET,生产环境还需 ENCRYPTION_KEY。设置 BASE_URL 可启用 MCP 连接器的 OAuth 登录;无头客户端可用 X-API-Key 请求头。
安装
在 SourceWeft 中
- 打开 控制台中的 Polar Health Data (self-hosted),将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
polar-flow-server
Self-hosted health analytics for Polar devices — own your data, analyze it against your own baselines, and let your AI assistant read it.
[Tests] [Docs] [Docker] [MCP] [License: MIT]
Full Documentation · MCP Server · Integration Guide · API Reference
What This Does
Your watch knows more about you than you do — and Polar's API only lets you see the last 28-30 days of it. This server syncs everything, keeps it forever, and turns it into answers:
- Syncs all 13 Polar API endpoints automatically — sleep, HRV, activity, workouts, SpO2, ECG, skin temperature, the lot
- Stores everything in PostgreSQL. Your data, your server, no cloud between you and it
- Computes personal baselines (rolling averages, IQR anomaly bounds) so "is this normal?" means normal for you
- Ships a built-in MCP server with OAuth sign-in — ask Claude "should I train hard today?" and it answers from your overnight HRV vs your baseline
- Admin dashboard (HTMX), REST API, per-user API keys, multi-user ready
Ask Your AI About Your Body (MCP)
A built-in Model Context Protocol server — protocol revision 2026-07-28, streamable HTTP — runs inside the main server at /mcp. Ten curated tools cover the one-shot health assessment, sleep, recovery, activity, workouts, seven biosensing streams, personal baselines, patterns/anomalies, and sync control.
In clients that render MCP Apps (claude.ai, Claude Desktop, VS Code), asking "how am I doing?" draws an actual card in the conversation:
Connecting is a sign-in, not a paste. With BASE_URL set, the server is its own OAuth 2.1 authorization server: add https://your-server/mcp as a custom connector in Claude Desktop or claude.ai, click Connect, log in on your server, approve the consent screen. Tokens are user-scoped, expire hourly, refresh automatically, and every connected app is revocable from Settings. API keys still work for headless clients:
Full setup in the MCP docs.
Architecture
Stack:
- Litestar (async web framework)
- SQLAlchemy 2.0 (async ORM)
- PostgreSQL
- HTMX + Tailwind (admin UI)
- polar-flow SDK v1.5.0
Don't fancy running a server? A hosted version is in the works — join the waitlist. Self-hosting stays free forever.
Quick Start
Option 1: Docker (Recommended)
Option 2: From Source
Setup
- Open http://localhost:8000/admin
- Get Polar credentials from admin.polaraccesslink.com (set redirect URI to
http://localhost:8000/admin/oauth/callback) - Enter credentials and click "Connect with Polar"
- Hit "Sync Now" to pull your data
The server syncs data every hour automatically.
Dashboard
The admin panel at /admin/dashboard is organised into tabs (with a
floating tab bar on mobile):
- Overview - stat tiles (HRV, resting HR, SpO2, skin temp, steps, strain, sleep score, alertness...), Today's Readiness recommendations, and "Today at a Glance" mini-charts (sleep stages, heart rate, steps)
- Trends & Baselines - personal baselines and detected patterns
- Sleep - sleep score and stage-duration charts
- Heart Rate - daily HR, HRV and ANS charge charts, biosensing panel
- Training Load - activity and cardio load charts
Charts have a selectable 7/14/30-day range and CSV export. API keys are managed from the settings page, with rate limit tracking. All frontend assets are vendored - the dashboard works offline and on a LAN with no CDNs.
Data Synced (13 Endpoints)
Configuration
Required Environment Variables
Generate an encryption key:
Optional Environment Variables
API Authentication
API endpoints require authentication. Health data should never be publicly accessible.
Authentication Methods
- Per-User API Keys (recommended) - Create from the admin dashboard or via OAuth flow
- Master API Key - Set
API_KEYenv var for full access (bypasses rate limits)
Using API Keys
Rate Limiting
- Default: 1000 requests per hour per API key
- Rate limits reset hourly
- Master API key (
API_KEYenv var) bypasses rate limiting - Rate limit info returned in response headers
OAuth Integration (SaaS / Multi-User)
For applications that need to integrate with polar-flow-server (e.g., Laravel, mobile apps, web frontends).
This allows any Polar user to connect their account to your application.
OAuth Flow
Step 1: Redirect user to start OAuth
Step 2: User authorizes on Polar
User is redirected to Polar, logs in with their credentials, and authorizes your app.
Step 3: User redirected to your callback
Step 4: Exchange temp code for API key (server-to-server)
Response:
Step 5: Store and use the API key
Store api_key and polar_user_id for this user. Use the API key for all data requests:
Polar Admin Setup
In admin.polaraccesslink.com, set your app's redirect URI to:
Key Management
API Endpoints
Development
Production Deployment
Deploy anywhere that runs Docker:
Coolify, Railway, Render, etc. - Point at the GitHub repo, it builds from the Dockerfile.
Required for production:
- Set
ENCRYPTION_KEYenvironment variable (tokens won't persist across restarts otherwise) - Set
DATABASE_URLto your PostgreSQL instance
Database migrations run automatically on startup.
Multi-Tenancy
The server supports multiple users out of the box:
- Every table includes
user_idcolumn - All queries scoped by
user_id - Per-user API keys ensure users can only access their own data
- Self-hosted: typically one user
- Multi-user: many users, same codebase
Built With
- polar-flow - Python SDK for Polar AccessLink API
- Litestar - Async web framework
- SQLAlchemy - Async ORM
- HTMX - Admin UI interactions
- Tailwind CSS - Styling
License
MIT
来源:README.md,提交 dfe3fc2
工具
0版本历史
5- v1.6.2最新Oct 19, 2026
- v1.6.1Oct 2, 2026
- v1.6.0Oct 2, 2026
- v1.5.2Oct 2, 2026
- v1.5.1Sep 16, 2026
评分
已满足适用检查项的 40%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分
请在仓库或注册中心条目中声明许可证。