arre99 commited on
Commit
95e43e2
·
1 Parent(s): d07810d

removed unuses json files and added constructor info function

Browse files
app.py CHANGED
@@ -6,9 +6,8 @@ from utils.constants import (
6
  DRIVER_NAMES,
7
  CONSTRUCTOR_NAMES,
8
  CURRENT_YEAR,
9
- AVAILABLE_SESSION_TYPES,
10
  DROPDOWN_SESSION_TYPES,
11
- DRIVER_DETAILS
12
  )
13
 
14
  iface_driver_championship_standings = gr.Interface(
@@ -87,80 +86,24 @@ iface_driver_info = gr.Interface(
87
  ],
88
  outputs="text",
89
  title="Driver Info",
90
- description="Get personal information about a driver"
91
  )
92
 
93
- # Create your markdown-only tab using Blocks
94
- with gr.Blocks() as markdown_tab:
95
- gr.Markdown("""
96
- # 🏁 Formula 1 MCP server 🏎️
97
-
98
- Welcome to the Formula 1 MCP server, your one-stop destination for comprehensive Formula 1 data and visualizations.
99
- <br>
100
- This application leverages the FastF1 library to provide detailed insights into Formula 1 races, drivers, and teams.
101
-
102
- ## Available Tools in Gradio UI
103
-
104
- ### Championship Standings
105
- - **Driver Championship**: Track driver positions, points, and wins
106
- - **Constructor Championship**: Monitor team performances and rankings
107
-
108
- ### Race Information
109
- - **Event Info**: Get detailed information about specific Grand Prix events
110
- - **Season Calendar**: View the complete race calendar for any season
111
- - **Session Results**: Access race, qualifying, and sprint session results
112
-
113
- ### Driver & Team Data
114
- - **Driver Info**: View detailed driver profiles and statistics
115
- - **Track Visualizations**: Explore interactive track maps with speed, gear, and corner data
116
-
117
-
118
- ## Usage
119
-
120
- There are different ways to interact with the MCP server:
121
 
122
- 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.
123
 
124
- 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.
 
 
125
 
126
- 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).
127
-
128
-
129
- ## MCP json configuration
130
-
131
- 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):
132
-
133
- ```json
134
- {
135
- "mcpServers": {
136
- "gradio": {
137
- "url": "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse"
138
- }
139
- }
140
- }
141
- ```
142
-
143
- For Claude Desktop, the following configuration can instead be used, but make sure you have Node.js installed:
144
-
145
- ```json
146
- {
147
- "mcpServers": {
148
- "gradio": {
149
- "command": "npx",
150
- "args": [
151
- "mcp-remote",
152
- "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse",
153
- "--transport",
154
- "sse-only"
155
- ]
156
- }
157
- }
158
- }
159
- ```
160
-
161
- """)
162
-
163
-
164
 
165
  named_interfaces = {
166
  "About": markdown_tab,
@@ -171,6 +114,7 @@ named_interfaces = {
171
  "Track Visualizations": iface_track_visualization,
172
  "Session Results": iface_session_results,
173
  "Driver Info": iface_driver_info,
 
174
  }
175
 
176
  # Tab names and interfaces
 
6
  DRIVER_NAMES,
7
  CONSTRUCTOR_NAMES,
8
  CURRENT_YEAR,
 
9
  DROPDOWN_SESSION_TYPES,
10
+ MARKDOWN_INTRODUCTION
11
  )
12
 
13
  iface_driver_championship_standings = gr.Interface(
 
86
  ],
87
  outputs="text",
88
  title="Driver Info",
89
+ description="Get information about a specific driver"
90
  )
91
 
