get_hrv_range
Retrieve heart rate variability data for a date range, returned as day-by-day records with dates and values. Analyze daily HRV trends.
Instructions
Get HRV data over a date range (day-by-day). Returns array of {date, data} records
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startDate | Yes | Start date in YYYY-MM-DD format | |
| endDate | Yes | End date in YYYY-MM-DD format |
Implementation Reference
- src/client/garmin.client.ts:398-401 (handler)The core 'getHRV' async method that fetches HRV data from the Garmin API endpoint for a given date. This is the underlying API call used by getHRVRange.
async getHRV(date?: string): Promise<unknown> { const resolvedDate = date ?? todayString(); return this.request(`${HRV_ENDPOINT}/${resolvedDate}`); } - src/client/garmin.client.ts:610-612 (handler)The 'getHRVRange' method on GarminClient that iterates over a date range and fetches HRV data for each day via fetchRange.
async getHRVRange(startDate: string, endDate: string): Promise<{ date: string; data: unknown }[]> { return this.fetchRange(startDate, endDate, (d) => this.getHRV(d)); } - src/tools/range.tools.ts:21-34 (registration)The tool registration for 'get_hrv_range' using server.registerTool, mapping to client.getHRVRange with dateRangeParamSchema input.
server.registerTool( 'get_hrv_range', { description: 'Get HRV data over a date range (day-by-day). Returns array of {date, data} records', inputSchema: dateRangeParamSchema.shape, }, async ({ startDate, endDate }) => { const data = await client.getHRVRange(startDate, endDate); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/dtos/date-params.dto.ts:19-22 (schema)The input schema (dateRangeParamSchema) used by get_hrv_range, defining startDate and endDate as YYYY-MM-DD strings.
export const dateRangeParamSchema = z.object({ startDate: dateString.describe('Start date in YYYY-MM-DD format'), endDate: dateString.describe('End date in YYYY-MM-DD format'), }); - src/client/garmin.client.ts:162-174 (helper)The private fetchRange helper that generates a list of dates and fetches data for each date via the provided fetcher callback.
private async fetchRange( startDate: string, endDate: string, fetcher: (date: string) => Promise<unknown>, ): Promise<{ date: string; data: unknown }[]> { const dates = this.dateRange(startDate, endDate); const results: { date: string; data: unknown }[] = []; for (const date of dates) { const data = await fetcher(date).catch(() => null); results.push({ date, data }); } return results; }