Skip to main content
Glama
Josh-Mantel

F1 MCP Server

by Josh-Mantel

get_driver_standings

Retrieve Formula 1 driver championship standings for any season, optionally filtered by specific race round to track championship progression.

Instructions

Get driver championship standings for a season

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesSeason year (e.g., 2024)
round_numberNoRound number (optional, gets standings after this round)

Implementation Reference

  • The implementation of the get_driver_standings function that processes input arguments, retrieves race data via FastF1, calculates standings, and returns the formatted response.
    async def get_driver_standings(arguments: Dict[str, Any]) -> List[TextContent]:
        """Get driver championship standings."""
        year = arguments["year"]
        round_number = arguments.get("round_number")
    
        try:
            # Get the schedule to determine which round to use
            schedule = fastf1.get_event_schedule(year)
    
            if round_number is None:
                # Get latest completed round
                current_date = datetime.now()
                completed_rounds = schedule[schedule["EventDate"] <= current_date]
                if completed_rounds.empty:
                    round_number = 1
                else:
                    round_number = int(completed_rounds["RoundNumber"].max())
    
            # Get race session for standings calculation
            session = fastf1.get_session(year, round_number, "R")
            session.load()
    
            # Calculate standings (simplified - in real implementation you'd sum points across all rounds)
            results = session.results
            standings_data = []
    
            for _, driver in results.iterrows():
                standings_data.append(
                    {
                        "position": (
                            int(driver["Position"])
                            if pd.notna(driver["Position"])
                            else None
                        ),
                        "driver": driver["Abbreviation"],
                        "full_name": driver["FullName"],
                        "team": driver["TeamName"],
                        "points": (
                            float(driver["Points"])
                            if pd.notna(driver.get("Points", 0))
                            else 0
                        ),
                    }
                )
    
            # Sort by points (descending)
            standings_data.sort(key=lambda x: x["points"] or 0, reverse=True)
    
            result = {
                "year": year,
                "after_round": round_number,
                "standings": standings_data,
            }
    
            return [
                TextContent(
                    type="text",
                    text=f"F1 {year} Driver Standings (after Round {round_number}):\n\n"
                    + json.dumps(result, indent=2),
                )
            ]
  • The registration of the get_driver_standings tool in the server configuration, including the inputSchema.
    Tool(
        name="get_driver_standings",
        description="Get driver championship standings for a season",
        inputSchema={
            "type": "object",
            "properties": {
                "year": {
                    "type": "integer",
                    "description": "Season year (e.g., 2024)",
                },
                "round_number": {
                    "type": "integer",
                    "description": "Round number (optional, gets standings after this round)",
                    "minimum": 1,
                    "maximum": 24,
                },

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