92
+ iface_constructor_info = gr.Interface(
93
+ fn=fastf1_tools.get_constructor_info,
94
+ inputs=[
95
+ gr.Dropdown(label="Constructor", choices=CONSTRUCTOR_NAMES)
96
+ ],
97
+ outputs="text",
98
+ title="Constructor Info",
99
+ description="Get information about a specific constructor"
100
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
 
102
 
103
+ # Create your markdown-only tab using Blocks
104
+ with gr.Blocks() as markdown_tab:
105
+ gr.Markdown(MARKDOWN_INTRODUCTION)
106
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
 
108
  named_interfaces = {
109
  "About": markdown_tab,
 
114
  "Track Visualizations": iface_track_visualization,
115
  "Session Results": iface_session_results,
116
  "Driver Info": iface_driver_info,
117
+ "Constructor Info": iface_constructor_info,
118
  }
119
 
120
  # Tab names and interfaces
assets/constructor_details.json CHANGED
@@ -1,94 +1,82 @@
1
  {
2
- "constructors": [
3
- {
4
- "constructor": "McLaren",
5
- "team_name": "McLaren Formula 1 Team",
6
- "chassis": "MCL39",
7
- "power_unit": "Mercedes",
8
- "base": "Woking, United Kingdom",
9
- "team_principal": "Andrea Stella",
10
- "drivers": ["Lando Norris", "Oscar Piastri"]
11
- },
12
- {
13
- "constructor": "Ferrari",
14
- "team_name": "Scuderia Ferrari HP",
15
- "chassis": "SF-25",
16
- "power_unit": "Ferrari",
17
- "base": "Maranello, Italy",
18
- "team_principal": "Frédéric Vasseur",
19
- "drivers": ["Charles Leclerc", "Lewis Hamilton"]
20
- },
21
- {
22
- "constructor": "Red Bull Racing",
23
- "team_name": "Oracle Red Bull Racing",
24
- "chassis": "RB21",
25
- "power_unit": "Honda RBPT",
26
- "base": "Milton Keynes, United Kingdom",
27
- "team_principal": "Christian Horner",
28
- "drivers": ["Max Verstappen", "Liam Lawson"]
29
- },
30
- {
31
- "constructor": "Mercedes",
32
- "team_name": "Mercedes-AMG Petronas Formula One Team",
33
- "chassis": "W16",
34
- "power_unit": "Mercedes",
35
- "base": "Brackley, United Kingdom",
36
- "team_principal": "Toto Wolff",
37
- "drivers": ["George Russell", "Andrea Kimi Antonelli"]
38
- },
39
- {
40
- "constructor": "Aston Martin",
41
- "team_name": "Aston Martin Aramco Formula One Team",
42
- "chassis": "AMR25",
43
- "power_unit": "Mercedes",
44
- "base": "Silverstone, United Kingdom",
45
- "team_principal": "Andy Cowell",
46
- "drivers": ["Fernando Alonso", "Lance Stroll"]
47
- },
48
- {
49
- "constructor": "Alpine",
50
- "team_name": "BWT Alpine F1 Team",
51
- "chassis": "A525",
52
- "power_unit": "Renault",
53
- "base": "Enstone, United Kingdom",
54
- "team_principal": "Oliver Oakes",
55
- "drivers": ["Pierre Gasly", "Jack Doohan"]
56
- },
57
- {
58
- "constructor": "Haas",
59
- "team_name": "MoneyGram Haas F1 Team",
60
- "chassis": "VF-25",
61
- "power_unit": "Ferrari",
62
- "base": "Kannapolis, United States",
63
- "team_principal": "Ayao Komatsu",
64
- "drivers": ["Esteban Ocon", "Oliver Bearman"]
65
- },
66
- {
67
- "constructor": "Racing Bulls",
68
- "team_name": "Visa Cash App Racing Bulls",
69
- "chassis": "VCARB 02",
70
- "power_unit": "Honda RBPT",
71
- "base": "Faenza, Italy",
72
- "team_principal": "Laurent Mekies",
73
- "drivers": ["Yuki Tsunoda", "Isack Hadjar"]
74
- },
75
- {
76
- "constructor": "Williams",
77
- "team_name": "Williams Racing",
78
- "chassis": "FW47",
79
- "power_unit": "Mercedes",
80
- "base": "Grove, United Kingdom",
81
- "team_principal": "James Vowles",
82
- "drivers": ["Alexander Albon", "Carlos Sainz"]
83
- },
84
- {
85
- "constructor": "Kick Sauber",
86
- "team_name": "Stake F1 Team Kick Sauber",
87
- "chassis": "C45",
88
- "power_unit": "Ferrari",
89
- "base": "Hinwil, Switzerland",
90
- "team_principal": "Mattia Binotto",
91
- "drivers": ["Nico Hülkenberg", "Gabriel Bortoleto"]
92
- }
93
- ]
94
  }
 
1
  {
2
+ "McLaren": {
3
+ "team_name": "McLaren Formula 1 Team",
4
+ "chassis": "MCL39",
5
+ "power_unit": "Mercedes",
6
+ "base": "Woking, United Kingdom",
7
+ "team_principal": "Andrea Stella",
8
+ "drivers": ["Lando Norris", "Oscar Piastri"]
9
+ },
10
+ "Ferrari": {
11
+ "team_name": "Scuderia Ferrari HP",
12
+ "chassis": "SF-25",
13
+ "power_unit": "Ferrari",
14
+ "base": "Maranello, Italy",
15
+ "team_principal": "Frédéric Vasseur",
16
+ "drivers": ["Charles Leclerc", "Lewis Hamilton"]
17
+ },
18
+ "Red Bull Racing": {
19
+ "team_name": "Oracle Red Bull Racing",
20
+ "chassis": "RB21",
21
+ "power_unit": "Honda RBPT",
22
+ "base": "Milton Keynes, United Kingdom",
23
+ "team_principal": "Christian Horner",
24
+ "drivers": ["Max Verstappen", "Liam Lawson"]
25
+ },
26
+ "Mercedes": {
27
+ "team_name": "Mercedes-AMG Petronas Formula One Team",
28
+ "chassis": "W16",
29
+ "power_unit": "Mercedes",
30
+ "base": "Brackley, United Kingdom",
31
+ "team_principal": "Toto Wolff",
32
+ "drivers": ["George Russell", "Andrea Kimi Antonelli"]
33
+ },
34
+ "Aston Martin": {
35
+ "team_name": "Aston Martin Aramco Formula One Team",
36
+ "chassis": "AMR25",
37
+ "power_unit": "Mercedes",
38
+ "base": "Silverstone, United Kingdom",
39
+ "team_principal": "Andy Cowell",
40
+ "drivers": ["Fernando Alonso", "Lance Stroll"]
41
+ },
42
+ "Alpine": {
43
+ "team_name": "BWT Alpine F1 Team",
44
+ "chassis": "A525",
45
+ "power_unit": "Renault",
46
+ "base": "Enstone, United Kingdom",
47
+ "team_principal": "Oliver Oakes",
48
+ "drivers": ["Pierre Gasly", "Jack Doohan"]
49
+ },
50
+ "Haas": {
51
+ "team_name": "MoneyGram Haas F1 Team",
52
+ "chassis": "VF-25",
53
+ "power_unit": "Ferrari",
54
+ "base": "Kannapolis, United States",
55
+ "team_principal": "Ayao Komatsu",
56
+ "drivers": ["Esteban Ocon", "Oliver Bearman"]
57
+ },
58
+ "Racing Bulls": {
59
+ "team_name": "Visa Cash App Racing Bulls",
60
+ "chassis": "VCARB 02",
61
+ "power_unit": "Honda RBPT",
62
+ "base": "Faenza, Italy",
63
+ "team_principal": "Laurent Mekies",
64
+ "drivers": ["Yuki Tsunoda", "Isack Hadjar"]
65
+ },
66
+ "Williams": {
67
+ "team_name": "Williams Racing",
68
+ "chassis": "FW47",
69
+ "power_unit": "Mercedes",
70
+ "base": "Grove, United Kingdom",
71
+ "team_principal": "James Vowles",
72
+ "drivers": ["Alexander Albon", "Carlos Sainz"]
73
+ },
74
+ "Kick Sauber": {
75
+ "team_name": "Stake F1 Team Kick Sauber",
76
+ "chassis": "C45",
77
+ "power_unit": "Ferrari",
78
+ "base": "Hinwil, Switzerland",
79
+ "team_principal": "Mattia Binotto",
80
+ "drivers": ["Nico Hülkenberg", "Gabriel Bortoleto"]
81
+ }
 
 
 
 
 
 
 
 
 
 
 
 
82
  }
assets/driver_details.json CHANGED
@@ -3,120 +3,140 @@
3
  "birth_date": "1997-09-30",
4
  "number": 1,
5
  "team": "Red Bull Racing",
6
- "nationality": "🇳🇱 Netherlands"
 
7
  },
