Skip to main content
Glama

withings-mcp

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

用于 Withings Health API 的 MCP 服务器,支持 OAuth、本地 SQLite 缓存和趋势分析。

与其他 Withings MCP 服务器的不同之处:

  • 本地 SQLite 缓存,支持快速离线查询和历史趋势分析

  • 增量同步——仅获取上次同步以来的新数据

  • 广泛的 Withings 覆盖:17 项身体成分指标,外加睡眠、日常活动、锻炼和 ECG/AFib

  • 自动 OAuth 令牌刷新(访问令牌:3 小时,刷新令牌:1 年)

  • 除 mcp 外零依赖(HTTP 通过标准库实现)

  • Python 3.13+

工具

工具

描述

数据来源

withings_sync

将数据从 Withings API 同步到本地缓存

实时 API -> SQLite

withings_get_body

身体成分(体重、体脂率、肌肉、骨骼、血压、SpO2)

本地缓存(过期时自动同步)

withings_get_sleep

睡眠摘要,或使用 detail=True 获取详细阶段时间序列

缓存(摘要)/ 实时(详细)

withings_get_activity

每日步数、距离、卡路里、活动时间

本地缓存(过期时自动同步)

withings_get_workouts

锻炼会话,包含类型、时长、心率

本地缓存(过期时自动同步)

withings_get_heart

ECG 记录和 AFib 检测

实时 API(始终)

withings_get_devices

已连接设备及电池状态

实时 API(始终)

withings_trends

周期平均值、周/月/季度趋势、对比

本地缓存(过期时自动同步)

基于缓存的查询工具会在数据过期时自动同步,并接受 live=True 以绕过缓存直接从 Withings API 获取。withings_get_heart 和 withings_get_devices 始终为实时获取。withings_get_sleep(detail=True) 返回逐分钟的睡眠阶段(实时,每次请求最多 7 天)。

Related MCP server: Withings MCP Server

前提条件

  • Python 3.13+

  • uv(推荐)或 pip

  • Withings 开发者账户和已注册的应用程序

安装

pip install withings-mcp

或者无需安装,直接使用 uvx withings-mcp 运行。从克隆的仓库进行开发:

git clone https://github.com/partymola/withings-mcp.git
cd withings-mcp
uv venv --python 3.13 .venv
uv pip install -e .

设置

1. 注册 Withings 应用

  1. 前往 https://developer.withings.com/dashboard

  2. 创建一个新应用程序

  3. 将回调 URL 设置为 http://localhost:8585

  4. 记下你的 Client ID 和 Client Secret

2. 认证

.venv/bin/withings-mcp auth

这将在浏览器中打开 Withings 授权页面。批准后,令牌将保存在本地的 config/ 目录中。

3. 注册到 Claude Code

claude mcp add -s user withings -- /path/to/withings-mcp/.venv/bin/withings-mcp

4. 首次同步

在 Claude Code 中说:"Sync my Withings data"

这将运行 withings_sync 来填充本地缓存。后续同步仅获取新数据。

如果任何功能无法正常工作——在预期位置没有数据、同步停止执行——请运行 withings-mcp doctor。它会报告实际使用的路径和凭据以及需要修复的内容,而不会发起 API 调用。

你也可以在命令行中直接同步,无需 MCP 客户端:

.venv/bin/withings-mcp sync                      # all data types, last 30 days
.venv/bin/withings-mcp sync --types body,sleep   # a subset
.venv/bin/withings-mcp sync --days 90            # deeper history on first sync

CLI

withings-mcp              Start the MCP server (stdio transport)
withings-mcp auth         Interactive OAuth setup (opens the browser)
withings-mcp sync         Sync data to the local cache (--types, --days)
withings-mcp doctor       Check the setup and report what needs fixing
withings-mcp --version    Print the installed package version

配置

环境变量

默认值

描述

WITHINGS_MCP_CONFIG_DIR

./config/

凭据和令牌的存储目录

WITHINGS_MCP_DB_PATH

./withings.db

SQLite 数据库路径

示例提示词

  • "Sync my Withings data"

  • "Show my weight for the last 3 months"

  • "How has my sleep changed this year?"

  • "Compare my body composition this month vs last month"

  • "What workouts did I do in March?"

  • "What Withings devices do I have connected?"

  • "Show my sleep trends quarterly"

