set_hydration
Log daily water consumption in milliliters. Specify date to track hydration accurately.
Instructions
Set daily hydration intake in milliliters
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in YYYY-MM-DD format. Defaults to today | |
| valueMl | Yes | Hydration value in milliliters |
Implementation Reference
- src/tools/write.tools.ts:77-88 (handler)The tool handler function for 'set_hydration' - registers tool, calls client.setHydration, returns JSON response.
server.registerTool( 'set_hydration', { description: 'Set daily hydration intake in milliliters', inputSchema: setHydrationSchema.shape, }, async ({ valueMl, date }) => { const data = await client.setHydration(valueMl, date); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, - src/dtos/write.dto.ts:56-64 (schema)Input schema for set_hydration: requires valueMl (0-20000) and optional date (YYYY-MM-DD).
export type SetHydrationDto = { date?: string; valueMl: number; }; export const setHydrationSchema = z.object({ date: dateString.optional().describe('Date in YYYY-MM-DD format. Defaults to today'), valueMl: z.number().min(0).max(20000).describe('Hydration value in milliliters'), }); - src/client/garmin.client.ts:707-717 (helper)Client method that sends PUT request to the hydration endpoint with calendarDate, valueInML, and timestampLocal.
async setHydration(valueMl: number, date?: string): Promise<unknown> { const resolvedDate = date ?? todayString(); return this.request(SET_HYDRATION_ENDPOINT, { method: 'PUT', body: { calendarDate: resolvedDate, valueInML: valueMl, timestampLocal: `${resolvedDate}T00:00:00.0`, }, }); } - src/tools/write.tools.ts:77-89 (registration)Registration of the 'set_hydration' tool via server.registerTool with its schema and handler.
server.registerTool( 'set_hydration', { description: 'Set daily hydration intake in milliliters', inputSchema: setHydrationSchema.shape, }, async ({ valueMl, date }) => { const data = await client.setHydration(valueMl, date); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - API endpoint constant for the hydration log service.
export const SET_HYDRATION_ENDPOINT = '/usersummary-service/usersummary/hydration/log';