8
  "Liam Lawson": {
9
  "birth_date": "2002-02-11",
10
  "number": 30,
11
  "team": "Red Bull Racing",
12
- "nationality": "🇳🇿 New Zealand"
 
13
  },
14
  "Charles Leclerc": {
15
  "birth_date": "1997-10-16",
16
  "number": 16,
17
  "team": "Ferrari",
18
- "nationality": "🇲🇨 Monaco"
 
19
  },
20
  "Lewis Hamilton": {
21
  "birth_date": "1985-01-07",
22
  "number": 44,
23
  "team": "Ferrari",
24
- "nationality": "🇬🇧 United Kingdom"
 
25
  },
26
  "George Russell": {
27
  "birth_date": "1998-02-15",
28
  "number": 63,
29
  "team": "Mercedes",
30
- "nationality": "🇬🇧 United Kingdom"
 
31
  },
32
  "Andrea Kimi Antonelli": {
33
  "birth_date": "2006-08-25",
34
  "number": 12,
35
  "team": "Mercedes",
36
- "nationality": "🇮🇹 Italy"
 
37
  },
38
  "Lando Norris": {
39
  "birth_date": "1999-11-13",
40
  "number": 4,
41
  "team": "McLaren",
42
- "nationality": "🇬🇧 United Kingdom"
 
43
  },
44
  "Oscar Piastri": {
45
  "birth_date": "2001-04-06",
46
  "number": 81,
47
  "team": "McLaren",
48
- "nationality": "🇦🇺 Australia"
 
49
  },
50
  "Fernando Alonso": {
51
  "birth_date": "1981-07-29",
52
  "number": 14,
53
  "team": "Aston Martin",
54
- "nationality": "🇪🇸 Spain"
 
55
  },
56
  "Lance Stroll": {
57
  "birth_date": "1998-10-29",
58
  "number": 18,
59
  "team": "Aston Martin",
60
- "nationality": "🇨🇦 Canada"
 
61
  },
62
  "Pierre Gasly": {
63
  "birth_date": "1996-02-07",
64
  "number": 10,
65
  "team": "Alpine",
66
- "nationality": "🇫🇷 France"
 
67
  },
68
  "Jack Doohan": {
69
  "birth_date": "2003-01-20",
70
  "number": 7,
71
  "team": "Alpine",
72
- "nationality": "🇦🇺 Australia"
 
73
  },
74
  "Esteban Ocon": {
75
  "birth_date": "1996-09-17",
76
  "number": 31,
77
  "team": "Haas",
78
- "nationality": "🇫🇷 France"
 
79
  },
80
  "Oliver Bearman": {
81
  "birth_date": "2005-05-08",
82
  "number": 87,
83
  "team": "Haas",
84
- "nationality": "🇬🇧 United Kingdom"
 
85
  },
86
  "Yuki Tsunoda": {
87
  "birth_date": "2000-05-11",
88
  "number": 22,
89
  "team": "Racing Bulls",
90
- "nationality": "🇯🇵 Japan"
 
91
  },
92
  "Isack Hadjar": {
93
  "birth_date": "2004-09-28",
94
  "number": 6,
95
  "team": "Racing Bulls",
96
- "nationality": "🇫🇷 France"
 
97
  },
98
  "Alexander Albon": {
99
  "birth_date": "1996-03-23",
100
  "number": 23,
101
  "team": "Williams",
102
- "nationality": "🇹🇭 Thailand"
 
103
  },
104
  "Carlos Sainz Jr": {
105
  "birth_date": "1994-09-01",
106
  "number": 55,
107
  "team": "Williams",
108
- "nationality": "🇪🇸 Spain"
 
109
  },
110
  "Nico Hülkenberg": {
111
  "birth_date": "1987-08-19",
112
  "number": 27,
113
  "team": "Kick Sauber",
114
- "nationality": "🇩🇪 Germany"
 
115
  },
