get_weekly_steps
Retrieve weekly step totals for trend analysis over up to 52 weeks. Specify an end date to get historical step counts.
Instructions
Get weekly aggregated step counts for trend analysis. Defaults to 52 weeks (1 year). Max 52 weeks
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endDate | Yes | End date in YYYY-MM-DD format | |
| weeks | No | Number of weeks to look back (1-52). Defaults to 52 (full year) |
Implementation Reference
- src/tools/trends.tools.ts:21-34 (registration)Tool registration for 'get_weekly_steps' on the MCP server. Defines schema via weeklyParamSchema and handler that calls client.getWeeklySteps().
server.registerTool( 'get_weekly_steps', { description: 'Get weekly aggregated step counts for trend analysis. Defaults to 52 weeks (1 year). Max 52 weeks', inputSchema: weeklyParamSchema.shape, }, async ({ endDate, weeks }) => { const data = await client.getWeeklySteps(endDate, weeks ?? 52); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/tools/trends.tools.ts:28-33 (handler)Handler function for get_weekly_steps tool. Receives { endDate, weeks }, defaults weeks to 52, calls client.getWeeklySteps(), and returns JSON-stringified response.
async ({ endDate, weeks }) => { const data = await client.getWeeklySteps(endDate, weeks ?? 52); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, - src/client/garmin.client.ts:342-344 (helper)Client method getWeeklySteps() – makes the actual API request to the Garmin weekly steps endpoint.
async getWeeklySteps(endDate: string, weeks = 52): Promise<unknown> { return this.request(`${WEEKLY_STEPS_ENDPOINT}/${endDate}/${weeks}`); } - src/dtos/date-params.dto.ts:29-38 (schema)weeklyParamSchema – Zod schema defining input: endDate (string, YYYY-MM-DD) and weeks (optional number, 1-52, default 52).
export const weeklyParamSchema = z.object({ endDate: dateString.describe('End date in YYYY-MM-DD format'), weeks: z .number() .min(1) .max(52) .default(52) .optional() .describe('Number of weeks to look back (1-52). Defaults to 52 (full year)'), }); - WEEKLY_STEPS_ENDPOINT constant – the Garmin API path '/usersummary-service/stats/steps/weekly' used by the client.
export const WEEKLY_STEPS_ENDPOINT = '/usersummary-service/stats/steps/weekly';