google-health-mcp

google-health-mcp

Read-only MCP server exposing daily health facts, 7/28-day baselines, and deterministic daily pulse from Google Health API data.

Category
访问服务器

README

Google Health Daily Pulse

A self-hosted health service for Google Health API v4. It synchronizes Fitbit, Pixel Watch, and compatible health data, preserves timestamped records locally, calculates reproducible 7-day and 28-day comparisons, and exposes both summaries and full-fidelity data to Hermes Agent through a read-only MCP server.

You can do anything you want with this repo. Codex was used to code it. Use at your own risk. For Mac users, there should not be much of a difference. I will test it on a Mac later and update the repository if there are any issues.

Architecture

Google Health API
  → OAuth 2.0 + encrypted tokens
  → FastAPI / healthctl
  → SQLCipher-encrypted database + encrypted sensitive payloads
  → deterministic baselines
  → local read-only MCP server
  → Hermes (optional)
  → Discord

The health core works without Hermes. If Hermes, the subscription, or a rate limit is unavailable, the service can produce a deterministic English template message.

Quick start

Requirement: Python 3.11 or newer.

python -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -e ".[dev]"
Copy-Item .env.example .env
healthctl seed-demo
healthctl daily-pulse --no-hermes

Alternatively, healthctl setup creates .env interactively without displaying the client secret. OAuth client credentials are stored in data/credentials.enc, not .env.

Existing installations should run this once after upgrading:

healthctl migrate-security

This converts an existing plaintext SQLite database to SQLCipher, moves Google OAuth client credentials out of .env, protects the master key with Windows DPAPI, and restricts local file permissions.

For real data:

  1. Configure Google Cloud.
  2. Run healthctl serve.
  3. In a second terminal, run healthctl authorize.
  4. Run healthctl sync.
  5. Run healthctl daily-pulse --no-hermes.

See docs/windows-setup.md for the complete Windows, Hermes, Codex, Discord, MCP, and scheduler setup.

What needs to stay running?

healthctl serve and the MCP server are separate:

  • healthctl serve starts the local FastAPI service on 127.0.0.1:8765. It is needed for the Google OAuth callback and only if you want to use the REST endpoints.
  • The local MCP server uses stdio. Hermes starts google-health-mcp automatically when it loads the configured google-health MCP connection.
  • You do not need to keep healthctl serve running for MCP access, synchronization through the CLI, or daily-pulse generation.
  • To use health tools from Discord continuously, the Hermes gateway must be running.
  • To refresh the local database, run healthctl sync manually or schedule healthctl run-daily.

REST API

The service binds only to 127.0.0.1:8765 by default.

healthctl serve
Method Path Purpose
GET /healthz Configuration and sync status without secrets
GET /oauth/google/start Start Google OAuth
GET /oauth/google/callback Receive the OAuth callback
DELETE /oauth/google Revoke Google access
POST /v1/sync Synchronize a date range
POST /v1/daily-pulse Generate facts and a message

Examples:

Invoke-RestMethod -Method Post `
  -Uri http://localhost:8765/v1/sync `
  -ContentType application/json `
  -Body '{"start_date":"2026-05-15","end_date":"2026-06-20"}'

Invoke-RestMethod -Method Post `
  -Uri http://localhost:8765/v1/daily-pulse `
  -ContentType application/json `
  -Body '{"use_hermes":true,"send":false}'

Uvicorn access logs are disabled by the CLI server so OAuth codes do not appear in query-string logs.

Data model

The database stores two complementary layers.

Normalized daily values:

  • Sleep duration, sleep period, awake time, awakenings, and efficiency
  • Light, deep, and REM sleep when available
  • Steps
  • Light, moderate, and vigorous activity minutes
  • Exercise count, duration, and types
  • Daily resting heart rate
  • Daily HRV/RMSSD

Full-fidelity records preserve the complete structured Google payload and timestamps for every supported stream under the configured activity, health-metrics, and sleep scopes. This includes:

  • Complete sleep sessions, stage segments, and out-of-bed segments
  • Intraday heart rate, HRV, oxygen saturation, and respiratory measurements
  • Heart-rate zones, activity intervals, sedentary periods, and exercise details
  • Energy, distance, floors, VO2 max, body measurements, and temperature records
  • Daily rollups for total calories and calories in heart-rate zones

The complete SQLite database, including normalized metrics, timestamps, indexes, OAuth states, and tokens, is encrypted with SQLCipher. Sensitive payloads and OAuth tokens retain an additional Fernet encryption layer. Google OAuth client credentials are stored in an encrypted credential file rather than .env.

On Windows, the local master key at data/token.key is wrapped with DPAPI for the current Windows account. The data directory, database, key, credential store, and .env use ACLs restricted to that account and SYSTEM. Secrets must be decrypted in application memory while in use; no application can protect them from malware already running as the same signed-in user.

The default daily sync uses 35 days for compact baseline metrics and two recent days for full-resolution records. This avoids re-downloading hundreds of thousands of one-second heart-rate samples every morning. Detailed records accumulate locally as the scheduled sync advances. Configure HEALTH_DETAILED_SYNC_LOOKBACK_DAYS from 1 to 90 for a larger initial backfill.

CLI

healthctl setup
healthctl migrate-security
healthctl serve
healthctl authorize
healthctl sync
healthctl facts [--date YYYY-MM-DD]
healthctl daily-pulse [--send] [--no-hermes]
healthctl run-daily [--send]
healthctl seed-demo
healthctl doctor

Local MCP server

The project includes a read-only stdio MCP server for Hermes and other local MCP clients:

google-health-mcp --project-dir C:\path\to\Google-Health

It exposes:

  • Calculated daily facts and 7-day/28-day baselines
  • The deterministic English daily pulse
  • Selected normalized history for up to 90 days
  • A catalog of all detailed data types and their local coverage
  • Full-fidelity records for a date range with bounded pagination
  • Exact timestamp-window queries for calendar and workout correlation
  • Authorization, sync, and local data-coverage status

It does not expose OAuth tokens, Google credentials, synchronization, revocation, or database-write operations. Detailed health payloads are intentionally available to the local agent, but each call is date bounded, limited to at most 500 records, and pageable.

Hermes normally starts this executable automatically. You should not run it manually unless you are testing an MCP client.

Hermes skill

The repository includes skills/google-health/SKILL.md. It teaches Hermes how to choose the correct health tool, correlate exact windows with calendar events, handle timezones and personal baselines, and use memory without copying raw health data into it.

Install it into the active Hermes profile:

$SkillsRoot = if (Test-Path "$env:LOCALAPPDATA\hermes\skills") {
  "$env:LOCALAPPDATA\hermes\skills"
} else {
  "$HOME\.hermes\skills"
}
$Target = Join-Path $SkillsRoot "personal\google-health"
New-Item -ItemType Directory -Force $Target | Out-Null
Copy-Item .\skills\google-health\SKILL.md $Target\SKILL.md -Force

Start a new Hermes session after installing or changing the skill.

Security and product boundaries

  • Never put secrets in issues, chat messages, or Git.
  • Only read-only Google Health scopes are requested.
  • The complete health database is encrypted at rest with SQLCipher.
  • OAuth client credentials are encrypted outside .env; tokens are encrypted inside the SQLCipher database with an additional Fernet layer.
  • Hermes Discord access is restricted through DISCORD_ALLOWED_USERS.
  • The FastAPI service binds to localhost by default and provides no public multi-user authentication.
  • Health guidance describes trends; it does not provide diagnoses or treatment.
  • A centrally hosted service requires a different security architecture, privacy review, Google OAuth verification, and recurring restricted-scope security review.

Tests

pytest
ruff check .

Official references

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选