116
  "Gabriel Bortoleto": {
117
  "birth_date": "2004-10-14",
118
  "number": 5,
119
  "team": "Kick Sauber",
120
- "nationality": "🇧🇷 Brazil"
 
121
  }
122
  }
 
3
  "birth_date": "1997-09-30",
4
  "number": 1,
5
  "team": "Red Bull Racing",
6
+ "nationality": "🇳🇱 Netherlands",
7
+ "summary": "Son of former F1 driver Jos Verstappen, Max was destined for racing greatness from a young age. He made history by becoming the youngest F1 driver at 17 and the youngest race winner at 18. His aggressive yet calculated driving style has earned him multiple World Championships with Red Bull Racing, making him one of the most dominant drivers in the sport's history."
8
  },
9
  "Liam Lawson": {
10
  "birth_date": "2002-02-11",
11
  "number": 30,
12
  "team": "Red Bull Racing",
13
+ "nationality": "🇳🇿 New Zealand",
14
+ "summary": "Hailing from New Zealand, Lawson quickly rose through the ranks of single-seater racing, impressing in Formula 2 and DTM. His composed performances as a reserve driver for Red Bull earned him a race seat, showcasing his ability to adapt quickly to different racing disciplines and challenging conditions."
15
  },
16
  "Charles Leclerc": {
17
  "birth_date": "1997-10-16",
18
  "number": 16,
19
  "team": "Ferrari",
20
+ "nationality": "🇲🇨 Monaco",
21
+ "summary": "A product of the Ferrari Driver Academy, Leclerc's journey to F1 was marked by personal tragedy and triumph. The Monegasque driver won back-to-back championships in GP3 and F2 before joining Sauber and then Ferrari. Known for his qualifying pace and racecraft, he became Ferrari's leading driver and a consistent championship contender."
22
  },
23
  "Lewis Hamilton": {
24
  "birth_date": "1985-01-07",
25
  "number": 44,
26
  "team": "Ferrari",
27
+ "nationality": "🇬🇧 United Kingdom",
28
+ "summary": "One of the most successful drivers in F1 history, Hamilton's journey began in karting where he was signed by McLaren at age 13. The seven-time world champion made history as the first black driver in F1 and holds numerous records, including most race wins and pole positions. His move to Ferrari in 2025 marked a new chapter in his legendary career."
29
  },
30
  "George Russell": {
31
  "birth_date": "1998-02-15",
32
  "number": 63,
33
  "team": "Mercedes",
34
+ "nationality": "🇬🇧 United Kingdom",
35
+ "summary": "Dubbed 'Mr. Saturday' for his exceptional qualifying performances, Russell's path to F1 was paved with success in junior categories, including winning the GP3 and F2 championships in consecutive years. After impressing at Williams, he earned a Mercedes seat, where he continues to showcase his speed and racecraft against the sport's best."
36
  },
37
  "Andrea Kimi Antonelli": {
38
  "birth_date": "2006-08-25",
39
  "number": 12,
40
  "team": "Mercedes",
41
+ "nationality": "🇮🇹 Italy",
42
+ "summary": "The youngest driver on the grid, Antonelli is one of the most exciting prospects in motorsport. After dominating the junior categories with multiple championships, he made an early jump to F1 with Mercedes, skipping F2. His rapid progression and natural talent have drawn comparisons to Max Verstappen's meteoric rise in the sport."
43
  },
44
  "Lando Norris": {
45
  "birth_date": "1999-11-13",
46
  "number": 4,
47
  "team": "McLaren",
48
+ "nationality": "🇬🇧 United Kingdom",
49
+ "summary": "Known for his charismatic personality and raw speed, Norris rose through the ranks of karting and single-seaters before joining McLaren. The British driver has developed into one of F1's brightest talents, known for his consistency, racecraft, and entertaining social media presence. His performances have made him a fan favorite and a future championship contender."
50
  },
51
  "Oscar Piastri": {
52
  "birth_date": "2001-04-06",
53
  "number": 81,
54
  "team": "McLaren",
55
+ "nationality": "🇦🇺 Australia",
56
+ "summary": "The Australian sensation made history by winning three consecutive junior championships (Formula Renault, F3, and F2) before his F1 debut. After a year on the sidelines as Alpine's reserve driver, Piastri joined McLaren where he quickly established himself as one of the grid's most promising talents, known for his technical feedback and race intelligence."
57
  },
58
  "Fernando Alonso": {
59
  "birth_date": "1981-07-29",
60
  "number": 14,
61
  "team": "Aston Martin",
62
+ "nationality": "🇪🇸 Spain",
63
+ "summary": "A two-time World Champion, Alonso is known for his incredible racecraft and fierce determination. The Spaniard made his F1 debut with Minardi in 2001 before winning back-to-back titles with Renault. His career has seen him race for top teams including Ferrari and McLaren, and he continues to be one of the most respected and experienced drivers on the grid with Aston Martin."
64
  },
65
  "Lance Stroll": {
66
  "birth_date": "1998-10-29",
67
  "number": 18,
68
  "team": "Aston Martin",
69
+ "nationality": "🇨🇦 Canada",
70
+ "summary": "The son of billionaire Lawrence Stroll, Lance has worked hard to prove himself beyond his family connections. After winning the European F3 championship, he made history as the first Canadian to take an F1 podium in the wet at Baku 2017. His smooth driving style and wet-weather prowess have earned him respect in the paddock."
71
  },
