Skip to main content
Glama

English: README.en.md

小米设备数据导出skill(Mi Fitness Data Bridge)

Glama score

把小米运动健康(Mi Fitness)数据保存到自己的电脑,导出为 CSV、JSON 或 SQLite。 适合个人备份、表格整理和自己的分析程序;也提供 Python 接口和本机 stdio MCP 查询工具。实际可获取的数据类型取决于设备、账户地区和上游服务。

非官方、实验性项目。 本项目与小米没有隶属、背书或支持关系;小米、米家(Mi Home)和 Mi Fitness 是小米公司的商标。适配器依赖非公开上游接口,小米的服务、账户地区、设备、固件或认证方式变化后,登录、连接或某些数据类型可能随时失效。仅可用于你有权访问的账户和数据。

▶ 不用登录,先看合成数据导出演示 · 兼容性与上手限制 · English

隐私与 MCP:会把我的数据公开吗?

按项目当前提供的本机使用方式,公开源码或启动 MCP 不会自动把你的账号、凭证或健康数据公开到互联网。 本项目不是托管健康数据的云服务;但“保存在本地”不等于“没有任何泄露风险”。

  • 数据存在哪里? 连接器从小米云端读取你有权访问的数据,将同步结果保存在运行它的电脑上的 SQLite 数据库,导出为本地 JSON / CSV。凭证通过本机 keyring 接口保存,实际保护程度取决于系统及所用密钥环后端。项目没有将这些内容自动上传到 GitHub 或维护者服务器的功能;同步本身仍需与小米云端通信,并非全程离线。

  • MCP 会开放公网端口吗? 当前 serve 使用本机标准输入/输出(stdio),没有提供 HTTP / SSE 网络服务入口。公开仓库、MCP 目录条目和合成演示页都不等于公开了你电脑上的 MCP 服务。不要额外配置公网转发、远程网关或托管凭证代理;这些用法不在本项目的安全模型内。

  • AI 能看到什么? 如果你接入 MCP 客户端,客户端可以调用已提供的工具并接收相应健康数据。客户端可能进一步把结果发送给云端模型或保存在会话记录中;这不等于向所有人公开,但已经超出了“只在本机保存”的范围。请只接入可信客户端,并确认工具调用权限、模型服务的数据处理方式及会话保留设置。仅做备份或导出时,不需要启动 MCP。

  • 隐藏账号信息就够了吗? 不够。即使移除姓名或账号,心率、睡眠、体重等记录仍是敏感数据,导出文件还可能包含明文 user_id。请勿把凭证、数据库、导出文件、原始日志或健康截图提交到仓库、Issue、公开邮件列表或共享目录。.gitignore 只是防误提交措施,不会清除历史记录,也不能阻止你通过其他方式分享文件。

关于登录方式: 当前 CLI 使用交互式 setup 配置已有的 user_id 和 passToken,本项目本身不提供扫码登录或一键授权流程。如果你通过其他工具获取凭证,那一步的数据去向和安全性需单独核实,不能由本项目的本地存储说明作保证。详见凭证前提。

简而言之:源码公开 ≠ 个人数据公开;本地 MCP ≠ AI 全流程离线。 以上说明适用于当前项目实现,不是对设备、第三方客户端或所有部署方式的零风险承诺。安全问题请按 SECURITY.md 私下报告,不要附真实凭证或健康记录。

Related MCP server: miband-mcp

先试结果,再连接账户

  • 只是想看导出效果? 打开上面的静态演示,在浏览器中切换活动、睡眠、运动和身体测量样例,下载合成 CSV / JSON。无需安装、账号或 Token。

  • 想验证本地流程? 按下方安装步骤完成后,运行 python examples/synthetic_demo.py;无需 setup,不连接小米。

  • 想同步自己的数据? 先阅读兼容性和凭证前提。当前没有一键账号授权流程,也不能保证所有设备和地区可用。

