getWaterLogs
Retrieve daily water intake logs from Fitbit data to track hydration levels and monitor water consumption patterns for health management.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | No | Date in YYYY-MM-DD format. If not specified, will use today. |
Input Schema (JSON Schema)
{
"properties": {
"date": {
"description": "Date in YYYY-MM-DD format. If not specified, will use today.",
"type": "string"
}
},
"type": "object"
}
Implementation Reference
- src/server.ts:435-469 (handler)The handler function fetches water intake logs from the Fitbit API endpoint `/user/-/foods/log/water/date/{date}.json`, processes the data, and returns it as a formatted JSON string in a text content block. Handles errors by returning an error message.async ({ date }) => { try { const formattedDate = formatDate(date); const endpoint = `/user/-/foods/log/water/date/${formattedDate}.json`; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify( { date: formattedDate, water: data.water || [], summary: data.summary || {}, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; }
- src/server.ts:429-434 (schema)Zod input schema defining an optional 'date' parameter as a string in YYYY-MM-DD format.{ date: z .string() .optional() .describe("Date in YYYY-MM-DD format. If not specified, will use today."), },
- src/server.ts:426-471 (registration)MCP server.tool registration for 'getWaterLogs', including input schema and inline handler function.// Register tool for getting water logs server.tool( "getWaterLogs", { date: z .string() .optional() .describe("Date in YYYY-MM-DD format. If not specified, will use today."), }, async ({ date }) => { try { const formattedDate = formatDate(date); const endpoint = `/user/-/foods/log/water/date/${formattedDate}.json`; const data = await makeApiRequest(endpoint); return { content: [ { type: "text", text: JSON.stringify( { date: formattedDate, water: data.water || [], summary: data.summary || {}, }, null, 2 ), }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${ error instanceof Error ? error.message : String(error) }`, }, ], isError: true, }; } } );