get_profile
Retrieve user profile data from Fitbit, including health metrics and personal information, to access fitness tracking details.
Instructions
Get the raw JSON response for the user's Fitbit profile.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/profile.ts:34-45 (handler)Handler function for the 'get_profile' MCP tool. Fetches the user's Fitbit profile JSON by calling handleFitbitApiCall with endpoint 'profile.json'.handler: async () => { const endpoint = 'profile.json'; return handleFitbitApiCall<FitbitProfile, Record<string, never>>( endpoint, {}, getAccessTokenFn, { errorContext: 'profile data' } ); }
- src/profile.ts:26-47 (registration)registerProfileTool function defines and registers the 'get_profile' tool with the MCP server, specifying name, description, empty input schema, and handler.export function registerProfileTool( server: McpServer, getAccessTokenFn: () => Promise<string | null> ): void { registerTool(server, { name: 'get_profile', description: "Get the raw JSON response for the user's Fitbit profile.", parametersSchema: {}, handler: async () => { const endpoint = 'profile.json'; return handleFitbitApiCall<FitbitProfile, Record<string, never>>( endpoint, {}, getAccessTokenFn, { errorContext: 'profile data' } ); } }); }
- src/index.ts:79-79 (registration)Invocation of registerProfileTool in the main index.ts to register the 'get_profile' tool on the MCP server instance.registerProfileTool(server, getAccessToken);
- src/profile.ts:8-19 (schema)TypeScript interface defining the structure of the Fitbit profile response used in the get_profile tool.interface FitbitProfile { user: { fullName: string; age: number; gender: string; height: number; // in centimeters weight: number; // in kilograms avatar: string; // URL to the user's avatar memberSince: string; // Date the user joined Fitbit // Add other fields as needed }; }
- src/utils.ts:183-222 (helper)Generic handleFitbitApiCall helper function used by the get_profile handler to perform the API request, 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); }