Skip to main content
Glama

英語版: README.en.md

米橋(Mi Fitness Data Bridge)

Glama score

ローカル優先のデータブリッジ。あなた自身の Xiaomi 運動健康データを SQLite、JSON、CSV、Python、および MCP 互換ツールにエクスポートします。

Xiaomi 運動健康アプリは歩数・睡眠・心拍数を喜んで表示してくれますが、それらのデータを持ち出すことは決して許可してくれません。このブリッジは、あなた自身のデータをあなた自身のハードディスク上の SQLite ファイルに格納します。

商標に関する声明:Xiaomi、米家、Mi Fitness はすべて Xiaomi 社の商標です。本プロジェクトは非公式のコミュニティプロジェクトであり、Xiaomi 社との提携・推奨関係は一切ありません。

実験的なクラウドアダプターは、Xiaomi がプライベート API を変更した場合にいつでも動作しなくなる可能性があります。アクセス権限のあるアカウントとデータでのみ使用してください。

実測検証

2026-07-20 に Windows(Python 3.14)上で main ブランチのコミットに基づいて録画されました。すべてのデータは合成データであり、認証情報やネットワークアクセスは一切含まれません。(テスト数は 2026-08-17 に再確認・更新済み。)

テストスイート:

$ python -m pytest -q -p no:cacheprovider
........................................................................ [ 96%]
...                                                                      [100%]
75 passed in 10.27s

エンドツーエンド合成デモ(examples/synthetic_demo.py はまず合成レコードでローカル SQLite キャッシュを埋め、その後実際の JSON/CSV エクスポートパイプラインを実行します):

$ python examples/synthetic_demo.py
Seeded synthetic database: C:\Users\<you>\AppData\Local\Temp\mi-fitness-demo-53el7cfh\mi_fitness.db
  daily_activity: 2026-07-15 .. 2026-07-15 (1 day(s))
  sleep: 2026-07-14 .. 2026-07-14 (1 day(s))
  workouts: 2026-07-15 .. 2026-07-15 (1 day(s))
  body_measurements: 2026-07-15 .. 2026-07-15 (1 day(s))

Export completed
  mi_fitness.json
  daily_activity.csv
  sleep.csv
  workouts.csv
  body_measurements.csv
  heart_rate.csv
  spo2.csv
  stress.csv
  abnormal_heart_beat.csv

JSON envelope:
  schema_version: 1.0
  source: mi_fitness_data_bridge
  records.daily_activity: 1 row(s)
  records.sleep: 1 row(s)
  records.workouts: 1 row(s)
  records.body_measurements: 1 row(s)

Sample sleep row (synthetic):
  start_at=2026-07-14T23:20:00 end_at=2026-07-15T07:05:00
  duration_minutes=465 score=86
  stages=[{"stage": "deep", "minutes": 82}, {"stage": "light", "minutes": 271}, {"stage": "rem", "minutes": 88}, {"stage": "awake", "minutes": 24}]

Related MCP server: miband-mcp

health-assistant プロジェクトを統合

health-assistant プロジェクト(ローカル優先のパーソナルヘルスダッシュボード:Strava、睡眠、身体組成、食事分析)は本リポジトリに統合され、元のリポジトリはアーカイブされました。取り込まれたアセットは docs/health-assistant/ ディレクトリにあります:

  • analytics.py —— 依存関係ゼロのトレーニング/回復サマリーとアドバイスエンジンのリファレンス実装(7日間のトレーニング統計、急性/慢性負荷比、レディネスチェック、毎日のトレーニングアドバイス)。

  • coaching_methodology.md —— その背後にある説明可能なサイクリングコーチ、身体組成、スポーツ栄養の方法論。

  • README.md —— 意図的に移植しなかった部分(FastAPI ダッシュボード、Strava OAuth/Webhook パイプライン、食事写真分析)とその理由を含む完全な移行説明。

このプロジェクトが行うこと

  • 実験的な中国リージョンクラウドアダプターを通じて Xiaomi 運動健康データを読み取ります。

  • 正規化されたレコードをローカル SQLite データベースに保存します。

  • 認証情報を含まないポータブルな JSON または CSV をエクスポートします。

  • 個人の自動化のためのローカル MCP クエリツールを公開します。

  • 下流プロジェクト(個人の減量アドバイザーなど)向けに再利用可能なコネクタ実装を提供します。

意図的に医療アドバイス、減量指導、ホスト型アカウントアクセス、マルチユーザークラウドサービスは提供しません。

なぜこのブリッジを作ったのか?

以前

以後

