Skip to main content
Glama
Josh-Mantel

F1 MCP Server

by Josh-Mantel

get_race_schedule

Retrieve the Formula 1 race schedule for a specific season by providing the year, enabling users to access event dates and locations.

Instructions

Get the race schedule for a specific F1 season

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
yearYesSeason year (e.g., 2024)

Implementation Reference

  • The handler function `get_race_schedule` that processes the tool request, fetches the schedule using fastf1, and formats the output.
    async def get_race_schedule(arguments: Dict[str, Any]) -> List[TextContent]:
        """Get race schedule for a season."""
        year = arguments["year"]
    
        try:
            schedule = fastf1.get_event_schedule(year)
    
            # Convert to a more readable format
            schedule_data = []
            for _, event in schedule.iterrows():
                schedule_data.append(
                    {
                        "round": (
                            int(event["RoundNumber"])
                            if pd.notna(event["RoundNumber"])
                            else None
                        ),
                        "event_name": event["EventName"],
                        "location": event["Location"],
                        "country": event["Country"],
                        "event_date": (
                            event["EventDate"].strftime("%Y-%m-%d")
                            if pd.notna(event["EventDate"])
                            else None
                        ),
                        "event_format": (
                            event["EventFormat"]
                            if "EventFormat" in event
                            else "Conventional"
                        ),
                    }
                )
    
            result = {
                "season": year,
                "total_rounds": len(schedule_data),
                "events": schedule_data,
            }
    
            return [
                TextContent(
                    type="text",
                    text=f"F1 {year} Race Schedule:\n\n" + json.dumps(result, indent=2),
                )
            ]
    
        except Exception as e:
            return [
                TextContent(
                    type="text", text=f"Error getting schedule for {year}: {str(e)}"
                )
            ]
  • Tool registration in the list_tools() function.
    Tool(
        name="get_race_schedule",
        description="Get the race schedule for a specific F1 season",
        inputSchema={
            "type": "object",
            "properties": {
                "year": {
                    "type": "integer",
                    "description": "Season year (e.g., 2024)",
                    "minimum": 1950,
                    "maximum": 2030,
                }
            },
            "required": ["year"],
        },
    ),
  • Routing logic in call_tool() to dispatch the tool call to the handler.
    if name == "get_race_schedule":
        return await get_race_schedule(arguments)

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