mi-health-mcp
Provides tools for retrieving sleep, heart rate, and step data from Xiaomi Health for the authenticated user and authorized relatives.
Click on "Install 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-health-mcpShow my sleep and heart rate for the past week."
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-health-mcp
Project Introduction
mi-health-mcp provides the sleep, heart rate, and step data of the currently logged-in Xiaomi account and authorized family members to MCP clients such as Hermes via the MCP protocol. The service runs on Cloudflare Workers. This project originates from wusaki0723/mi-health-mcp, retains the GPL-3.0 license, and references the interface implementations of Misty02600/mi-fitness-python and shkyyy18/mi_fitness_data_bridge.
Related MCP server: boyuan-health-bridge
Deployment
Requires Node.js 20 or later and a Cloudflare account.
git clone https://github.com/<your-github-account>/mi-health-mcp.git
cd mi-health-mcp
npm install
npx wrangler login
npx wrangler kv namespace create MI_HEALTH_KVWrite the namespace ID output by the command into kv_namespaces[0].id in wrangler.toml. The KV namespace ID is a Cloudflare resource identifier, not an access credential; public repositories must commit wrangler.toml so that Workers Builds can identify the Worker entry point and binding. After forking, you must replace it with the namespace ID from your own account before deploying.
Then set the access token and deploy:
npx wrangler secret put AUTH_TOKEN
npx wrangler deployUse a long random string you generate yourself for the value of AUTH_TOKEN; do not write it into source code, wrangler.toml, or Git.
passToken login
It is recommended to set userId, passToken, and deviceId from the Xiaomi Account browser Cookie as Cloudflare Secrets. deviceId usually starts with wb_. The Worker uses them to exchange for a short-lived health API session with sid=miothealth; the raw passToken is never written to KV, logs, or MCP responses.
npx wrangler secret put XIAOMI_USER_ID
npx wrangler secret put XIAOMI_PASS_TOKEN
npx wrangler secret put XIAOMI_DEVICE_IDYou can also add Secrets with the same names in the Worker's "Settings > Variables and Secrets" in the Cloudflare Dashboard. XIAOMI_USER_ID and XIAOMI_PASS_TOKEN must be set together; XIAOMI_DEVICE_ID is optional, and when set, use the deviceId from the same browser session in which that passToken was obtained.
The KV binding name must remain MI_HEALTH_KV. AUTH_TOKEN, XIAOMI_USER_ID, and XIAOMI_PASS_TOKEN must be set as Cloudflare Secrets; do not write them into source code, configuration files, or Git.
Hermes configuration
mcp_servers:
mi_health:
url: "https://<worker-name>.<account-subdomain>.workers.dev/mcp"
headers:
Authorization: "Bearer ${MI_HEALTH_AUTH_TOKEN}"Replace the URL with the address of your own deployed Worker. The value of MI_HEALTH_AUTH_TOKEN must match the AUTH_TOKEN Secret of that Worker. The example does not contain real credentials.
Hermes skill
The skills/mi-health/SKILL.md in the repository routes "me/myself" and "family/friends" requests to the correct tools and explains the field meanings of compact results. Once the repository is public, it can be installed from the raw file URL:
hermes skills install https://raw.githubusercontent.com/<your-github-account>/mi-health-mcp/main/skills/mi-health/SKILL.md
hermes skills listThe skill does not automatically create scheduled tasks. To connect it to an existing task, first check the task and its recent execution records, then add it by task ID:
hermes cron status
hermes cron list
hermes cron runs <job-id>
hermes cron edit <job-id> --add-skill mi-healthScheduled tasks run in an independent session; the prompt must clearly specify the query target, number of days, timezone, delivery location, and how to handle failures. Do not put any credentials in the prompt; periodic tasks should pin the provider and model to avoid behavior changes when global defaults change.
Usage
After configuring
XIAOMI_USER_IDandXIAOMI_PASS_TOKEN, callhealth_login_refresh;XIAOMI_DEVICE_IDis an optional Secret used to specify the browser session in which thatpassTokenwas obtained when needed. The Worker exchanges and caches amiothealthsession; on failure, the current cached session is not deleted.Use
health_meto confirm the current account; callhealth_latest,health_sleep,health_heart, orhealth_stepsto query individual raw summaries, and preferhealth_analyzewith the user's current IANA timezone when trend analysis is needed.When querying family members, first call
health_relatives, then passtarget: "relative"and the returnedrelative_uid.
health_login_start and health_login_poll are kept only for compatibility. This QR code flow is rejected by Xiaomi on some accounts with 70036, and the 小米运动健康 App may also report that the QR code is unsupported; this project does not describe it as a verified login method.
Health queries default to target: "self", using the personal data endpoint and not sending relative_uid; family queries must provide a valid relative_uid and will not automatically select the first item in the family list.
MCP tools
health_me: Returns the current login status anduser_id; does not return credentials.health_login_status: Returns whether the current health API session is available and the login method; does not return credentials.health_login_refresh: Forces a session refresh using the Xiaomi account Secrets; keeps the existing cached session on failure.health_relatives: Lists therelative_uidand notes of queryable family members.health_latest: Queries the latest sleep, heart rate, and step summaries.health_analyze: Queries 30 days by default, building a personal baseline from the most recent 7 complete days and earlier records; separates unfinished same-day activity, reports missing dates, sync delay, sleep stage completeness, and heart rate sampling quality, and outputs non-diagnostic robust statistics.health_sleep: Queries daily sleep summaries for the last 1 to 30 days, at most one per day.health_heart: Queries daily heart rate statistics for the last 1 to 30 days; does not return all sample points.health_steps: Queries daily step summaries for the last 1 to 30 days, at most one per day.
When querying yourself, omit target or explicitly pass {"target":"self"}. When querying family members, you must pass:
{
"target": "relative",
"relative_uid": "...",
"days": 7
}Trend analysis example:
{
"target": "self",
"days": 30,
"recent_days": 7,
"timezone": "Europe/Berlin"
}health_analyze does not recompute dates already returned by the health API; timezone is only used to identify the current calendar day, marking the current day's steps and daily heart rate as partial and excluding them from the complete-day baseline. Sleep is treated as a completed record based on the wake-up date. When duplicate summaries exist for the same date, the analyzer deterministically selects one by valid measurements, sampling or sleep stage completeness, record time, and stable key. recent_days represents the most recent calendar-day window; dates that are missing or excluded due to insufficient quality are not backfilled by earlier records. The results first return data_quality: missing_dates means the record for that day is missing, and missing_measurements means the record exists but the target value is empty, non-numeric, or negative; both are treated as unknown rather than as 0. The results also report the latest data sync delay, sleep stage completeness, and heart rate sampling quality. Dates with fewer than 50% of the median complete-day sample count are listed in low_sample_dates, and dates lacking a valid sample count are listed in unknown_sample_dates; neither enters the heart rate trend. Trend comparisons use unrounded median, MAD, IQR, and robust z-score, rounding only at output; when samples are insufficient, insufficient_data is returned without forcing a trend conclusion. All comparisons are personal historical summaries and cannot be used for disease diagnosis or medication advice.
Usage boundaries
Only for logging into your own Xiaomi account and querying data of family members you are authorized to access. Do not use it for any purpose that infringes on others' privacy or violates the Xiaomi User Agreement.
Personal data uses POST /app/v1/data/get_fitness_data_by_time. For the China region, the query window is extended by 18 hours on both ends, and records are assigned to dates by their zone_offset; when zone_offset is missing, it falls back to UTC+8. Personal steps records are aggregated per day according to the endpoint's incremental semantics; personal heart sample points are converted to daily statistics; for sleep, on the same day, records that are not naps, have longer duration, and have a newer update time are preferred. Family data uses the daily_report of /app/v1/relatives/*; records on the same day are not summed repeatedly.
MCP responses use a field whitelist and do not return AUTH_TOKEN, passToken, cUserId, serviceToken, ssecurity, or Cookies. Do not commit .dev.vars, .env, wrangler.toml, or .wrangler/.
License
This project is licensed under the GNU General Public License v3.0 (GPL-3.0), consistent with the license of the upstream Misty02600/mi-fitness-python.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Collect Apple Health data from your wearables through the Context app and query it via MCP
Read wearables and lab health data — sleep, activity, workouts, timeseries, lab tests and orders.
MCP server for Withings health data — sleep, activity, heart, and body metrics.
Private Apple Health metrics and workout detail for ChatGPT, Claude, and any MCP client.
Related MCP Servers
- AlicenseCqualityBmaintenanceEnables 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.107MIT
- AlicenseNot gradedqualityBmaintenanceMCP 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.GPL 3.0
- AlicenseNot gradedqualityBmaintenanceEnables AI clients to query and analyze Huawei Health data, including training records, sleep, heart rate, and athletic performance, through 14 MCP tools without third-party servers.1MIT
- FlicenseNot gradedqualityCmaintenanceEnables users to query Polar health data (activity, sleep, recovery, training sessions, heart rate) through MCP with secure authentication, redacted personal info, and bounded responses.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Zhou-Ruichen/mi-health-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server