演示只使用合成记录,不证明真实云端同步或设备兼容性。静态演示页不接收凭证或健康记录。真实导出可能含明文 user_id;本地 MCP 也不等于整个 AI 工作流离线,请另外确认客户端和模型如何处理数据。

合成睡眠记录导出预览:无需账号,可下载 CSV 和 JSON

截图和本文全部示例均为合成数据;不含凭证、账户标识符或真实健康导出数据。

功能一览

功能

说明

本地缓存

将同步并规范化后的记录保存到你的本机 SQLite 数据库。

可移植导出

导出 JSON 或 CSV 文件,便于备份、交给自己的分析工具或导入大模型;不会导出已保存的 passToken。

本地 MCP 服务

通过标准输入/输出(stdio)提供个人自动化和本地 AI 工作流所需的查询工具。

Python 集成

保留 mi_fitness_mcp 命名空间,兼容既有下游使用者。

默认云端地区为 cn,也可在配置时指定其他地区。实际可用记录取决于账户地区、设备、固件及小米上游服务;某个数据类型同步成功但返回 0 条记录,可能只是指定范围内没有该类型数据。

支持的数据

  • 日常活动:步数、距离、活动卡路里、活动分钟及相关字段。

  • 睡眠:睡眠会话与阶段。

  • 运动记录。

  • 身体测量:体重,以及账户或设备提供的身体成分字段。

  • 心率样本:包括可用时的静息心率。

  • 可用时的 血氧(SpO₂)、压力和异常心跳事件。

日常活动的步数按本地“分钟切片”汇总:当手机、手环或手表对同一分钟上报重叠记录时,会保留较大的单条记录而不是相加,以避免双设备重复计步。该规则是对非公开上游数据的最佳兼容处理,最终数值仍可能与 App 的服务端修正结果不同。

项目边界

这是数据连接器和本地数据基础设施,明确不提供:

  • 医疗诊断、治疗、健康教练或减重建议;

  • 托管账户、共享凭证、公开 Token 代理或多用户云服务;

  • Web 仪表盘、第三方健身 OAuth/Webhook 或餐食照片分析。

下游项目应安装本包或消费本地导出结果,而不是复制连接器源码。

安装

要求:Python 3.11 或更高版本。

git clone https://github.com/shkyyy18/mi_fitness_data_bridge.git
cd mi_fitness_data_bridge
python -m venv .venv

Windows PowerShell:

.\.venv\Scripts\Activate.ps1
pip install -e .

macOS / Linux:

source .venv/bin/activate
pip install -e .

安装开发依赖:

pip install -e '.[dev]'

主命令为 mi-fitness-bridge;旧命令 mi-fitness-mcp 仍保留为兼容别名。

配置与诊断

请使用交互式配置。passToken 提示会隐藏输入,避免它进入 shell 历史:

mi-fitness-bridge setup
mi-fitness-bridge doctor

配置过程会询问 Mi Fitness 的 user_id、passToken 和地区(默认 cn)。凭证会在可用时保存到本机操作系统的密钥环;使用前请了解当前密钥环后端的安全特性。不要在命令行、脚本、Issue、日志或截图中粘贴 passToken。setup 不接受 --user-id 或 --pass-token 命令行参数。

doctor 会检查本地配置、凭证和数据库;配置了凭证时还会检查云端连通性。云端检查可能因网络或上游服务变动失败,但已有本地数据和导出操作仍可离线使用。

sync、export、serve 和 doctor 支持 --db,也支持 MI_FITNESS_DB_PATH 环境变量指定数据库路径,优先级为:命令行参数 > 环境变量 > 配置/默认路径。

同步数据

同步日期范围内所有支持的数据类型:

mi-fitness-bridge sync --start-date 2026-07-01 --end-date 2026-07-15

只同步某一种数据:

mi-fitness-bridge sync --type sleep --start-date 2026-07-01 --end-date 2026-07-15
mi-fitness-bridge sync --type body_measurements --start-date 2026-07-01 --end-date 2026-07-15

