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.08 kB
JavaScript
import { z } from 'zod';
import { registerTool, handleFitbitApiCall } from './utils.js';
/**
* Registers an activity goals tool with the MCP server.
* @param server The McpServer instance.
* @param getAccessTokenFn Function to retrieve the current access token.
*/
export function registerActivityGoalsTool(server, getAccessTokenFn) {
registerTool(server, {
name: 'get_activity_goals',
description: "Get the raw JSON response for user's activity goals from Fitbit. Supports 'daily' and 'weekly' periods. Returns goal values for steps, distance, calories, floors, active minutes, and active zone minutes.",
parametersSchema: {
period: z
.enum(['daily', 'weekly'])
.describe("Goal period - either 'daily' or 'weekly'")
},
handler: async ({ period }) => {
const endpoint = `activities/goals/${period}.json`;
return handleFitbitApiCall(endpoint, { period }, getAccessTokenFn, {
errorContext: `period '${period}'`
});
}
});
}