Google Health Mcp

io.github.partymola由 GitHub 账号 partymola 发布v1.12.0更新于 Nov 7, 2026

MCP server for the Google Health API, with a local SQLite cache and trend analysis.

概览

AI 生成的概览

本地 MCP 服务器,让助手从本地 SQLite 缓存查询你的 Google Health 数据,如心率、睡眠、活动、体重和锻炼。

可以做什么
  • 读取每日健康指标:心率、HRV、血氧、呼吸频率、体重、体脂、身高、体温、VO2 max 和活跃区间分钟
  • 读取活动与锻炼:步数、卡路里、距离、楼层、锻炼记录、分段和 GPS 路线
  • 读取睡眠阶段、饮食与饮水记录、心电图读数和不规则心律提醒
  • 读取已配对设备、个人资料设置以及缓存历史内的累计统计
  • 按周、月或季度汇总趋势,并比较两个时间段
  • 按需同步缓存或回填指定日期区间,并导入已有的 JSON 导出文件
适用场景
适合让助手回答关于你自己 Google Health 历史的问题、发现趋势或比较时间段,而无需手动导出数据。也适合希望健康数据留在本机、并需要快速且可离线查询的用户。
运行要求
需要 Python 3.13+ 和 google-health-mcp 包(pip 或 uvx)。需要一个有健康数据的 Google 账号,以及你自己启用 Google Health API 的 Google Cloud 项目、Desktop 类型的 OAuth 客户端 JSON 和已授予的只读权限范围。OAuth 回调需要本机 8081 端口空闲,授权主机需能打开浏览器。可选环境变量可设置配置目录、SQLite 路径和离线模式。
安装前请注意
你需要自行创建并授权 OAuth 客户端;令牌保存在磁盘上,在 Windows 上该令牌文件并不限于你的账号访问。应用未发布时刷新令牌七天后过期,同步会悄然停止。同步只新增和修正、从不删除,因此在 Google 中删除的记录仍留在缓存里。GPS 路线和心电波形会缓存到磁盘,仅在明确请求时才传给模型。doctor 输出会显示本地文件路径。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Google Health Mcp,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

google-health-mcp

[CI] [License: GPL v3] [Python 3.13+] [PyPI] [Glama MCP Server]

MCP server for the Google Health API, with a local SQLite cache and trend analysis.

Designed for Claude Code and other MCP clients. Your data syncs to a database on your own machine, so queries are fast, work offline, and cost no API quota.

Features

  • Local SQLite cache - sync once, query instantly
  • Incremental sync - each run fetches only what is new, resuming from where the last one stopped
  • Offline mode - serve the cache with no credentials and no network at all
  • Trends - weekly, monthly or quarterly aggregates, and two-period comparisons
  • ECG - readings stored whole, waveform included, returned only when asked for
  • doctor - diagnoses a setup offline and read-only, without spending quota

Data types

ToolData
health_get_heart_rateResting heart rate
health_get_activitySteps, calories, distance, floors
health_get_exercisesWorkouts: name, duration, heart rate, calories, Google's metrics summary, and splits on request
health_get_exercise_routeOne workout's GPS route, as the TCX file Google exports
health_get_sleepDuration, stages, sleep period
health_get_sleep_sessionsEach session as Google recorded it: metadata, summary, and every stage segment on request
health_get_weightWeight, body fat %, one row a day
health_get_weight_readingsEvery weigh-in and body-fat reading, as Google recorded each one
health_get_heightHeight readings
health_get_spo2Nightly blood oxygen saturation
health_get_hrvHeart rate variability (RMSSD)
health_get_azmActive zone minutes, with the per-zone breakdown
health_get_breathing_rateNightly breaths per minute
health_get_skin_temperatureNightly variation from your baseline, and the absolutes behind it
health_get_core_temperatureBody temperature readings you logged by hand
health_get_cardio_fitnessVO2 max, where the device reports it
health_get_food_logFood calories and water, where logged
health_get_ecgElectrocardiograms: classification, average rate, duration, waveform on request
health_get_irregular_rhythmIrregular-rhythm notifications and the windows that triggered them
health_get_devicesPaired devices, battery level, last sync
health_get_profileYour profile, settings and irregular-rhythm enrolment, as Google returns them
health_get_lifetime_statsTotals and best days over the cached history, with its coverage
health_trendsAggregated averages and period comparisons

Requirements

  • Python 3.13+ (tested on 3.13, 3.14 and 3.15, on Linux, macOS and Windows, in CI)
  • A Google account with health data, and a Google Cloud project to authorise against. No billing account is needed - the console offers a free trial throughout setup and you can decline all of it.

Setup

1. Install

bash
pip install google-health-mcp