--type 可选值:daily_activity、heart_rate、body_measurements、sleep、workouts、spo2、stress、abnormal_heart_beat。CLI 会按数据类型报告新增、更新、部分完成和失败情况。指定明确日期范围的重复同步是幂等的,不会复制已有记录;若小米后来修正了较早日期,请用显式的较早 --start-date 重跑该范围。

睡眠分为空(Issue #14)

睡眠同步现在优先保留原始记录的有效评分;主睡眠缺少评分时,会尝试从本人账户的每日聚合睡眠报告补取。按本地醒来日期、来源及可用的睡眠段起止时间匹配,只给可明确识别的主睡眠补分;不把每日分数复制给小睡或其他设备,不自行估算。

  • sleep_score_source 标明 sleep_record(原始记录)或 daily_report(每日报告);旧缓存的未知来源为 null。每日报告分数不是对每段睡眠分别计算的评分。

  • 仍属非官方、实验性兼容。 本次只经过合成数据和 HTTP mock 验证,不代表已验证某款设备或地区。KNOWN_REGIONS 只是路由候选,不是睡眠分兼容名单。

  • 聚合接口不可用、无评分或匹配有歧义时,会提示但保留基础睡眠记录;没有可用历史评分时仍为 null。评分为 0 的上游默认值仍按不可用处理,不计为零分。相同起止时间与小睡标记的旧记录会保留最后已知评分,因此它不一定是本次同步的新结果。

  • 更新包含此修复的代码后,先重新同步,再导出,并重启已有 MCP 进程。 只重跑 export 不会获取新数据。无需删除数据库,初始化时会自动添加来源列。

mi-fitness-bridge sync --type sleep --start-date 2026-09-13 --end-date 2026-09-21
mi-fitness-bridge export --format json --type sleep --start-date 2026-09-13 --end-date 2026-09-21 --output exports/sleep.json

以上为日期范围示例;跨午夜的睡眠可把范围前后各放宽一天。查询汇总按本地醒来日期,导出仍按原有 start_at 筛选,详见 导出格式。如仍为空,仅反馈设备型号、账户地区、安装版本、App 是否有评分及同步状态;不要上传凭证、真实健康数据、数据库或日志。

导出本地数据

导出一个 JSON 文件:

mi-fitness-bridge export --format json --output exports/mi_fitness.json

导出 CSV(每个数据集一个文件):

mi-fitness-bridge export --format csv --output exports/csv

按数据集和日期筛选:

mi-fitness-bridge export --format json --type sleep \
  --start-date 2026-07-01 --end-date 2026-07-15 \
  --output exports/sleep.json

日期必须使用 YYYY-MM-DD,开始日期不得晚于结束日期。JSON 使用 UTF-8,CSV 使用带 BOM 的 utf-8-sig,便于 Excel 正确打开中文。导出的健康记录属于敏感个人数据,且可能含明文 user_id;默认 .gitignore 会忽略数据库、导出目录和常见日志,但你仍需妥善保存、分享和备份它们。

详见 导出格式说明(英文),其中描述 JSON 信封、CSV 布局及包含边界的日期筛选规则。

MCP 服务

启动本地 stdio MCP 服务:

mi-fitness-bridge serve
# 兼容别名
mi-fitness-mcp serve

可用工具包括:get_connection_status、sync_data、get_sync_status、cancel_sync、query_sync_history、get_profile、query_daily_activity、query_metric_series、get_data_coverage、query_body_measurements、query_sleep、query_workouts、query_workout_series、workout_detail_series、query_heart_rate、query_spo2、query_stress 和 query_abnormal_heart_beat。旧名称 get_daily_summary 和 workout_series 仍可作为兼容调用,但不会出现在工具目录中。

记录列表查询支持 limit/offset 分页,响应中的 data.pagination.next_offset 为下一页位置;翻页时保持筛选条件不变,且不要执行同步。单次运动曲线使用 query_workout_series 的 max_points 控制点数,不使用列表分页。后台 MCP 同步可用 cancel_sync 停止,已写入的记录不会回滚。任务状态保存在本地 SQLite 中,重启后可用 get_sync_status 或 query_sync_history 查询;保留最近 500 个终态 MCP 任务及活动任务,不包含 CLI 同步。重启时未完成任务会标记为 interrupted,不会自动续跑。同一数据库同时只允许一个 MCP 服务进程使用。

服务通过标准输入/输出通信,应由本机 MCP 客户端启动和管理;直接在终端运行时看似“卡住”是因为它正在等待 MCP 消息。它不会在启动时连接小米,只有状态检查或同步操作才按需建立云端连接。不要将它暴露为公网服务或凭证代理。

客户端配置示例:

{
  "mcpServers": {
    "mi-bridge": {
      "command": "mi-fitness-bridge",
      "args": ["serve"]
    }
  }
}

完成 workout_detail 同步后,可通过 workout_detail_series 查询设备提供的秒级心率、步频、配速及速度曲线,并通过 workout_gps 导出 GPS 轨迹。默认全量同步会回填缓存中缺少明细的运动,force_full_sync 可重新抓取已覆盖的运动。非官方 FDS 协议仍受设备及固件版本限制,详见 运动明细可行性说明。

作为 Python 依赖使用

兼容包名保持为 mi_fitness_mcp:

from mi_fitness_mcp.adapters.mi_fitness_cloud import MiFitnessCloudAdapter

不要硬编码真实凭证,也不要将它们提交到源代码管理。下游项目应安装本包,而不要供应或复制其源码。

合成端到端演示

仓库包含完全不访问网络或真实账户的演示:

python examples/synthetic_demo.py

它会创建临时 SQLite 数据库、写入合成记录,并运行真实的 JSON/CSV 导出流程。可用于验证本地导出路径,或准备不泄露隐私的 Bug 报告。

开发

pip install -e '.[dev]'
python -m pytest -q -p no:cacheprovider
python -m ruff check src tests

Issue、测试、文档和截图中只可使用合成数据。安全问题请遵循 SECURITY.md;发布步骤请见 docs/release-checklist.md。

隐私、来源与许可

  • 将 passToken、SQLite 数据库、导出文件和日志保密。

  • 不要提交真实健康数据,或包含个人指标的截图。

  • query_* MCP 工具返回的健康数据会流入你使用的 MCP 客户端;仅限本机 stdio 客户端使用,切勿接入远程或托管代理。

  • 本软件仅用于个人数据访问和工程研究,不用于诊断或治疗。

  • 上游来源和 MIT 归属见 THIRD_PARTY_NOTICES.md。

当前版本采用 AGPL-3.0-only 许可证;2026-08-03 之前发布的版本为 MIT。详见 LICENSE。

帮助项目成长

如果这个工具对你有用,欢迎点一个 Star,帮助有相同需求的人发现它。更有价值的是安全反馈兼容性、改进安装文档或提供合成复现。请勿上传凭证或真实健康数据。

Available Tools

17 tools
cancel_syncA
Idempotent

Cancel a queued/running background MCP sync by its exact sync_id. Returns the terminal job status after cancellation completes; already-finished jobs are returned unchanged. Stops future requests without deleting or rolling back records already committed to SQLite; counts may be incomplete. Unknown IDs or foreground jobs return status=error. No new cloud request. Use get_sync_status to inspect progress and sync_data with user consent to resume via a new job.

Inputs: sync_id (required).

get_connection_statusA

Check whether the configured Mi Fitness account can connect before requesting a sync. May contact Xiaomi, authenticate and rotate credentials in the local keyring; does not sync health records. Requires local interactive CLI setup, never credentials in tool arguments. Returns connected, mode, last_sync_at and available_data_types; configured responses also include connection_state, region, last_connection_error and sync_in_progress. While syncing, reports existing connection state instead of probing. For cached date coverage use get_data_coverage.

Inputs: no named parameters.

get_data_coverageA
Read-onlyIdempotent

Inspect which date ranges already exist in the local cache before choosing query dates or requesting sync_data. Returns data.coverage [{data_type, first_date, last_date, days_with_data}] for nonempty datasets; omitted/empty data_types means all datasets. Empty datasets are omitted, and first/last dates do not guarantee uninterrupted coverage between them. This does not test cloud connectivity or report a background job; use get_connection_status or get_sync_status respectively. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use sync_data to refresh with user consent.

Inputs: data_types.

get_profileA
Read-onlyIdempotent

Read minimal metadata for the already-connected local account, not a medical or demographic profile. No cloud request or cache write; returns JSON text with status, source and data.profile containing account_id_masked, configured timezone and devices (currently an empty placeholder). Never returns credentials or plaintext account IDs. Returns status=error if disconnected; get_connection_status can establish/check the connection first. Use query_daily_activity for activity totals.

Inputs: no named parameters.

get_sync_statusA
Read-onlyIdempotent

Read one MCP sync job by sync_id, including after a server restart. Returns sync_id, status, timestamps and available result counts. States are queued, running, ok, partial, error, cancelled or interrupted (previous process stopped). Read-only local lookup; no cloud request. History retains the latest 500 completed jobs per account; unknown/expired IDs return status=error. Use query_sync_history to discover IDs, cancel_sync to stop a live background job, or get_connection_status for cloud connectivity. Restarted lookups omit raw error text for privacy.

Inputs: sync_id (required).

query_abnormal_heart_beatA
Read-onlyIdempotent

Read device-reported abnormal-heartbeat events starting within an inclusive YYYY-MM-DD range. Returns data.events [{event_id, start_at, end_at, duration_seconds}] and data.count, earliest first. limit defaults to 5000; use offset for subsequent pages. Events are upstream flags, not a diagnosis; an empty list is not evidence of a healthy heart. Use query_heart_rate for ordinary bpm samples, not this event list. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), limit, offset.

