Skip to main content
Glama
notsedano

Formula One MCP Server

get_session_results

Retrieve Formula One race, qualifying, or practice session results by specifying year, event, and session type to access detailed performance data.

Instructions

Get results for a specific Formula One session

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')

Implementation Reference

  • Core handler function that implements the get_session_results tool logic using FastF1 API to load session data, extract results, serialize to JSON-compatible format, and handle validation/errors.
    def get_session_results(
        year: Any, event_identifier: str, session_name: str
    ) -> dict[str, Any]:
        """
        Get results for a specific Formula One session.
    
        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.)
    
        Returns:
            dict: Status and session results data or error information
        """
        try:
            # Validate year
            year_int = validate_year(year)
    
            # Validate session name
            valid_sessions = [
                "Race",
                "Qualifying",
                "Sprint",
                "FP1",
                "FP2",
                "FP3",
                "SprintQualifying",
            ]
            if session_name not in valid_sessions:
                raise ValueError(
                    f"Invalid session name. Must be one of: {', '.join(valid_sessions)}"
                )
    
            logger.debug(
                f"Fetching session results for {year_int}, "
                f"event: {event_identifier}, session: {session_name}"
            )
    
            session = fastf1.get_session(year_int, event_identifier, session_name)
            # Load session without telemetry for faster results
            session.load(telemetry=False)
    
            # Get results as a DataFrame
            results = session.results
    
            # Convert results to JSON serializable format
            result_list = []
            for _, result in results.items():
                driver_result = result.to_dict()
                # Clean and convert non-serializable values
                clean_dict = {k: json_serial(v) for k, v in driver_result.items()}
                result_list.append(clean_dict)
    
            logger.info(
                f"Successfully retrieved results for {year_int}, "
                f"event: {event_identifier}, session: {session_name}"
            )
            return {"status": "success", "data": result_list}
        except Exception as e:
            logger.error(f"Error retrieving session results: {str(e)}", exc_info=True)
            return {
                "status": "error",
                "message": f"Failed to retrieve session results: {str(e)}",
            }
  • MCP tool schema definition including input validation schema for get_session_results parameters (year, event_identifier, session_name).
    types.Tool(
        name="get_session_results",
        description="Get results for a specific Formula One session",
        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')"
                    ),
                },
            },
            "required": ["year", "event_identifier", "session_name"],
        },
    ),
  • Import of the get_session_results handler function into the MCP server module for registration and use in tool dispatching.
    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,
    )
  • Tool dispatching logic in the MCP call_tool handler that validates inputs and invokes the get_session_results function.
    elif name == "get_session_results":
        # Additional validations for session-related tools
        if "event_identifier" not in arguments:
            raise ValueError("Missing required argument: event_identifier")
        if "session_name" not in arguments:
            raise ValueError("Missing required argument: session_name")
    
        event_identifier = str(arguments["event_identifier"])
        session_name = str(arguments["session_name"])
    
        # Validate session_name format
        valid_sessions = [
            "Race",
            "Qualifying",
            "Sprint",
            "FP1",
            "FP2",
            "FP3",
            "SprintQualifying",
        ]
        if session_name not in valid_sessions:
            raise ValueError(
                "Invalid session_name: must be one of "
                f"{', '.join(valid_sessions)}"
            )
    
        result = get_session_results(
            sanitized_args["year"],
            event_identifier,
            session_name,
        )
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. It only states what the tool does without mentioning any behavioral traits like whether it's read-only, requires authentication, has rate limits, or what the output format might be. This leaves significant gaps for an agent to understand how to handle the tool safely and effectively.

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, direct sentence that efficiently conveys the core purpose without any wasted words. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 lack of annotations and output schema, the description is incomplete. It does not address what the results include (e.g., lap times, positions), potential errors, or behavioral aspects like data freshness or access restrictions. For a tool with three parameters and no structured output, more context is needed to guide effective usage.

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 has 100% description coverage, clearly documenting all three required parameters. The description does not add any additional meaning beyond the schema, such as parameter interactions or examples. Since the schema does the heavy lifting, the baseline score of 3 is appropriate.

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 verb ('Get') and resource ('results for a specific Formula One session'), making the purpose unambiguous. However, it does not differentiate from sibling tools like 'get_event_info' or 'get_telemetry', which might also retrieve session-related data, so it lacks explicit sibling distinction.

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 does not mention prerequisites, context, or exclusions, such as whether it's for historical data only or how it differs from siblings like 'get_event_info' or 'analyze_driver_performance'.

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