get_daily_activity_summary
Retrieve daily Fitbit activity data including steps, calories, distances, heart rate zones, and goals for a specific date using YYYY-MM-DD format.
Instructions
Get the raw JSON response for daily activity summary from Fitbit for a specific date. Includes goals, steps, calories, distances, and heart rate zones. Requires a 'date' parameter in YYYY-MM-DD format.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| date | Yes | The date for which to retrieve data (YYYY-MM-DD) |
Implementation Reference
- src/daily-activity.ts:60-71 (handler)The core handler function for the 'get_daily_activity_summary' tool. It constructs the API endpoint based on the date parameter and invokes handleFitbitApiCall to fetch and return the daily activity summary from Fitbit.handler: async ({ date }: DailyActivityParams) => { const endpoint = `activities/date/${date}.json`; return handleFitbitApiCall<DailyActivitySummaryResponse, DailyActivityParams>( endpoint, { date }, getAccessTokenFn, { errorContext: `date '${date}'` } ); }
- src/daily-activity.ts:54-72 (registration)Registers the 'get_daily_activity_summary' tool on the MCP server within the registerDailyActivityTool function, specifying name, description, input schema, and handler.registerTool(server, { name: 'get_daily_activity_summary', description: "Get the raw JSON response for daily activity summary from Fitbit for a specific date. Includes goals, steps, calories, distances, and heart rate zones. Requires a 'date' parameter in YYYY-MM-DD format.", parametersSchema: { date: CommonSchemas.date, }, handler: async ({ date }: DailyActivityParams) => { const endpoint = `activities/date/${date}.json`; return handleFitbitApiCall<DailyActivitySummaryResponse, DailyActivityParams>( endpoint, { date }, getAccessTokenFn, { errorContext: `date '${date}'` } ); } });
- src/index.ts:83-83 (registration)Top-level call to registerDailyActivityTool during server initialization, passing the MCP server instance and access token getter.registerDailyActivityTool(server, getAccessToken);
- src/utils.ts:106-109 (schema)Zod schema definition for the 'date' parameter used in the tool's input validation (CommonSchemas.date).date: z .string() .regex(DATE_REGEX, VALIDATION_MESSAGES.DATE_FORMAT) .describe('The date for which to retrieve data (YYYY-MM-DD)'),
- src/utils.ts:183-223 (helper)Helper function called by the handler to perform the actual Fitbit API request using makeFitbitRequest, handle errors, and format the MCP tool response.export async function handleFitbitApiCall<TResponse, TParams>( endpoint: string, params: TParams, getAccessTokenFn: () => Promise<string | null>, options: { apiBase?: string; successDataExtractor?: (data: TResponse) => unknown[] | null; noDataMessage?: string; errorContext?: string; } = {} ): Promise<ToolResponseStructure> { const { apiBase = FITBIT_API_VERSIONS.V1, successDataExtractor, noDataMessage, errorContext = JSON.stringify(params) } = options; const responseData = await makeFitbitRequest<TResponse>( endpoint, getAccessTokenFn, apiBase ); if (!responseData) { return createErrorResponse( `${ERROR_MESSAGES.API_REQUEST_FAILED} for ${errorContext}. ${ERROR_MESSAGES.CHECK_TOKEN_PERMISSIONS}.` ); } // Check for empty data if extractor provided if (successDataExtractor) { const extractedData = successDataExtractor(responseData); if (!extractedData || extractedData.length === 0) { return createNoDataResponse(noDataMessage || errorContext); } } return createSuccessResponse(responseData); }