Labsco
neiltron logo

Apple Health MCP

โ˜… 552

from neiltron

Query Apple Health data using natural language and SQL.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeNeeds API keys

Apple Health MCP Server

An MCP (Model Context Protocol) server for querying Apple Health data using SQL. Built with DuckDB for fast, efficient health data analysis.

[!NOTE] This project currently relies on the Simple Health Export CSV app by Eric Wolter. See Exporting Data below for more info on how best to use the app.

This is currently the easiest way I could find to quickly and reliably get Apple Health data exported in CSV format. If you have ideas of better ways to import data, please submit an issue.

Features

  • Natural language querying: Your MCP client translates your questions to database queries

  • SQL Query Execution: Direct SQL queries against your Apple Health data

  • Automated Reports: Generate weekly/monthly health summaries

  • Efficient Data Loading: Lazy loading with configurable time windows

  • Smart Caching: Query result caching with TTL

Available Tools

  • health_schema: Get information about available tables and their structure

  • health_query: Execute SQL queries directly on your health data

  • health_report: Generate comprehensive health reports

Data Structure

The server expects Apple Health data exported as CSV files with the following naming pattern:

  • HKQuantityTypeIdentifier*.csv - Quantitative health metrics

  • HKCategoryTypeIdentifier*.csv - Categorical health data

  • HKWorkoutActivityType*.csv - Workout and activity data

Each CSV file should have these columns:

  • type: The specific health metric type

  • sourceName: Source device/app

  • startDate: Start timestamp (UTC)

  • endDate: End timestamp (UTC)

  • value: The measurement value

  • unit: Unit of measurement

Development

For local development:

Copy & paste โ€” that's it
# Clone and install dependencies
git clone https://github.com/neiltron/apple-health-mcp.git
cd apple-health-mcp
npm install

# Build the project
npm run build

# Type checking
npm run typecheck

Contributing

Contributions are welcome! Please ensure:

  • Code follows existing patterns

  • TypeScript types are properly defined

  • Error handling is comprehensive

  • Performance impact is considered

License

MIT