Skip to main content
Glama

compare_driver_telemetry

Analyze and compare Formula 1 driver telemetry data to evaluate racing lines, braking points, and driving styles across different sessions.

Instructions

Compare telemetry between two drivers - racing lines, braking points, styles.

Args: year: Season year (2018+) gp: Grand Prix name or round session: 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R' driver1, driver2: Driver codes or numbers lap1, lap2: Lap numbers (fastest if None)

Returns: TelemetryComparisonResponse with both drivers' telemetry

Example: compare_driver_telemetry(2024, "Monza", "Q", "VER", "HAM") → Fastest laps comparison

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
gpYes
sessionYes
driver1Yes
driver2Yes
lap1No
lap2No

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
driver1YesFirst driver abbreviation
driver2YesSecond driver abbreviation
event_nameYesGrand Prix name
driver1_lapYesFirst driver lap number
driver2_lapYesSecond driver lap number
session_nameYesSession name
driver1_lap_timeNoFirst driver lap time
driver2_lap_timeNoSecond driver lap time
driver1_telemetryYesFirst driver telemetry
driver2_telemetryYesSecond driver telemetry

Implementation Reference

  • Main handler function that loads F1 session data with FastF1, retrieves specified or fastest laps for two drivers, fetches their telemetry DataFrames, converts to TelemetryPoint models using helper, and returns structured TelemetryComparisonResponse.
    def compare_driver_telemetry(
        year: int,
        gp: Union[str, int],
        session: str,
        driver1: Union[str, int],
        driver2: Union[str, int],
        lap1: Optional[int] = None,
        lap2: Optional[int] = None
    ) -> TelemetryComparisonResponse:
        """
        Compare telemetry between two drivers - racing lines, braking points, styles.
    
        Args:
            year: Season year (2018+)
            gp: Grand Prix name or round
            session: 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R'
            driver1, driver2: Driver codes or numbers
            lap1, lap2: Lap numbers (fastest if None)
    
        Returns:
            TelemetryComparisonResponse with both drivers' telemetry
    
        Example:
            compare_driver_telemetry(2024, "Monza", "Q", "VER", "HAM") → Fastest laps comparison
        """
        session_obj = fastf1_client.get_session(year, gp, session)
        session_obj.load(laps=True, telemetry=True, weather=False, messages=False)
    
        event = session_obj.event
    
        # Get driver 1 lap
        driver1_laps = session_obj.laps.pick_drivers(driver1)
        if lap1 is None:
            lap1_data = driver1_laps.pick_fastest()
        else:
            lap1_data = driver1_laps[driver1_laps['LapNumber'] == lap1].iloc[0]
    
        # Get driver 2 lap
        driver2_laps = session_obj.laps.pick_drivers(driver2)
        if lap2 is None:
            lap2_data = driver2_laps.pick_fastest()
        else:
            lap2_data = driver2_laps[driver2_laps['LapNumber'] == lap2].iloc[0]
    
        # Get telemetry
        tel1_df = lap1_data.get_telemetry()
        tel2_df = lap2_data.get_telemetry()
    
        # Convert to Pydantic models
        driver1_telemetry = _telemetry_to_points(tel1_df)
        driver2_telemetry = _telemetry_to_points(tel2_df)
    
        return TelemetryComparisonResponse(
            session_name=session_obj.name,
            event_name=event['EventName'],
            driver1=str(lap1_data['Driver']),
            driver1_lap=int(lap1_data['LapNumber']),
            driver1_telemetry=driver1_telemetry,
            driver1_lap_time=str(lap1_data['LapTime']) if pd.notna(lap1_data.get('LapTime')) else None,
            driver2=str(lap2_data['Driver']),
            driver2_lap=int(lap2_data['LapNumber']),
            driver2_telemetry=driver2_telemetry,
            driver2_lap_time=str(lap2_data['LapTime']) if pd.notna(lap2_data.get('LapTime')) else None,
        )
  • Pydantic BaseModel defining the output schema for the tool response, including telemetry lists for both drivers. TelemetryPoint model (lines 5-19) defines individual data points.
    class TelemetryComparisonResponse(BaseModel):
        """Telemetry comparison response for two drivers."""
    
        session_name: str = Field(description="Session name")
        event_name: str = Field(description="Grand Prix name")
        driver1: str = Field(description="First driver abbreviation")
        driver1_lap: int = Field(description="First driver lap number")
        driver1_telemetry: list[TelemetryPoint] = Field(description="First driver telemetry")
        driver1_lap_time: Optional[str] = Field(None, description="First driver lap time")
        driver2: str = Field(description="Second driver abbreviation")
        driver2_lap: int = Field(description="Second driver lap number")
        driver2_telemetry: list[TelemetryPoint] = Field(description="Second driver telemetry")
        driver2_lap_time: Optional[str] = Field(None, description="Second driver lap time")
  • server.py:159-159 (registration)
    Registration of the tool using FastMCP decorator in the main server file.
    mcp.tool()(compare_driver_telemetry)
  • Supporting function to transform FastF1 telemetry pandas DataFrame rows into list of TelemetryPoint pydantic models for serialization.
    def _telemetry_to_points(telemetry_df):
        """Convert telemetry DataFrame to list of TelemetryPoint pydantic models."""
        points = []
        for idx, row in telemetry_df.iterrows():
            point = TelemetryPoint(
                session_time=str(row['SessionTime']) if pd.notna(row.get('SessionTime')) else None,
                distance=float(row['Distance']) if pd.notna(row.get('Distance')) else None,
                speed=float(row['Speed']) if pd.notna(row.get('Speed')) else None,
                rpm=float(row['RPM']) if pd.notna(row.get('RPM')) else None,
                n_gear=int(row['nGear']) if pd.notna(row.get('nGear')) else None,
                throttle=float(row['Throttle']) if pd.notna(row.get('Throttle')) else None,
                brake=float(row['Brake']) if pd.notna(row.get('Brake')) else None,
                drs=int(row['DRS']) if pd.notna(row.get('DRS')) else None,
                x=float(row['X']) if pd.notna(row.get('X')) else None,
                y=float(row['Y']) if pd.notna(row.get('Y')) else None,
                z=float(row['Z']) if pd.notna(row.get('Z')) else None,
            )
            points.append(point)
        return points
