UNPKG

mcp-fitbit

Version:

Model Context Protocol (MCP) server for accessing Fitbit health and fitness data. Connect AI assistants like Claude to your Fitbit data for personalized health insights.

25 lines (24 loc) 1.11 kB
import { registerTool, CommonSchemas, handleFitbitApiCall } from './utils.js'; // --- Tool Registration --- /** * Registers a single, parameterized Fitbit weight tool with the MCP server. * @param server The McpServer instance. * @param getAccessTokenFn Function to retrieve the current access token. */ export function registerWeightTool(server, getAccessTokenFn) { 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 }) => { const endpoint = `/body/weight/date/today/${period}.json`; return handleFitbitApiCall(endpoint, { period }, getAccessTokenFn, { successDataExtractor: (data) => data['body-weight'] || [], noDataMessage: `the period '${period}'`, errorContext: `period '${period}'` }); } }); }