query_body_measurementsA
Read-onlyIdempotent

Read timestamped body measurements over an inclusive YYYY-MM-DD range. Returns data.measurements and data.count in timestamp order; latest_only=true returns only the last matching record, not the latest value of each field. Omitted/empty metrics returns all available fields; otherwise timestamp plus selected fields, with absent optional measurements omitted. Units are kg for mass, percent for body fat/water, dimensionless for BMI. Use query_metric_series(metric=weight_kg) for a daily or aggregated weight trend. latest_only selects before pagination. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), limit, offset, +2 more.

query_daily_activityA
Read-onlyIdempotent

Choose this for a multi-column daily activity table, not a single-metric trend. Read daily activity totals: steps, distance_m, active_kcal, total_kcal, floors and active_minutes, plus data_quality. Supply date for one day or both start_date/end_date for an inclusive YYYY-MM-DD range; date takes precedence if both forms are given. Returns data.summaries and data.data_quality. Missing optional upstream metrics may appear as zero with quality warnings; do not treat them as confirmed measurements. For one metric across days/weeks/months use query_metric_series; sleep and workouts have separate tools. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: date, limit, offset, end_date, +1 more.

query_heart_rateA
Read-onlyIdempotent

Read timestamped heart-rate samples in bpm over an inclusive YYYY-MM-DD range, optionally filtering sample_type. Returns data.samples [{timestamp, bpm, sample_type}] and data.count, earliest first. limit defaults to 5000; use a smaller page/date window for large datasets. The cloud adapter normally stores resting/active/passive, so sample_type=workout may be empty; use query_workout_series with a workout_id to analyze all samples in that activity window. Not a diagnosis. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), limit, offset, +1 more.

