Skip to main content
Glama
Machine-To-Machine

Formula One MCP Server (Python)

get_championship_standings

Retrieve Formula One championship standings for a season year, with optional round number to get standings at that point in the season.

Instructions

Get Formula One championship standings

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesSeason year (e.g., 2023)
round_numNoRound number (optional, gets latest standings if not provided)

Implementation Reference

  • Handler function that fetches F1 championship standings (drivers and constructors) using the FastF1 Ergast API. Accepts a year (required) and optional round_num. Returns JSON-serializable driver and constructor standings data.
    def get_championship_standings(year, round_num=None):
        """
        Get championship standings for drivers and constructors.
    
        Args:
            year (int or str): The year of the F1 season
            round_num (int, optional): Specific round number or None for latest
    
        Returns:
            dict: Status and championship standings or error information
        """
        try:
            year = int(year)
    
            # Create Ergast API client
            ergast = fastf1.ergast.Ergast()
    
            # Get Ergast API data
            if round_num:
                round_num = int(round_num)  # Ensure proper type conversion
                drivers_standings = ergast.get_driver_standings(
                    season=year, round=round_num
                ).content[0]
                constructor_standings = ergast.get_constructor_standings(
                    season=year, round=round_num
                ).content[0]
            else:
                drivers_standings = ergast.get_driver_standings(season=year).content[0]
                constructor_standings = ergast.get_constructor_standings(
                    season=year
                ).content[0]
    
            # Convert driver standings to JSON serializable format
            drivers_list = []
            for _, row in drivers_standings.iterrows():
                driver_dict = row.to_dict()
                clean_dict = {k: json_serial(v) for k, v in driver_dict.items()}
                drivers_list.append(clean_dict)
    
            # Convert constructor standings to JSON serializable format
            constructors_list = []
            for _, row in constructor_standings.iterrows():
                constructor_dict = row.to_dict()
                clean_dict = {k: json_serial(v) for k, v in constructor_dict.items()}
                constructors_list.append(clean_dict)
    
            return {
                "status": "success",
                "data": {
                    "drivers": drivers_list,
                    "constructors": constructors_list,
                },
            }
        except Exception as e:
            logger.error(f"Error analyzing driver performance: {str(e)}", exc_info=True)
            return {
                "status": "error",
                "message": f"Failed to analyze driver performance: {str(e)}",
            }
  • Schema definition for get_championship_standings tool registration. Defines input parameters: year (required, number) and round_num (optional, number).
    types.Tool(
        name="get_championship_standings",
        description="Get Formula One championship standings",
        inputSchema={
            "type": "object",
            "properties": {
                "year": {
                    "type": "number",
                    "description": "Season year (e.g., 2023)",
                },
                "round_num": {
                    "type": "number",
                    "description": (
                        "Round number (optional, gets latest "
                        "standings if not provided)"
                    ),
                },
            },
            "required": ["year"],
        },
  • Tool registration via list_tools() function returning a types.Tool object with name 'get_championship_standings'.
    types.Tool(
        name="get_championship_standings",
        description="Get Formula One championship standings",
        inputSchema={
            "type": "object",
            "properties": {
                "year": {
                    "type": "number",
                    "description": "Season year (e.g., 2023)",
                },
                "round_num": {
                    "type": "number",
                    "description": (
                        "Round number (optional, gets latest "
                        "standings if not provided)"
                    ),
                },
            },
            "required": ["year"],
        },
    ),
  • Call handler routing in f1_tool() - validates round_num argument then dispatches to get_championship_standings handler function.
    elif name == "get_championship_standings":
        round_num = arguments.get("round_num")
        if round_num is not None:
            try:
                round_num = int(round_num)
                if round_num <= 0:
                    raise ValueError("Round number must be positive")
            except (ValueError, TypeError) as e:
                raise ValueError(f"Invalid round number: {round_num}") from e
    
        result = get_championship_standings(sanitized_args["year"], round_num)
  • Import of get_championship_standings from f1_data module into server.py.
    from .f1_data import (
        analyze_driver_performance,
        compare_drivers,
        get_championship_standings,
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 disclosing behavior. It only states the basic action without mentioning what data is returned, how errors are handled, or any side effects. This is insufficient for a tool that likely returns complex standings data.

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 concise sentence that front-loads the purpose. 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?

Given the absence of an output schema, the description should explain what the response contains (e.g., drivers' or constructors' standings). It fails to do so, leaving the agent without essential context about the tool's return value.

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?

Schema coverage is 100%, so the input schema itself documents both parameters well. The description adds no additional meaning beyond what the schema provides, earning the baseline score of 3. It does not clarify the output structure or any parameter dependencies.

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 the resource 'Formula One championship standings'. It is specific enough to distinguish from sibling tools like get_session_results or get_driver_info, though it does not specify if standings are for drivers or constructors.

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. There is no mention of prerequisites, typical use cases, or scenarios where another tool would be more appropriate.

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