get_stress_range
Retrieve daily stress levels for a specified date range, returning each day's stress data.
Instructions
Get daily stress 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:36-49 (registration)Registration of the 'get_stress_range' tool on the MCP server with description, input schema, and handler that delegates to the Garmin client.
server.registerTool( 'get_stress_range', { description: 'Get daily stress data over a date range (day-by-day). Returns array of {date, data} records', inputSchema: dateRangeParamSchema.shape, }, async ({ startDate, endDate }) => { const data = await client.getStressRange(startDate, endDate); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/client/garmin.client.ts:614-616 (handler)Client-side handler that fetches stress data over a date range, calling fetchRange with the getStress fetcher.
async getStressRange(startDate: string, endDate: string): Promise<{ date: string; data: unknown }[]> { return this.fetchRange(startDate, endDate, (d) => this.getStress(d)); } - src/client/garmin.client.ts:162-174 (helper)Generic helper that iterates over a date range and calls a fetcher function for each day, collecting results.
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:279-282 (helper)Single-day stress fetcher that makes an API request to the daily stress endpoint.
async getStress(date?: string): Promise<unknown> { const resolvedDate = date ?? todayString(); return this.request(`${DAILY_STRESS_ENDPOINT}/${resolvedDate}`); } - src/dtos/date-params.dto.ts:19-22 (schema)Zod schema defining the input parameters (startDate, endDate) for the get_stress_range tool.
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'), });