Skip to main content
Glama
notsedano

Formula One MCP Server

compare_drivers

Compare Formula One driver performance by analyzing race results, qualifying times, and session data for specific seasons and events.

Instructions

Compare performance between multiple Formula One drivers

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesSeason year (e.g., 2023)
event_identifierYesEvent name or round number (e.g., 'Monaco' or '7')
session_nameYesSession name (e.g., 'Race', 'Qualifying', 'Sprint', 'FP1', 'FP2', 'FP3')
driversYesComma-separated list of driver codes (e.g., 'HAM,VER,LEC')

Implementation Reference

  • Core handler function that implements the compare_drivers tool logic using FastF1 to load session data, extract laps for multiple drivers, compute performance metrics like fastest lap, average lap time, and total laps, and return structured comparison data.
    def compare_drivers(year, event_identifier, session_name, drivers):
        """
        Compare performance between multiple Formula One drivers.
    
        Args:
            year (int or str): The year of the F1 season
            event_identifier (str): Event name or round number
            session_name (str): Session type (Race, Qualifying, Sprint, etc.)
            drivers (str): Comma-separated list of driver codes
    
        Returns:
            dict: Status and driver comparison data or error information
        """
        try:
            year = int(year)
            drivers_list = drivers.split(",")
    
            session = fastf1.get_session(year, event_identifier, session_name)
            session.load()
    
            driver_comparisons = []
    
            for driver in drivers_list:
                # Get laps and fastest lap for each driver
                driver_laps = session.laps.pick_driver(driver)
                fastest_lap = driver_laps.pick_fastest()
    
                # Calculate average lap time
                valid_lap_times = []
                for _, lap in driver_laps.iterrows():
                    if lap["LapTime"] is not None and not pd.isna(lap["LapTime"]):
                        valid_lap_times.append(lap["LapTime"].total_seconds())
    
                avg_lap_time = (
                    sum(valid_lap_times) / len(valid_lap_times) if valid_lap_times else None
                )
    
                # Format lap time as string
                formatted_fastest = None
                fastest_lap_number = None
                if fastest_lap is not None:
                    formatted_fastest = (
                        str(fastest_lap["LapTime"])
                        if not pd.isna(fastest_lap["LapTime"])
                        else None
                    )
                    fastest_lap_number = (
                        int(fastest_lap["LapNumber"])
                        if not pd.isna(fastest_lap["LapNumber"])
                        else None
                    )
    
                # Compile driver data
                driver_data = {
                    "DriverCode": driver,
                    "FastestLap": formatted_fastest,
                    "FastestLapNumber": fastest_lap_number,
                    "TotalLaps": len(driver_laps),
                    "AverageLapTime": avg_lap_time,
                }
    
                driver_comparisons.append(driver_data)
    
            return {"status": "success", "data": driver_comparisons}
        except Exception as e:
            return {"status": "error", "message": str(e)}
  • Dispatch logic in the MCP server's call_tool handler that routes requests for 'compare_drivers' to the actual implementation function.
    elif name == "compare_drivers":
        result = compare_drivers(
            sanitized_args["year"],
            str(arguments["event_identifier"]),
            str(arguments["session_name"]),
            str(arguments["drivers"]),
        )
  • MCP tool registration in list_tools() that defines the compare_drivers tool name, description, and input schema for validation.
    types.Tool(
        name="compare_drivers",
        description=(
            "Compare performance between multiple Formula One drivers"
        ),
        inputSchema={
            "type": "object",
            "properties": {
                "year": {
                    "type": "number",
                    "description": "Season year (e.g., 2023)",
                },
                "event_identifier": {
                    "type": "string",
                    "description": (
                        "Event name or round number (e.g., 'Monaco' or '7')"
                    ),
                },
                "session_name": {
                    "type": "string",
                    "description": (
                        "Session name (e.g., 'Race', 'Qualifying', "
                        "'Sprint', 'FP1', 'FP2', 'FP3')"
                    ),
                },
                "drivers": {
                    "type": "string",
                    "description": (
                        "Comma-separated list of driver codes "
                        "(e.g., 'HAM,VER,LEC')"
                    ),
                },
            },
            "required": [
                "year",
                "event_identifier",
                "session_name",
                "drivers",
            ],
        },
    ),
  • Secondary registration of compare_drivers in the FastAPI bridge's tool_functions mapping for direct HTTP tool calls.
    tool_functions = {
        'get_championship_standings': get_championship_standings,
        'get_event_schedule': get_event_schedule,
        'get_event_info': get_event_info,
        'get_session_results': get_session_results,
        'get_driver_info': get_driver_info,
        'analyze_driver_performance': analyze_driver_performance,
        'compare_drivers': compare_drivers,
        'get_telemetry': get_telemetry
    }
  • Client-side TypeScript schema reference for the compare_drivers tool.
    name: 'compare_drivers',
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 but provides minimal information. It states what the tool does but doesn't describe how it works, what format the comparison takes, whether it returns statistical data or visualizations, error conditions, or performance characteristics. For a tool with 4 required parameters and no annotations, this is inadequate.

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 a single, clear sentence that states the core purpose without unnecessary words. It's appropriately sized for a straightforward comparison tool and gets directly to the point with zero wasted verbiage.

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

Completeness2/5

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

For a tool with 4 required parameters, no annotations, and no output schema, the description is insufficiently complete. It doesn't explain what 'performance' means in this context, what metrics are compared, the format of results, or how to interpret the output. The agent would struggle to use this tool effectively without trial and error.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds no additional parameter information beyond what's in the schema. The baseline score of 3 is appropriate when the schema does the heavy lifting, though the description could have added context about parameter relationships or usage patterns.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/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 as 'Compare performance between multiple Formula One drivers' with a specific verb ('compare') and resource ('drivers'). It distinguishes from some siblings like 'get_driver_info' (individual info) and 'get_championship_standings' (overall standings), but doesn't explicitly differentiate from 'analyze_driver_performance' which might have overlapping functionality.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose this over 'analyze_driver_performance', 'get_session_results', or other sibling tools. There's no context about prerequisites, limitations, or appropriate scenarios for using this comparison tool.

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/notsedano/f1-mcp-server'

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