get_weight
Retrieve raw weight data from Fitbit for a specified period ending today using a 'period' parameter like '1d', '7d', or '1y'. Ideal for integrating weight trends into health applications.
Instructions
Get the raw JSON response for weight entries from Fitbit for a specified period ending today. Requires a 'period' parameter such as '1d', '7d', '30d', '3m', '6m', '1y'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | Yes | The time period for which to retrieve weight data. |
Implementation Reference
- src/weight.ts:39-52 (handler)The handler function that implements the core logic of the 'get_weight' tool. It builds the Fitbit API endpoint for body weight data over the specified period and invokes the generic handleFitbitApiCall helper to fetch, extract, and return the data.handler: async ({ period }: WeightParams) => { const endpoint = `/body/weight/date/today/${period}.json`; return handleFitbitApiCall<WeightTimeSeriesResponse, WeightParams>( endpoint, { period }, getAccessTokenFn, { successDataExtractor: (data) => data['body-weight'] || [], noDataMessage: `the period '${period}'`, errorContext: `period '${period}'` } ); }
- src/weight.ts:33-53 (registration)Tool registration block within registerWeightTool function, specifying name, description, input schema, and handler for 'get_weight'.registerTool(server, { name: 'get_weight', description: "Get the raw JSON response for weight entries from Fitbit for a specified period ending today. Requires a 'period' parameter such as '1d', '7d', '30d', '3m', '6m', '1y'", parametersSchema: { period: CommonSchemas.period, }, handler: async ({ period }: WeightParams) => { const endpoint = `/body/weight/date/today/${period}.json`; return handleFitbitApiCall<WeightTimeSeriesResponse, WeightParams>( endpoint, { period }, getAccessTokenFn, { successDataExtractor: (data) => data['body-weight'] || [], noDataMessage: `the period '${period}'`, errorContext: `period '${period}'` } ); } });
- src/weight.ts:36-38 (schema)Input schema definition for the 'get_weight' tool, requiring a 'period' parameter referencing CommonSchemas.period.parametersSchema: { period: CommonSchemas.period, },
- src/index.ts:77-77 (registration)Top-level call to register the weight tool (and thus 'get_weight') on the main MCP server instance.registerWeightTool(server, getAccessToken);