query_metric_seriesA
Read-onlyIdempotent

Build a dated trend for steps (count), distance_m (meters), active_kcal (kcal), or weight_kg (kg) over an inclusive YYYY-MM-DD range. Returns data.metric and data.series [{date, value}], sorted ascending, without filling missing dates. Activity uses daily totals; weight uses the latest stored measurement per day. granularity=day returns these daily values; week groups from Monday, month from the first day. aggregation (default sum) applies only to week/month daily values; latest selects the last available day. Prefer avg or latest for weight. For raw body readings use query_body_measurements; heart-rate samples use query_heart_rate; one workout uses query_workout_series. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: metric (required), end_date (required), start_date (required), limit, +3 more.

query_sleepA
Read-onlyIdempotent

Read sleep sessions (start-date filtered) and a main-sleep summary (local wake-date filtered) over an inclusive YYYY-MM-DD range. Returns data.sessions, count, main_sessions, metrics and data_quality; main sleep is the longest valid non-nap per wake date. include_naps defaults true and affects the raw list only, not main-sleep selection. Times include start_at/end_at; durations are minutes; sleep_score/source can be null and missing scores are not zero. Expand dates around midnight if needed; raw counts can differ from wake-date summary counts. Use this instead of query_daily_activity for sleep. Pagination affects sessions/count only; main_sessions, metrics and quality still describe the full date range, so keep ranges narrow. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), limit, offset, +1 more.

