Skip to main content
Glama

Apple Health MCP Server

Server Configuration

Describes the environment variables required to run the server.

NameRequiredDescriptionDefault
ES_HOSTNoElasticsearch hostlocalhost
ES_PORTNoElasticsearch port9200
ES_USERNoElasticsearch usernameelastic
ES_INDEXNoElasticsearch index nameapple_health_data
ES_PASSWORDNoElasticsearch passwordelastic
RAW_XML_PATHYesPath to the Apple Health XML fileraw.xml
XML_SAMPLE_SIZENoNumber of XML records to sample1000

Schema

Prompts

Interactive templates invoked by user choice

NameDescription

No prompts

Resources

Contextual data attached and managed by the client

NameDescription

No resources

Tools

Functions exposed to the LLM to take actions

NameDescription
get_health_summary_es

Get a summary of Apple Health data from Elasticsearch. The function returns total record count, record type breakdown, and (optionally) a date range aggregation.

Notes for LLM:

  • IMPORTANT - Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

search_health_records_es

Search health records in Elasticsearch with flexible query building.

Parameters:

  • params: HealthRecordSearchParams object containing all search/filter parameters.

Notes for LLMs:

  • This function should return a list of health record documents (dicts) matching the search criteria.

  • Each document in the list should represent a single health record as stored in Elasticsearch.

  • If an error occurs, the function should return a list with a single dict containing an 'error' key and the error message.

  • Use this to retrieve structured health data for further analysis, filtering, or display.

  • Example source_name: "Rob’s iPhone", "Polar Flow", "Sync Solver".

  • Example date_from/date_to: "2020-01-01T00:00:00+00:00"

  • Example value_min/value_max: "10", "100.5"

  • IMPORTANT - Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

get_statistics_by_type_es

Get comprehensive statistics for a specific health record type from Elasticsearch.

Parameters:

  • record_type: The type of health record to analyze. Use RecordType for most frequent types. Use str if that type is beyond RecordType scope.

Returns:

  • record_type: The analyzed record type

  • total_count: Total number of records of this type in the index

  • value_statistics: Statistical summary of the 'value' field including:

    • count: Number of records with values

    • min: Minimum value recorded

    • max: Maximum value recorded

    • avg: Average value across all records

    • sum: Sum of all values

  • sources: Breakdown of records by source device/app (e.g., "Rob's iPhone", "Polar Flow")

Notes for LLMs:

  • This function provides comprehensive statistical analysis for any health record type.

  • The value_statistics object contains all basic statistics (count, min, max, avg, sum) for the 'value' field.

  • The sources breakdown shows which devices/apps contributed data for this record type.

  • Example types: "HKQuantityTypeIdentifierStepCount", "HKQuantityTypeIdentifierBodyMassIndex", "HKQuantityTypeIdentifierHeartRate", etc.

  • Use this function to understand the distribution, range, and trends of specific health metrics.

  • The function is useful for health analysis, identifying outliers, and understanding data quality.

  • date_range key for query is commented, since it contained hardcoded from date, but you can use it anyway if you replace startDate with your data.

  • IMPORTANT - Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

get_trend_data_es

Get trend data for a specific health record type over time using Elasticsearch date histogram aggregation.

Parameters:

  • record_type: The type of health record to analyze (e.g., "HKQuantityTypeIdentifierStepCount")

  • interval: Time interval for aggregation.

  • date_from, date_to: Optional ISO8601 date strings for filtering date range

Returns:

  • record_type: The analyzed record type

  • interval: The time interval used

  • trend_data: List of time buckets with statistics for each period:

    • date: The time period (ISO string)

    • avg_value: Average value for the period

    • min_value: Minimum value for the period

    • max_value: Maximum value for the period

    • count: Number of records in the period

Notes for LLMs:

  • Use this to analyze trends, patterns, and seasonal variations in health data

  • The function automatically handles date filtering if date_from/date_to are provided

  • IMPORTANT - interval must be one of: "day", "week", "month", or "year". Do not use other values.

  • Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

get_xml_structure

Analyze the structure and metadata of an Apple Health XML export file without loading the entire content.

Returns:

  • file_size_mb: Size of the file in megabytes

  • root_elements: List of unique root-level XML tags

  • record_types: List of unique health record types (see RecordType for most frequent types, but may include others)

  • workout_types: List of unique workout types

  • sources: List of unique data sources (device/app names)

Notes for LLMs:

  • Use this to quickly understand the contents and structure of a health XML file

  • RecordType contains only the most frequent types; other types may appear as strings

  • Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

search_xml_content

Search for specific content in the Apple Health XML file and return matching records as XML text.

Parameters:

  • query: Text to search for in any attribute value

  • max_results: Maximum number of matching records to return (default: 50)

Returns:

  • A string containing up to max_results XML elements that match the query, or a message if no matches are found.

Notes for LLMs:

  • Searches both Record and Workout elements

  • Useful for finding all records containing a specific value, device, or type

  • This function streams the file for memory efficiency and does not load the entire file into memory.

  • If filename is not provided, the file set by set_xml_file will be used.

  • Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

get_xml_by_type

Get all records of a specific health record type from the Apple Health XML file.

Parameters:

  • record_type: The type of health record to retrieve (use RecordType for most frequent types, or any string for custom/rare types)

  • limit: Maximum number of records to return (default: 20)

Returns:

  • A string containing up to limit XML elements of the specified type, or a message if no records are found.

Notes for LLMs:

  • Use this to extract all records of a given type for further analysis or conversion

  • RecordType contains only the most frequent types; other types may appear as strings

  • This function streams the file for memory efficiency and does not load the entire file into memory.

  • If filename is not provided, the file set by set_xml_file will be used.

  • Do not guess, auto-fill, or assume any missing data.

  • When asked for medical advice, try to use my data from ElasticSearch first.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/the-momentum/apple-health-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server