Mi Fitness Data Bridge
Mi Bridge (Mi Fitness Data Bridge)
Eine lokal orientierte Datenbrücke, die deine eigenen Xiaomi Fitness- & Gesundheitsdaten nach SQLite, JSON, CSV sowie in MCP-kompatible Werkzeuge exportiert.
Die Xiaomi Fitness- & Gesundheits-App zeigt dir gerne deine Schritte, deinen Schlaf und deine Herzfrequenz – aber sie lässt dich diese Daten nie mitnehmen. Diese Brücke bringt deine eigenen Daten in eine eigene SQLite-Datei auf deiner eigenen Festplatte.
Markenrechtlicher Hinweis: Xiaomi, Mijia und Mi Fitness sind Marken der Xiaomi Corporation. Dieses Projekt ist ein inoffizielles Community-Projekt und steht in keiner Verbindung zu Xiaomi und wird von Xiaomi nicht unterstützt.
Experimenteller Hinweis: Der Cloud-Adapter kann jederzeit ausfallen, da Xiaomi seine proprietären Schnittstellen ändern kann. Verwende ihn nur mit Konten und Daten, auf die du zugriffsberechtigt bist.
Verifiziert durch echte Tests
Aufgenommen am 2026-07-20 unter Windows (Python 3.14) basierend auf dem main-Branch-Commit. Alle Daten sind synthetische Daten, keine echten Anmeldeinformationen und kein Netzwerkzugriff. (Anzahl der Tests erneut geprüft am 2026-08-17.)
Testsuite:
$ python -m pytest -q -p no:cacheprovider
........................................................................ [ 96%]
... [100%]
75 passed in 10.27sEnd-to-End-Synthese-Demo (examples/synthetic_demo.py füllt zuerst den lokalen SQLite-Cache mit synthetischen Datensätzen und führt dann echte JSON/CSV-Exporte durch):
$ 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
Zusammengeführtes health-assistant-Projekt
Das health-assistant-Projekt (lokal orientiertes persönliches Health-Dashboard: Strava, Schlaf, Körperzusammensetzung, Ernährungsanalyse) wurde in dieses Repository zusammengeführt, das ursprüngliche Repository wurde archiviert. Die übernommenen Inhalte befinden sich in docs/health-assistant/:
analytics.py– Referenzimplementierung einer trainingsfreien Erholungszusammenfassung und Empfehlungs-Engine (7-Tage-Trainingsstatistik, akute/chronische Belastungsquote, Bereitschaftsprüfung, tägliche Trainingsempfehlungen).coaching_methodology.md– Die erklärbare Methodik dahinter: Radsport-Coaching, Körperzusammensetzung und Sporternährung.README.md– Vollständige Migrationsbeschreibung, einschließlich der bewusst nicht übernommenen Teile (FastAPI-Dashboard, Strava-OAuth/Webhook-Pipeline, Essensfoto-Analyse) und der Gründe dafür.
Was dieses Projekt tut
Über einen experimentellen Cloud-Adapter für die chinesische Region Xiaomi Fitness- & Gesundheitsdaten abrufen.
Normalisierte Datensätze in einer lokalen SQLite-Datenbank speichern.
Tragbare JSON- oder CSV-Dateien ohne Anmeldeinformationen exportieren.
Lokale MCP-Abfragewerkzeuge für persönliche Automatisierung bereitstellen.
Eine wiederverwendbare Konnektorimplementierung für nachgelagerte Projekte (z. B. persönliche Fettreduktionsberater) bereitstellen.
Es bietet bewusst keine medizinische Beratung, keine Abnehmhilfe, keinen kontenbasierten Mehrbenutzerzugriff und keinen Cloud-Dienst.
Warum diese Brücke?
Vorher | Nachher |
Deine Gesundheitshistorie existiert nur in der Xiaomi Fitness- & Gesundheits-App; der einzige "Export" ist ein Screenshot. |
|
Um "Wie war mein Schlaf letzten Monat?" zu beantworten, musstest du Tag für Tag in der App zurückblättern. |
|
Um KI-Assistenten auf deine Gesundheitsdaten zugreifen zu lassen, musstest du deine Anmeldeinformationen einem gehosteten Dienst anvertrauen. |
|
Unterstützte Datensätze
Tägliche Aktivitäten: Schritte, Distanz, Aktivitätskalorien und aktive Minuten.
Schlafaufzeichnungen und Schlafphasen.
Trainingsaufzeichnungen.
Körpermessungen: Gewicht und verfügbare Körperzusammensetzungsfelder.
Herzfrequenzproben, einschließlich Ruheherzfrequenz, sofern verfügbar.
Blutsauerstoff (SpO2), Stress und abnormale Herzschlagereignisse (sofern vom Konto/der Region/dem Gerät unterstützt).
Die tatsächliche Verfügbarkeit hängt von Gerät, Kontoregion, Firmware und den vorgelagerten Xiaomi-Diensten ab.
Installation
git clone https://github.com/shkyyy18/mi-bridge.git mi_fitness_data_bridge
cd mi_fitness_data_bridge
python -m venv .venvWindows 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]'Konfiguration
Der sicherere interaktive Konfigurationspfad vermeidet, dass passToken in der Shell-Historie landet:
mi-fitness-bridge setup
mi-fitness-bridge doctorWenn verfügbar, werden Anmeldeinformationen im Schlüsselbund des Betriebssystems (keyring) gespeichert. Einige keyring-Backends speichern Schlüssel jedoch möglicherweise nicht sicher – informiere dich vor der Verwendung über das keyring-Verhalten deines Betriebssystems.
So erhältst du user_id und passToken
Diese Brücke verwendet Anmeldeinformationen auf Xiaomi-Kontoebene (dieselbe Anmeldesitzung wie die Mijia-App). Wähle eine der beiden folgenden Methoden:
Methode 1: Manuelles Kopieren aus dem Browser
Öffne account.xiaomi.com im Browser und melde dich mit deinem Xiaomi-Konto an (dasselbe Konto wie in der Xiaomi Fitness- & Gesundheits-App).
Öffne die Entwicklertools (F12) → "Anwendung / Application" → Cookies →
https://account.xiaomi.com.Kopiere die Werte von
userIdundpassTokenund füge sie ein, wennmi-fitness-bridge setupdanach fragt.
Methode 2: QR-Code-Login-Tool
Verwende das Open-Source-Tool mijia-api für einen einmaligen QR-Code-Login:
pip install mijiaAPI
python -c "from mijiaAPI import mijiaAPI; mijiaAPI().login()" # 终端出二维码,用米家 App 扫码Der Login-Status wird standardmäßig in ~/.config/mijia-api/auth.json gespeichert (unter Windows: %USERPROFILE%\.config\mijia-api\auth.json). Die darin enthaltenen userId- und passToken-Werte können direkt mit dieser Brücke verwendet werden – Xiaomi-Kontoanmeldeinformationen sind dienstübergreifend gültig, und die Brücke verwendet sie, um eine Sitzung für Xiaomi Fitness & Health (sid=miothealth) zu erhalten. Hinweis: auth.json speichert Anmeldeinformationen im Klartext: Nachdem du userId und passToken in diese Brücke (Schlüsselbund des Betriebssystems) eingegeben hast, wird empfohlen, diese Datei zu löschen.
Hinweise:
passTokenläuft ab; wenndoctoreinen Authentifizierungsfehler meldet, wiederhole einfach die obigen Schritte, um neue Werte zu erhalten.Verwende für die Browsermethode am besten deine übliche Netzwerkumgebung; häufige oder ortsfremde Anmeldeversuche können die Xiaomi-Konto-Sicherheitsprüfung auslösen (Slider-/SMS-Verifizierung). Falls die Sicherheitsprüfung ausgelöst wird, verwende stattdessen die QR-Code-Methode.
Cookie-Name und Anmeldeablauf basieren auf Tests vom 2026-08 und können je nach Kontoregion, Gerät oder Sicherheitsrichtlinien abweichen; Xiaomi kann seine proprietären Schnittstellen auch jederzeit anpassen (siehe experimentellen Hinweis oben).
Diese beiden Werte entsprechen deinem angemeldeten Konto – gib sie nicht weiter und committe sie nicht in Git.
Synchronisierung
mi-fitness-bridge sync --start-date 2026-07-01 --end-date 2026-07-15Oder synchronisiere nur einen einzelnen Datensatz:
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-15Die Datenbank liegt standardmäßig im benutzerspezifischen Datenverzeichnis der Plattform (durch platformdirs bestimmt). sync, export, serve und doctor unterstützen alle die Angabe eines anderen Speicherorts über den --db-Parameter oder die Umgebungsvariable MI_FITNESS_DB_PATH. Priorität: Befehlszeilenparameter > Umgebungsvariable > Standardverzeichnis. Hinweis: platformdirs berücksichtigt auf Windows die Umgebungsvariable LOCALAPPDATA nicht; für einen benutzerdefinierten Pfad verwende eine der beiden oben genannten Methoden.
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.dbBekannte Einschränkung: Die inkrementelle Synchronisierung ohne Datumsangabe beginnt beim Zeitstempel des letzten lokalen Datensatzes; Korrekturen oder Nachträge für frühere Zeiträume auf der Serverseite werden nicht automatisch abgerufen. Verwende bei Bedarf ein früheres --start-date, um den Zeitraum explizit erneut zu synchronisieren (die Synchronisierung ist idempotent und überschreibt ohne Duplikate).
Export
Erzeugt eine tragbare JSON-Datei:
mi-fitness-bridge export --format json --output exports/mi_fitness.jsonErzeugt eine CSV-Datei pro Datensatztyp:
mi-fitness-bridge export --format csv --output exports/csvNach Datensatztyp und Datumsbereich filtern:
mi-fitness-bridge export --format json --type sleep \
--start-date 2026-07-01 --end-date 2026-07-15 \
--output exports/sleep.jsonExportdateien enthalten niemals das gespeicherte Xiaomi-passToken, enthalten jedoch Klartext-Identifikationsspalten wie user_id – Exportdateien sind sensible personenbezogene Daten und entsprechend sorgfältig aufzubewahren. Exportierte Gesundheitsdatensätze sind standardmäßig in Git ignoriert.
Details zum Exportformat (JSON-Envelope-Struktur, CSV-Layout, Regeln für die Filterung inklusiver Datumsbereiche) findest du unter Exportformat.
MCP-Dienst
Der kompatible Befehl ist weiterhin verfügbar:
mi-fitness-bridge serve
# legacy alias
mi-fitness-mcp serveVerfügbare Werkzeuge umfassen Verbindungsstatus, Synchronisierung, Abdeckung, Tageszusammenfassung, Körpermessungen, Schlaf, Training, Herzfrequenz, Blutsauerstoff (SpO2) und Stressabfragen sowie das für Agenten entwickelte Werkzeug workout_series für Trainingszeitreihen – es führt automatisch ein Downsampling gemäß dem harten Limit max_points durch (feste Zeit-Bucket-Mittelwerte, Aggregation in SQLite) und kennzeichnet in der Antwort ehrlich downsampled, source_points, returned_points und method, zusammen mit Statistiken in voller Präzision (avg/min/max/Perzentile) und Zeitanteilen in Herzfrequenzzonen. Listen-/Zusammenfassungswerkzeuge wie query_workouts und get_daily_summary enthalten zusätzlich data_quality (abgedeckte Tage, fehlende Metriken, letzter Synchronisierungszeitpunkt).
Beispiel für die Client-Integration (Konfigurations-JSON für MCP-Clients wie Claude Code / Codex):
{
"mcpServers": {
"mi-bridge": {
"command": "mi-fitness-bridge",
"args": ["serve"]
}
}
}Hinweis: serve ist ein stdio-Dienst, der über Standardeingabe/-ausgabe mit dem Client kommuniziert, kein HTTP-Dienst. Wenn du ihn direkt im Terminal ausführst, scheint er "hängen zu bleiben" – das liegt daran, dass er auf MCP-Nachrichten des Clients wartet und ist normales Verhalten; im Alltag startest du ihn über den MCP-Client mit der obigen Konfiguration.
Als Python-Abhängigkeit verwenden
Der normalisierte Adapter ist weiterhin unter dem kompatiblen Modulnamen verfügbar:
from mi_fitness_mcp.adapters.mi_fitness_cloud import MiFitnessCloudAdapterNachgelagerte Projekte sollten dieses Paket installieren, anstatt den Konnektor-Quellcode zu vendoren oder zu kopieren.
Lizenz
Lizenzhistorie: Versionen, die vor dem 2026-08-03 veröffentlicht wurden, stehen unter der MIT-Lizenz (die MIT-Anerkennungen der vorgelagerten Projekte kubulashvili/mi-fitness-mcp und binglua/mi-fitness-mcp-cn sind im NOTICE-Block oben in LICENSE erhalten); der neu hinzugefügte Code der aktuellen Version steht unter AGPL-3.0-only. Siehe LICENSE und THIRD_PARTY_NOTICES.md.
Datenschutz & Sicherheit
Bewahre
passToken, die lokale Datenbank, Exportdateien und Protokolle sorgfältig auf und gib sie nicht weiter.Exportdateien enthalten kein
passToken, enthalten jedoch Klartext-Identifikationsspalten wieuser_id– auch sie sind sensible personenbezogene Daten.Betreibe diese Brücke nicht als öffentlichen Anmeldeinformations-Proxy.
Committe keine echten Gesundheitsdaten oder Screenshots mit persönlichen Metriken.
Verwende in Fehlerberichten und Dokumentation ausschließlich synthetische Daten.
Diese Software dient ausschließlich dem persönlichen Datenzugriff und der technischen Forschung, nicht der Diagnose oder Behandlung.
Verantwortungsvolle Offenlegung: siehe SECURITY.md; Herkunftsnachweise: siehe THIRD_PARTY_NOTICES.md.
Entwicklung
pip install -e '.[dev]'
python -m pytest -q -p no:cacheprovider
python -m ruff check src testsVeröffentlichung
Versionshistorie siehe CHANGELOG.md; Veröffentlichungs- und Nachveröffentlichungs-Checkliste siehe docs/release-checklist.md.
Verwandte Projekte
garmin-mcp – Lokal orientierter MCP-Dienst für Garmin-Daten. Teilt mit diesem Projekt den Datenvertrag
agent-safe-series/v1(die Semantik der Downsampling-Felder für Zeitreihen ist bytegenau identisch), sodass derselbe KI-Agent nahtlos Daten beider Dienste konsumieren kann.
Unterstütze dieses Projekt
Wenn dir dieses Werkzeug geholfen hat, gib mir auf GitHub einen Stern.
Available Tools
17 toolscancel_syncAIdempotent
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_coverageARead-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_profileARead-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_statusARead-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_beatARead-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_measurementsARead-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_activityARead-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_rateARead-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_seriesARead-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_sleepARead-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_spo2ARead-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_stressARead-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_historyARead-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_workoutsARead-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_seriesARead-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
Scored across 17 tools
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).
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.
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.
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
Related MCP Connectors
Apple Health training load, recovery, HRV and workout detail for Claude, ChatGPT and any MCP client.
Your Garmin, Oura, WHOOP, Hevy and 35 more fitness apps, queryable from your own AI.
Ask Claude, ChatGPT or Cursor about your Apple Health data: workouts, sleep, food. Read-only.
Hosted Apple Health MCP: daily brief, records, sleep, HRV in ChatGPT, Claude, Grok. Free, no export.
Related MCP Servers
- AlicenseCqualityCmaintenanceEnables 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.1021MIT
- FlicenseNot gradedqualityCmaintenanceEnables 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-
- AlicenseNot gradedqualityBmaintenanceLets 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 PyPI9MIT
- AlicenseCqualityBmaintenanceEnables 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.14MIT