Skip to main content
Glama

get-recent-cycles

Read-onlyIdempotent

Retrieve recent physiological cycles from WHOOP to analyze strain, heart rate, and recovery data for performance tracking.

Instructions

Get recent physiological cycles (days) from WHOOP, including strain and heart rate data

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoNumber of cycles to retrieve (max 25)
daysNoNumber of days to look back (optional, default gets most recent)

Implementation Reference

  • Main handler function 'getRecentCycles' that executes the tool logic. Fetches recent physiological cycles from WHOOP API, calculates date ranges, formats cycle data with strain, heart rate, and calorie information, and returns a summary with formatted results.
    export default async function getRecentCycles({ limit, days }: InferSchema<typeof schema>) {
      try {
        const client = WhoopAPIClient.getInstance();
        
        // Calculate date range if days specified
        let params: any = { limit };
        if (days) {
          const endDate = new Date();
          const startDate = new Date();
          startDate.setDate(startDate.getDate() - days);
          
          params.start = startDate.toISOString();
          params.end = endDate.toISOString();
        }
        
        const response = await client.getCycleCollection(params);
        
        // Format the cycles for better readability
        const formattedCycles = response.records.map(cycle => {
          const startDate = new Date(cycle.start);
          const endDate = cycle.end ? new Date(cycle.end) : null;
          
          return {
            id: cycle.id,
            date: startDate.toLocaleDateString(),
            start_time: startDate.toLocaleString(),
            end_time: endDate ? endDate.toLocaleString() : 'Ongoing',
            is_current: !cycle.end,
            duration_hours: endDate ? 
              ((endDate.getTime() - startDate.getTime()) / (1000 * 60 * 60)).toFixed(1) : 
              'Ongoing',
            score_state: cycle.score_state,
            ...(cycle.score && {
              strain: cycle.score.strain.toFixed(2),
              calories: `${(cycle.score.kilojoule / 4.184).toFixed(0)} kcal`, // Convert kJ to kcal
              kilojoules: cycle.score.kilojoule.toFixed(0),
              avg_heart_rate: `${cycle.score.average_heart_rate} bpm`,
              max_heart_rate: `${cycle.score.max_heart_rate} bpm`,
            }),
          };
        });
        
        const summary = {
          total_cycles: formattedCycles.length,
          date_range: {
            from: formattedCycles[formattedCycles.length - 1]?.date || 'N/A',
            to: formattedCycles[0]?.date || 'N/A',
          },
          ...(formattedCycles.some(c => c.score_state === 'SCORED') && {
            average_strain: (
              formattedCycles
                .filter(c => c.strain)
                .reduce((sum, c) => sum + parseFloat(c.strain!), 0) / 
              formattedCycles.filter(c => c.strain).length
            ).toFixed(2),
          }),
        };
        
        return {
          content: [{
            type: 'text',
            text: JSON.stringify({
              summary,
              cycles: formattedCycles,
              has_more: !!response.next_token,
              next_token: response.next_token,
            }, null, 2),
          }],
        };
      } catch (error) {
        return {
          content: [{
            type: 'text',
            text: `Error: ${error instanceof Error ? error.message : 'Unknown error occurred'}`,
          }],
          isError: true,
        };
      }
    }
  • Zod schema defining input parameters: 'limit' (number 1-25, default 10) for number of cycles to retrieve, and 'days' (optional number 1-30) for date range filtering.
    export const schema = {
      limit: z.number().min(1).max(25).default(10).describe('Number of cycles to retrieve (max 25)'),
      days: z.number().min(1).max(30).optional().describe('Number of days to look back (optional, default gets most recent)'),
    };
  • Tool metadata registration including name 'get-recent-cycles', description, and annotations (title, readOnlyHint, destructiveHint, idempotentHint) for MCP tool registration.
    export const metadata: ToolMetadata = {
      name: 'get-recent-cycles',
      description: 'Get recent physiological cycles (days) from WHOOP, including strain and heart rate data',
      annotations: {
        title: 'Get Recent WHOOP Cycles',
        readOnlyHint: true,
        destructiveHint: false,
        idempotentHint: true,
      },
    };
  • WhoopAPIClient.getCycleCollection method used by the handler to fetch cycle data from WHOOP API. Constructs query parameters for pagination and date filtering.
    async getCycleCollection(params?: {
      limit?: number;
      start?: string;
      end?: string;
      nextToken?: string;
    }): Promise<PaginatedResponse<Cycle>> {
      const queryParams = new URLSearchParams();
      
      if (params?.limit) queryParams.append('limit', params.limit.toString());
      if (params?.start) queryParams.append('start', params.start);
      if (params?.end) queryParams.append('end', params.end);
      if (params?.nextToken) queryParams.append('nextToken', params.nextToken);
      
      const queryString = queryParams.toString();
      const endpoint = `/v2/cycle${queryString ? `?${queryString}` : ''}`;
      
      return this.request<PaginatedResponse<Cycle>>(endpoint);
    }
  • TypeScript type definitions for Cycle and CycleScore interfaces that define the structure of cycle data including strain, kilojoule, heart rate metrics, and score state.
    export interface CycleScore {
      strain: number;
      kilojoule: number;
      average_heart_rate: number;
      max_heart_rate: number;
    }
    
    export interface Cycle {
      id: number;
      user_id: number;
      created_at: string;
      updated_at: string;
      start: string;
      end?: string; // Optional - if not present, user is currently in this cycle
      timezone_offset: string;
      score_state: 'SCORED' | 'PENDING_SCORE' | 'UNSCORABLE';
      score?: CycleScore;
    }
Behavior3/5

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

Annotations already indicate readOnlyHint=true, idempotentHint=true, and destructiveHint=false, so the agent knows this is a safe, repeatable read operation. The description adds context about retrieving 'recent' cycles and including 'strain and heart rate data', which provides useful behavioral insight beyond annotations, but doesn't detail rate limits or authentication needs.

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 a single, efficient sentence that front-loads the purpose and key details ('including strain and heart rate data'). It avoids redundancy and wastes no words, making it highly concise and well-structured.

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 the tool's moderate complexity (2 parameters, no output schema), annotations cover safety and idempotency, and schema fully documents parameters. The description adds value by specifying data types included, but lacks output format details or error handling, making it adequate but with gaps for a read operation.

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%, with both parameters ('limit' and 'days') fully documented in the schema. The description mentions 'recent' cycles, which aligns with the 'days' parameter, but adds no additional semantic meaning beyond what the schema provides, meeting the baseline for high coverage.

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

Purpose4/5

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

The description clearly states the action ('Get recent physiological cycles') and resource ('from WHOOP'), specifying it includes 'strain and heart rate data'. It distinguishes from siblings by focusing on cycles rather than recovery or sleep data, though it doesn't explicitly contrast with them.

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

Usage Guidelines2/5

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

No guidance is provided on when to use this tool versus alternatives like 'get-recovery-for-cycle' or 'get-sleep-for-cycle'. The description implies it's for retrieving recent cycles with specific data types, but lacks explicit context or exclusions for usage.

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/izqui/whoop-mcp'

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