Skip to main content
Glama

get_weight

Retrieve weight data from Fitbit for a specified time period. Use this tool to access historical weight entries by providing a period parameter like '7d' or '1y'.

Instructions

Get the raw JSON response for weight entries from Fitbit for a specified period ending today. Requires a 'period' parameter such as '1d', '7d', '30d', '3m', '6m', '1y'

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
periodYesThe time period for which to retrieve data

Implementation Reference

  • The handler function that executes the get_weight tool logic: constructs the Fitbit API endpoint for body weight data over a given period and invokes handleFitbitApiCall to fetch, extract, and format the response.
    handler: async ({ period }: WeightParams) => {
      const endpoint = `/body/weight/date/today/${period}.json`;
      
      return handleFitbitApiCall<WeightTimeSeriesResponse, WeightParams>(
        endpoint,
        { period },
        getAccessTokenFn,
        {
          successDataExtractor: (data) => data['body-weight'] || [],
          noDataMessage: `the period '${period}'`,
          errorContext: `period '${period}'`
        }
      );
    }
  • src/weight.ts:33-53 (registration)
    Registration of the get_weight tool via registerTool, specifying name, description, input schema (period parameter), and handler function.
    registerTool(server, {
      name: 'get_weight',
      description: "Get the raw JSON response for weight entries from Fitbit for a specified period ending today. Requires a 'period' parameter such as '1d', '7d', '30d', '3m', '6m', '1y'",
      parametersSchema: {
        period: CommonSchemas.period,
      },
      handler: async ({ period }: WeightParams) => {
        const endpoint = `/body/weight/date/today/${period}.json`;
        
        return handleFitbitApiCall<WeightTimeSeriesResponse, WeightParams>(
          endpoint,
          { period },
          getAccessTokenFn,
          {
            successDataExtractor: (data) => data['body-weight'] || [],
            noDataMessage: `the period '${period}'`,
            errorContext: `period '${period}'`
          }
        );
      }
    });
  • src/index.ts:77-77 (registration)
    Top-level call to registerWeightTool, which sets up the get_weight tool on the MCP server instance.
    registerWeightTool(server, getAccessToken);
  • TypeScript interfaces defining the structure of Fitbit weight time series data used in the tool's handler.
    interface WeightTimeSeriesEntry {
      dateTime: string; // Date (and potentially time) of the entry
      value: string; // Weight value as a string
    }
    
    // Represents the structure of the response from the Fitbit Time Series API for weight
    interface WeightTimeSeriesResponse {
      'body-weight': WeightTimeSeriesEntry[]; // Array of weight entries
    }
  • Shared helper function handleFitbitApiCall used by the get_weight handler to perform the API request, handle authentication, errors, no-data cases, 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);
    }
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 that the tool returns 'raw JSON response' (helpful output format context) and mentions the period parameter requirement. However, it doesn't address important behavioral aspects like authentication needs, rate limits, error conditions, or what happens with invalid periods. The description adds some value but leaves significant gaps.

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 perfectly concise with two sentences that each earn their place. The first sentence establishes purpose and scope, while the second provides critical parameter guidance. No wasted words, and information is front-loaded appropriately.

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?

Given no annotations and no output schema, the description provides adequate basic information but lacks completeness for a data retrieval tool. It covers what data is retrieved and the required parameter, but doesn't describe the response format beyond 'raw JSON,' doesn't mention authentication requirements, and provides no error handling context. For a tool interacting with an external API like Fitbit, more behavioral context would be helpful.

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

Parameters4/5

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

Schema description coverage is 100% with the parameter fully documented in the schema. The description adds meaningful context by specifying that periods end today ('ending today') and providing concrete examples of period values ('1d', '7d', etc.). This enhances understanding beyond the schema's enum list and generic description.

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 specific action ('Get the raw JSON response'), resource ('weight entries from Fitbit'), and scope ('for a specified period ending today'). It distinguishes this tool from siblings like get_heart_rate or get_sleep_by_date_range by specifying it's for weight data, not other fitness metrics.

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

Usage Guidelines3/5

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

The description implies usage context by mentioning 'for a specified period ending today' and listing period options, but doesn't explicitly state when to use this tool versus alternatives like get_heart_rate or get_nutrition_by_date_range. No guidance is provided about when not to use it or what makes this the preferred choice for weight data.

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