Or run it without installing, in which case every google-health-mcp ... command you run below becomes uvx google-health-mcp ...:

bash
uvx google-health-mcp --version

2. Create the Google Cloud project

Every user registers their own OAuth client. This is seven console steps, and the page names are Google's as of August 2026.

Google's own setup page will send you somewhere else - follow the steps below instead. Its quick-start builds a Web client with https://www.google.com as the redirect URI, which suits the OAuth Playground rather than a program running on your machine; this server refuses that file and says so. Use that page only to check whether one of the pages below has been renamed.

  1. Project. Create a project at console.cloud.google.com/projectcreate and select it.
  2. API. Enable Google Health API on the API Enablement page.
  3. Get started. Open Google Auth Platform and complete Get started - app name, support email, External audience, contact email. A new project has no Audience, Data Access or Clients page until this is done.
  4. Audience. Under Test users, add your own Google account. Skipping this fails sign-in with 403: access_denied.
  5. Data Access. Click Add or remove scopes, search for "Google Health API", and tick the read-only scopes listed under OAuth scopes below.
  6. Clients. Create an OAuth client of type Desktop app and download its JSON. A Desktop client permits the loopback redirect automatically, so there is nothing to register; a Web client does not, and fails at consent instead.
  7. Publish. Back on the Audience page, click Publish app.

Step 7 is the one that bites, and it is worth checking rather than assuming. While an app's publishing status is Testing, Google issues refresh tokens that expire seven days after consent - so everything works, and then syncing stops a week later with nothing pointing back to this moment. The Audience page can read "In production" while the token server disagrees. Two readings that do not: the verification-status line on the Branding page, and google-health-mcp doctor, which fails loudly when the stored token records a short expiry.

3. Authorise

Put the downloaded client JSON where the server looks for it, unedited:

bash
mkdir -p ~/.config/google-health-mcpcp ~/Downloads/client_secret_*.json ~/.config/google-health-mcp/google_client.jsongoogle-health-mcp auth

Your browser will warn that Google hasn't verified this app. That is expected, and the app is your own: these health scopes are classified restricted, and verification only matters above 100 users. Click Advanced, then Go to google-health-mcp (unsafe), and grant the scopes.

If you have more than one Google account, pick the one your health data is in. auth checks the account once the tokens are saved, and if Google reports it is not linked to Google Health, it says so and exits 1; run it again and choose the other account.

The flow listens on localhost:8081 for the callback, so that port must be free. It saves tokens to ~/.config/google-health-mcp/google_tokens.json, created 0600 on POSIX. Windows keeps only the owner-write bit, as its read-only attribute, and governs access by ACLs - so there the file is not restricted to your account, and what it grants is whatever its directory's ACLs pass down. Access tokens last an hour and refresh automatically. Refresh tokens do not rotate, so a token minted on a machine with a browser can be copied to a headless one.

If you authorised before publishing the app, re-run google-health-mcp auth afterwards: publishing does not extend a token already granted, and that one still expires after seven days.

4. Register with your MCP client

bash
claude mcp add -s user google-health -- google-health-mcp

Running it with uvx instead: claude mcp add -s user google-health -- uvx google-health-mcp.

5. Check it

bash
google-health-mcp doctor

Worth running before step 3 (Authorise) as well as after: it reports whether port 8081 can be bound and whether this host can open a browser, which are the two ways auth fails before it starts.

Offline and read-only: it reports which paths resolved where, whether the credential files are the right shape, whether the token is short-lived, whether the grant holds every permission this version reads, and whether the cache is being kept up to date.

doctor --json reports the same findings for a monitor to act on:

json
{  "version": "1.12.0",  "findings": [    {      "check": "stopped-series",      "name": "hrv series",      "severity": "warn",      "detail": "No hrv since 2026-03-30, after rows on 28 of the 30 days before that.",      "fix": "Re-sync that type alone (...)"    }  ],  "counts": {"ok": 7, "warn": 1, "fail": 0}}

The payload goes to stdout; logging goes to stderr, so a subprocess consumer should read the two separately.

Match on check, never on name or detail: the first is a stable identifier, the other two are prose and carry the data type. check is null for findings nothing consumes programmatically yet.

The exit code is 1 only when something is graded fail, in both formats - a warning never changes it, which is the reason this flag exists: a stopped data series is a warning, so the exit code alone cannot tell you about the one failure most worth watching for.

Check version before trusting an absent finding. A build older than a check does not report it, so "no series-never-filled finding" and "this build cannot report one" look identical without it. A release before 1.1.0 rejects --json and exits 2. version is itself null when the package is run from a source tree with no installed distribution metadata - the payload is still emitted, since a diagnostic that dies on a half-configured install is worthless exactly when it is needed.

