add_weigh_in
Record a weight measurement to your Garmin Connect profile. Specify weight, unit (kg or lbs), and date as needed.
Instructions
Record a weight measurement
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| weight | Yes | Weight value | |
| unitKey | No | Weight unit: kg or lbs. Defaults to kg | kg |
| date | No | Date in YYYY-MM-DD format. Defaults to today |
Implementation Reference
- src/client/garmin.client.ts:694-705 (handler)The core handler method on GarminClient that sends a POST request to the Garmin weight endpoint with weight data.
async addWeighIn(weight: number, unitKey = 'kg', date?: string): Promise<unknown> { const resolvedDate = date ?? todayString(); return this.request(ADD_WEIGH_IN_ENDPOINT, { method: 'POST', body: { dateTimestamp: `${resolvedDate}T00:00:00.0`, gmtTimestamp: `${resolvedDate}T00:00:00.0`, unitKey, value: weight, }, }); } - src/tools/write.tools.ts:63-75 (registration)Registers the 'add_weigh_in' tool with the MCP server, with inputSchema from addWeighInSchema and a handler function that calls client.addWeighIn().
server.registerTool( 'add_weigh_in', { description: 'Record a weight measurement', inputSchema: addWeighInSchema.shape, }, async ({ weight, unitKey, date }) => { const data = await client.addWeighIn(weight, unitKey ?? 'kg', date); return { content: [{ type: 'text' as const, text: JSON.stringify(data, null, 2) }], }; }, ); - src/dtos/write.dto.ts:46-54 (schema)Zod schema defining the input validation for add_weigh_in: weight (positive number, max 700), unitKey (kg/lbs, defaults to kg), date (optional YYYY-MM-DD).
export const addWeighInSchema = z.object({ weight: z.number().positive().max(700).describe('Weight value'), unitKey: z .enum(['kg', 'lbs']) .default('kg') .optional() .describe('Weight unit: kg or lbs. Defaults to kg'), date: dateString.optional().describe('Date in YYYY-MM-DD format. Defaults to today'), }); - src/dtos/write.dto.ts:40-44 (schema)TypeScript type definition for the add_weigh_in input data.
export type AddWeighInDto = { weight: number; unitKey?: string; date?: string; }; - Endpoint constant for the Garmin Connect weight service API.
export const ADD_WEIGH_IN_ENDPOINT = '/weight-service/user-weight';