Skip to main content
Glama

get_workout_info

Retrieve detailed workout information for a specific date, including exercises, sets, reps, and weights from JEFit workout data.

Instructions

Get detailed workout information for a specific date.

Args: date: Date in YYYY-MM-DD format

Returns: Markdown-formatted workout details including exercises, sets, reps, and weights

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateYes

Implementation Reference

  • Handler function for the 'get_workout_info' tool. It validates the date input, fetches raw workout data using the helper function, enriches it with exercise details from a preloaded database, formats the output as structured Markdown, and returns it as a ToolResult. The @mcp.tool decorator handles registration.
    @mcp.tool
    def get_workout_info(date: str) -> ToolResult:
        """
        Get detailed workout information for a specific date.
        
        Args:
            date: Date in YYYY-MM-DD format
        
        Returns:
            Markdown-formatted workout details including exercises, sets, reps, and weights
        """
        # Validate date format
        try:
            datetime.strptime(date, "%Y-%m-%d")
        except ValueError as e:
            raise ValueError(f"Invalid date format. Use YYYY-MM-DD format: {e}")
        
        # Get workout data from API
        workout_data = get_workout_for_date(date)
        
        # Build markdown output
        output_lines = []
        output_lines.append(f"# Workout for {date}\n")
        
        if 'data' not in workout_data or not workout_data['data']:
            output_lines.append("No workout found for this date.")
            markdown_text = "\n".join(output_lines)
            return ToolResult(content=[TextContent(type="text", text=markdown_text)])
        
        for session in workout_data['data']:
            session_date = datetime.fromtimestamp(session['date']).strftime('%Y-%m-%d %H:%M:%S')
            duration_minutes = session['total_time'] // 60
            duration_seconds = session['total_time'] % 60
            total_weight = session['total_weight']
            
            output_lines.append(f"**Started:** {session_date}")
            output_lines.append(f"**Duration:** {duration_minutes}m {duration_seconds}s")
            output_lines.append(f"**Weight Lifted:** {total_weight} lbs\n")
            
            output_lines.append("## Exercises\n")
            
            for i, log in enumerate(session['logs'], 1):
                exercise_id = log['exercise_id']
                exercise = EXERCISE_DB.get(exercise_id, {})
                
                name = exercise.get('name', f'Unknown Exercise ({exercise_id})')
                muscle_groups = ', '.join(exercise.get('body_parts', ['Unknown']))
                equipment = ', '.join(exercise.get('equipment', ['Unknown']))
                
                output_lines.append(f"### {i}. {name}")
                output_lines.append(f"- **Muscle Groups:** {muscle_groups}")
                output_lines.append(f"- **Equipment:** {equipment}")
                output_lines.append("")
                
                # Add sets information
                for j, s in enumerate(log['log_sets'], 1):
                    weight = s.get('weight', 0)
                    reps = s.get('reps', 0)
                    output_lines.append(f"  - Set {j}: {weight} lbs × {reps} reps")
                
                output_lines.append("")  # Blank line between exercises
        
        markdown_text = "\n".join(output_lines)
        return ToolResult(content=[TextContent(type="text", text=markdown_text)])
  • Core helper function that makes the API request to JEFit to retrieve raw workout session data for a specific date. Converts date to Unix timestamp and uses authenticated headers.
    def get_workout_for_date(date_str):
        """Get workout logs for a specific date"""
        date_unix = int(time.mktime(time.strptime(date_str, "%Y-%m-%d")))
        # Get Access Token and User ID
        access_token = get_access_token()
        user_id = get_user_id(access_token)
        url = f"https://www.jefit.com/api/v2/users/{user_id}/sessions?startDate={date_unix}"
        headers = {
            'content-type': 'application/json',
            'Cookie': f'jefitAccessToken={access_token}'
        }
        
        response = requests.get(url, headers=headers)
        return response.json()
  • Helper function that loads or fetches and caches the JEFit exercise database (names, muscle groups, equipment) used to enrich workout logs with human-readable exercise information.
    def load_exercise_db():
        """Load exercise database from JSON cache, creating it if necessary"""
        db_path = Path('data/exercises_db.json')
        
        # Create data directory if it doesn't exist
        db_path.parent.mkdir(exist_ok=True)
        
        # If database doesn't exist, fetch and create it
        if not db_path.exists():
            print("Exercise database not found. Fetching from JEFit...")
            try:
                exercises = fetch_exercise_database()
                
                if not exercises:
                    print("⚠️  No exercises found. Check your authentication.")
                    return {}
                
                # Save to JSON
                with open(db_path, 'w') as f:
                    json.dump(exercises, f, indent=2)
                
                print(f"✓ Created exercise database with {len(exercises)} exercises")
                return exercises
                
            except Exception as e:
                print(f"⚠️  Failed to fetch exercise database: {e}")
                return {}
        
        # Load existing database
        try:
            with open(db_path, 'r') as f:
                return json.load(f)
        except Exception as e:
            print(f"⚠️  Error loading exercise database: {e}")
            return {}
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool returns 'Markdown-formatted workout details' but doesn't cover other important aspects like error handling (e.g., what happens if no workout exists for the date), authentication needs, rate limits, or whether it's a read-only operation. The description is minimal and lacks behavioral context beyond the basic return format.

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

Conciseness4/5

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

The description is well-structured and concise, with a clear purpose statement followed by 'Args' and 'Returns' sections. Each sentence adds value: the first states the tool's function, the second specifies the date format, and the third describes the return content. There's no wasted text, though it could be slightly more front-loaded by integrating the date format into the initial sentence.

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 low complexity (one parameter, no annotations, no output schema), the description is adequate but has gaps. It covers the parameter format and return format, but lacks behavioral details like error handling or sibling tool differentiation. For a simple read operation, this is minimally viable, but it doesn't fully prepare an agent for edge cases or optimal usage.

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?

The description adds significant value beyond the input schema, which has 0% description coverage. It specifies that the 'date' parameter should be in 'YYYY-MM-DD format', which is crucial semantic information not present in the schema (which only indicates it's a string). With only one parameter, this clarification is sufficient to compensate for the schema's lack of documentation.

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 tool's purpose: 'Get detailed workout information for a specific date.' It specifies the verb ('Get'), resource ('workout information'), and scope ('for a specific date'). However, it doesn't explicitly differentiate from sibling tools like 'get_batch_workouts' or 'list_workout_dates' beyond the single-date focus.

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?

The description provides no guidance on when to use this tool versus its siblings. It mentions retrieving information 'for a specific date' but doesn't clarify when to choose this over 'get_batch_workouts' (likely for multiple dates) or 'list_workout_dates' (likely for listing dates without details). No exclusions or prerequisites are mentioned.

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/ai-mcp-garage/jefit-mcp'

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