Skip to main content
Glama

get_session_weather

Retrieve detailed weather data recorded during Formula 1 sessions to analyze how temperature, humidity, wind, and rainfall conditions affect race performance and strategy decisions.

Instructions

Get weather data throughout a session.

Retrieves time-series weather information recorded during a session, including temperature, humidity, pressure, wind, and rainfall data. Essential for understanding session conditions and their impact on performance.

Args: year: The season year (2018 onwards) gp: The Grand Prix name (e.g., 'Monza', 'Monaco') or round number session: Session type - 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R'

Returns: SessionWeatherDataResponse: Weather data throughout session in JSON-serializable format

Examples: >>> # Get weather data from 2024 Spa race >>> weather = get_session_weather(2024, "Spa", "R")

>>> # Check weather conditions during qualifying >>> quali_weather = get_session_weather(2024, "Silverstone", "Q")

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
gpYes
sessionYes
yearYes

Implementation Reference

  • The core handler function that implements the get_session_weather tool logic. It retrieves the session object using FastF1Client, loads weather data, processes it into structured WeatherDataPoint objects, and returns a formatted SessionWeatherDataResponse.
    def get_session_weather(year: int, gp: Union[str, int], session: str) -> SessionWeatherDataResponse: """ Get time-series weather data - temp, humidity, pressure, wind, rainfall. Args: year: Season year (2018+) gp: Grand Prix name or round session: 'FP1', 'FP2', 'FP3', 'Q', 'S', 'R' Returns: SessionWeatherDataResponse with weather points Example: get_session_weather(2024, "Spa", "R") → Weather throughout race """ session_obj = fastf1_client.get_session(year, gp, session) session_obj.load(laps=False, telemetry=False, weather=True, messages=False) event = session_obj.event weather_df = session_obj.weather_data # Convert to Pydantic models weather_points = [] for idx, row in weather_df.iterrows(): point = WeatherDataPoint( time=str(row['Time']) if pd.notna(row.get('Time')) else None, air_temp=float(row['AirTemp']) if pd.notna(row.get('AirTemp')) else None, track_temp=float(row['TrackTemp']) if pd.notna(row.get('TrackTemp')) else None, humidity=float(row['Humidity']) if pd.notna(row.get('Humidity')) else None, pressure=float(row['Pressure']) if pd.notna(row.get('Pressure')) else None, wind_speed=float(row['WindSpeed']) if pd.notna(row.get('WindSpeed')) else None, wind_direction=float(row['WindDirection']) if pd.notna(row.get('WindDirection')) else None, rainfall=bool(row['Rainfall']) if pd.notna(row.get('Rainfall')) else None, ) weather_points.append(point) return SessionWeatherDataResponse( session_name=session_obj.name, event_name=event['EventName'], weather_data=weather_points, total_points=len(weather_points) )
  • Pydantic BaseModel classes defining the output schema (SessionWeatherDataResponse containing list of WeatherDataPoint) for the get_session_weather tool. Input schema is defined by function type hints.
    class WeatherDataPoint(BaseModel): """Single weather data point.""" time: Optional[str] = Field(None, description="Timestamp") air_temp: Optional[float] = Field(None, description="Air temperature (°C)") track_temp: Optional[float] = Field(None, description="Track surface temperature (°C)") humidity: Optional[float] = Field(None, description="Relative humidity (%)") pressure: Optional[float] = Field(None, description="Atmospheric pressure (mbar)") wind_speed: Optional[float] = Field(None, description="Wind speed (m/s)") wind_direction: Optional[float] = Field(None, description="Wind direction (degrees)") rainfall: Optional[bool] = Field(None, description="Whether it's raining") class SessionWeatherDataResponse(BaseModel): """Session weather data response.""" session_name: str = Field(description="Session name") event_name: str = Field(description="Grand Prix name") weather_data: list[WeatherDataPoint] = Field(description="Weather data points throughout session") total_points: int = Field(description="Total number of weather data points")
  • server.py:161-161 (registration)
    MCP tool registration decorator applied to the get_session_weather handler function.
    mcp.tool()(get_session_weather)

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