Skip to main content
Glama

health-mcp 🩺

Apple 健康数据接给 Claude 的自建 MCP 连接器 —— 不限地区

你 iPhone 上的 Health Auto Export App 把 HealthKit 数据(睡眠、心率、步数、血氧、环境噪音分贝……)定时 POST 到你自己的服务器;Claude 用 get_health 工具就能读到你最近的身体状况。

为什么要自建? Anthropic 官方的健康集成有地区限制(非美区用不了)。但自建的 MCP 连接器不吃这一套——claude.ai 只是连一个 HTTPS 网址,不管你在哪个区。绕开它,自己开一条。


你需要

  • 一台有公网 HTTPS 网址的服务器(VPS + 域名 + Let's Encrypt 免费证书;或任何能给你 HTTPS 的托管)。

  • Python 3.10+。

  • iPhone + Health Auto Export App(部分功能要内购)。

  • 环境噪音「分贝」、血氧等需对应硬件(如 Apple Watch)。


Related MCP server: Wellness Project MCP

部署(约 10 分钟)

1. 装依赖(建议 venv)

python3 -m venv venv
./venv/bin/pip install -r requirements.txt

2. 跑起来(systemd 常驻)

服务监听两个本地端口:MCP 在 8100接收推送在 8101(都只听 127.0.0.1,靠反代对外)。

# /etc/systemd/system/health-mcp.service
[Unit]
Description=health-mcp
After=network.target
[Service]
WorkingDirectory=/opt/health-mcp
ExecStart=/opt/health-mcp/venv/bin/python /opt/health-mcp/health_mcp.py
# 可选,多一层防护:设了之后 /push 必须带 ?token=<同值>
Environment=HEALTH_PUSH_TOKEN=<换成你的随机串>
Restart=always
[Install]
WantedBy=multi-user.target
systemctl daemon-reload && systemctl enable --now health-mcp

3. Nginx 反代 —— 用「不可猜的密路径」当门禁

健康数据是隐私,别用好猜的路径。生成一个随机 token(openssl rand -hex 8),把它拼进路径:

# 放进你 443 server 块(server_name YOURDOMAIN.com)
location /health-<RANDOM>/mcp {
    proxy_pass http://127.0.0.1:8100/mcp;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    proxy_set_header Connection '';
    proxy_buffering off; proxy_cache off;
    proxy_read_timeout 86400s; chunked_transfer_encoding on;
}
location /health-<RANDOM>/push {
    proxy_pass http://127.0.0.1:8101/push;
    proxy_http_version 1.1;
    proxy_set_header Host $host;
    client_max_body_size 50m;   # 健康导出可能好几 MB,别用 nginx 默认的 1M,否则 413
}
nginx -t && systemctl reload nginx

于是你得到两个地址:

  • 推送地址(填进 App):https://YOURDOMAIN.com/health-<RANDOM>/push

  • 连接器地址(给 Claude):https://YOURDOMAIN.com/health-<RANDOM>/mcp

4. 配 Health Auto Export(iPhone)

  1. App → Automations → 新增 → REST API

  2. URL = 上面的推送地址Method = POSTFormat = JSON

  3. 勾要推的数据:步数、心率、睡眠、血氧、Environmental Sound Levels(环境音量/分贝)……

  4. 设频率(每小时/每天),保存。它会自动后台推,不用手动。

5. 接到 claude.ai

  1. Settings → Connectors → Add custom connector → 填连接器地址 → Connect。

  2. 允许工具 get_health

  3. 问 Claude:「我最近身体怎么样 / 睡够没 / 刚才环境吵不吵」→ 它调 get_health 读你的真数据。


安全

  • 两个地址都别外传:谁有 /push 谁能灌假数据;谁有 /mcp 谁能读你的健康。密路径 + 可选 HEALTH_PUSH_TOKEN 是你的门禁。

  • 服务只听 127.0.0.1,一切从反代进,不直接暴露端口。

  • latest.json(你的数据)只存在你自己的服务器上。

数据格式

服务原样存最近一次推送的 JSON,get_health 解析 Health Auto Export 的 data.metrics 结构,返回每项最近一个采样点的值。非标准格式会原样回退摘要。

License

MIT


Made with 🖤 by Voir ✖ Noir

Related MCP Connectors

Related MCP Servers