开发

# Install with dev dependencies
uv pip install -e . && uv pip install pytest

# Run tests (all use in-memory SQLite with fictional data)
.venv/bin/python -m pytest tests/ -v      # .venv\Scripts\python on Windows

安全性

  • 只读:没有工具会修改 Withings 服务器上的数据

  • 本地存储:健康数据保存在你的本地 SQLite 数据库中

  • 令牌存储:OAuth 令牌存储在 config/ 中(已加入 gitignore;在 POSIX 上创建时权限为 0600——Windows 忽略该权限模式,通过 ACL 控制访问)

  • 错误消息:绝不包含健康数据值——仅包含状态码

  • 预提交钩子:可选钩子(scripts/check-no-data.sh)阻止数据库文件和凭据被提交——使用 CONTRIBUTING.md 中的一行命令安装

贡献

有关开发环境搭建、测试工作流和预提交钩子,请参阅 CONTRIBUTING.md。变更记录在 CHANGELOG.md 中。

许可证

GPL-3.0-or-later

Available Tools

8 tools
withings_get_activityA

Get daily activity summaries (steps, distance, calories, active time).

Returns one entry per day from the local cache by default. Run withings_sync first to populate the cache.

Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: 30 days back from the end date or today, whichever is earlier. end_date: End date as "YYYY-MM-DD", "YYYY-MM" (its last day), or "Nd". Default: today. live: If true, fetch from Withings API instead of cache.

Returns daily activity data sorted by date, with steps, distance in km, calories, and active minutes by intensity level. Not for workout sessions -- use withings_get_workouts instead.

Inputs: live, end_date, start_date.

withings_get_bodyA

Get body composition measurements (weight, fat, muscle, etc.).

Returns measurements from the local cache by default. Use live=True to fetch directly from Withings API. Run withings_sync first to populate the cache.

Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d" for relative days. Default: 30 days back from the end date or today, whichever is earlier. end_date: End date as "YYYY-MM-DD", "YYYY-MM" (its last day), or "Nd". Default: today. metrics: Comma-separated metric filter, e.g. "weight_kg,fat_pct". Default: all available metrics. Names match exactly and are case-sensitive; one that is not on this list is refused, naming them. Options: weight_kg, height_m, lean_mass_kg, fat_pct, fat_mass_kg, muscle_mass_kg, hydration_kg, bone_mass_kg, heart_rate, systolic_bp, diastolic_bp, spo2_pct, temperature_c, body_temperature_c, pulse_wave_velocity, visceral_fat_index, basal_metabolic_rate.

live: If true, fetch from Withings API instead of cache.

Returns measurements sorted by date, one entry per measurement group. Not for sleep or activity data -- use withings_get_sleep or withings_get_activity instead.

Inputs: live, metrics, end_date, start_date.

withings_get_devicesA

Get connected Withings devices with battery and firmware info.

Always fetched live from the Withings API.

Returns device type, model name, battery level (high/medium/low), and last session date for each connected device.

Inputs: no named parameters.

withings_get_heartA

Get ECG recordings and atrial fibrillation detection results.

Always fetched live from the Withings API (not cached due to large signal data). Requires a Withings device with ECG capability (ScanWatch, BPM Core).

Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "30d". Default: 30 days back from the end date or today, whichever is earlier. end_date: End date as "YYYY-MM-DD", "YYYY-MM" (its last day), or "Nd". Default: today.

Returns ECG recording list with timestamps, AFib classification (negative/positive/inconclusive), and heart rate. Does not include raw signal waveforms. For resting heart rate trends, use withings_get_body or withings_get_sleep instead.

Inputs: end_date, start_date.

withings_get_sleepA

Get sleep data (summaries or detailed phases).

Summary mode (default): nightly totals with duration, sleep score, HR, respiratory rate, and snoring. From local cache unless live=True.