query_spo2A
Read-onlyIdempotent

Read stored blood oxygen saturation samples (spo2_pct, percent) over an inclusive YYYY-MM-DD range. Returns data.samples [{timestamp, spo2_pct}] and data.count, earliest first. limit defaults to 5000; use offset for subsequent pages. These are device measurements, not a diagnosis; missing records do not indicate normal oxygen levels. Use query_heart_rate for bpm rather than oxygen saturation. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), limit, offset.

query_stressA
Read-onlyIdempotent

Read device stress samples over an inclusive YYYY-MM-DD range, optionally filtered by level (low/medium/high). Returns data.samples [{timestamp, stress_score, level}] and data.count, earliest first. stress_score is the upstream device score, not a clinical assessment. limit defaults to 5000; use offset for subsequent pages. Use query_sleep for sleep quality rather than inferring it from stress. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), level, limit, +1 more.

query_sync_historyA
Read-onlyIdempotent

List this account's MCP sync jobs, newest first, from persistent local SQLite. Returns data.jobs and data.pagination with timestamps, statuses, available counts and safe error codes, never credentials, raw errors or health records. Includes foreground/background jobs started since this feature was installed, not CLI syncs; retains the latest 500 completed jobs plus active jobs. Read-only, no cloud calls. Use get_sync_status for one ID and cancel_sync for a live background job. Empty jobs means no retained history. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: limit, offset.

query_workoutsA
Read-onlyIdempotent

List recorded workouts starting within an inclusive YYYY-MM-DD range. Returns data.workouts, count and data_quality; rows include workout_id, activity_type, start_at/end_at, duration_minutes, distance_m, calories_kcal and available heart-rate/pace fields (missing fields may be null). activity_types matches case-insensitively; min_duration is minutes and min_distance_km is kilometers (unlike output distance_m). Filters combine with AND before pagination. Use a returned workout_id with query_workout_series for a heart-rate curve; this tool returns session summaries, not samples. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent. Returns data.pagination {limit, offset, has_more, next_offset}; next_offset is null at the end. Keep filters unchanged and avoid syncing between pages.

Inputs: end_date (required), start_date (required), limit, offset, +3 more.

query_workout_seriesA
Read-onlyIdempotent

