SuperAPI AI Directory

mi_fitness_data_bridge

Unofficial Mi Fitness connector: local SQLite storage and JSON/CSV exports of sleep, activity, workouts and other records.

Open website

About this tool

Mi Fitness Data Bridge skill

Purpose: save Mi Fitness data to your own computer and export it as CSV, JSON, or SQLite. Suitable for personal backup, spreadsheet organization, and your own analysis programs; it also provides a Python interface and a local stdio MCP query tool. The data types actually available depend on the device, account region, and upstream services.

Main capabilities:

  • Export data to local SQLite, CSV, or JSON.
  • Supported data types: daily activity (steps, distance, active calories, active minutes), body measurements (weight and body composition fields provided by the device/account), heart rate samples (including resting heart rate when available), sleep, workouts, blood oxygen (SpO₂), stress, and abnormal heart beat events.
  • Steps are aggregated by local "minute slices": when a phone, band, or watch reports overlapping records for the same minute, the larger single record is kept rather than summed, to avoid double-counting steps from two devices. This rule is a best-effort compatibility handling for non-public upstream data, and the final values may still differ from the App's server-side corrected results.
  • The default cloud region is cn, and other regions can also be specified during configuration.
  • The CLI supports --type to select the data type: daily_activity, heart_rate, body_measurements, sleep, workouts, spo2, stress, abnormal_heart_beat.
  • Repeated syncs with an explicit date range are idempotent and will not duplicate existing records; if Xiaomi later corrects an earlier date, you can rerun that range with an explicit earlier --start-date.
  • Sleep score: sleep sync prioritizes keeping the valid score of the original record; when the main sleep lacks a score, it tries to supplement it from the daily aggregated sleep report of the user's own account, matching by local wake date, source, and the available start and end times of the sleep segment, and only supplements the score for main sleep that can be clearly identified. sleep_score_source indicates sleep_record (original record) or daily_report (daily report), and the unknown source of old cache is null. An upstream default value of 0 is treated as unavailable.
  • Workout details: after completing a workout_detail sync, you can query second-by-second heart rate, cadence, pace, and speed curves through workout_detail_series, and throughExport GPS tracks via workout_gps. By default, a full sync backfills workouts in the cache that are missing details; force_full_sync can re-fetch workouts that have already been covered.

Usage:

  • Requires Python 3.11 or higher.
  • The main command is mi-fitness-bridge; the old command mi-fitness-mcp is still retained as a compatibility alias.
  • After installation, use interactive configuration: the configuration process will ask for the Mi Fitness user_id, passToken, and region (default cn). Credentials will be saved to the local operating system's keyring when available. Do not paste the passToken in the command line, scripts, Issues, logs, or screenshots. setup does not accept --user-id or --pass-token command-line arguments.
  • doctor checks the local configuration, credentials, and database; when credentials are configured, it also checks cloud connectivity. Existing local data and export operations can still be used offline.
  • sync, export, serve, and doctor support --db, and also support the MI_FITNESS_DB_PATH environment variable to specify the database path; the priority is: command-line argument > environment variable > configuration/default path.
  • Export CSV (one file per dataset); dates must use YYYY-MM-DD, and the start date must not be later than the end date. JSON uses UTF-8, CSV uses utf-8-sig with BOM.
  • Start the local stdio MCP service; available tools include: 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, and query_abnormal_heart_beat. The old names get_daily_summary and workout_series can still be called for compatibility, but will not appear in the tool catalog.
  • Record list queries support limit / offset pagination; data.pagination.next_offset in the response is the position of the next page; keep the filter conditions unchanged when paging, and do not perform a sync. For a single workout series, use max_points in query_workout_series to control the number of points, and do not use list pagination. Background MCP sync can be stopped with cancel_sync; records that have already been written will not be rolled back.
  • Task status is stored in the local SQLite; after a restart, it can be queried with get_sync_status or query_sync_history; the most recent 500 terminal MCP tasks and active tasks are retained. On restart, incomplete tasks are marked as interrupted and will not automatically resume. Only one MCP service process is allowed to use the same database at the same time.
  • The service communicates via standard input/output and should be started and managed by the local MCP client; it will not connect to Xiaomi at startup, and only status checks or sync operations will establish a cloud connection on demand. Do not expose it as a public network service or credential proxy.
  • The compatibility package name remains mi_fitness_mcp.
  • Provides a login-free synthetic data export demo: the static demo can switch between activity, sleep, workout, and body measurement samples in the browser, and download synthetic CSV / JSON; locally you can run python examples/synthetic_demo.py to verify the export process, with no setup required and no connection to Xiaomi.

Use cases:

  • Personal health data backup.
  • Spreadsheet organization and your own analysis programs.
  • Query locally synced data through a local stdio MCP client.
  • Use synthetic data to prepare privacy-preserving bug reports.

Limitations:

  • Unofficial, experimental project, with no affiliation, endorsement, or support relationship with Xiaomi; the adapter relies on non-public upstream interfaces, and after changes to Xiaomi's services, account region, devices, firmware, or authentication methods, login, connection, or certain data types may fail at any time.
  • There is currently no one-click account authorization process, and availability for all devices and regions cannot be guaranteed; KNOWN_REGIONS is only a routing candidate.
  • Explicitly does not provide: medical diagnosis, treatment, health coaching, or weight-loss advice; supManage accounts, shared credentials, public Token proxies, or multi-user cloud services; Web dashboards, third-party fitness OAuth/Webhooks, or meal photo analysis.
  • Real exports may contain plaintext user_id; a local MCP also does not mean the entire AI workflow is offline, and you need to separately confirm how the client and model handle data.
  • Exported health records are sensitive personal data; the default .gitignore will ignore databases, export directories, and common logs, but they still need to be properly stored, shared, and backed up.
  • It may only be used for accounts and data you have the right to access.
  • This software is only for personal data access and engineering research, not for diagnosis or treatment.
  • For upstream sources and MIT attribution, see THIRD_PARTY_NOTICES.md. The current version uses the AGPL-3.0-only license; versions released before 2026-08-03 were MIT.
  • For details such as installation steps, re-syncing after updates, and reminders to restart the MCP process, refer to the repository documentation; missing information is not provided for now.