
本地优先的Apple Health MCP服务器。让AI助手从本地导出中回答关于您的睡眠、锻炼、活动和心率数据的问题。
概览
一个MCP(模型上下文协议)服务器,用于使用SQL查询苹果健康数据。采用DuckDB构建,实现快速高效的健康数据分析。 该项目目前依赖Eric Wolter开发的Simple Health Export CSV应用。有关如何最佳使用该应用的更多信息,请参见下方“导出数据”。目前这是我能找到的最简单且可靠地将Apple Health数据导出成CSV格式的方法。如果您有更好的导入方法,请提交问题。 - : 你的MCP客户端将你的问题转换为数据库查询 - : 直接对你的Apple Health数据进行SQL查询 - : 生成每周/每月健康摘要 - : 带可配置时间窗口的懒惰加载 - : 带TTL的查询结果缓存 无需安装!通过 Claude Desktop 或其他 MCP 客户端直接与 npx 一起使用。 添加到你的Claude桌面配置中(~/Library/Application Support/Claude/claude_desktop_config。
概述(AI 翻译)
使用 SQL 和 DuckDB 从 MCP 客户端查询 Apple Health 数据。服务器运行 本地,按需读取CSV导出,并提供模式发现工具, 分析性质询和健康摘要。
要求
- Node.js 22及以上
- Apple Health CSV 导出文件,创建于 简单健康导出CSV
原生的Apple Health export.xml格式目前不支持。
配置一个MCP客户端
对于 Claude Desktop,请添加以下内容
~/Library/Application Support/Claude/claude_desktop_config.json:
更改配置后重启客户端。其他MCP客户端可以使用
相同的命令、参数、环境和stdio传输。
环境变量
| 变量 | 必需 | 默认 | 目的 |
|---|---|---|---|
HEALTH_DATA_DIR |
是的 | — | 包含导出CSV文件的目录 |
MAX_MEMORY_MB |
否 | 2048 |
DuckDB 内存限制(兆字节) |
CACHE_SIZE |
无 | 100 |
缓存查询结果的最大数量 |
导出健康数据
- 在你的iPhone上安装并打开Simple Health Export CSV。
- 选择全部,选择导出的时间范围。
- 将归档传输到运行MCP客户端的计算机。
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Apple Health MCP Server
Query Apple Health data from an MCP client using SQL and DuckDB. The server runs locally, reads CSV exports on demand, and provides tools for schema discovery, analytical queries, and health summaries.
Requirements
- Node.js 22 or newer
- An Apple Health CSV export created with Simple Health Export CSV
The native Apple Health export.xml format is not currently supported.
Configure an MCP client
For Claude Desktop, add the following to
~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"apple-health": {
"command": "npx",
"args": ["-y", "@neiltron/apple-health-mcp"],
"env": {
"HEALTH_DATA_DIR": "/path/to/your/unzipped/health-export"
}
}
}
}
Restart the client after changing its configuration. Other MCP clients can use
the same command, arguments, environment, and stdio transport.
Environment variables
| Variable | Required | Default | Purpose |
|---|---|---|---|
HEALTH_DATA_DIR |
Yes | — | Directory containing the exported CSV files |
MAX_MEMORY_MB |
No | 2048 |
DuckDB memory limit in megabytes |
CACHE_SIZE |
No | 100 |
Maximum number of cached query results |
Export health data
- Install and open Simple Health Export CSV on your iPhone.
- Select All and choose the time range to export.
- Transfer the archive to the computer running your MCP client.
- Unzip it and set
HEALTH_DATA_DIRto the resulting directory.
The server reads the files in place. It does not upload the export or make network requests, although query results returned to your MCP client may be sent to that client’s configured model provider.
Tools
| Tool | Purpose |
|---|---|
health_schema |
Discover table names, columns, units, and sample rows |
health_query |
Run one DuckDB SELECT-family analytical statement with JSON, CSV, or summary output |
health_report |
Generate a weekly, monthly, or custom health summary |
Start with health_schema; table names depend on the files in your export.
See Querying Apple Health data
for the data model and working examples.
health_query accepts one DuckDB analytical statement. See
Query safeguards
for supported statements and restricted operations.
Query safeguards
The server limits DuckDB file access to HEALTH_DATA_DIR. It also disables
network access and temporary disk storage, and it locks the database settings.
安装
npx -y @neiltron/apple-health-mcp配置
{
"mcpServers": {
"apple-health": {
"command": "npx",
"args": ["-y", "@neiltron/apple-health-mcp"],
"env": {
"HEALTH_DATA_DIR": "/path/to/your/unzipped/health-export"
}
}
}
}