本地健康数据,AI 智能分析
简介
通过 MCP 将 Apple Health 导出数据接入 AI 代理,实现本地隐私安全的趋势分析与 SQL 查询,无需云端上传健康记录。
原始描述
Connect agents to Apple Health exports with MCP setup, schema validation, and privacy-safe analysis.
通过你的 Agent 添加
安装目录:apple-health/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。
点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。
或者手动安装
包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可;
目录名不用换,也不要把包直接解压到 skills 根目录。
技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。
中文使用说明 来自收录源
核心用法
Apple Health 技能是一种基于 MCP(Model Context Protocol)的桥接方案,让 AI 代理能够读取并分析 Apple Health 的 CSV 导出数据。它并非直接调用 HealthKit API,而是通过处理用户从 iPhone 导出的结构化数据文件(HKQuantityTypeIdentifier*.csv、HKCategoryTypeIdentifier*.csv、HKWorkoutActivityType*.csv),在本地环境中执行 SQL 查询和趋势报告。
工作流程分为四个阶段:首先确认用户采用 csv-export 模式;其次验证本地导出文件夹的有效性(文件存在且非空);接着运行运行时预检(Node.js LTS 版本、DuckDB 依赖、绝对路径配置);最后配置 MCP 服务器并执行模式发现与日期限定的查询分析。
显著优点
- 隐私优先架构:健康数据完全留在本地机器,仅 npm 包安装请求和可选的 App Store 流量会离开设备,无强制云端同步。
- 结构化查询能力:基于 DuckDB 的 SQL 分析支持复杂趋势计算、滚动窗口对比(7天/30天/90天)和多维度健康指标关联。
- 明确的信任边界:清晰区分"导出数据"与"实时 API",避免用户对数据时效性的误解。
- 可复现的查询日志:
query-log.md记录已知良好的 SQL 模式和输出模板,便于跨会话复用。
潜在局限
- 数据时效性依赖人工导出:无法获取实时或当天数据,需用户定期从 iPhone 重新导出 CSV, stale 数据可能导致过时结论。
- Node.js 运行时敏感:DuckDB 原生模块对 Node 版本要求严格,非 LTS 版本(如 19、21)易引发启动失败。
- 第三方工具依赖:核心功能依赖
@neiltron/apple-health-mcp包及其维护状态,若作者停更可能存在兼容性风险。 - 无原生 iOS 集成:无法直接读取 iCloud Health 或绕过 Apple 权限提示,导出步骤对非技术用户存在门槛。
适合人群
- 注重隐私、不愿将健康数据上传至第三方云服务的用户
- 具备基础技术能力、能够完成 iPhone 导出和本地 Node 环境配置的用户
- 需要定期生成健康趋势报告(如睡眠、运动、心率)进行自我量化分析的爱好者
- 开发者在本地构建 HealthKit 相关原型时的数据调试场景
常规风险
- 路径配置错误:相对路径或未验证的
HEALTH_DATA_DIR会导致 MCP 服务器启动成功但返回空数据,造成"假阴性"。 - 无界查询性能问题:在未限定日期范围的情况下扫描大型导出文件,可能导致分析缓慢和输出噪音。
- 过时数据误读:若未检查
memory.md中的最后导出时间戳,可能基于陈旧数据给出"今日"建议。 - 供应链信任:npm 包的任何恶意更新都可能影响本地数据安全,建议锁定版本并审计依赖。
技能正文
name: Apple Health slug: apple-health version: 1.0.0 homepage: https://clawic.com/skills/apple-health description: Connect agents to Apple Health exports with MCP setup, schema validation, and privacy-safe analysis. changelog: Initial release with Apple Health MCP integration workflow and guarded query patterns. metadata: {"clawdbot":{"emoji":"❤️","requires":{"bins":["node","npx"],"env":["HEALTH_DATA_DIR"]},"install":[{"id":"npm","kind":"npm","package":"@neiltron/apple-health-mcp","bins":["apple-health-mcp"],"label":"Install Apple Health MCP Server (npm)"}],"os":["darwin","linux","win32"]}}
Setup
On first use, read setup.md for integration guidelines.
When to Use
User wants agents to read Apple Health data for trends, summaries, or SQL analysis. Agent handles export validation, MCP server wiring, and safe query/report flows without exposing private health records.
Architecture
Memory lives in ~/apple-health/. See memory-template.md for setup.
~/apple-health/
|-- memory.md # Status, client integration state, latest export path
|-- integrations.md # Connected MCP clients and validation notes
|-- query-log.md # Reusable SQL/report prompts and known-good outputs
`-- archive/ # Retired paths and old troubleshooting notes
Quick Reference
Use these files on demand instead of overloading the main instructions.
| Topic | File |
|---|---|
| Setup process | setup.md |
| Memory template | memory-template.md |
| MCP client wiring | mcp-config.md |
| Query recipes | query-recipes.md |
| Fallback CLI paths | fallback-cli.md |
Core Rules
1. Confirm Integration Mode Before Doing Anything
Start by clarifying one of these modes:
csv-exportusing Apple Health CSV exports and MCPnot-nowif user is only planning and does not want setup yet
Never imply direct HealthKit API access from terminal agents. This skill works from exported data.
2. Validate Local Export Before MCP Wiring
Require a real export folder before configuration:
- Must exist locally and be readable
- Must include files matching
HKQuantityTypeIdentifier*.csv,HKCategoryTypeIdentifier*.csv, orHKWorkoutActivityType*.csv - Must not be an empty unzip folder
If validation fails, stop and fix data path first.
3. Run Runtime Preflight Before MCP Configuration
Before wiring MCP, verify runtime:
node -vshould be an LTS line (18, 20, or 22)- If
npx @neiltron/apple-health-mcpfails with missingduckdb.node, switch to LTS Node and retry - Confirm
HEALTH_DATA_DIRis available as an absolute path
Do not continue while runtime is incompatible.
4. Configure MCP With Explicit Path and Command
Use the MCP server command from mcp-config.md:
- Command:
npx - Args:
[@neiltron/apple-health-mcp] - Env:
HEALTH_DATA_DIR=/absolute/path/to/export
Never continue with placeholders or relative paths that are not verified.
5. Schema First, Then Queries
First run schema discovery (health_schema) and map available tables.
Only then run health_query or health_report.
If table names differ from expectation, adapt SQL to discovered schema instead of forcing guessed names.
6. Use Date-Bounded Queries By Default
Every analytical query should include time bounds and clear units.
Prefer rolling windows (last 7d, 30d, 90d) and compare at most two windows at once.
Avoid unbounded full-history scans unless user explicitly asks.
7. Track Data Freshness and Refresh Points
Log last export timestamp in memory and warn when data is stale. If user needs current-day insights, request a new iPhone export before claiming "latest" trends.
Common Traps
- Assuming live HealthKit access from CLI agents -> setup fails because only exported data is available
- Using wrong export path in MCP env -> server starts but returns no data
- Running SQL before schema discovery -> queries fail on wrong table names
- Unbounded queries on large exports -> slow analysis and noisy output
- Reporting "today" metrics from stale export -> inaccurate recommendations
- Running MCP package on non-LTS Node -> DuckDB native module errors can break startup
External Endpoints
| Endpoint | Data Sent | Purpose |
|---|---|---|
| https://registry.npmjs.org | Package install metadata only | Download MCP server package |
| https://raw.githubusercontent.com | Public markdown only | Read validated fallback skill docs |
| https://apps.apple.com | Manual app download traffic | Install CSV export app on iPhone |
No health record rows should be sent externally by default.
Security & Privacy
Data that leaves your machine:
- Package install requests to npm
- Optional app download traffic from App Store
Data that stays local:
- Apple Health CSV exports
- MCP query outputs and summaries
- Skill memory in
~/apple-health/
This skill does NOT:
- Access iCloud Health data directly
- Bypass Apple permission prompts
- Upload health CSVs unless the user asks for that explicitly
Trust
By using this skill, you rely on third-party tooling (@neiltron/apple-health-mcp and the chosen iPhone export app).
Only install and run if you trust those tools.
Related Skills
Install with clawhub install <slug> if user confirms:
health- General health guidance boundaries and framingios- iOS-specific setup and platform troubleshootingsleep- Sleep trend interpretation workflowsapi- Reliable API and integration debugging habitsswift- HealthKit-side implementation context when app code is involved
Feedback
- If useful:
clawhub star apple-health - Stay updated:
clawhub sync
正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。