华为健康数据MCP服务器

通过Model Context Protocol将华为可穿戴设备的健康数据(心率、睡眠、血氧等)接入AI代理的开源服务,适用于OpenClaw、Claude Desktop等MCP兼容智能体。

  • by SabaTech-dev
  • Python
  • 混合部署
  • 45 星标
  • 更新于
在 GitHub 查看 llllJokerllll/huawei-health-mcp

使用说明

🏥 Huawei Health MCP Server

Connect your Huawei Watch health data to AI agents via Model Context Protocol

The first open-source MCP Server for Huawei Health Kit, enabling AI agents (OpenClaw, Claude Desktop, etc.) to read and analyze health data from any Huawei wearable device.

🎯 Features

  • 30+ health data types — Heart rate, sleep, SpO2, stress, temperature, activity, ECG, and more
  • REST API (Cloud) — Server-side data access, no phone dependency after OAuth
  • MCP Protocol — Plug into any MCP-compatible AI agent
  • Real-time capable — Continuous heart rate, SpO2 monitoring
  • Privacy-first — Your data, your server, your control

📊 Supported Data

Category Metrics
Cardiovascular Heart rate (instant, continuous, resting, exercise), ECG, arrhythmia alerts
Sleep Phases (deep, light, REM), naps, apnea detection, quality score
Oxygenation Continuous SpO2, sleep SpO2
Stress Stress level, trends, breathing exercises
Temperature Skin temperature (day + night)
Activity Steps, distance, calories, Activity Rings, 100+ workout modes
Women's Health Period, ovulation, fertile window
Emotional Mood state, emotional wellbeing (TruSense)
Advanced Sports Golf, free diving, trail running, cycling power, running form

🏗️ Architecture

Huawei Watch GT 5 Pro
        ↓
Huawei Health (Android)
        ↓
Huawei Health Kit REST API (Cloud)
        ↓
┌─────────────────────┐
│   Backend API       │  ← OAuth, data sync, storage
│   (FastAPI)         │
└──────────┬──────────┘
           ↓
┌─────────────────────┐
│   MCP Server        │  ← Tools for AI agents
│   (TypeScript)      │
└──────────┬──────────┘
           ↓
┌─────────────────────┐
│   AI Agents         │  ← OpenClaw, Claude Desktop, etc.
│   (OpenClaw/LLM)    │
└─────────────────────┘

📁 Project Structure

huawei-health-mcp/
├── android-app/          # Android OAuth bridge (minimal)
│   └── app/              # Kotlin app for Health Kit authorization
├── mcp-server/           # MCP Server (TypeScript/Node.js)
│   └── src/              # Tools, types, client
├── api/                  # Backend API (Python/FastAPI)
│   └── src/              # OAuth, data sync, endpoints
├── docs/                 # Documentation
│   ├── setup.md          # Setup guide
│   └── api-reference.md  # MCP tools reference
└── .github/workflows/    # CI/CD

🚀 Quick Start

Prerequisites

  • Huawei Developer account (developer.huawei.com)
  • Health Kit enabled for your project
  • Node.js 18+
  • Python 3.11+

Backend API Setup

  1. Clone and setup:
git clone https://github.com/sabatech-dev/huawei-health-mcp.git
cd huawei-health-mcp
  1. Configure environment variables:
cd api
cp .env.example .env
# Edit .env with your Huawei OAuth credentials
  1. Install dependencies and run:
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn src.main:app --reload

The API will be available at http://localhost:8080 (check http://localhost:8080/api/v1/health)

Docker Deployment

# From project root
docker-compose up -d

MCP Server Setup

cd mcp-server
npm install        # use NODE_ENV=development to include devDependencies
npm run build

Configure the backend connection via environment variables:

  • API_URL — backend base URL (default http://localhost:8081)
  • API_TOKEN — bearer token if the backend enforces API_TOKEN auth

Example claude_desktop_config.json / OpenClaw MCP config:

{
  "mcpServers": {
    "huawei-health": {
      "command": "node",
      "args": ["/path/to/mcp-server/dist/index.js"],
      "env": { "API_URL": "http://localhost:8081" }
    }
  }
}

Streamable HTTP transport (optional)

Besides stdio (the default), the MCP server exposes a Streamable HTTP endpoint per the MCP spec (POST/GET/DELETE /mcp, SSE responses, sessions via the mcp-session-id header). Enable it with MCP_HTTP=1:

cd mcp-server
npm run build
MCP_HTTP=1 MCP_HTTP_PORT=3001 node dist/index.js

Point an MCP HTTP client at http://127.0.0.1:3001/mcp. Extra env vars: MCP_HTTP_HOST (default 127.0.0.1), MCP_HTTP_PORT (default 3001), LOG_LEVEL (debug|info|warn|error).

MCP Tools

Tool Description
get_heart_rate Get current and historical heart rate data
get_sleep_data Get sleep analysis (phases, quality, duration)
get_spo2 Get blood oxygen saturation
get_steps Get daily step count and distance
get_stress Get stress levels and trends
get_temperature Get skin temperature readings
get_health_summary Get comprehensive daily/weekly health summary
get_workout_history Get exercise and workout data
get_ecg Get ECG analysis results
get_auth_status Check Huawei API authentication status

🔐 Security

  • All data stays on your server
  • OAuth 2.0 authorization flow (authorization code + refresh, bounded token-endpoint timeouts)
  • Outbound Huawei API calls: rate limited, with bounded retries on 429/5xx
  • No third-party data storage
  • User consent required for each data type

📋 License

Apache-2.0 — Free and open source.

🤝 Contributing

Contributions welcome! This is a new project. See CONTRIBUTING.md for guidelines.

🙏 Credits

Built with ❤️ by SabaTech Industries — Powered by OpenClaw


✅ Current Status

  • ✅ Backend API (FastAPI) - Fully implemented with all endpoints
  • ✅ MCP Server (TypeScript) - All 9 tools defined, compiles successfully
  • ✅ Docker Support - Multi-stage build, non-root runtime, healthcheck
  • ✅ Test Suite - 60 tests passing, 86% coverage on api/src (pytest --cov)
  • ✅ MCP Compliance - Audited against the MCP spec: see docs/mcp-compliance.md
  • ⏳ Huawei Developer Verification - Pending (can't test real API yet)
  • ⏳ Android OAuth Bridge - Coming soon

Note: While waiting for Huawei developer account verification, the full infrastructure is ready. Once verified, just add credentials to .env and the system will work with real Huawei Health Kit API.

Huawei Developer Project: MyHealthWatch (ID: 101653523863750125)