Skip to main content
Glama
wusaki0723
by wusaki0723

mi-health-mcp

Project Introduction

mi-health-mcp exposes Xiaomi Sports Health family member data, including sleep, heart rate, and steps, to LLM clients such as RikkaHub via the MCP protocol. The service runs on Cloudflare Workers, requiring no self-hosted server, and can be used within Cloudflare's free tier. This project is a rewrite of the interface reverse-engineering work from Misty02600/mi-fitness-python into a Cloudflare Worker + MCP service. Thanks to the upstream project.

Related MCP server: boyuan-health-bridge

One-Click Deploy

Deploy to Cloudflare

The deployment flow requires binding Cloudflare KV. If the button flow prompts you to create or select a KV namespace, follow the guidance and make sure the binding is named MI_HEALTH_KV.

Manual Deployment When the Button Doesn't Work

Requires Node.js 20 or higher, and a Cloudflare account.

git clone https://github.com/wusaki0723/mi-health-mcp.git
cd mi-health-mcp
npm install
npx wrangler login
npx wrangler kv namespace create MI_HEALTH_KV

Fill the namespace ID output by the command into wrangler.toml, replacing your-kv-namespace-id. Then set the access token and deploy:

npx wrangler secret put AUTH_TOKEN
npx wrangler deploy

Use a long random string you generate yourself for the AUTH_TOKEN value. Do not write it into source code, wrangler.toml, or Git.

Post-Deployment Configuration

  1. Create a KV namespace:

    npx wrangler kv namespace create MI_HEALTH_KV
  2. Fill the namespace ID output by the command into [[kv_namespaces]] in wrangler.toml, replacing your-kv-namespace-id, then redeploy. When using one-click deployment, you can also create and bind KV by following the guidance in the button flow.

  3. Interactively set the MCP authentication token. Generate a long random string yourself for the token:

    npx wrangler secret put AUTH_TOKEN
  4. Redeploy when configuration changes:

    npx wrangler deploy

The KV binding name must remain MI_HEALTH_KV.

Client Configuration

In RikkaHub, open "Settings > MCP > New Connection > Streamable HTTP" and fill in:

  • URL: https://<your-domain>/mcp

  • Custom Header: Authorization: Bearer <your token>

The <your token> must exactly match the AUTH_TOKEN set during deployment.

Usage Flow

  1. The client first calls health_login_start to obtain loginUrl.

  2. Use any QR code tool to render loginUrl into a QR code.

  3. Scan the QR code with the Xiaomi Sports Health App and confirm the login.

  4. The client polls health_login_poll until it returns success.

  5. After successful login, use health_latest, health_sleep, health_heart, or health_steps to query data.

The Worker does not generate QR code images. When querying, it dynamically reads the family member list and uses the first entry; user IDs are not hardcoded in the code.

Usage Boundaries

For logging into your own Xiaomi account and querying family member data you are authorized to access. Do not use it for any purpose that infringes on others' privacy or violates Xiaomi's user agreement.

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.

Related MCP Connectors

Related MCP Servers

  • A
    license
    C
    quality
    C
    maintenance
    Enables 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.
    10
    12
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables LLM clients to query Xiaomi Mi Fitness authorized family members' sleep, heart rate, and step data via MCP after QR-code login, deployable on Cloudflare Workers.
    GPL 3.0