Skip to main content
Glama
Josh-Mantel

F1 MCP Server

by Josh-Mantel

get_lap_times

Retrieve lap time data for Formula 1 sessions to analyze driver performance and session results by specifying season, round, and session type.

Instructions

Get lap times for a specific session

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesSeason year (e.g., 2024)
round_numberYesRound number (1-24)
sessionYesSession type
driverNoDriver abbreviation (optional, e.g., 'VER', 'HAM')

Implementation Reference

  • The main handler function for the get_lap_times tool, which fetches lap times using FastF1.
    async def get_lap_times(arguments: Dict[str, Any]) -> List[TextContent]:
        """Get lap times for a session."""
        year = arguments["year"]
        round_number = arguments["round_number"]
        session_type = arguments["session"]
        driver_filter = arguments.get("driver")
    
        try:
            session = fastf1.get_session(year, round_number, session_type)
            session.load()
    
            laps = session.laps
    
            # Filter by driver if specified
            if driver_filter:
                laps = laps[laps["Driver"] == driver_filter.upper()]
    
            # Convert lap times to readable format
            lap_data = []
            for _, lap in laps.iterrows():
                lap_data.append(
                    {
                        "lap_number": (
                            int(lap["LapNumber"]) if pd.notna(lap["LapNumber"]) else None
                        ),
                        "driver": lap["Driver"],
                        "team": lap["Team"],
                        "lap_time": (
                            str(lap["LapTime"]) if pd.notna(lap["LapTime"]) else None
                        ),
                        "sector_1": (
                            str(lap["Sector1Time"])
                            if pd.notna(lap.get("Sector1Time"))
                            else None
                        ),
                        "sector_2": (
                            str(lap["Sector2Time"])
                            if pd.notna(lap.get("Sector2Time"))
                            else None
                        ),
                        "sector_3": (
  • Tool definition and registration for get_lap_times.
    Tool(
        name="get_lap_times",
        description="Get lap times for a specific session",
        inputSchema={
            "type": "object",
            "properties": {
                "year": {
                    "type": "integer",
                    "description": "Season year (e.g., 2024)",
                },
                "round_number": {
                    "type": "integer",
                    "description": "Round number (1-24)",
                },
                "session": {
                    "type": "string",
                    "description": "Session type",

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/Josh-Mantel/MCP-F1'

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