Skip to main content
Glama

get_session_weather

Retrieve detailed weather data for specific Formula 1 sessions, including temperature, humidity, pressure, wind, and rainfall measurements throughout the event.

Instructions

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
gpYes
sessionYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
event_nameYesGrand Prix name
session_nameYesSession name
total_pointsYesTotal number of weather data points
weather_dataYesWeather data points throughout session

Implementation Reference

  • The core handler function that retrieves historical weather data for a specific F1 session using FastF1 client, processes the pandas DataFrame into individual WeatherDataPoint models, and constructs the 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 models defining the input/output structure: WeatherDataPoint for individual readings and SessionWeatherDataResponse for the full session weather response.
    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)
    Registers the get_session_weather function as an MCP tool in the main server.
    mcp.tool()(get_session_weather)
  • Package-level import of the tool for exposure through tools namespace.
    from .weather import get_session_weather
  • Subpackage export of the tool function.
    from .session_weather import get_session_weather
    
    __all__ = ["get_session_weather"]
Behavior3/5

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

With no annotations provided, the description carries full burden. It indicates this is a read operation (no destructive behavior mentioned) and specifies the data format returned (time-series). However, it doesn't disclose important behavioral traits like rate limits, authentication requirements, error conditions, or whether the data is real-time vs historical. The description adds some context but leaves gaps.

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 efficiently structured with a clear purpose statement, parameter explanations, return value description, and an illustrative example - all in 4 brief sentences. Every element adds value without redundancy, and the information is front-loaded with the core purpose first.

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 moderate complexity (3 parameters, time-series data) and the presence of an output schema, the description provides good coverage. It explains what data is returned and includes a helpful example. However, for a tool with no annotations, it could benefit from more behavioral context about data freshness, availability, or limitations.

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 providing clear semantics for all 3 parameters: 'year' is explained as 'Season year (2018+)', 'gp' as 'Grand Prix name or round', and 'session' with specific valid values ('FP1', 'FP2', 'FP3', 'Q', 'S', 'R'). The example further clarifies parameter usage with concrete values.

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 verb ('Get') and resource ('time-series weather data'), listing the exact data fields returned (temp, humidity, pressure, wind, rainfall). It distinguishes from sibling tools by focusing specifically on weather data rather than telemetry, results, or other session information.

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 about when to use this tool - for obtaining weather data during specific F1 sessions. However, it doesn't explicitly state when NOT to use it or mention alternatives (like whether other tools might provide weather data in different formats). The example helps illustrate proper 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/praneethravuri/pitstop'

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