import json import datetime # Variables CURRENT_YEAR = datetime.datetime.now().year AVAILABLE_SESSION_TYPES = [ "fp1", "fp2", "fp3", "q", "s", "ss", "sq", "r", "practice 1", "practice 2", "practice 3", "sprint", "sprint qualifying", "qualifying", "race" ] DROPDOWN_SESSION_TYPES = [ "practice 1", "practice 2", "practice 3", "sprint", "sprint qualifying", "qualifying", "race" ] # Load in driver names DRIVER_NAMES: list[str] = json.load(open("assets/driver_names.json"))["drivers"] # Load in constructor team names CONSTRUCTOR_NAMES: list[str] = json.load(open("assets/constructors.json"))["constructors"] # Load in driver details DRIVER_DETAILS: dict[str, dict[str, str]] = json.load(open("assets/driver_details.json")) # Load in constructor details CONSTRUCTOR_DETAILS: dict[str, dict[str, str]] = json.load(open("assets/constructor_details.json")) MARKDOWN_INTRODUCTION = """ # 🏁 Formula 1 MCP server 🏎️ Welcome to the Formula 1 MCP server, your one-stop destination for comprehensive Formula 1 data and visualizations.
This application leverages the FastF1 library to provide detailed insights into Formula 1 races, drivers, and teams. ## Available Tools in Gradio UI ### Championship Standings - **Driver Championship**: Track driver positions, points, and wins - **Constructor Championship**: Monitor team performances and rankings ### Race Information - **Event Info**: Get detailed information about specific Grand Prix events - **Season Calendar**: View the complete race calendar for any season - **Session Results**: Access race, qualifying, and sprint session results ### Driver & Team Data - **Driver Info**: View detailed driver profiles and statistics - **Track Visualizations**: Explore interactive track maps with speed, gear, and corner data ## Usage There are different ways to interact with the MCP server: 1) (recommended) Add the MCP server to your `mcp.json` file. This is the most user-friendly way to interact with the MCP server. See the section below for the config file. 2) (not recommended) One can establish an MCP client by running `mcp_client.py` locally. This client is connected to the MCP server hosted on HuggingFace spaces. Warning: I personally had trouble getting this to work properly using local Ollama models. 3) (limited functionality) One can also use the Gradio interface directly to interact with the MCP server. However, I have limited the number of tools/functions available in the Gradio interface due to there not being a clean and nice way to implement the `OpenF1` tools in Gradio (literally just direct HTTP endpoints with tons of filters xD). ## MCP json configuration For MCP clients that support SSE transport (For Claude desktop see below), the following configuration can be used in your `mcp.json` file (or its equivalent): ```json { "mcpServers": { "gradio": { "url": "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse" } } } ``` For Claude Desktop, the following configuration can instead be used, but make sure you have Node.js installed: ```json { "mcpServers": { "gradio": { "command": "npx", "args": [ "mcp-remote", "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse", "--transport", "sse-only" ] } } } ``` """