72
  "Pierre Gasly": {
73
  "birth_date": "1996-02-07",
74
  "number": 10,
75
  "team": "Alpine",
76
+ "nationality": "🇫🇷 France",
77
+ "summary": "Gasly's journey to F1 was marked by success in junior categories, including winning the 2016 GP2 championship. After a challenging stint at Red Bull, he found his stride at AlphaTauri, securing a memorable victory at Monza in 2020. The Frenchman is known for his emotional personality and strong work ethic."
78
  },
79
  "Jack Doohan": {
80
  "birth_date": "2003-01-20",
81
  "number": 7,
82
  "team": "Alpine",
83
+ "nationality": "🇦🇺 Australia",
84
+ "summary": "Son of motorcycle legend Mick Doohan, Jack has carved his own path in four-wheel racing. The Australian impressed in F2 with multiple race wins and pole positions before earning his F1 debut with Alpine. Known for his technical feedback and smooth driving style, he represents the next generation of Australian racing talent."
85
  },
86
  "Esteban Ocon": {
87
  "birth_date": "1996-09-17",
88
  "number": 31,
89
  "team": "Haas",
90
+ "nationality": "🇫🇷 France",
91
+ "summary": "Ocon's journey to F1 was marked by financial challenges before catching the eye of Mercedes' junior program. After winning the 2015 GP3 series and serving as a reserve driver, he made his debut with Manor Racing. The Frenchman is known for his consistency, racecraft, and memorable battles with teammate Sergio Perez during their Force India days."
92
  },
93
  "Oliver Bearman": {
94
  "birth_date": "2005-05-08",
95
  "number": 87,
96
  "team": "Haas",
97
+ "nationality": "🇬🇧 United Kingdom",
98
+ "summary": "One of the youngest drivers on the grid, Bearman made a name for himself with dominant performances in Italian F4 and Formula 3. The British driver's rapid progression through the junior categories earned him a spot in Ferrari's Driver Academy and a race seat with Haas. His technical understanding and mature approach belie his young age."
99
  },
100
  "Yuki Tsunoda": {
101
  "birth_date": "2000-05-11",
102
  "number": 22,
103
  "team": "Racing Bulls",
104
+ "nationality": "🇯🇵 Japan",
105
+ "summary": "The first Japanese driver in F1 since 2014, Tsunoda's rapid rise through the ranks was supported by Honda's young driver program. After finishing third in F2, he made his F1 debut with AlphaTauri. Known for his aggressive driving style and passionate radio messages, Tsunoda has developed into a consistent points scorer for Racing Bulls."
106
  },
107
  "Isack Hadjar": {
108
  "birth_date": "2004-09-28",
109
  "number": 6,
110
  "team": "Racing Bulls",
111
+ "nationality": "🇫🇷 France",
112
+ "summary": "Hadjar emerged as one of the most exciting young talents in junior single-seater racing, impressing in F3 before moving up to F2. The French-Algerian driver's smooth driving style and natural speed earned him a spot in Red Bull's junior program. His rapid adaptation to different racing categories has marked him as a future star."
113
  },
114
  "Alexander Albon": {
115
  "birth_date": "1996-03-23",
116
  "number": 23,
117
  "team": "Williams",
118
+ "nationality": "🇹🇭 Thailand",
119
+ "summary": "Born to a British father and Thai mother, Albon's journey to F1 included being dropped by Red Bull's junior program before fighting his way back through GP3 and F2. After strong performances with Toro Rosso and Red Bull, he found a home at Williams where his consistent point-scoring has made him team leader. His smooth driving style and technical feedback are among his greatest strengths."
120
  },
121
  "Carlos Sainz Jr": {
122
  "birth_date": "1994-09-01",
123
  "number": 55,
124
  "team": "Williams",
125
+ "nationality": "🇪🇸 Spain",
126
+ "summary": "Son of rally legend Carlos Sainz, the Spaniard has forged his own successful career in F1. After learning his craft at Toro Rosso, he impressed at Renault, McLaren, and Ferrari before moving to Williams. Known for his consistency and intelligence behind the wheel, Sainz is regarded as one of the most complete drivers on the grid."
127
  },
128
  "Nico Hülkenberg": {
129
  "birth_date": "1987-08-19",
130
  "number": 27,
131
  "team": "Kick Sauber",
132
+ "nationality": "🇩🇪 Germany",
133
+ "summary": "The experienced German driver holds the record for most F1 starts without a podium. After winning titles in A1GP and GP2, Hülkenberg made his F1 debut with Williams in 2010. Known for his qualifying prowess and technical feedback, he returned to F1 with Haas before moving to Kick Sauber, bringing valuable experience to the team."
134
  },
135
  "Gabriel Bortoleto": {
136
  "birth_date": "2004-10-14",
137
  "number": 5,
138
  "team": "Kick Sauber",
139
+ "nationality": "🇧🇷 Brazil",
140
+ "summary": "The latest Brazilian talent to reach F1, Bortoleto made waves by winning the 2023 F3 championship in dominant fashion. His smooth driving style and racecraft earned him a spot in the McLaren young driver program before securing a race seat with Kick Sauber. The young Brazilian carries the hopes of a nation that has produced legends like Senna, Piquet, and Massa."
141
  }
142
  }