あなたの健康履歴は Xiaomi 運動健康アプリの中にしか存在せず、唯一の「エクスポート」方法はスクリーンショットでした。

mi-fitness-bridge sync が毎日のアクティビティ、睡眠、運動、身体測定、心拍数、血中酸素(SpO2)、ストレスを正規化されたローカル SQLite データベースに取り込みます。

「先月の睡眠はどうだったか」を知るには、アプリで1日ずつ遡る必要がありました。

mi-fitness-bridge export --format csv --type sleep --start-date ... --end-date ... は、その期間で正確にフィルタリングされ、表計算ソフトで直接開ける CSV を出力します。

AI アシスタントに健康データへアクセスさせるには、ホスト型サービスに認証情報を預ける必要がありました。

mi-fitness-bridge serve はあなた自身のデータベースに基づいてローカル MCP クエリツールを公開します。passToken は OS のキーチェーンに残り、エクスポートファイルに含まれることは決してありません。

対応データセット

  • 毎日のアクティビティ:歩数、距離、アクティビティカロリー、アクティブ時間。

  • 睡眠記録と睡眠ステージ。

  • 運動記録。

  • 身体測定:体重と利用可能な身体組成フィールド。

  • 心拍数サンプル(利用可能な場合は安静時心拍数を含む)。

  • 血中酸素(SpO2)、ストレス、異常心拍イベント(アカウント/デバイスが提供する場合)。

実際の利用可能性は、デバイス、アカウントのリージョン、ファームウェア、Xiaomi の上流サービスによって異なります。

インストール

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

Windows PowerShell:

.\.venv\Scripts\Activate.ps1
pip install -e ".[dev]"

Windows Git Bash:

source .venv/Scripts/activate
pip install -e ".[dev]"

macOS/Linux:

source .venv/bin/activate
pip install -e '.[dev]'

設定

より安全な対話型設定パスにより、passToken をシェル履歴に直接書き込むことを避けられます:

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

利用可能な場合、認証情報はローカルキーチェーン(keyring)に保存されます。一部の代替 keyring 実装はキーを十分に安全でない方法で保存する場合があるため、使用前に OS の keyring の動作を理解してください。

user_id と passToken の取得方法

このブリッジは Xiaomi アカウントレベルの認証情報(米家アプリと同じログイン状態)を使用します。以下のいずれかの方法で取得できます:

方法1:ブラウザで手動コピー

  1. ブラウザで account.xiaomi.com を開き、Xiaomi アカウント(Xiaomi 運動健康アプリと同じアカウント)にログインします。

  2. 開発者ツール(F12)→「アプリケーション / Application」→ Cookies → https://account.xiaomi.com を開きます。

  3. userId と passToken の2つの Cookie の値をコピーし、mi-fitness-bridge setup のプロンプトで貼り付けます。

方法2:QRコードログインツール

オープンソースの mijia-api で一度 QR コードログインします:

pip install mijiaAPI
python -c "from mijiaAPI import mijiaAPI; mijiaAPI().login()"   # 终端出二维码,用米家 App 扫码

ログイン状態はデフォルトで ~/.config/mijia-api/auth.json(Windows では %USERPROFILE%\.config\mijia-api\auth.json)に保存され、その中の userId と passToken をそのままこのブリッジに使用できます——Xiaomi アカウントレベルの認証情報はサービス間で共通であり、ブリッジはそれを使用して Xiaomi 運動健康(sid=miothealth)のセッションを取得します。auth.json は認証情報を平文で保存することに注意してください:userId と passToken をこのブリッジ(システムキーチェーン)に入力した後は、このファイルを削除することをお勧めします。

注意:

  • passToken は期限切れになります。doctor が認証失敗を報告した場合は、上記の手順で再取得してください。

  • ブラウザ方式は普段使用しているネットワーク環境でログインしてください。頻繁な操作や異なる場所からの操作は Xiaomi アカウントのリスク管理(スライダー/SMS 認証)を引き起こす可能性があります。リスク管理に遭遇した場合は QR コード方式を使用してください。

  • Cookie 名とログインフローは 2026-08 の実測に基づいており、アカウントのリージョン、デバイス、リスク管理ポリシーによって異なる場合があります。また Xiaomi はプライベート API を随時変更する可能性があります(上部の実験的声明を参照)。

  • これらの2つの値はアカウントのログイン状態と同等です。漏洩させず、Git にコミットしないでください。

同期

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

