Mi Fitness MCP
Syncs Xiaomi Mi Fitness / Xiaomi Health cloud data (daily activity, sleep stages, workouts, body measurements, heart rate, SpO2, stress, and daily band/watch metrics like RHR, VO2 max, PAI, vitality and training load) for Smart Band & Watch devices into a local store, and exposes tools to query, summarize, and compare that data.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Offline-first SQLite cache with incremental watermarks, versioned migrations, and multi-device scoping
Full wearable coverage: daily activity, sleep (stages, naps, efficiency, respiratory rate, sleep HR/SpO2), workouts, body measurements, heart rate, SpO2, stress, and daily band/watch metrics (RHR, VO2 max, PAI, vitality, training load)
Dual transport: standard
stdiofor local MCP clients and authenticated Streamable HTTP + Legacy SSE (--transport http)Cross-distro & headless ready: stores credentials in the OS keyring when available, with automatic fallback to a restricted local credentials file (
chmod 600) or environment variables on tiling WMs (Hyprland/Sway/i3), SSH, WSL, and containers
Quick Start
1. Install
git clone https://github.com/kaarlyz/mi-fitness-mcp.git
cd mi-fitness-mcp
python3 -m venv .venv
source .venv/bin/activate
pip install -e .Or with uv:
git clone https://github.com/kaarlyz/mi-fitness-mcp.git
cd mi-fitness-mcp
uv sync2. Get Xiaomi Credentials
Open
https://account.xiaomi.comin your browser and sign in.Open DevTools → Cookies for
account.xiaomi.com.Copy
userIdandpassToken.
3. Configure & Verify
mi-fitness-mcp setup --mode mi_fitness_cloud --user-id "<userId>" --region sg --timezone Asia/Jakarta
mi-fitness-mcp doctorNotes:
Interactive setup prompts for
passTokenwithout echoing it to the terminal.For automation, pass
--pass-token-stdinor setMI_FITNESS_USER_IDandMI_FITNESS_PASS_TOKEN.On systems without a running OS Secret Service (
NoKeyringError),setupautomatically stores credentials in~/.config/mi-fitness-mcp/credentials.jsonwith0600permissions (or pass--credential-store file).Regional backends (
cn,de,i2,ru,sg,us) are supported;ruremains the default if omitted, and global/EU accounts automatically discover and persist their accepted region.
4. Sync & Run
mi-fitness-mcp sync --start-date 2026-01-01 --end-date 2026-12-31
mi-fitness-mcp serveTo inspect exact XDG config, credentials, and SQLite database paths (useful before switching distros):
mi-fitness-mcp pathsRelated MCP server: Mi Fitness MCP
MCP Client Configuration
stdio (Claude Desktop, Cursor, Antigravity, Zed)
See mcp-server-config.example.json and examples/mcp-stdio.json:
{
"mcpServers": {
"mi-fitness": {
"command": "/path/to/mi-fitness-mcp/.venv/bin/mi-fitness-mcp",
"args": ["serve"]
}
}
}Streamable HTTP / Legacy SSE
Start the HTTP server (generates a random auth token if MI_FITNESS_MCP_HTTP_TOKEN / --auth-token is omitted):
mi-fitness-mcp serve --transport http --host 127.0.0.1 --port 8765Connect using either the printed secret URL prefix (/t/<token>/mcp or /t/<token>/sse) or Authorization: Bearer <token> on /mcp. See examples/mcp-http.json and examples/mi-fitness-mcp.service.
Supported Data & MCP Tools
17 MCP tools across 8 synchronized data types (daily_activity, sleep, workouts, body_measurements, heart_rate, spo2, stress, daily_metrics):
Category | Tools |
Connection & Sync |
|
Activity & Trends |
|
Sleep & Vitals |
|
Workouts |
|
Full parameter and metric documentation is available in docs/TOOLS.md.
Documentation
docs/SETUP.md — installation, credential extraction, CLI commands, and HTTP/stdio setup
docs/DISTRO_MIGRATION.md — backing up/moving between Linux distros, Hyprland/Sway/headless setups, and keyring troubleshooting
docs/TOOLS.md — full catalog of all 17 MCP tools, data types, and supported metrics
SECURITY.md — credential storage model and safe usage guidelines
CONTRIBUTING.md — local setup, testing, and PR checklist
Endpoint Probe Utility
For debugging Xiaomi regional endpoints and raw cloud keys locally:
uv run python probe_mifitness.py --user-id "<userId>"It prompts for passToken silently or accepts --pass-token-stdin / MI_FITNESS_PASS_TOKEN.
Development
ruff check .
pytest -q
python -m buildCI runs on Python 3.11, 3.12, and 3.13, keeps HTTP tests offline via respx, checks ruff, measures coverage, builds a wheel, and smoke-tests CLI subcommands in a clean virtual environment.
Configuration Compatibility
SQLite schema upgrades run automatically through the versioned migration runner (
LATEST_SCHEMA_VERSION = 10) without losing existing data.busy_timeoutconfigures SQLite lock waiting in milliseconds (default5000).Legacy keys (
auto_sync_on_start,stale_after_minutes,store_raw_payloads,default_lookback_days,logs_path) remain accepted when loading olderconfig.jsonfiles as deprecated no-ops, and are omitted when saving fresh configs.
Credits & Disclaimer
Originally based on kubulashvili/mi-fitness-mcp (MIT License), extended with sleep/SpO2/stress/daily band metrics, Streamable HTTP & Legacy SSE transport, and cross-distro credential portability.
This is an unofficial project and is not affiliated with Xiaomi.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for Withings health data — sleep, activity, heart, and body metrics.
Multi-tenant hosted MCP server for Oura Ring — 21 read-only tools, OAuth per user.
Your own Garmin data (sleep, HRV, Body Battery, activities) in Claude, ChatGPT and any MCP app.
1Read and log your supplement intake, meals, and lab measurements from Micros.
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
- AlicenseCqualityCmaintenanceMCP server for Mi Fitness cloud data. Provides a local SQLite-backed server to sync and query daily activity, heart rate, and body measurements.128MIT
- 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
- AlicenseAqualityAmaintenanceProvides local MCP tools to query your own Xiaomi Mi Fitness health data (sleep, workouts, heart rate, etc.) stored in a local SQLite database, enabling AI assistants to access personal health records without exposing credentials.1781AGPL 3.0