Skip to main content
Glama
Machine-To-Machine

Formula One MCP Server (Python)

get_driver_info

Retrieve detailed information about a Formula One driver by specifying season year, event, session, and driver identifier.

Instructions

Get information about a specific Formula One driver

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')
driver_identifierYesDriver identifier (number, code, or name; e.g., '44', 'HAM', 'Hamilton')

Implementation Reference

  • The actual implementation of get_driver_info: loads a session via FastF1, retrieves driver information using session.get_driver(), converts to JSON-serializable dict, and returns it wrapped in a status/data response.
    def get_driver_info(
        year: Any, event_identifier: str, session_name: str, driver_identifier: str
    ) -> dict[str, Any]:
        """
        Get information about a specific Formula One driver.
    
        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.)
            driver_identifier (str): Driver number, code, or name
    
        Returns:
            dict: Status and driver information or error information
        """
        try:
            # Validate year
            year_int = validate_year(year)
    
            logger.debug(
                f"Fetching driver info for {year_int}, "
                f"event: {event_identifier}, session: {session_name}, "
                f"driver: {driver_identifier}"
            )
            session = fastf1.get_session(year_int, event_identifier, session_name)
            # Load session without telemetry for faster results
            session.load(telemetry=False)
    
            driver_info = session.get_driver(driver_identifier)
    
            # Convert to JSON serializable format
            driver_dict = driver_info.to_dict()
            clean_dict = {k: json_serial(v) for k, v in driver_dict.items()}
    
            logger.info(f"Successfully retrieved driver info for {driver_identifier}")
            return {"status": "success", "data": clean_dict}
        except Exception as e:
            logger.error(f"Error retrieving driver info: {str(e)}", exc_info=True)
            return {
                "status": "error",
                "message": f"Failed to retrieve driver information: {str(e)}",
            }
  • Input schema/registration for get_driver_info tool: defines 4 required parameters (year, event_identifier, session_name, driver_identifier) and their descriptions and types.
    types.Tool(
        name="get_driver_info",
        description=("Get information about a specific Formula One driver"),
        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')"
                    ),
                },
                "driver_identifier": {
                    "type": "string",
                    "description": (
                        "Driver identifier (number, code, or name; "
                        "e.g., '44', 'HAM', 'Hamilton')"
                    ),
                },
            },
            "required": [
                "year",
                "event_identifier",
                "session_name",
                "driver_identifier",
            ],
        },
  • Import of get_driver_info from f1_data module into server.py, enabling its use as a registered tool.
    from .f1_data import (
        analyze_driver_performance,
        compare_drivers,
        get_championship_standings,
        get_driver_info,
        get_event_info,
        get_event_schedule,
        get_session_results,
        get_telemetry,
    )
  • The validate_year helper function used by get_driver_info to validate the year parameter.
    def validate_year(year: Any) -> int:
        """
        Validate that the provided year is valid for F1 data.
    
        Args:
            year: Year value to validate
    
        Returns:
            Valid year as integer
    
        Raises:
            ValueError: If year is invalid
        """
        try:
            year_int = int(year)
            # F1 started in 1950 and we don't want future years far ahead
            current_year = datetime.now().year
            if year_int < 1950 or year_int > current_year + 1:
                raise ValueError(f"Year must be between 1950 and {current_year + 1}")
            return year_int
        except (ValueError, TypeError) as e:
            raise ValueError(f"Invalid year format: {year}") from e
  • The json_serial helper function used by get_driver_info to convert non-JSON-serializable objects (datetime, numpy types, NaN) to JSON-compatible values.
    def json_serial(obj: Any) -> str | int | float | None:
        """
        Convert non-JSON serializable objects to strings.
    
        Args:
            obj: Object to be serialized to JSON
    
        Returns:
            JSON serializable representation of the object
        """
        if isinstance(obj, datetime | pd.Timestamp):
            return obj.isoformat()
        if isinstance(obj, np.integer):
            return int(obj)
        if isinstance(obj, np.floating):
            return float(obj)
        if pd.isna(obj) or obj is None:
            return None
        return str(obj)
Behavior2/5

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

With no annotations, the description carries the full burden of behavioral disclosure. It only states the basic purpose, offering no details about side effects (none expected), authentication needs, rate limits, or data freshness. The agent is left guessing about operational characteristics.

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?

A single sentence that is concise and front-loaded with the key action and resource. No unnecessary words or redundancy.

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?

Despite 4 required parameters and no output schema, the description fails to explain what information is returned, any constraints (e.g., driver must be participating in the session), or possible error conditions. It is insufficiently complete for a data retrieval tool.

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 input schema covers 100% of parameters with descriptions, so the baseline is 3. The description adds no extra semantic information beyond what the schema already provides; it just paraphrases the tool's purpose.

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 action ('Get') and resource ('information about a specific Formula One driver'), distinguishing it from sibling tools like 'get_telemetry' or 'get_session_results'. However, it could more precisely indicate that it returns session-level information, as implied by the required parameters.

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?

No guidance is provided on when to use this tool versus alternatives like 'analyze_driver_performance' or 'compare_drivers'. There is no mention of prerequisites, exclusions, or use cases, leaving the agent to infer from names alone.

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

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