Skip to main content
Glama

get_tire_strategy

Analyze tire compounds, life, and stint data for F1 sessions to understand race strategy and tire management decisions.

Instructions

Get tire strategy and compound usage for a session.

Analyzes tire compounds used throughout a session, including compound types, tire life, and stint information. Essential for understanding race strategy and tire management.

Args: year: The season year (2018 onwards) gp: The Grand Prix name or round number session: Session type - 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R' driver: Optional driver identifier (3-letter code or number). If None, returns data for all drivers

Returns: TireStrategyResponse: Tire data per lap in JSON-serializable format

Examples: >>> # Get tire strategy for all drivers in 2024 Monza race >>> strategy = get_tire_strategy(2024, "Monza", "R")

>>> # Get Verstappen's tire strategy >>> ver_strategy = get_tire_strategy(2024, "Monza", "R", "VER")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
driverNo
gpYes
sessionYes
yearYes

Implementation Reference

  • The core handler function implementing the get_tire_strategy tool logic. Fetches session data using FastF1Client, processes tire stint data from laps DataFrame, constructs list of TireStint models, and returns structured TireStrategyResponse.
    def get_tire_strategy(year: int, gp: Union[str, int], session: str, driver: Optional[Union[str, int]] = None) -> TireStrategyResponse: """ Get tire strategy and compound usage for a session. Analyzes tire compounds used throughout a session, including compound types, tire life, and stint information. Essential for understanding race strategy and tire management. Args: year: The season year (2018 onwards) gp: The Grand Prix name or round number session: Session type - 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R' driver: Optional driver identifier (3-letter code or number). If None, returns data for all drivers Returns: TireStrategyResponse: Tire data per lap in JSON-serializable format Examples: >>> # Get tire strategy for all drivers in 2024 Monza race >>> strategy = get_tire_strategy(2024, "Monza", "R") >>> # Get Verstappen's tire strategy >>> ver_strategy = get_tire_strategy(2024, "Monza", "R", "VER") """ session_obj = fastf1_client.get_session(year, gp, session) session_obj.load(laps=True, telemetry=False, weather=False, messages=False) event = session_obj.event if driver: laps = session_obj.laps.pick_drivers(driver) else: laps = session_obj.laps tire_data = laps[['Driver', 'LapNumber', 'Compound', 'TyreLife', 'FreshTyre']] # Convert to Pydantic models tire_stints = [] for idx, row in tire_data.iterrows(): stint = TireStint( driver=str(row['Driver']) if pd.notna(row.get('Driver')) else "", lap_number=int(row['LapNumber']) if pd.notna(row.get('LapNumber')) else 0, compound=str(row['Compound']) if pd.notna(row.get('Compound')) else None, tyre_life=float(row['TyreLife']) if pd.notna(row.get('TyreLife')) else None, fresh_tyre=bool(row['FreshTyre']) if pd.notna(row.get('FreshTyre')) else None, ) tire_stints.append(stint) return TireStrategyResponse( session_name=session_obj.name, event_name=event['EventName'], driver=str(driver) if driver else None, tire_data=tire_stints, total_laps=len(tire_stints) )
  • Pydantic BaseModel definitions for TireStint (per-lap tire data) and TireStrategyResponse (overall tire strategy output structure), providing input/output validation and serialization.
    from pydantic import BaseModel, Field from typing import Optional class TireStint(BaseModel): """Tire data for a single lap.""" driver: str = Field(description="Driver abbreviation") lap_number: int = Field(description="Lap number") compound: Optional[str] = Field(None, description="Tire compound (SOFT, MEDIUM, HARD, INTERMEDIATE, WET)") tyre_life: Optional[float] = Field(None, description="Age of tire in laps") fresh_tyre: Optional[bool] = Field(None, description="Whether it's a new tire") class TireStrategyResponse(BaseModel): """Tire strategy response.""" session_name: str = Field(description="Session name") event_name: str = Field(description="Grand Prix name") driver: Optional[str] = Field(None, description="Driver filter (if applied)") tire_data: list[TireStint] = Field(description="Tire data per lap") total_laps: int = Field(description="Total number of laps")
  • server.py:153-153 (registration)
    Explicit registration of the get_tire_strategy function as an MCP tool using the mcp.tool() decorator.
    mcp.tool()(get_tire_strategy)

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