get_event_schedule
Fetch the Formula One race calendar for a specific season by providing the year. Access event schedules, race dates, and locations directly through the Formula One MCP Server.
Instructions
Get Formula One race calendar for a specific season
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| year | Yes | Season year (e.g., 2023) |
Implementation Reference
- src/f1_mcp_server/f1_data.py:108-140 (handler)Core handler function implementing the get_event_schedule tool logic. Validates input year, fetches schedule using fastf1.get_event_schedule, converts to JSON-serializable format, handles errors.def get_event_schedule(year: Any) -> dict[str, Any]: """ Get the event schedule for a specified Formula One season. Args: year (int or str): The year of the F1 season Returns: dict: Status and schedule data or error information """ try: # Validate year year_int = validate_year(year) logger.debug(f"Fetching event schedule for {year_int}") schedule = fastf1.get_event_schedule(year_int) # Convert DataFrame to JSON serializable format result = [] for _, row in schedule.iterrows(): event_dict = row.to_dict() # Clean and convert non-serializable values clean_dict = {k: json_serial(v) for k, v in event_dict.items()} result.append(clean_dict) logger.info(f"Successfully retrieved {len(result)} events for {year_int}") return {"status": "success", "data": result} except Exception as e: logger.error(f"Error retrieving event schedule: {str(e)}", exc_info=True) return { "status": "error", "message": f"Failed to retrieve event schedule: {str(e)}", }
- src/f1_mcp_server/server.py:285-297 (schema)MCP tool schema definition including input schema for 'year' parameter.name="get_event_schedule", description=("Get Formula One race calendar for a specific season"), inputSchema={ "type": "object", "properties": { "year": { "type": "number", "description": "Season year (e.g., 2023)", }, }, "required": ["year"], }, ),
- src/f1_mcp_server/server.py:161-164 (registration)Registration and dispatch logic in the MCP server's @app.call_tool() handler that routes calls to get_event_schedule.if name == "get_event_schedule": if "year" not in sanitized_args: sanitized_args["year"] = int(arguments["year"]) result = get_event_schedule(sanitized_args["year"])
- f1-messenger-app/mcp-bridge.py:104-104 (registration)Tool registration in the HTTP bridge that maps tool name to the handler function.'get_event_schedule': get_event_schedule,
- TypeScript schema definition for Gemini function calling, matching the MCP tool schema.name: 'get_event_schedule', description: 'Get Formula One race calendar/schedule for a specific season with all Grand Prix events', parameters: { type: SchemaType.OBJECT, properties: { year: { type: SchemaType.NUMBER, description: 'Season year (e.g., 2024, 2023, 2022). Must be between 1950 and current year.', } }, required: ['year'] }