Skip to main content
Glama

get_live_intervals

Retrieve real-time gaps and intervals between Formula 1 drivers during sessions. Query live timing data from OpenF1 to analyze performance differences and track positions.

Instructions

Get real-time gaps and intervals between drivers from OpenF1.

Args: year: Season year (2023+, OpenF1 data availability) country: Country name (e.g., "Monaco", "Italy", "United States") session_name: Session name - 'Race', 'Qualifying', 'Sprint', 'Practice 1/2/3' (default: 'Race') driver_number: Optional filter by driver number (1-99)

Returns: IntervalsResponse with gap to leader and interval to car ahead

Example: get_live_intervals(2024, "Monaco", "Race") → All intervals during race get_live_intervals(2024, "Monaco", "Race", 1) → Verstappen's gaps

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYes
countryYes
session_nameNoRace
driver_numberNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearNoYear
countryNoCountry name
intervalsYesList of interval data points
session_nameNoSession name
total_data_pointsYesTotal number of data points

Implementation Reference

  • The core handler function implementing the get_live_intervals tool logic, fetching live driver gaps and intervals from OpenF1 API using session keys.
    def get_live_intervals(
        year: int,
        country: str,
        session_name: str = "Race",
        driver_number: Optional[int] = None
    ) -> IntervalsResponse:
        """
        Get real-time gaps and intervals between drivers from OpenF1.
    
        Args:
            year: Season year (2023+, OpenF1 data availability)
            country: Country name (e.g., "Monaco", "Italy", "United States")
            session_name: Session name - 'Race', 'Qualifying', 'Sprint', 'Practice 1/2/3' (default: 'Race')
            driver_number: Optional filter by driver number (1-99)
    
        Returns:
            IntervalsResponse with gap to leader and interval to car ahead
    
        Example:
            get_live_intervals(2024, "Monaco", "Race") → All intervals during race
            get_live_intervals(2024, "Monaco", "Race", 1) → Verstappen's gaps
        """
        # Get meeting and session info
        meetings = openf1_client.get_meetings(year=year, country_name=country)
        if not meetings:
            return IntervalsResponse(
                session_name=session_name,
                year=year,
                country=country,
                intervals=[],
                total_data_points=0
            )
    
        # Get sessions for this meeting
        sessions = openf1_client.get_sessions(year=year, country_name=country, session_name=session_name)
        if not sessions:
            return IntervalsResponse(
                session_name=session_name,
                year=year,
                country=country,
                intervals=[],
                total_data_points=0
            )
    
        session = sessions[0]
        session_key = session['session_key']
    
        # Get intervals data
        interval_data = openf1_client.get_intervals(
            session_key=session_key,
            driver_number=driver_number
        )
    
        # Convert to Pydantic models
        intervals = [
            IntervalData(
                date=data['date'],
                driver_number=data['driver_number'],
                gap_to_leader=data.get('gap_to_leader'),
                interval=data.get('interval'),
                session_key=data['session_key'],
                meeting_key=data['meeting_key']
            )
            for data in interval_data
        ]
    
        return IntervalsResponse(
            session_name=session_name,
            year=year,
            country=country,
            intervals=intervals,
            total_data_points=len(intervals)
        )
  • Pydantic models (IntervalData and IntervalsResponse) defining the input parameters and output schema for the get_live_intervals tool.
    class IntervalData(BaseModel):
        """Interval and gap data."""
        date: str = Field(..., description="Timestamp")
        driver_number: int = Field(..., description="Driver number (1-99)")
        gap_to_leader: Optional[Union[str, float]] = Field(None, description="Gap to race leader")
        interval: Optional[Union[str, float]] = Field(None, description="Interval to car ahead")
        session_key: int = Field(..., description="Session identifier")
        meeting_key: int = Field(..., description="Meeting identifier")
    
    
    class IntervalsResponse(BaseModel):
        """Response for intervals data."""
        session_name: Optional[str] = Field(None, description="Session name")
        year: Optional[int] = Field(None, description="Year")
        country: Optional[str] = Field(None, description="Country name")
        intervals: list[IntervalData] = Field(..., description="List of interval data points")
        total_data_points: int = Field(..., description="Total number of data points")
  • server.py:170-170 (registration)
    Registration of the get_live_intervals tool with the MCP server using the mcp.tool() decorator.
    mcp.tool()(get_live_intervals)
  • Initialization of the shared OpenF1Client instance used by the get_live_intervals handler.
    openf1_client = OpenF1Client()
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions 'real-time' data and OpenF1 as the source, but doesn't address important behavioral aspects like rate limits, authentication requirements, data freshness, error conditions, or whether this is a read-only operation. The description provides basic functionality but lacks operational context.

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 clear sections (purpose, Args, Returns, Example). Every sentence earns its place, providing necessary information without redundancy. The front-loaded purpose statement immediately communicates the tool's function, followed by well-organized supporting details.

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 (4 parameters, no annotations, but has output schema), the description provides good coverage. The presence of an output schema means the description doesn't need to detail return values, and it adequately explains all parameters. However, it could better address behavioral aspects given the lack of annotations.

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?

With 0% schema description coverage, the description compensates well by explaining all 4 parameters in the Args section. It clarifies year constraints (2023+), provides country examples, lists valid session_name options, and explains driver_number's optional filtering purpose. The description adds substantial value beyond the bare schema, though it doesn't specify exact format requirements for country names.

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 ('Get real-time gaps and intervals between drivers') and identifies the data source (OpenF1). It distinguishes this tool from siblings like get_laps, get_live_pit_stops, and get_stints_live by focusing specifically on interval/gap data rather than lap times, pit stops, or stint information.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides implied usage guidance through examples showing when to use the optional driver_number parameter, but lacks explicit guidance on when to choose this tool over alternatives like get_session_results or compare_driver_telemetry. The examples demonstrate different use cases but don't articulate clear decision criteria.

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