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.

26 lines (25 loc) 1.27 kB
import { registerTool, CommonSchemas, handleFitbitApiCall } from './utils.js'; // --- Tool Registration --- /** * Registers a Fitbit activities/exercises tool with the MCP server. * @param server The McpServer instance. * @param getAccessTokenFn Function to retrieve the current access token. */ export function registerActivitiesTool(server, getAccessTokenFn) { registerTool(server, { name: 'get_exercises', description: "Get the raw JSON response for exercise and activity logs from Fitbit after a specific date. Requires 'afterDate' parameter in 'YYYY-MM-DD' format. Retrieves a detailed list of logged exercises and activities.", parametersSchema: { afterDate: CommonSchemas.afterDate, limit: CommonSchemas.limit, }, handler: async ({ afterDate, limit = 20 }) => { const endpoint = `activities/list.json?afterDate=${afterDate}&sort=asc&offset=0&limit=${limit}`; return handleFitbitApiCall(endpoint, { afterDate, limit }, getAccessTokenFn, { successDataExtractor: (data) => data.activities || [], noDataMessage: `after date '${afterDate}'`, errorContext: `after date '${afterDate}'` }); } }); }