get_session_results
Retrieve Formula One session results by specifying the season year, event identifier, and session name. Access race, qualifying, or practice data for detailed analysis.
Instructions
Get results for a specific Formula One session
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| event_identifier | Yes | Event name or round number (e.g., "Monaco" or "7") | |
| session_name | Yes | Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3") | |
| year | Yes | Season year (e.g., 2023) |
Input Schema (JSON Schema)
{
"properties": {
"event_identifier": {
"description": "Event name or round number (e.g., \"Monaco\" or \"7\")",
"type": "string"
},
"session_name": {
"description": "Session name (e.g., \"Race\", \"Qualifying\", \"Sprint\", \"FP1\", \"FP2\", \"FP3\")",
"type": "string"
},
"year": {
"description": "Season year (e.g., 2023)",
"type": "number"
}
},
"required": [
"year",
"event_identifier",
"session_name"
],
"type": "object"
}
Implementation Reference
- python/f1_data.py:65-85 (handler)The core handler function that executes the get_session_results tool logic: loads the F1 session using fastf1, retrieves results, and serializes to JSON.def get_session_results(year, event_identifier, session_name): """Get results for a specific session""" try: year = int(year) session = fastf1.get_session(year, event_identifier, session_name) session.load(telemetry=False) # Load session without telemetry for faster results # Get results as a DataFrame results = session.results # Convert results to JSON serializable format result_list = [] for driver_num, result in results.items(): driver_result = result.to_dict() # Clean and convert non-serializable values clean_dict = {k: json_serial(v) for k, v in driver_result.items()} result_list.append(clean_dict) return {"status": "success", "data": result_list} except Exception as e: return {"status": "error", "message": str(e), "traceback": traceback.format_exc()}
- src/index.ts:123-143 (schema)Input schema definition for the get_session_results tool, specifying parameters: year (number), event_identifier (string), session_name (string).{ name: 'get_session_results', description: 'Get results for a specific Formula One session', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, event_identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, session_name: { type: 'string', description: 'Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3")', }, }, required: ['year', 'event_identifier', 'session_name'], },
- python/f1_data.py:290-299 (registration)Registration of the get_session_results function in the main functions dictionary used by the Python bridge to dispatch calls.functions = { "get_event_schedule": get_event_schedule, "get_event_info": get_event_info, "get_session_results": get_session_results, "get_driver_info": get_driver_info, "analyze_driver_performance": analyze_driver_performance, "compare_drivers": compare_drivers, "get_telemetry": get_telemetry, "get_championship_standings": get_championship_standings }
- src/index.ts:307-314 (handler)MCP tool call handler in TypeScript that dispatches to the Python implementation via executePythonFunction.case 'get_session_results': { const typedArgs = args as SessionResultsArgs; result = await executePythonFunction('get_session_results', [ typedArgs.year.toString(), typedArgs.event_identifier.toString(), typedArgs.session_name.toString(), ]); break;
- src/index.ts:89-272 (registration)MCP server registration of the tool in the listTools response, including name and schema.this.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { 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'], }, }, { name: 'get_event_info', description: 'Get detailed information about a specific Formula One Grand Prix', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, }, required: ['year', 'identifier'], }, }, { name: 'get_session_results', description: 'Get results for a specific Formula One session', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, event_identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, session_name: { type: 'string', description: 'Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3")', }, }, required: ['year', 'event_identifier', 'session_name'], }, }, { name: 'get_driver_info', description: 'Get information about a specific Formula One driver', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, event_identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, session_name: { type: 'string', description: 'Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3")', }, driver_identifier: { type: 'string', description: 'Driver identifier (number, code, or name; e.g., "44", "HAM", "Hamilton")', }, }, required: ['year', 'event_identifier', 'session_name', 'driver_identifier'], }, }, { name: 'analyze_driver_performance', description: 'Analyze a driver\'s performance in a Formula One session', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, event_identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, session_name: { type: 'string', description: 'Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3")', }, driver_identifier: { type: 'string', description: 'Driver identifier (number, code, or name; e.g., "44", "HAM", "Hamilton")', }, }, required: ['year', 'event_identifier', 'session_name', 'driver_identifier'], }, }, { name: 'compare_drivers', description: 'Compare performance between multiple Formula One drivers', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, event_identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, session_name: { type: 'string', description: 'Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3")', }, drivers: { type: 'string', description: 'Comma-separated list of driver codes (e.g., "HAM,VER,LEC")', }, }, required: ['year', 'event_identifier', 'session_name', 'drivers'], }, }, { name: 'get_telemetry', description: 'Get telemetry data for a specific Formula One lap', inputSchema: { type: 'object', properties: { year: { type: 'number', description: 'Season year (e.g., 2023)', }, event_identifier: { type: 'string', description: 'Event name or round number (e.g., "Monaco" or "7")', }, session_name: { type: 'string', description: 'Session name (e.g., "Race", "Qualifying", "Sprint", "FP1", "FP2", "FP3")', }, driver_identifier: { type: 'string', description: 'Driver identifier (number, code, or name; e.g., "44", "HAM", "Hamilton")', }, lap_number: { type: 'number', description: 'Lap number (optional, gets fastest lap if not provided)', }, }, required: ['year', 'event_identifier', 'session_name', 'driver_identifier'], }, }, { 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'], }, }, ], }));