Behavior3/5

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

With no annotations provided, the description carries the full burden. It describes the tool's behavior by specifying what gets compared and default behavior (fastest laps if lap numbers not provided), but doesn't cover important aspects like data availability constraints, rate limits, or authentication needs for a telemetry comparison tool.

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 structured and front-loaded: purpose statement first, then Args with all parameters explained, Returns section, and a concrete Example. Every sentence earns its place with zero waste, making it easy for an agent to parse and understand.

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

Completeness4/5

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

Given the tool's complexity (7 parameters, comparison operation) and the presence of an output schema (TelemetryComparisonResponse), the description is nearly complete. It explains all parameters thoroughly and provides usage context. The main gap is lack of behavioral constraints disclosure, which would be helpful for a data-intensive comparison tool.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by explaining all 7 parameters in detail: year constraints (2018+), gp format options, session codes, driver identifiers, and lap number behavior (fastest if None). The Args section provides complete semantic understanding beyond the bare 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 tool's purpose with specific verbs ('compare telemetry') and resources ('two drivers'), listing concrete aspects like 'racing lines, braking points, styles'. It distinguishes itself from siblings like get_lap_telemetry (single driver) or get_analysis (general analysis).

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 usage through the example, showing it's for comparing drivers in specific sessions. However, it doesn't explicitly state when NOT to use it or name alternatives among siblings, though the purpose implies differentiation from single-driver tools.

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/praneethravuri/pitstop'

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