Skip to main content
Glama

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
NameRequiredDescriptionDefault
dateYesThe date for which to retrieve data (YYYY-MM-DD)

Implementation Reference

  • 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}'` } ); }
  • 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);
  • 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)'),
  • 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); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TheDigitalNinja/mcp-fitbit'

If you have feedback or need assistance with the MCP directory API, please join our Discord server