The payload names the resolved config, database and credential paths, the same way the text report does. That is deliberate - it is what makes a wrong-path setup diagnosable - but a consumer that forwards the payload off the machine is disclosing them. No credential values appear in either format.

6. First sync (optional)

Query tools sync on first use each day, so you can skip this. To pre-populate the cache, or to pull history older than it:

bash
google-health-mcp sync --days 30google-health-mcp sync --since 2023-10-01     # backfill

CLI usage

google-health-mcp                Start the MCP server (stdio transport)google-health-mcp -V, --version  Print the installed package versiongoogle-health-mcp auth           Interactive OAuth setupgoogle-health-mcp doctor         Check the setup and report what needs fixing  --json                Emit the findings as JSON, for a monitor rather than                        a person. Each finding carries a stable `check` name                        to match on; the exit code is the same either way.google-health-mcp sync           Sync data to the local cache  --days N              Days of history for a first sync (default: 30)  --types TYPE,...      Data types to sync (default: all). One or more of:                        heart_rate, activity, exercises, sleep, weight, spo2,                        hrv, azm, breathing_rate, skin_temperature,                        core_temperature, cardio_fitness, food_log, ecg, irn,                        account, height, exercise_routes, sleep_sessions,                        weight_readings, body_fat_readings  --since YYYY-MM-DD    Fetch from this date, ignoring the incremental cursor  --until YYYY-MM-DD    Inclusive end date for a --since window; together they                        re-fetch exactly that window, to repair a gap in the                        middle of the cachegoogle-health-mcp import         Import exported JSON data files  --data-dir PATH       Directory containing the JSON files

MCP tool reference

Query tools sync on the first query of each day per data type, then read the cache.

All query tools except health_get_devices, health_get_lifetime_stats, health_get_profile and health_get_exercise_route accept:

  • start_date - YYYY-MM-DD, YYYY-MM, or 30d (relative). Default: 30 days back from the end date or today, whichever is earlier, except health_get_height, which goes back ten years.
  • end_date - YYYY-MM-DD, YYYY-MM (its last day), or 30d. Default: today.
  • live - if true, re-fetch this window from the API before reading the cache. A failed refresh is reported rather than silently answered from the cache.

A start after the end, or a date of the right shape that does not exist, such as 2026-13, is refused with a message rather than answered as a period with no data.

health_get_profile takes only live.

health_get_exercises also takes exercise_type, a case-insensitive substring match on the workout name. Google names the workouts, so a value matching no workout name in your cache is refused with the cached names listed and the live=True hint, rather than answered as a period you did not train in. It also takes include_detail: without it each workout carries how many exercise events, splits and split summaries it has, rather than every one. health_get_ecg also takes include_waveform: a trace is thousands of voltages, so the default response carries the classification, average rate, duration and a sample count instead. health_get_sleep_sessions also takes include_stages, for the same reason: without it each session carries how many stage segments, short awakenings and out-of-bed segments it has, rather than every one.

health_get_exercise_route takes a workout's log_id. The route text comes back only with include_tcx, since it can run to hundreds of kilobytes. Only workouts recorded with GPS have a route, and a sync fetches routes for the workouts in its own window, so an older one needs health_sync with data_types="exercise_routes" and since. A route holds every position you recorded, start and end included: it is cached on disk like the rest, and reaches the model only when include_tcx is set.

If your authorisation lacks a permission this version reads, every successful tool response carries an authorisation note naming it, doctor reports it under the check missing-scopes, and sync prints it. The data types read under it are skipped rather than failed, so sync still exits 0. A grant does not gain permissions on refresh, so this is what an upgrade that adds one looks like until you run google-health-mcp auth again. doctor on the syncing host sees the new grant straight away; the tool note, and doctor on a cache-only host, catch up once the next sync has run. Run google-health-mcp sync after authorising to fetch the newly granted data at once; a query tool otherwise waits for the next day, since a skipped type counts as synced for that day.

health_sync

  • data_types - all, or a comma-separated subset of the names listed under CLI usage above (irn is the irregular-rhythm notifications, and account is the profile, settings and irregular-rhythm enrolment). Default: all.
  • days - days of history for a first sync (default: 30). Later syncs are incremental.
  • since / until - fetch an exact window regardless of what is cached.

A sync adds and corrects, and never removes. An entry deleted in the app it was logged in simply stops appearing in the API, with nothing to say it was deleted, so a re-sync of that window leaves the cached row as it was. The API offers no tombstone, no change feed and no modified-since filter, so there is nothing to detect it by. In practice this reaches only the types you fill in by hand, since a device series is not deleted after the fact. Re-creating the cache is the way to clear one.

