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
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | Season year (e.g., 2024) |
Implementation Reference
- f1_mcp_server/server.py:203-254 (handler)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)}" ) ] - f1_mcp_server/server.py:71-86 (registration)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"], }, ), - f1_mcp_server/server.py:186-187 (handler)Routing logic in call_tool() to dispatch the tool call to the handler.
if name == "get_race_schedule": return await get_race_schedule(arguments)