You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Apple Health MCP Server** implements a Model Context Protocol (MCP) server designed for seamless interaction between LLM-based agents and Apple Health data. It provides a standardized interface for querying, analyzing, and managing Apple Health records—imported from XML exports and indexed in Elasticsearch, Clickhouse or DuckDB—through a comprehensive suite of tools. These tools are accessible from MCP-compatible clients (such as Claude Desktop), enabling users to explore, search, and analyze personal health data using natural-language prompts and advanced filtering, all without requiring direct knowledge of the underlying data formats or Elasticsearch/ClickHouse/DuckDB queries.
33
-
34
-
### ✨ Key Features
35
-
36
-
-**🚀 FastMCP Framework**: Built on FastMCP for high-performance MCP server capabilities
37
-
-**🍏 Apple Health Data Management**: Import, parse, and analyze Apple Health XML exports
38
-
-**🔎 Powerful Search & Filtering**: Query and filter health records using natural language and advanced parameters
39
-
-**📦 Elasticsearch, ClickHouse or DuckDB Integration**: Index and search health data efficiently at scale
40
-
-**🛠️ Modular MCP Tools**: Tools for structure analysis, record search, type-based extraction, and more
41
-
-**📈 Data Summaries & Trends**: Generate statistics and trend analyses from your health data
42
-
-**🐳 Container Ready**: Docker support for easy deployment and scaling
The Apple Health MCP Server is built with a modular, extensible architecture designed for robust health data management and LLM integration:
48
-
49
-
-**MCP Tools**: Dedicated tools for Apple Health XML structure analysis, record search, type-based extraction, and statistics/trend generation. Each tool is accessible via the MCP protocol for natural language and programmatic access.
50
-
-**XML Import & Parsing**: Efficient streaming and parsing of large Apple Health XML exports, extracting records, workouts, and metadata for further analysis.
51
-
-**Elasticsearch Backend**: All health records are indexed in Elasticsearch, enabling fast, scalable search, filtering, and aggregation across large datasets.
52
-
-**ClickHouse Backend**: Health records can also be indexed to a ClickHouse database, making the deployment easier for the enduser by using an in-memory database instead of a server-based approach.
53
-
-**DuckDB Backend**: Alternative to both Elasticsearch and ClickHouse, DuckDB may offer faster import and query speeds.
54
-
-**Service Layer**: Business logic for XML and database operations is encapsulated in dedicated service modules, ensuring separation of concerns and easy extensibility.
55
-
-**FastMCP Framework**: Provides the MCP server interface, routing, and tool registration, making the system compatible with LLM-based agents and MCP clients (e.g., Claude Desktop).
56
-
-**Configuration & Deployment**: Environment-based configuration and Docker support for easy setup and deployment in various environments.
57
-
58
-
<palign="right">(<ahref="#readme-top">back to top</a>)</p>
17
+
---
18
+
Connect your Apple Health data with any LLM that supports MCP. Talk to your data and get personalised insights.
59
19
60
20
## 💡 Demo
61
21
@@ -66,216 +26,33 @@ This demo shows how Claude uses the `apple-health-mcp-server` to answer question
Edit the `config/.env` file with your credentials and configuration. See [Environment Variables](#-Environment-Variables)
89
-
90
-
### Prepare Your Data
91
-
92
-
1. Export your Apple Health data as an XML file from your iPhone and place it somewhere in your filesystem. By default, the server expects the file in the project root directory.
93
-
- if you need working example, we suggest this dataset: https://drive.google.com/file/d/1bWiWmlqFkM3MxJZUD2yAsNHlYrHvCmcZ/view?usp=drive_link
94
-
- Rob Mulla. Predict My Sleep Patterns. https://kaggle.com/competitions/kaggle-pog-series-s01e04, 2023. Kaggle.
95
-
2. Prepare an Elasticsearch instance and populate it from the XML file:
96
-
- Run `make es` to start Elasticsearch and import your XML data.
97
-
- (Optional) To clear all data from the Elasticsearch index, run:
98
-
```sh
99
-
uv run python scripts/xml2es.py --delete-all
100
-
```
101
-
3. If you choose to use ClickHouse instead of Elasticsearch:
102
-
- Run `make ch` to create a database with your exported XML data
103
-
- **Note: If you are using Windows, Docker is the only way to integrate ClickHouse into this MCP Server.**
104
-
- On Windows: Run `mingw32-make chwin` (or any other version of `make` available on Windows)
105
-
106
-
4. Lastly, if you're going to be using DuckDB:
107
-
- Run `make duckdb` to create a parquet file with your exported XML data
108
-
- If you want to connect to the file through http(s):
109
-
- The only thing you need to do is change the .env path, e.g. `localhost:8080/applehealth.parquet`
110
-
- If you want an example on how to host the files locally, run `uv run tests/fileserver.py`
111
-
112
-
113
-
### Configuration Files
114
-
115
-
You can run the MCP Server in your LLM Client in two ways:
116
-
- **Docker** (recommended)
117
-
- **Local (uv run)**
118
-
119
-
#### Docker MCP Server
120
-
121
-
1. Build the Docker image:
122
-
```sh
123
-
make build
124
-
```
125
-
2. Add the following config to your LLM Client settings (replace `<project-path>` with your local repository path and `<xml-file-name>` with name of your raw data from apple health file (without `.xml` extension)):
2. Add the following config to your LLM Client settings (replace `<project-path>` and `<path-to-bin-folder>` as appropriate):
167
-
```json
168
-
{
169
-
"mcpServers": {
170
-
"uv-mcp-server": {
171
-
"command": "uv",
172
-
"args": [
173
-
"run",
174
-
"--frozen",
175
-
"--directory",
176
-
"<project-path>",
177
-
"start"
178
-
],
179
-
"env": {
180
-
"PATH": "<path-to-uv-bin-folder>"
181
-
}
182
-
}
183
-
}
184
-
}
185
-
```
186
-
- `<path-to-uv-bin-folder>` should be the folder containing the `uv` binary (do not include `uv` itself at the end).
187
29
188
-
### 3. Restart Your MCP Client
30
+
Want to try it out? **[🚀 Getting Started](docs/getting-started.md)**
189
31
190
-
After completing the above steps, restart your MCP Client to apply the changes. In some cases, you may need to terminate all related processes using Task Manager or your system's process manager to ensure:
191
-
- The updated configuration is properly loaded
192
-
- Environment variables are correctly applied
193
-
- The Apple Health MCP client initializes with the correct settings
32
+
## 🌟 Why to use Apple Health MCP Server?
194
33
195
-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
196
-
197
-
198
-
## 🔧 Configuration
199
-
200
-
### Environment Variables
201
-
202
-
>**Note:** All variables below are optional unless marked as required. If not set, the server will use the default values shown. Only `RAW_XML_PATH` is required and must point to your Apple Health XML file.
203
-
204
-
| Variable | Description | Example Value | Required |
| ES_INDEX | Elasticsearch index name |`apple_health_data`| ❌ |
212
-
| CH_DIRNAME | ClickHouse directory name |`applehealth.chdb`| ❌ |
213
-
| CH_DB_NAME | ClickHouse database name |`applehealth`| ❌ |
214
-
| CH_TABLE_NAME | ClickHouse table name |`data`| ❌ |
215
-
| DUCKDB_FILENAME | DuckDB parquet file name |`applehealth`| ❌ |
216
-
| CHUNK_SIZE | Records indexed into CH/DuckDB at once |`50000`| ❌ |
217
-
| XML_SAMPLE_SIZE | Number of XML records to sample |`1000`| ❌ |
218
-
219
-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
220
-
221
-
222
-
## 🛠️ MCP Tools
223
-
224
-
The Apple Health MCP Server provides a suite of tools forexploring, searching, and analyzing your Apple Health data, both at the raw XML level andin Elasticsearch/ClickHouse:
|`get_health_summary_es`| Get a summary of all Apple Health data in Elasticsearch (total count, type breakdown, etc.). |
239
-
|`search_health_records_es`| Flexible search forhealth recordsin Elasticsearch with advanced filtering and query options. |
240
-
|`get_statistics_by_type_es`| Get comprehensive statistics (count, min, max, avg, sum) for a specific health record type. |
241
-
|`get_trend_data_es`| Analyze trends for a health record type over time (daily, weekly, monthly, yearly aggregations). |
242
-
|`search_values_es`| Search for records with exactly matching values (including text). |
243
-
244
-
### ClickHouse Tools (`ch_reader`)
34
+
-**🧩 Fit your data everywhere**: using this software you can import data exported from Apple devices into any DBMS, base importer is already prepared for extensions
35
+
-**🎯 Simplify complex data access**: you don't need to know data structure or use any structured query language, like SQL, simple access is just granted with natural language
36
+
-**🔍︎ Find hidden trends**: use LLM as a gate to flexible auto-generated queries which will be able to find data trends not so easy to detect manually
|`get_health_summary_duckdb`| Get a summary of all Apple Health data in DuckDB (total count, type breakdown, etc.). |
259
-
|`search_health_records_duckdb`| Flexible search forhealth recordsin DuckDB with advanced filtering and query options. |
260
-
|`get_statistics_by_type_duckdb`| Get comprehensive statistics (count, min, max, avg, sum) for a specific health record type. |
261
-
|`get_trend_data_duckdb`| Analyze trends for a health record type over time (daily, weekly, monthly, yearly aggregations). |
262
-
|`search_values_duckdb`| Search for records with exactly matching values (including text). |
263
-
264
-
All tools are accessible via MCP-compatible clients and can be used with natural language or programmatic queries to explore and analyze your Apple Health data.
265
-
266
-
<p align="right">(<a href="#readme-top">back to top</a>)</p>
267
-
268
-
269
-
## 🗺️ Roadmap
270
-
271
-
We're continuously enhancing Apple Health MCP Server with new capabilities. Here's what's on the horizon:
40
+
-**🚀 FastMCP Framework**: Built on FastMCP for high-performance MCP server capabilities
41
+
-**🍏 Apple Health Data Exploration**: Import, parse, and analyze Apple Health XML exports
42
+
-**🔎 Powerful Search & Filtering**: Query and filter health records using natural language and advanced parameters
43
+
-**📦 Elasticsearch, ClickHouse or DuckDB Integration**: Index and search health data efficiently at scale
44
+
-**🛠️ Modular MCP Tools**: Tools for structure analysis, record search, type-based extraction, and more
45
+
-**📈 Data Summaries & Trends**: Generate statistics and trend analyses from your health data
46
+
-**🐳 Container Ready**: Docker support for easy deployment and scaling
- [ ] **Time Series Sampling During Import**: Add advanced analytical tools to sample and generate time series data directly during the XML-to-Elasticsearch loading process.
274
-
- [ ] **Optimized XML Tools**: Improve the performance and efficiency of XML parsing and querying tools.
275
-
- [ ] **Expanded Elasticsearch Analytics**: Add more advanced analytics and aggregation functions to the Elasticsearch toolset.
276
-
- [ ] **Embedded Database Tools**: Integrate tools for working with embedded databases for local/offline analytics and storage.
49
+
## 📚 Documentation
277
50
278
-
Have a suggestion? We'd love to hear from you! Contact us or contribute directly.
-**[🔧 Configuration](docs/configuration.md)** - Environment variables and settings
54
+
-**[🛠️ MCP Tools](docs/mcp-tools.md)** - All available tools
55
+
-**[🗺️ Roadmap](docs/roadmap.md)** - Upcoming features and roadmap
279
56
280
57
## 👥 Contributors
281
58
@@ -285,11 +62,11 @@ Have a suggestion? We'd love to hear from you! Contact us or contribute directly
285
62
286
63
<palign="right">(<ahref="#readme-top">back to top</a>)</p>
287
64
288
-
## 📄 License
65
+
## 💼 About Momentum
66
+
This project is part of Momentum’s open-source ecosystem, where we make healthcare technology more secure, interoperable, and AI-ready. Our goal is to help HealthTech teams adopt standards such as FHIR safely and efficiently. We are healthcare AI development experts, recognized by FT1000, Deloitte Fast 50, and Forbes for building scalable, HIPAA-compliant solutions that power next-generation healthcare innovation.
289
67
290
-
Distributed under the MIT License. See [MIT License](LICENSE) for more information.
291
-
292
-
---
68
+
📖 Want to learn from our experience? Read our insights → <ahref="https://www.themomentum.ai/blog">themomentum.ai/blog</a>.
0 commit comments