Skip to main content
Glama

Apple Health MCP Server

get_trend_data_es

Analyze health data trends over time by aggregating specific record types (e.g., steps, heart rate) into daily, weekly, monthly, or yearly intervals. Returns statistics like average, min, max, and count for each period.

Instructions

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.

Input Schema

NameRequiredDescriptionDefault
date_fromNo
date_toNo
intervalNomonth
record_typeYes

Input Schema (JSON Schema)

{ "properties": { "date_from": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Date From" }, "date_to": { "anyOf": [ { "type": "string" }, { "type": "null" } ], "default": null, "title": "Date To" }, "interval": { "default": "month", "enum": [ "day", "week", "month", "year" ], "title": "Interval", "type": "string" }, "record_type": { "anyOf": [ { "enum": [ "HKQuantityTypeIdentifierStepCount", "HKQuantityTypeIdentifierBodyMassIndex", "HKQuantityTypeIdentifierHeartRate", "HKQuantityTypeIdentifierBodyMass", "HKQuantityTypeIdentifierHeight", "HKQuantityTypeIdentifierDietaryWater", "HKQuantityTypeIdentifierActiveEnergyBurned", "HKQuantityTypeIdentifierBasalEnergyBurned", "HKQuantityTypeIdentifierDistanceWalkingRunning", "HKQuantityTypeIdentifierRunningSpeed", "HKQuantityTypeIdentifierRunningPower", "HKQuantityTypeIdentifierAppleExerciseTime", "HKQuantityTypeIdentifierAppleStandTime", "HKQuantityTypeIdentifierFlightsClimbed", "HKQuantityTypeIdentifierWalkingStepLength", "HKQuantityTypeIdentifierWalkingSpeed", "HKQuantityTypeIdentifierEnvironmentalAudioExposure" ], "type": "string" }, { "type": "string" } ], "title": "Record Type" } }, "required": [ "record_type" ], "type": "object" }

Other Tools from Apple Health MCP Server

Related Tools

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