Read an auto-downsampled heart-rate curve for one workout_id obtained from query_workouts (contract agent-safe-series/v1). Uses all cached heart-rate sample types inside the workout window. Returns data with numeric t offsets in seconds from start_time, bpm values, downsampled/source_points/returned_points/method and full-resolution summary statistics. resolution defaults to 60 seconds and increases to respect max_points (default 400, hard cap 500). Pass the same reference_max_hr in bpm for comparable time_in_zone across activities; otherwise each workout uses its own maximum, so zones are not comparable. Unknown workout IDs or unsupported metrics return status=error. For raw date-range samples use query_heart_rate. Read-only local SQLite query; no cloud request or automatic sync. Requires a configured local account/cache. Returns JSON text with status, source=cache, generated_at and data; empty lists mean no cached matches, not zero measurements. Use get_data_coverage to inspect availability or sync_data to refresh with user consent.

Inputs: workout_id (required), metric, max_points, resolution, +1 more.

sync_dataA

Download selected Mi Fitness datasets from Xiaomi into local SQLite; writes records and sync watermarks, may authenticate/rotate local credentials, and does not modify cloud health records. Requires local CLI setup and user authorization to access the account. Omitted data_types selects all adapter-supported types; an empty list is invalid. Dates are inclusive YYYY-MM-DD; start_date must not exceed end_date. Omitted end_date uses today; omitted start_date resumes the watermark or uses configured lookback (default 30 days). force_full_sync ignores the watermark, not the requested date range, and does not erase the database. Only one sync runs at a time. background=false waits for status ok/partial/error, sync_id, record counts and per-type results; background=true returns accepted plus sync_id to poll with get_sync_status. Partial results may already be stored; inspect results before retrying. Use cached query tools instead when no refresh is needed.

Inputs: end_date, background, data_types, start_date, +1 more.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.6/5.0

    Scored across 17 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: query_* tools target specific health data types or aggregation levels, while sync lifecycle tools (connection, sync, status, cancel, history, coverage) are well separated. Descriptions explicitly cross-reference related tools to resolve potential overlaps (e.g., metric series vs daily activity vs raw body measurements).

    Naming Consistency5/5

    All names use consistent snake_case with predictable verb prefixes: get_ for system/status reads, query_ for cached data reads, and sync/cancel for actions. Minor singular/plural variation (query_workouts vs query_workout_series) is semantically meaningful and not confusing.

    Tool Count4/5

    17 tools is slightly above the typical 3–15 range but justified by the breadth of distinct health metrics and sync management operations. No tool appears redundant; each query tool maps to a unique data type or purpose.

    Completeness4/5

    The surface covers connection, sync lifecycle, cache coverage, profile, and queries for all major Mi Fitness data types (activity, body, heart rate, sleep, workouts, SpO2, stress, abnormal beats). Minor gaps like sleep stages or workout GPS details may exist, but agents can work around them.

    Maintenance

    ActivityActive
    ResponsivenessUsually handled

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      C
      quality
      C
      maintenance
      Enables reading and syncing Xiaomi Mi Fitness health data (steps, heart rate, sleep, workouts) from the Chinese cloud region to a local SQLite database via MCP tools.
      10
      21
      MIT
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI to query Xiaomi Mi Band health data (steps, sleep, heart rate) from Gadgetbridge SQLite exports via the MCP protocol, allowing natural language questions about daily activity.
      1
      -
    • A
      license
      Not graded
      quality
      B
      maintenance
      Lets AI assistants read your own Mi Fitness (Xiaomi cloud) health data — steps, heart rate, sleep, SpO2, stress, weight and workouts — through local MCP tools with QR-code login. Runs locally over stdio, returns results as JSON, and withholds GPS tracks unless explicitly allowed.
      629 PyPI
      9
      MIT
    • A
      license
      C
      quality
      B
      maintenance
      Enables AI clients to query and analyze your own Xiaomi/Mi Fitness health data — daily activity, minute-level heart rate, sleep stages, workouts, body composition, SpO₂, stress, and abnormal heart beat events — after syncing it from the Xiaomi cloud into a local SQLite database. Exposes 14 tools covering connection status, incremental sync control, and metric/date-range queries, with everything stored and served locally.
      14
      MIT