get_respiration_range
Retrieve daily respiration data for a specified date range. Returns array of dates and respiration records.
Instructions
Get respiration 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/tools/range.tools.ts:66-79 (registration)Registration of the 'get_respiration_range' tool on the MCP server with inputSchema from dateRangeParamSchema and a handler that calls client.getRespirationRange
server.registerTool( 'get_respiration_range', { description: 'Get respiration data over a date range (day-by-day). Returns array of {date, data} records', inputSchema: dateRangeParamSchema.shape, }, async ({ startDate, endDate }) => { const data = await client.getRespirationRange(startDate, endDate); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/client/garmin.client.ts:622-624 (handler)Handler method on GarminClient that calls fetchRange to iterate over dates and fetch respiration data for each date
async getRespirationRange(startDate: string, endDate: string): Promise<{ date: string; data: unknown }[]> { return this.fetchRange(startDate, endDate, (d) => this.getRespiration(d)); } - src/client/garmin.client.ts:162-174 (helper)Helper method fetchRange that iterates from startDate to endDate, calls the fetcher callback for each date, and collects results as {date, data} records
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; } - src/client/garmin.client.ts:293-296 (helper)The underlying getRespiration method that fetches a single day's respiration data from the Garmin API endpoint
async getRespiration(date?: string): Promise<unknown> { const resolvedDate = date ?? todayString(); return this.request(`${DAILY_RESPIRATION_ENDPOINT}/${resolvedDate}`); } - src/dtos/date-params.dto.ts:19-22 (schema)The dateRangeParamSchema used as inputSchema for the tool, 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'), });