assets/driver_details_with_summaries.json DELETED
@@ -1,142 +0,0 @@
1
- {
2
- "Max Verstappen": {
3
- "birth_date": "1997-09-30",
4
- "number": 1,
5
- "team": "Red Bull Racing",
6
- "nationality": "🇳🇱 Netherlands",
7
- "summary": "Son of former F1 driver Jos Verstappen, Max was destined for racing greatness from a young age. He made history by becoming the youngest F1 driver at 17 and the youngest race winner at 18. His aggressive yet calculated driving style has earned him multiple World Championships with Red Bull Racing, making him one of the most dominant drivers in the sport's history."
8
- },
9
- "Liam Lawson": {
10
- "birth_date": "2002-02-11",
11
- "number": 30,
12
- "team": "Red Bull Racing",
13
- "nationality": "🇳🇿 New Zealand",
14
- "summary": "Hailing from New Zealand, Lawson quickly rose through the ranks of single-seater racing, impressing in Formula 2 and DTM. His composed performances as a reserve driver for Red Bull earned him a race seat, showcasing his ability to adapt quickly to different racing disciplines and challenging conditions."
15
- },
16
- "Charles Leclerc": {
17
- "birth_date": "1997-10-16",
18
- "number": 16,
19
- "team": "Ferrari",
20
- "nationality": "🇲🇨 Monaco",
21
- "summary": "A product of the Ferrari Driver Academy, Leclerc's journey to F1 was marked by personal tragedy and triumph. The Monegasque driver won back-to-back championships in GP3 and F2 before joining Sauber and then Ferrari. Known for his qualifying pace and racecraft, he became Ferrari's leading driver and a consistent championship contender."
22
- },
23
- "Lewis Hamilton": {
24
- "birth_date": "1985-01-07",
25
- "number": 44,
26
- "team": "Ferrari",
27
- "nationality": "🇬🇧 United Kingdom",
28
- "summary": "One of the most successful drivers in F1 history, Hamilton's journey began in karting where he was signed by McLaren at age 13. The seven-time world champion made history as the first black driver in F1 and holds numerous records, including most race wins and pole positions. His move to Ferrari in 2025 marked a new chapter in his legendary career."
29
- },
30
- "George Russell": {
31
- "birth_date": "1998-02-15",
32
- "number": 63,
33
- "team": "Mercedes",
34
- "nationality": "🇬🇧 United Kingdom",
35
- "summary": "Dubbed 'Mr. Saturday' for his exceptional qualifying performances, Russell's path to F1 was paved with success in junior categories, including winning the GP3 and F2 championships in consecutive years. After impressing at Williams, he earned a Mercedes seat, where he continues to showcase his speed and racecraft against the sport's best."
36
- },
37
- "Andrea Kimi Antonelli": {
38
- "birth_date": "2006-08-25",
39
- "number": 12,
40
- "team": "Mercedes",
41
- "nationality": "🇮🇹 Italy",
42
- "summary": "The youngest driver on the grid, Antonelli is one of the most exciting prospects in motorsport. After dominating the junior categories with multiple championships, he made an early jump to F1 with Mercedes, skipping F2. His rapid progression and natural talent have drawn comparisons to Max Verstappen's meteoric rise in the sport."
43
- },
44
- "Lando Norris": {
45
- "birth_date": "1999-11-13",
46
- "number": 4,
47
- "team": "McLaren",
48
- "nationality": "🇬🇧 United Kingdom",
49
- "summary": "Known for his charismatic personality and raw speed, Norris rose through the ranks of karting and single-seaters before joining McLaren. The British driver has developed into one of F1's brightest talents, known for his consistency, racecraft, and entertaining social media presence. His performances have made him a fan favorite and a future championship contender."
50
- },
51
- "Oscar Piastri": {
52
- "birth_date": "2001-04-06",
53
- "number": 81,
54
- "team": "McLaren",
55
- "nationality": "🇦🇺 Australia",
56
- "summary": "The Australian sensation made history by winning three consecutive junior championships (Formula Renault, F3, and F2) before his F1 debut. After a year on the sidelines as Alpine's reserve driver, Piastri joined McLaren where he quickly established himself as one of the grid's most promising talents, known for his technical feedback and race intelligence."
57
- },
58
- "Fernando Alonso": {
59
- "birth_date": "1981-07-29",
60
- "number": 14,
61
- "team": "Aston Martin",
62
- "nationality": "🇪🇸 Spain",
63
- "summary": "A two-time World Champion, Alonso is known for his incredible racecraft and fierce determination. The Spaniard made his F1 debut with Minardi in 2001 before winning back-to-back titles with Renault. His career has seen him race for top teams including Ferrari and McLaren, and he continues to be one of the most respected and experienced drivers on the grid with Aston Martin."
64
- },
65
- "Lance Stroll": {
66
- "birth_date": "1998-10-29",
67
- "number": 18,
68
- "team": "Aston Martin",
69
- "nationality": "🇨🇦 Canada",
70
- "summary": "The son of billionaire Lawrence Stroll, Lance has worked hard to prove himself beyond his family connections. After winning the European F3 championship, he made history as the first Canadian to take an F1 podium in the wet at Baku 2017. His smooth driving style and wet-weather prowess have earned him respect in the paddock."
71
- },
72
- "Pierre Gasly": {
73
- "birth_date": "1996-02-07",
74
- "number": 10,
75
- "team": "Alpine",
76
- "nationality": "🇫🇷 France",
77
- "summary": "Gasly's journey to F1 was marked by success in junior categories, including winning the 2016 GP2 championship. After a challenging stint at Red Bull, he found his stride at AlphaTauri, securing a memorable victory at Monza in 2020. The Frenchman is known for his emotional personality and strong work ethic."
78
- },
79
- "Jack Doohan": {
80
- "birth_date": "2003-01-20",
81
- "number": 7,
82
- "team": "Alpine",
83
- "nationality": "🇦🇺 Australia",
84
- "summary": "Son of motorcycle legend Mick Doohan, Jack has carved his own path in four-wheel racing. The Australian impressed in F2 with multiple race wins and pole positions before earning his F1 debut with Alpine. Known for his technical feedback and smooth driving style, he represents the next generation of Australian racing talent."
85
- },
86
- "Esteban Ocon": {
87
- "birth_date": "1996-09-17",
88
- "number": 31,
89
- "team": "Haas",
90
- "nationality": "🇫🇷 France",
91
- "summary": "Ocon's journey to F1 was marked by financial challenges before catching the eye of Mercedes' junior program. After winning the 2015 GP3 series and serving as a reserve driver, he made his debut with Manor Racing. The Frenchman is known for his consistency, racecraft, and memorable battles with teammate Sergio Perez during their Force India days."
92
- },
93
- "Oliver Bearman": {
94
- "birth_date": "2005-05-08",
95
- "number": 87,
96
- "team": "Haas",
97
- "nationality": "🇬🇧 United Kingdom",
98
- "summary": "One of the youngest drivers on the grid, Bearman made a name for himself with dominant performances in Italian F4 and Formula 3. The British driver's rapid progression through the junior categories earned him a spot in Ferrari's Driver Academy and a race seat with Haas. His technical understanding and mature approach belie his young age."
99
- },
100
- "Yuki Tsunoda": {
101
- "birth_date": "2000-05-11",
102
- "number": 22,
103
- "team": "Racing Bulls",
104
- "nationality": "🇯🇵 Japan",
105
- "summary": "The first Japanese driver in F1 since 2014, Tsunoda's rapid rise through the ranks was supported by Honda's young driver program. After finishing third in F2, he made his F1 debut with AlphaTauri. Known for his aggressive driving style and passionate radio messages, Tsunoda has developed into a consistent points scorer for Racing Bulls."
106
- },
107
- "Isack Hadjar": {
108
- "birth_date": "2004-09-28",
109
- "number": 6,
110
- "team": "Racing Bulls",
111
- "nationality": "🇫🇷 France",
112
- "summary": "Hadjar emerged as one of the most exciting young talents in junior single-seater racing, impressing in F3 before moving up to F2. The French-Algerian driver's smooth driving style and natural speed earned him a spot in Red Bull's junior program. His rapid adaptation to different racing categories has marked him as a future star."
113
- },
114
- "Alexander Albon": {
115
- "birth_date": "1996-03-23",
116
- "number": 23,
117
- "team": "Williams",
118
- "nationality": "🇹🇭 Thailand",
119
- "summary": "Born to a British father and Thai mother, Albon's journey to F1 included being dropped by Red Bull's junior program before fighting his way back through GP3 and F2. After strong performances with Toro Rosso and Red Bull, he found a home at Williams where his consistent point-scoring has made him team leader. His smooth driving style and technical feedback are among his greatest strengths."
120
- },
121
- "Carlos Sainz Jr": {
122
- "birth_date": "1994-09-01",
123
- "number": 55,
124
- "team": "Williams",
125
- "nationality": "🇪🇸 Spain",
126
- "summary": "Son of rally legend Carlos Sainz, the Spaniard has forged his own successful career in F1. After learning his craft at Toro Rosso, he impressed at Renault, McLaren, and Ferrari before moving to Williams. Known for his consistency and intelligence behind the wheel, Sainz is regarded as one of the most complete drivers on the grid."
127
- },
128
- "Nico Hülkenberg": {
129
- "birth_date": "1987-08-19",
130
- "number": 27,
131
- "team": "Kick Sauber",
132
- "nationality": "🇩🇪 Germany",
133
- "summary": "The experienced German driver holds the record for most F1 starts without a podium. After winning titles in A1GP and GP2, Hülkenberg made his F1 debut with Williams in 2010. Known for his qualifying prowess and technical feedback, he returned to F1 with Haas before moving to Kick Sauber, bringing valuable experience to the team."
134
- },
135
- "Gabriel Bortoleto": {
136
- "birth_date": "2004-10-14",
137
- "number": 5,
138
- "team": "Kick Sauber",
139
- "nationality": "🇧🇷 Brazil",
140
- "summary": "The latest Brazilian talent to reach F1, Bortoleto made waves by winning the 2023 F3 championship in dominant fashion. His smooth driving style and racecraft earned him a spot in the McLaren young driver program before securing a race seat with Kick Sauber. The young Brazilian carries the hopes of a nation that has produced legends like Senna, Piquet, and Massa."
141
- }
142
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
assets/driver_numbers.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "Max Verstappen": 1,
3
- "Liam Lawson": 30,
4
- "Charles Leclerc": 16,
5
- "Lewis Hamilton": 44,
6
- "George Russell": 63,
7
- "Andrea Kimi Antonelli": 12,
8
- "Lando Norris": 4,
9
- "Oscar Piastri": 81,
10
- "Fernando Alonso": 14,
11
- "Lance Stroll": 18,
12
- "Pierre Gasly": 10,
13
- "Jack Doohan": 7,
14
- "Esteban Ocon": 31,
15
- "Oliver Bearman": 87,
16
- "Yuki Tsunoda": 22,
17
- "Isack Hadjar": 6,
18
- "Alexander Albon": 23,
19
- "Carlos Sainz Jr": 55,
20
- "Nico Hülkenberg": 27,
21
- "Gabriel Bortoleto": 5
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fastf1_tools.py CHANGED
@@ -18,7 +18,8 @@ from fastf1.core import Session
18
  from utils import parser_utils, track_utils
19
  from utils.constants import (
20
  AVAILABLE_SESSION_TYPES,
21
- DRIVER_DETAILS
 
22
  )
23
 
24
  # Custom types
@@ -229,8 +230,22 @@ def get_driver_info(driver_name: str) -> str:
229
  nationality, and a brief summary
230
  """
231
  driver = DRIVER_DETAILS[driver_name]
232
- driver_info_string = f"{driver_name} ({driver['birth_date']})\n{driver['team']} #{driver['number']}\n{driver['nationality']}\n\n{driver['summary']}"
233
  return driver_info_string
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
 
236
 
 
18
  from utils import parser_utils, track_utils
19
  from utils.constants import (
20
  AVAILABLE_SESSION_TYPES,
21
+ DRIVER_DETAILS,
22
+ CONSTRUCTOR_DETAILS
23
  )
24
 
25
  # Custom types
 
230
  nationality, and a brief summary
231
  """
232
  driver = DRIVER_DETAILS[driver_name]
233
+ driver_info_string = f"{driver_name} ({driver['birth_date']}) {driver['nationality']}\n{driver['team']} #{driver['number']}\n\n{driver['summary']}"
234
  return driver_info_string
235
+
236
+ def get_constructor_info(constructor_name: str) -> str:
237
+ """Retrieve detailed information about a specific constructor.
238
+
239
+ Args:
240
+ constructor_name (str): Full name of the constructor (e.g., 'Red Bull Racing')
241
+
242
+ Returns:
243
+ str: Formatted string with constructor's details including name, team, number,
244
+ nationality, and a brief summary
245
+ """
246
+ constructor = CONSTRUCTOR_DETAILS[constructor_name]
247
+ constructor_info_string = f"{constructor['team_name']} ({constructor_name})\n{constructor['base']}\nTeam principle: {constructor['team_principal']}\nDriver(s): {constructor['drivers'][0]} & {constructor['drivers'][1]}\nPower unit: {constructor['power_unit']}\nChassis: {constructor['chassis']}"
248
+ return constructor_info_string
249
 
250
 
251
 
todo.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ - For driver championship standings, make the Driver dropdown depend on the selected season. As it is implemented now one could not use it for older seasons!
2
+ * Solution is to have a static json file that maps drivers for each season/year
3
+ - Same applies for constructor championship standings but instead Constructor dropdown
4
+ * Similar solution to above
5
+ - Implement a tab for the OpenF1 tools but it might not be that user friendly :/
6
+ - Add some helpful info for each Gradio Tab to help user understand what they are able to do
7
+ - for session result remove the default placeholder value
utils/constants.py CHANGED
@@ -22,4 +22,75 @@ DRIVER_NAMES: list[str] = json.load(open("assets/driver_names.json"))["drivers"]
22
  CONSTRUCTOR_NAMES: list[str] = json.load(open("assets/constructors.json"))["constructors"]
23
 
24
  # Load in driver details
25
- DRIVER_DETAILS = json.load(open("assets/driver_details_with_summaries.json"))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  CONSTRUCTOR_NAMES: list[str] = json.load(open("assets/constructors.json"))["constructors"]
23
 
24
  # Load in driver details
25
+ DRIVER_DETAILS: dict[str, dict[str, str]] = json.load(open("assets/driver_details.json"))
26
+
27
+ # Load in constructor details
28
+ CONSTRUCTOR_DETAILS: dict[str, dict[str, str]] = json.load(open("assets/constructor_details.json"))
29
+
30
+
31
+ MARKDOWN_INTRODUCTION = """
32
+ # 🏁 Formula 1 MCP server 🏎️
33
+
34
+ Welcome to the Formula 1 MCP server, your one-stop destination for comprehensive Formula 1 data and visualizations.
35
+ <br>
36
+ This application leverages the FastF1 library to provide detailed insights into Formula 1 races, drivers, and teams.
37
+
38
+ ## Available Tools in Gradio UI
39
+
40
+ ### Championship Standings
41
+ - **Driver Championship**: Track driver positions, points, and wins
42
+ - **Constructor Championship**: Monitor team performances and rankings
43
+
44
+ ### Race Information
45
+ - **Event Info**: Get detailed information about specific Grand Prix events
46
+ - **Season Calendar**: View the complete race calendar for any season
47
+ - **Session Results**: Access race, qualifying, and sprint session results
48
+
49
+ ### Driver & Team Data
50
+ - **Driver Info**: View detailed driver profiles and statistics
51
+ - **Track Visualizations**: Explore interactive track maps with speed, gear, and corner data
52
+
53
+
54
+ ## Usage
55
+
56
+ There are different ways to interact with the MCP server:
57
+
58
+ 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.
59
+
60
+ 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.
61
+
62
+ 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).
63
+
64
+
65
+ ## MCP json configuration
66
+
67
+ 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):
68
+
69
+ ```json
70
+ {
71
+ "mcpServers": {
72
+ "gradio": {
73
+ "url": "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse"
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ For Claude Desktop, the following configuration can instead be used, but make sure you have Node.js installed:
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "gradio": {
85
+ "command": "npx",
86
+ "args": [
87
+ "mcp-remote",
88
+ "https://agents-mcp-hackathon-f1-mcp-server.hf.space/gradio_api/mcp/sse",
89
+ "--transport",
90
+ "sse-only"
91
+ ]
92
+ }
93
+ }
94
+ }
95
+ ```
96
+ """