The Apple Health MCP Server is a robust tool for managing, searching, and analyzing Apple Health data from XML exports through natural language queries and LLM-based agents.
Core Capabilities:
Data Import & Indexing: Efficiently imports and parses Apple Health XML exports, indexing them into Elasticsearch for scalable storage and retrieval
Natural Language Querying: Interact with health data using natural language prompts without needing to know underlying data formats or Elasticsearch queries
Advanced Search & Filtering: Perform flexible searches using parameters like date ranges, value ranges, record types, and source devices
Statistical Analysis & Trends: Generate comprehensive statistics (min, max, average, sum) and analyze temporal trends with daily, weekly, monthly, or yearly aggregations
Data Summaries: Provide overviews of all indexed data with total record counts and breakdowns by record types and data sources
XML Analysis Tools: Analyze raw XML structure, search XML content directly, and extract type-specific records
LLM Integration: Built on FastMCP framework for seamless integration with MCP clients like Claude Desktop
Docker Support: Container-ready for easy deployment and scaling with extensive configuration via environment variables
Processes Apple Health data exported from iPhones, enabling search, analysis, and management of personal health records, workouts, and other health metrics.
Indexes and searches Apple Health data, providing advanced querying, filtering, and aggregation capabilities for efficient health data analytics and trend analysis.
Parses and analyzes Apple Health XML exports, extracting structured health data for search, filtering, and statistical analysis.
📋 Table of Contents
- 🔍 About
- 💡 Demo
- 🚀 Getting Started
- 📝 Usage
- 🔧 Configuration
- 🐳 Docker Setup
- 🛠️ MCP Tools
- 🗺️ Roadmap
- 👥 Contributors
- 📄 License
🔍 About The Project
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.
✨ Key Features
- 🚀 FastMCP Framework: Built on FastMCP for high-performance MCP server capabilities
- 🍏 Apple Health Data Management: Import, parse, and analyze Apple Health XML exports
- 🔎 Powerful Search & Filtering: Query and filter health records using natural language and advanced parameters
- 📦 Elasticsearch, ClickHouse or DuckDB Integration: Index and search health data efficiently at scale
- 🛠️ Modular MCP Tools: Tools for structure analysis, record search, type-based extraction, and more
- 📈 Data Summaries & Trends: Generate statistics and trend analyses from your health data
- 🐳 Container Ready: Docker support for easy deployment and scaling
- 🔧 Configurable: Extensive
.env
-based configuration options
🏗️ Architecture
The Apple Health MCP Server is built with a modular, extensible architecture designed for robust health data management and LLM integration:
- 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.
- XML Import & Parsing: Efficient streaming and parsing of large Apple Health XML exports, extracting records, workouts, and metadata for further analysis.
- Elasticsearch Backend: All health records are indexed in Elasticsearch, enabling fast, scalable search, filtering, and aggregation across large datasets.
- 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.
- DuckDB Backend: Alternative to both Elasticsearch and ClickHouse, DuckDB may offer faster import and query speeds.
- Service Layer: Business logic for XML and database operations is encapsulated in dedicated service modules, ensuring separation of concerns and easy extensibility.
- 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).
- Configuration & Deployment: Environment-based configuration and Docker support for easy setup and deployment in various environments.
💡 Demo
This demo shows how Claude uses the apple-health-mcp-server
to answer questions about your data. Example prompts from the demo:
- I would like you to help me analyze my Apple Health data. Let's start by analyzing the data types - check what data is available and how much of it there is.
- What can you tell me about my activity in the last week? How did my daily statistics look?
- Please also summarise my running workouts in July and June. Do you see anything interesting?
https://github.com/user-attachments/assets/93ddbfb9-6da9-42c1-9872-815abce7e918
🚀 Getting Started
Follow these steps to set up Apple Health MCP Server in your environment.
Prerequisites
- Docker (recommended) or uv + docker: For dependency management 👉 uv Installation Guide
- Clone the repository:
- Set up environment variables:Edit the
config/.env
file with your credentials and configuration. See Environment Variables
Prepare Your Data
- 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.
- if you need working example, we suggest this dataset: https://drive.google.com/file/d/1bWiWmlqFkM3MxJZUD2yAsNHlYrHvCmcZ/view?usp=drive_link
- Rob Mulla. Predict My Sleep Patterns. https://kaggle.com/competitions/kaggle-pog-series-s01e04, 2023. Kaggle.
- Prepare an Elasticsearch instance and populate it from the XML file:
- Run
make es
to start Elasticsearch and import your XML data. - (Optional) To clear all data from the Elasticsearch index, run:
- Run
- If you choose to use ClickHouse instead of Elasticsearch:
- Run
make ch
to create a database with your exported XML data - Note: If you are using Windows, Docker is the only way to integrate ClickHouse into this MCP Server.
- On Windows: Run
mingw32-make chwin
(or any other version ofmake
available on Windows)
- Run
- Lastly, if you're going to be using DuckDB:
- Run
make duckdb
to create a parquet file with your exported XML data
- Run
Configuration Files
You can run the MCP Server in your LLM Client in two ways:
- Docker (recommended)
- Local (uv run)
Docker MCP Server
- Build the Docker image:
- 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)):
Local uv MCP Server
- Get the path to your
uv
binary:- On Windows:
- On MacOS/Linux:
- On Windows:
- Add the following config to your LLM Client settings (replace
<project-path>
and<path-to-bin-folder>
as appropriate):<path-to-uv-bin-folder>
should be the folder containing theuv
binary (do not includeuv
itself at the end).
3. Restart Your MCP Client
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:
- The updated configuration is properly loaded
- Environment variables are correctly applied
- The Apple Health MCP client initializes with the correct settings
🔧 Configuration
Environment Variables
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.
Variable | Description | Example Value | Required |
---|---|---|---|
RAW_XML_PATH | Path to the Apple Health XML file | raw.xml | ✅ |
ES_HOST | Elasticsearch host | localhost | ❌ |
ES_PORT | Elasticsearch port | 9200 | ❌ |
ES_USER | Elasticsearch username | elastic | ❌ |
ES_PASSWORD | Elasticsearch password | elastic | ❌ |
ES_INDEX | Elasticsearch index name | apple_health_data | ❌ |
CH_DIRNAME | ClickHouse directory name | applehealth.chdb | ❌ |
CH_DB_NAME | ClickHouse database name | applehealth | ❌ |
CH_TABLE_NAME | ClickHouse table name | data | ❌ |
DUCKDB_FILENAME | DuckDB parquet file name | applehealth | ❌ |
CHUNK_SIZE | Records indexed into CH/DuckDB at once | 50000 | ❌ |
XML_SAMPLE_SIZE | Number of XML records to sample | 1000 | ❌ |
🛠️ MCP Tools
The Apple Health MCP Server provides a suite of tools for exploring, searching, and analyzing your Apple Health data, both at the raw XML level and in Elasticsearch/ClickHouse:
XML Tools (xml_reader
)
Tool | Description |
---|---|
get_xml_structure | Analyze the structure and metadata of your Apple Health XML export (file size, tags, types). |
search_xml_content | Search for specific content in the XML file (by attribute value, device, type, etc.). |
get_xml_by_type | Extract all records of a specific health record type from the XML file. |
Elasticsearch Tools (es_reader
)
Tool | Description |
---|---|
get_health_summary_es | Get a summary of all Apple Health data in Elasticsearch (total count, type breakdown, etc.). |
search_health_records_es | Flexible search for health records in Elasticsearch with advanced filtering and query options. |
get_statistics_by_type_es | Get comprehensive statistics (count, min, max, avg, sum) for a specific health record type. |
get_trend_data_es | Analyze trends for a health record type over time (daily, weekly, monthly, yearly aggregations). |
ClickHouse Tools (ch_reader
)
Tool | Description |
---|---|
get_health_summary_ch | Get a summary of all Apple Health data in ClickHouse (total count, type breakdown, etc.). |
search_health_records_ch | Flexible search for health records in ClickHouse with advanced filtering and query options. |
get_statistics_by_type_ch | Get comprehensive statistics (count, min, max, avg, sum) for a specific health record type. |
get_trend_data_ch | Analyze trends for a health record type over time (daily, weekly, monthly, yearly aggregations). |
DuckDB Tools (duckdb_reader
)
Tool | Description |
---|---|
get_health_summary_duckdb | Get a summary of all Apple Health data in DuckDB (total count, type breakdown, etc.). |
search_health_records_duckdb | Flexible search for health records in DuckDB with advanced filtering and query options. |
get_statistics_by_type_duckdb | Get comprehensive statistics (count, min, max, avg, sum) for a specific health record type. |
get_trend_data_duckdb | Analyze trends for a health record type over time (daily, weekly, monthly, yearly aggregations). |
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.
🗺️ Roadmap
We're continuously enhancing Apple Health MCP Server with new capabilities. Here's what's on the horizon:
- Time Series Sampling During Import: Add advanced analytical tools to sample and generate time series data directly during the XML-to-Elasticsearch loading process.
- Optimized XML Tools: Improve the performance and efficiency of XML parsing and querying tools.
- Expanded Elasticsearch Analytics: Add more advanced analytics and aggregation functions to the Elasticsearch toolset.
- Embedded Database Tools: Integrate tools for working with embedded databases for local/offline analytics and storage.
Have a suggestion? We'd love to hear from you! Contact us or contribute directly.
👥 Contributors
📄 License
Distributed under the MIT License. See MIT License for more information.
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Tools
A Model Context Protocol server that enables seamless interaction between LLM-based agents and Apple Health data, allowing users to query, analyze, and manage health records through natural language commands.
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs to interact with Salesforce data through SOQL queries, SOSL searches, and various API operations including record management.Last updated -10133MIT License
- -securityAlicense-qualityA Model Context Protocol server that provides health data from the Senechal API to LLM applications, enabling AI assistants to access, analyze, and respond to personal health information.Last updated -GPL 3.0
- -securityAlicense-qualityA Model Context Protocol Server that enables LLMs to interact with and execute REST API calls through natural language prompts, supporting GET/PUT/POST/PATCH operations on configured APIs.Last updated -6Apache 2.0
- AsecurityAlicenseAqualityA Model Context Protocol server providing AI assistants with access to healthcare data tools, including FDA drug information, PubMed research, health topics, clinical trials, and medical terminology lookup.Last updated -72038MIT License