Skip to main content
Glama

get_activity_timeseries

Retrieve Fitbit activity data like steps, distance, or calories over a specified date range (up to 30 days) in JSON format for analysis or integration.

Instructions

Get the raw JSON response for activity time series data from Fitbit over a date range (max 30 days). Supports various resource paths like 'steps', 'distance', 'calories', 'activityCalories', 'caloriesBMR'.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resourcePathYesActivity resource to retrieve (e.g., 'steps', 'distance', 'calories')
startDateYesThe start date for which to retrieve data (YYYY-MM-DD)
endDateYesThe end date for which to retrieve data (YYYY-MM-DD)

Implementation Reference

  • Registers the 'get_activity_timeseries' MCP tool with name, description, parameters schema, and inline handler using the shared registerTool utility.
    registerTool(server, {
      name: 'get_activity_timeseries',
      description: "Get the raw JSON response for activity time series data from Fitbit over a date range (max 30 days). Supports various resource paths like 'steps', 'distance', 'calories', 'activityCalories', 'caloriesBMR'.",
      parametersSchema: {
        resourcePath: z
          .enum([
            'steps',
            'distance', 
            'calories',
            'activityCalories',
            'caloriesBMR',
            'tracker/activityCalories',
            'tracker/calories',
            'tracker/distance'
          ])
          .describe("Activity resource to retrieve (e.g., 'steps', 'distance', 'calories')"),
        startDate: CommonSchemas.startDate,
        endDate: CommonSchemas.endDate,
      },
      handler: async ({ resourcePath, startDate, endDate }: ActivityTimeSeriesParams) => {
        const endpoint = `activities/${resourcePath}/date/${startDate}/${endDate}.json`;
        
        return handleFitbitApiCall<ActivityTimeSeriesResponse, ActivityTimeSeriesParams>(
          endpoint,
          { resourcePath, startDate, endDate },
          getAccessTokenFn,
          {
            errorContext: `resource '${resourcePath}' from ${startDate} to ${endDate}`
          }
        );
      }
    });
  • The handler function for the tool, which constructs the specific Fitbit API endpoint for activity time series and invokes the shared handleFitbitApiCall helper.
    handler: async ({ resourcePath, startDate, endDate }: ActivityTimeSeriesParams) => {
      const endpoint = `activities/${resourcePath}/date/${startDate}/${endDate}.json`;
      
      return handleFitbitApiCall<ActivityTimeSeriesResponse, ActivityTimeSeriesParams>(
        endpoint,
        { resourcePath, startDate, endDate },
        getAccessTokenFn,
        {
          errorContext: `resource '${resourcePath}' from ${startDate} to ${endDate}`
        }
      );
    }
  • Zod-based input schema defining parameters for the tool: resourcePath (enum of activity types), startDate, and endDate.
    parametersSchema: {
      resourcePath: z
        .enum([
          'steps',
          'distance', 
          'calories',
          'activityCalories',
          'caloriesBMR',
          'tracker/activityCalories',
          'tracker/calories',
          'tracker/distance'
        ])
        .describe("Activity resource to retrieve (e.g., 'steps', 'distance', 'calories')"),
      startDate: CommonSchemas.startDate,
      endDate: CommonSchemas.endDate,
    },
  • src/index.ts:85-85 (registration)
    Top-level call to registerActivityTimeSeriesTool on the MCP server instance, integrating the tool into the main application.
    registerActivityTimeSeriesTool(server, getAccessToken);
  • Shared helper function that executes the Fitbit API request using makeFitbitRequest, handles API errors, empty data checks, and formats the response as MCP tool output.
    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);
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden. It discloses the 30-day limit constraint and mentions the response format ('raw JSON'), which is valuable. However, it doesn't cover other behavioral aspects like authentication requirements, rate limits, error conditions, or pagination behavior that would be helpful for a tool fetching time series data.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in two sentences: the first states the core purpose with key constraints, the second provides specific examples. Every word earns its place with no redundancy or wasted space, making it easy to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 3-parameter tool with no annotations and no output schema, the description provides adequate but incomplete context. It covers the purpose, constraints, and examples well, but lacks information about authentication, error handling, rate limits, and the structure of the returned JSON that would be needed for robust usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already fully documents all three parameters. The description adds marginal value by mentioning 'max 30 days' which contextualizes the date parameters, and listing example resource paths that match the enum. However, it doesn't provide additional semantic context beyond what's in the well-documented schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Get') and resource ('raw JSON response for activity time series data from Fitbit'), specifies the scope ('over a date range (max 30 days)'), and distinguishes from siblings by mentioning specific resource paths like 'steps' and 'distance' that aren't covered by tools like 'get_activity_goals' or 'get_daily_activity_summary'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('over a date range (max 30 days)') and mentions specific resource paths, but doesn't explicitly state when NOT to use it or name alternative tools for similar data. It implies usage for raw time series data versus summary tools, but lacks explicit exclusions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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