データベースはデフォルトでプラットフォームのユーザーデータディレクトリ(platformdirs が決定)に配置されます。sync、export、serve、doctor はすべて --db 引数または MI_FITNESS_DB_PATH 環境変数で場所を変更できます。優先順位:コマンドライン > 環境変数 > デフォルトの場所。platformdirs は Windows で LOCALAPPDATA 環境変数に応答しないことに注意してください。カスタムパスが必要な場合は上記の2つの方法を使用してください:

mi-fitness-bridge sync --db ./data/mi_fitness.db --start-date 2026-07-01 --end-date 2026-07-15
export MI_FITNESS_DB_PATH=./data/mi_fitness.db

既知の制限:日付引数なしの増分同期はローカルの最後のレコードの時刻を起点とし、上流の過去履歴の修正や補完は自動的に取得されません。必要に応じてより古い --start-date でその期間を明示的に再実行してください(冪等に上書きされ、重複レコードは生成されません)。

エクスポート

ポータブルな 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

エクスポートファイルには保存済みの Xiaomi passToken は決して含まれませんが、平文の user_id などの識別列は含まれます——エクスポートファイルは機密性の高い個人データであり、適切に保管してください。エクスポートされた健康記録はデフォルトで Git に無視されます。

エクスポート形式の説明(JSON エンベロープ構造、CSV レイアウト、閉区間の日付フィルタリングルール)は Export format を参照してください。

MCP サービス

互換コマンドは引き続き利用可能です:

mi-fitness-bridge serve
# legacy alias
mi-fitness-mcp serve

利用可能なツールには、接続状態、同期、カバレッジ、日次サマリー、身体測定、睡眠、運動、心拍数、血中酸素(SpO2)、ストレス照会、およびエージェント向けの workout_series 運動時系列ツールが含まれます——max_points のハード上限に従って自動ダウンサンプリング(固定時間バケット平均、SQLite 内集計)し、レスポンスで downsampled、source_points、returned_points、method を正直に示し、全精度統計(avg/min/max/分位数)と心拍数ゾーン時間も提供します。query_workouts、get_daily_summary などのリスト/サマリーツールには data_quality(カバー日数、欠落指標、最終同期時刻)が付属します。

クライアント接続例(Claude Code / Codex などの MCP クライアントの設定 JSON):

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

注意:serve は stdio サービスであり、標準入出力を介してクライアントと通信します。HTTP サービスではありません。ターミナルで直接実行すると「フリーズ」しているように見えます——それはクライアントからの MCP メッセージを待っているだけで、正常な動作です。日常的には MCP クライアントに上記の設定で起動させてください。

Python 依存関係として使用

正規化アダプターは互換モジュール名で引き続き利用可能です:

from mi_fitness_mcp.adapters.mi_fitness_cloud import MiFitnessCloudAdapter

下流プロジェクトはコネクタソースコードを vendor 化したりコピーしたりせず、このパッケージをインストールしてください。

ライセンス

ライセンスの変遷:2026-08-03 より前にリリースされたバージョンは MIT ライセンス(上流の kubulashvili/mi-fitness-mcp と binglua/mi-fitness-mcp-cn の MIT 帰属は LICENSE 冒頭の NOTICE ブロックに保持)を採用。現在のバージョンの新規コードは AGPL-3.0-only を採用しています。詳細は LICENSE と THIRD_PARTY_NOTICES.md を参照してください。

プライバシーとセキュリティ

  • passToken、ローカルデータベース、エクスポートファイル、ログを適切に保管し、外部に漏らさないでください。

  • エクスポートファイルには passToken は含まれませんが、平文の user_id などの識別列が含まれるため、同様に機密性の高い個人データです。

  • このブリッジを公開の認証情報プロキシとして実行しないでください。

  • 実際の健康データや個人指標を含むスクリーンショットをコミットしないでください。

  • バグレポートとドキュメントでは常に合成データを使用してください。

  • 本ソフトウェアは個人データアクセスと工学研究のみを目的としており、診断や治療には使用されません。

責任ある開示方法は SECURITY.md、出典のトレーサビリティは THIRD_PARTY_NOTICES.md を参照してください。

開発

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

リリース

バージョン履歴は CHANGELOG.md、リリースおよびリリース後のチェック項目は docs/release-checklist.md を参照してください。

関連プロジェクト

  • garmin-mcp —— ローカル優先の Garmin データ MCP サービス。本プロジェクトと agent-safe-series/v1 データ契約を共有しており(時系列ダウンサンプリングフィールドのセマンティクスがバイト単位で一致)、同じ AI エージェントが両サービスのデータをシームレスに消費できます。

このプロジェクトを支援する

このツールが役に立ったなら、GitHub でスターを付けてください。

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