Mi Fitness MCP
Provides tools to sync and serve Mi Fitness cloud data, including daily activity (steps, distance, calories), heart rate, and body measurements (weight, BMI, body composition metrics).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Mi Fitness MCP Show my daily activity for the last 14 days"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Mi Fitness MCP
MCP server for Mi Fitness data.
This project provides a local SQLite-backed MCP server for Mi Fitness cloud data.
Current data coverage
Confirmed with the current cloud flow:
daily activity
steps
distance
active calories
heart rate
body measurements
weight
BMI
fat, water, bone, and muscle metrics
visceral fat
basal metabolism
official Xiaomi workout sessions
sport/category, duration, distance, calories, pace, cadence, speed, elevation
heart-rate zones, training effect/load, recovery time, VO2 max when supplied
Not yet supported:
sleep. The available endpoint and payload contract have not been confirmed, so sleep is intentionally not advertised or synchronized yet.
Related MCP server: Mi Fitness MCP CN
Install
python -m venv .venv
source .venv/bin/activate
pip install -e '.[dev]'Setup
You need:
userIdpassToken
Typical flow:
Open
https://account.xiaomi.comSign in to your Xiaomi account
Open browser DevTools
Inspect cookies for
account.xiaomi.comCopy
userIdandpassToken
Configure the server. The interactive prompt hides passToken and stores credentials in the
system keyring:
mi-fitness-mcp setup --mode mi_fitness_cloud --user-id "<userId>" --region ru
mi-fitness-mcp doctorFor automation, prefer --pass-token-stdin or MI_FITNESS_PASS_TOKEN. The legacy
--pass-token argument remains available for backward compatibility but is deprecated because
command-line arguments may be visible in shell history and process listings.
Xiaomi accounts may be hosted in regional Mi Fitness backends. ru remains the default for
compatibility, while the adapter can discover and persist another accepted global/EU region such
as de, i2, sg, or us. This does not change the Xiaomi userId + passToken login flow.
For local endpoint exploration there is also a probe script:
uv run python probe_mifitness.py --user-id "<userId>"The probe prompts for passToken without echo. For automation, provide
MI_FITNESS_USER_ID and MI_FITNESS_PASS_TOKEN, or use --pass-token-stdin with a
protected input source. Secret command-line arguments are intentionally unsupported.
Use
mi-fitness-mcp sync --start-date 2025-04-01 --end-date 2025-05-31
mi-fitness-mcp serveMCP client config
Example Claude Desktop config:
{
"mcpServers": {
"mi-fitness": {
"command": "mi-fitness-mcp",
"args": ["serve"]
}
}
}Example prompts
Show my daily activity for the last 14 daysHow has my resting heart rate changed this month?Summarize my latest body measurementsShow my running workouts from the last 30 daysSummarize workout volume by sport or ISO weekCompare this month's workout totals with last monthWhat were my longest-distance and fastest-pace workout records?Sync my latest Mi Fitness data
MCP tools
get_connection_statussync_dataget_profileget_daily_summaryquery_metric_seriesquery_heart_ratequery_body_measurementsquery_workoutssummarize_workoutsget_workout_recordscompare_workout_periodsget_data_coverage
Existing tool names, argument semantics, and status: ok|error response envelopes remain
backward compatible. Sync reports successful and failed data types separately; a partial sync
returns ok, while a sync where every requested type fails returns error.
Commands
mi-fitness-mcp --help
mi-fitness-mcp setup --help
mi-fitness-mcp doctor
mi-fitness-mcp sync --help
mi-fitness-mcp serveDevelopment
uv run ruff check .
uv run pytest -q
uv run python -m buildThe current test suite contains 89 tests and reports 78% statement coverage. CI runs on Python
3.11, 3.12, and 3.13, keeps HTTP tests offline with respx, and installs the built wheel in a
clean environment before checking mi-fitness-mcp --help.
Configuration compatibility
SQLite schema changes use the existing versioned migration runner; existing tables and data are preserved.
busy_timeoutconfigures SQLite lock waiting in milliseconds and defaults to5000.auto_sync_on_start,stale_after_minutes,store_raw_payloads,default_lookback_days, andlogs_pathare retained for config-file compatibility but are deprecated no-ops.
Troubleshooting
Connection: failedverify
userIdandpassTokenverify the configured region; global/EU accounts may resolve to another backend
Credentials not foundrun
setupagain
syncreturns no datatry another date range
verify that the data actually exists in Mi Fitness cloud
Security
passTokenis stored via the system keyringuserIdis masked in CLI and MCP diagnostics;passTokenis never printeddo not commit
.env, local config files, or real credentialsrotate tokens if they were pasted into chats or shell history
Disclaimer
This is an unofficial project and is not affiliated with Xiaomi.
Available Tools
12 toolscompare_workout_periodsC
Compare workout totals between two date ranges
Inputs: first_end_date (required), second_end_date (required), first_start_date (required), second_start_date (required).
get_connection_statusC
Check connection status
Inputs: no named parameters.
get_daily_summaryC
Get daily activity summary
Inputs: date, end_date, start_date.
get_data_coverageD
Get data coverage
Inputs: data_types.
get_profileB
Get user profile information
Inputs: no named parameters.
get_workout_recordsC
Get personal workout records for a date range
Inputs: end_date (required), start_date (required), activity_type.
query_body_measurementsD
Query body measurements
Inputs: end_date (required), start_date (required), metrics, latest_only.
query_heart_rateC
Query heart rate samples
Inputs: end_date (required), start_date (required), limit, sample_type.
query_metric_seriesD
Query metric series
Inputs: metric (required), end_date (required), start_date (required), aggregation, +1 more.
query_workoutsC
Query official Xiaomi workout sessions
Inputs: end_date (required), start_date (required), min_duration, activity_types, +1 more.
summarize_workoutsB
Summarize workout volume by sport or ISO week
Inputs: end_date (required), start_date (required), group_by.
sync_dataC
Synchronize Mi Fitness data
Inputs: end_date, data_types, start_date, force_full_sync.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 12 tools
Most tools are clearly distinct, but `get_workout_records` vs `query_workouts` could be confused (personal vs official workouts). Also `query_metric_series` is somewhat generic and may overlap with `query_heart_rate` and `query_body_measurements`.
All tool names follow a verb_noun structure, but there is a mix of `get_` and `query_` prefixes (both meaning retrieval). This is a minor deviation from a perfectly uniform pattern.
12 tools is well within the ideal 3-15 range and each tool serves a distinct purpose for a fitness data server, covering connection, sync, profile, summaries, metrics, workouts, and data coverage.
The toolset offers broad coverage for retrieving and analyzing fitness data, including raw series, summaries, workouts, and comparisons. Minor gaps could include sleep tracking or goal management, but they are not obviously required for the stated purpose.
Maintenance
Related MCP Connectors
MCP server for Withings health data — sleep, activity, heart, and body metrics.
Remote MCP server for training, nutrition, wellness, and performance data with OAuth 2.0.
Adaptive running coach MCP server — training data, plans, and recovery for AI assistants.
Multi-tenant hosted MCP server for Oura Ring — 21 read-only tools, OAuth per user.
Related MCP Servers
- AlicenseBqualityCmaintenanceMCP server that provides local caching, sync, and tools for Zepp Life health data including steps, sleep, heart rate, workouts, and body measurements, supporting both file exports and cloud session access.1017MIT
- 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
- AlicenseNot gradedqualityCmaintenanceSelf-hosted MCP server that syncs Xiaomi fitness data to SQLite and provides authenticated tools to query health metrics (steps, sleep, HR, etc.) for AI assistants like Grok.GPL 3.0
- AlicenseNot gradedqualityDmaintenanceMCP server for read-only access to Xiaomi Mi Fitness shared family health data, enabling queries for family members, health summaries, and historical metrics via ChatGPT.2GPL 3.0