health_trends

  • data_type - any cached type with a daily series; ECG readings and rhythm alerts are episodes, and sleep sessions and individual readings are records, so they have no trend. Default: activity.
  • period - weekly, monthly, quarterly. Default: monthly.
  • start_date / end_date - default: 365 days back from the end date or today, whichever is earlier.
  • compare - two periods, e.g. last_30d vs previous_30d, 2026-03 vs 2026-02, 2026-Q1 vs 2025-Q4. When set, period, start_date and end_date are ignored. A period that names no dates, such as 2026-13 or last_0d, is refused.

OAuth scopes

Tick these read-only scopes on the Data Access page. All are under https://www.googleapis.com/auth/googlehealth.:

ScopeData accessed
activity_and_fitness.readonlySteps, distance, floors, calories, workouts, active zone minutes
health_metrics_and_measurements.readonlyHeart rate, HRV, SpO2, breathing rate, weight, body fat, height, temperature, VO2 max
sleep.readonlySleep sessions and stages
nutrition.readonlyFood and water logs
ecg.readonlyElectrocardiograms
irn.readonlyIrregular-rhythm notifications and enrolment
settings.readonlyPaired devices, units and time zone
profile.readonlyAge, membership start, stride lengths
location.readonlyGPS routes of workouts

The console also offers reproductive_health.readonly, logged_symptoms.readonly and mindfulness.readonly, which this package does not request. As of September 2026 the cycle, ovulation-test, symptom and mood data types can be written but not read, and the API has no mindfulness data type, so there is nothing to read under them.

Read the list off the console, not off the published scope page - read-only scopes exist that appear in neither Google's documentation nor the API's own discovery document, and the discovery document omits nutrition.readonly outright. To request fewer, tick fewer on the Data Access page and remove them from GOOGLE_SCOPE_READERS in config.py before authorising, which needs a source checkout rather than a pip or uvx install; the data types under a scope you leave out are skipped by every sync. A grant does not gain scopes on refresh, so widening the list later means running auth again.

Configuration

VariableDefaultDescription
GOOGLE_HEALTH_MCP_CONFIG_DIR~/.config/google-health-mcp/Directory holding the OAuth client and tokens
GOOGLE_HEALTH_MCP_DB_PATH~/.local/share/google-health-mcp/google_health.dbSQLite cache
GOOGLE_HEALTH_MCP_OFFLINEunsetIf truthy (1, true, yes, on), run as a cache-only reader

Offline / cache-only mode

By default the server syncs on demand, so no cron job is needed. Set GOOGLE_HEALTH_MCP_OFFLINE=1 to run as a pure reader instead:

  • No credentials are required - the server never opens the token file.
  • No network call is made. Auto-sync is off, and live=True, health_get_devices and health_sync return a clear "offline mode" message rather than reaching the API.
  • Query tools serve the cache, tagged "offline_mode": true.

Typical uses:

  • Several machines, one cache - one host runs google-health-mcp sync from cron or systemd against a shared database; the others set GOOGLE_HEALTH_MCP_OFFLINE=1, point GOOGLE_HEALTH_MCP_DB_PATH at the same file, and only read.
  • CI and privacy - run queries with no network access and no credentials.

Rate limits

Google applies a per-user request quota, documented at developers.google.com/health/rate-limits. Ordinary syncing is nowhere near it: a day's update is a handful of requests, and a measured three-year backfill of every data type was around 250. If a sync is cut short, that data type is recorded as a partial sync and the next run resumes from its cursor rather than starting over.

Querying from the cache - the default - costs no quota at all.

Data safety

Your health data stays on your machine: this server has no backend, sends nothing anywhere, and talks only to Google's API with your own credentials.

The repository ships a pre-commit hook that refuses to commit database files, anything under config/, and large files; CONTRIBUTING.md says how to install it.

Importing existing data

If you already have health data as JSON files, from an export or a script of your own:

bash
google-health-mcp import --data-dir /path/to/json/files/

Expected file names: heart_rate.json, activity.json, exercises.json, sleep.json, weight.json, spo2.json, hrv.json. See src/google_health_mcp/importer.py for the shape each one expects. Import covers those seven types; everything else arrives by sync.

Contributing

See CONTRIBUTING.md for development setup, the test workflow, and the pre-commit hook. Changes are tracked in CHANGELOG.md.

License

GPL-3.0-or-later

来源:README.md,提交 f2fc729

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

9
  1. v1.12.0最新Nov 7, 2026
  2. v1.11.1Nov 6, 2026
  3. v1.11.0Nov 5, 2026
  4. v1.10.0Nov 3, 2026
  5. v1.9.0Oct 20, 2026
  6. v1.8.0Oct 4, 2026
  7. v1.7.0Sep 29, 2026
  8. v1.6.0Sep 27, 2026
  9. v1.5.0Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分