Detail mode (detail=True): minute-by-minute sleep phases (awake, light, deep, REM) with HR and respiratory rate. Always fetched live. Maximum 7 days per request (Withings API limit).

Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "7d". Default: 7 days (detail) or 30 days (summary) back from the end date or today, whichever is earlier. end_date: End date as "YYYY-MM-DD", "YYYY-MM" (its last day), or "Nd". Default: today. detail: If true, return minute-by-minute sleep phases instead of nightly summaries. Always live, max 7 days. live: If true, fetch summaries from API instead of cache. Ignored when detail=True (always live).

Returns nightly sleep data sorted by date. Not for body composition -- use withings_get_body instead.

Inputs: live, detail, end_date, start_date.

withings_get_workoutsA

Get workout sessions (type, duration, HR, calories).

Returns individual workout sessions from the local cache by default. Run withings_sync first to populate the cache.

Args: start_date: Start date as "YYYY-MM-DD", "YYYY-MM", or "90d". Default: 90 days back from the end date or today, whichever is earlier. end_date: End date as "YYYY-MM-DD", "YYYY-MM" (its last day), or "Nd". Default: today. category: Filter by workout type, case-insensitive partial match. A value matching none of the categories below is refused, naming the ones your cache holds. Options: badminton, baseball, basketball, bmx, bodyboard, boxing, calisthenics, climbing, cycling, dancing, elliptical, fencing, football, golf, handball, hiking, hockey, horse_riding, ice_hockey, ice_skating, indoor_cycling, indoor_running, indoor_walk, kitesurfing, martial_arts, multi_sport, other, pilates, rowing, rugby, run, skating, skiing, snowboarding, soccer, squash, surfing, swimming, table_tennis, tennis, volleyball, walk, waterpolo, weightlifting, windsurfing, wrestling, yoga, zumba.

live: If true, fetch from Withings API instead of cache.

Returns workout sessions sorted by date with type, duration, calories, distance, and heart rate data. Not for daily step/activity totals -- use withings_get_activity.

Inputs: live, category, end_date, start_date.

withings_syncA

Sync Withings health data to the local cache.

Fetches data from the Withings API and stores it in SQLite for fast offline queries. Run this before using other withings_get_* tools.

Syncs incrementally: only fetches data newer than the last sync. First sync fetches the specified number of days of history.

Args: data_types: What to sync. Options: "all", "body", "sleep", "activity", "workouts". Comma-separated for multiple, e.g. "body,sleep". Default: "all". days: Days of history for first sync (default: 30). Ignored on subsequent syncs (uses last sync timestamp).

Returns summary of records synced per data type. Not for querying data - use withings_get_body, withings_get_sleep, withings_get_activity, or withings_get_workouts instead.

Inputs: days, data_types.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 8 tools

    Disambiguation5/5

    Each tool targets a clearly distinct data domain or action: sync, devices, body, sleep, activity, workouts, heart/ECG, and trends. Descriptions explicitly cross-reference each other and clarify boundaries such as activity vs workouts, body vs heart, and trends vs raw data.

    Naming Consistency4/5

    All tools share the withings_ prefix and mostly follow a verb_noun pattern (get_body, get_sleep, get_activity). However, withings_sync and withings_trends deviate from the get_* pattern, which is a minor inconsistency.

    Tool Count5/5

    Eight tools is well-scoped for a health data server, covering each major data type with dedicated query tools plus sync and trends. No tool appears redundant or unnecessary.

    Completeness4/5

    The surface covers the core Withings health domains: devices, sync, body composition, sleep, activity, workouts, ECG, and trend analysis. Minor gaps exist around user profile/goals or device settings, but these are not essential for the apparent read-focused purpose.

    Maintenance

    ActivityActive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables retrieval of health data from Withings smart scales including weight measurements and comprehensive body composition metrics like fat mass, muscle mass, and hydration levels. Supports multiple users, unit preferences, and OAuth authentication for secure access to personal health data.
      2
      ISC
    • A
      license
      A
      quality
      C
      maintenance
      Enables access to Withings Health API data including body measurements, activity tracking, sleep analysis, workouts, and heart rate monitoring through OAuth2 authentication.
      8
      1
      MIT
    • A
      license
      A
      quality
      F
      maintenance
      Enables read-only access to your own Withings health data through a personal developer app, exposing body measurements, blood pressure, daily activity, sleep summaries, and linked devices for natural-language queries.
      8
      MIT