Skip to main content
Glama
rakeshgangwar

Formula One MCP Server

compare_drivers

Analyze and compare Formula One driver performance by season, event, and session using driver codes, providing insights into race results and statistics.

Instructions

Compare performance between multiple Formula One drivers

Input Schema

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

Implementation Reference

  • Core implementation of the compare_drivers tool. Loads F1 session data using fastf1, computes and compares key performance metrics (fastest lap, average lap time, total laps, etc.) for multiple drivers specified as a comma-separated list.
    def compare_drivers(year, event_identifier, session_name, drivers):
        """Compare performance between multiple drivers"""
        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 = str(fastest_lap['LapTime']) if not pd.isna(fastest_lap['LapTime']) else None
                
                # Compile driver data
                driver_data = {
                    "DriverCode": driver,
                    "FastestLap": formatted_fastest,
                    "FastestLapNumber": int(fastest_lap['LapNumber']) if not pd.isna(fastest_lap['LapNumber']) else None,
                    "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), "traceback": traceback.format_exc()}
  • src/index.ts:197-222 (registration)
    MCP tool registration in the listTools response, including name, description, and input schema validation.
    {
      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'],
      },
    },
  • TypeScript type definition for the input arguments of the compare_drivers tool.
    type CompareDriversArgs = { year: number; event_identifier: string; session_name: string; drivers: string };
  • TypeScript handler that proxies the compare_drivers tool call to the Python backend via executePythonFunction.
    case 'compare_drivers': {
      const typedArgs = args as CompareDriversArgs;
      result = await executePythonFunction('compare_drivers', [
        typedArgs.year.toString(),
        typedArgs.event_identifier.toString(),
        typedArgs.session_name.toString(),
        typedArgs.drivers.toString(),
      ]);
      break;
  • Registration of the compare_drivers function in the Python bridge's function dispatch dictionary.
    "compare_drivers": compare_drivers,
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions 'compare performance' but doesn't specify what 'performance' entails (e.g., lap times, positions, statistics), how results are returned, or any constraints like rate limits or authentication needs. This is a significant gap for a tool with multiple required parameters and no output schema.

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, efficient sentence that directly states the tool's purpose without any fluff. It's front-loaded and wastes no words, making it easy for an agent to parse quickly. Every word earns its place in conveying the core function.

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?

Given the complexity of comparing multiple drivers across events and sessions, with no annotations and no output schema, the description is insufficient. It doesn't explain what 'performance' means, how comparisons are made, or what the output looks like. This leaves critical gaps for an agent to understand the tool's behavior and results.

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?

The schema description coverage is 100%, with each parameter clearly documented in the input schema. The description adds no additional meaning beyond the schema, such as explaining interactions between parameters or usage examples. This meets the baseline for high schema coverage but doesn't enhance understanding.

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: 'Compare performance between multiple Formula One drivers.' It specifies the verb 'compare' and the resource 'Formula One drivers,' but doesn't explicitly differentiate from siblings like 'analyze_driver_performance' or 'get_session_results,' which might overlap in functionality. This makes it clear but not fully distinct.

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. With siblings like 'analyze_driver_performance' and 'get_session_results' that might offer similar or related data, there's no indication of context, prerequisites, or exclusions. This leaves the agent without direction on tool selection.

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

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

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