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 the year, event, session, and driver identifier. Access race statistics, performance data, and session-specific insights.

Instructions

Get information about a specific Formula One driver

Input Schema

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

  • The core handler function that retrieves specific driver information from a Formula One session using the fastf1 library, including validation, data fetching, and JSON serialization.
    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)}", }
  • Registers the 'get_driver_info' tool with the MCP server, including its name, description, and input schema for validation.
    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", ], }, ), types.Tool(
  • Defines the input schema for the get_driver_info tool, specifying parameters and their types/requirements.
    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", ], }, ),
  • Dispatches the call to the get_driver_info handler function within the MCP tool execution logic.
    elif name == "get_driver_info": # Handle remaining tools with proper validation # ... similar validation for other parameters ... result = get_driver_info( sanitized_args["year"], str(arguments["event_identifier"]), str(arguments["session_name"]), str(arguments["driver_identifier"]), )

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

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