Skip to main content
Glama
README.md
# f1-mcp

**Ask Claude about Formula 1, then turn the answer into a narrated TikTok.** Every race since 1950, lap-by-lap data from 2023, and vertical videos with a hype commentator voice and captions. No API keys, no accounts for the core tools.

[![Watch the 60-second demo](assets/demo.png)](assets/demo.mp4)

*Above: "Make a 1-minute narrated TikTok of the first 4 laps of Bahrain 2024." Click to watch (voice on).*

No API keys. No accounts. History comes from a local copy of [F1DB](https://github.com/f1db/f1db) (every race since 1950, no API needed after the first download), with [Jolpica-F1](https://github.com/jolpica/jolpica-f1) as a live fallback. Lap-level data comes from [OpenF1](https://openf1.org) (2023 onward).

## Try asking

- "Who won the 2021 Abu Dhabi Grand Prix and how did the top 5 finish?"
- "Compare Verstappen and Norris on their fastest qualifying laps in Bahrain 2024. Where did Max gain time?"
- "Show the 2024 constructors' standings after round 10."
- "Make me a TikTok-ready bar chart race of the 2024 drivers' championship."
- "Who had the best tyre management in the 2024 Bahrain GP? Compare Verstappen and Perez."
- "Compare Senna and Schumacher: wins, poles, titles."
- "Who has won the most at Monaco?"
- "How many wins did drivers starting 10th or lower get? Use the database."
- "Make a career wins video of Hamilton, Schumacher and Verstappen."
- "Make a 1-minute narrated TikTok of the first 3 laps of Bahrain 2024, with an excited commentator voice."
- "Was there a safety car at Monaco 2024? Who gained from it?"
- "Who pulled off undercuts at Silverstone 2024?"
- "What did Leclerc say on the radio in the Monaco 2024 race?"
- "Show Hamilton's laps and tyre stints at Abu Dhabi 2021."
- "Get my narrated clip ready to post on TikTok."
- "Where did Norris lose time to Verstappen in Bahrain qualifying?"
- "Was Silverstone 2024 wet? How did the temperatures change?"
- "Make a tyre strategy video of the 2024 Bahrain GP."
- "Make a track map replay of the first 3 laps of the 2024 Monaco Grand Prix."
- "Make a narrated video of the safety car at Jeddah 2024, laps 5 to 9."
- "Make a narrated head-to-head of Norris vs Verstappen's fastest laps in Bahrain 2024 qualifying."

## Talk to it like a fan

Names don't have to be exact. Drivers, races and sessions are matched forgivingly:

- **Drivers:** "Max", "VER", "Verstappen", "Pérez", "checo", "hulk", the car number, or a small typo like "Hamiltn" all work. If a name fits two drivers (like "Schumacher"), you get a clear question back instead of a guess. "Hamilton" means Lewis, because he has far more starts than anyone else with that name.
- **Races:** "Monza", "british gp", "the Italian Grand Prix", "COTA", "Vegas", "Montréal", "Mexico City" or "silverston". The history tools also accept a race name instead of a round number: "Who won Monza 2023?".
- **Sessions:** "race", "quali", "sprint", "sprint shootout", "fp1".

## Tools

| Tool | What it does | Source |
| --- | --- | --- |
| `get_race_results` | Full classification for any race since 1950 | F1DB (local) |
| `get_standings` | Driver or constructor standings after any round | F1DB (local) |
| `get_season_schedule` | Race calendar for a season | F1DB (local) |
| `get_qualifying_results` | Q1/Q2/Q3 classification for a race | F1DB (local) |
| `get_sprint_results` | Sprint race results (2021+) | F1DB (local) |
| `get_pit_stops` | Every pit stop in a race plus the fastest (2011+) | F1DB (local) |
| `get_driver_career` | Starts, wins, podiums, poles, titles, teams for any driver since 1950 | F1DB (local) |
| `compare_driver_careers` | Head-to-head career stats and win rates for two drivers, any era | F1DB (local) |
| `get_circuit_history` | Every winner at a circuit and who has won most there | F1DB (local) |
| `create_career_wins_video` | 1080x1920 MP4 racing 2-4 drivers' cumulative wins by season of career | F1DB (local) |
| `describe_f1_database` | Lists every table and column in the local history database | F1DB (local) |
| `query_f1_database` | Read-only SQL for any historical question the other tools don't cover | F1DB (local) |
| `get_driver_lap_times` | Every lap and sector time for one driver in a session | OpenF1 |
| `compare_fastest_laps` | Two drivers' best laps: time, sectors, top speed, delta | OpenF1 |
| `create_championship_race_video` | 1080x1920 MP4 bar chart race of a season | F1DB (local) |
| `create_track_replay_with_beats` | Step 1 of a narrated TikTok: the track map replay plus a timed beat sheet (start, laps, position changes, safety cars, flags, penalties, pit stops, finish) | OpenF1 |
| `create_speed_trace_video` | Two drivers' fastest laps head to head: cars on the map, speed traces and a live time gap, plus a beat sheet for narration | OpenF1 |
| `add_narration` | Step 2: adds an excited voice-over, word-by-word captions and optional music from a script Claude writes | edge-tts |
| `get_race_control` | Safety cars, red and yellow flags, penalties and investigations with lap numbers | OpenF1 |
| `get_weather` | Air and track temperature, humidity, wind, rain | OpenF1 |
| `get_overtakes` | Passes cleaned of pit-stop noise: who, whom, which lap (an estimate, not official) | OpenF1 |
| `get_gaps` | Gap to the leader and to the car ahead at the start of every lap | OpenF1 |
| `get_speed_trace` | Fastest-lap car data; two drivers compared by lap distance, with where time was won | OpenF1 |
| `get_team_radio` | Links to released team radio clips with lap numbers | OpenF1 |
| `detect_undercuts` | Undercuts and overcuts from pit stops, positions and gaps, with whether each worked (a heuristic) | OpenF1 |
| `transcribe_team_radio` | Text transcripts of team radio clips with a free local speech-to-text model (optional extra) | OpenF1 + faster-whisper |
| `get_historical_lap_times` | Every lap a driver did in any race from 1996 | Jolpica-F1 |
| `get_historical_laps` | Laps with tyre compound, age, stints and degradation from 2018 (optional extra) | FastF1 |
| `get_historical_tyre_strategy` | Tyre stints for every driver, 2018 onward (optional extra) | FastF1 |
| `prepare_post` | Checks a clip against TikTok, Reels or Shorts specs, makes a cover image and a paste-ready caption file | local |
| `get_tyre_strategy` | Every driver's stints: compound and lap ranges, ordered by finish | OpenF1 |
| `analyze_tyre_degradation` | Seconds lost per lap of tyre age for each stint, raw and fuel-corrected | OpenF1 |
| `create_tyre_strategy_video` | 1080x1920 MP4 of tyre strategies growing lap by lap | OpenF1 |
| `create_track_map_replay` | 1080x1920 MP4 of the cars racing around the circuit from GPS data, with a live top-10 order | OpenF1 |

## Install

Requires Python 3.10+ and [ffmpeg](https://ffmpeg.org/) on your PATH (only for the video tools).

```bash
git clone https://github.com/Megabreadon/f1-mcp
cd f1-mcp
pip install -e .
```

### Claude Code

```bash
claude mcp add f1 -- f1-mcp
```

On Windows, Smart App Control can block the `f1-mcp.exe` launcher that pip creates ("An Application Control policy has blocked this file"). Register the module instead, which runs the same server:

```bash
claude mcp add f1 -- python -m f1_mcp.server
```

If you use [uv](https://docs.astral.sh/uv/), you can skip the clone:

```bash
claude mcp add f1 -- uvx --from git+https://github.com/Megabreadon/f1-mcp f1-mcp
```

### Optional: the skill

The server already tells Claude how to use its tools. For the best results in Claude Code, also install the bundled skill, a step-by-step guide for results analysis, the narrated-video script rules and error handling:

```bash
mkdir -p ~/.claude/skills && cp -r skills/f1 ~/.claude/skills/
```

On Windows PowerShell:

```powershell
New-Item -ItemType Directory -Force "$HOME\.claude\skills" | Out-Null; Copy-Item -Recurse skills\f1 "$HOME\.claude\skills\f1"
```

### Claude Desktop

Add this to `claude_desktop_config.json` and restart:

```json
{
  "mcpServers": {
    "f1": { "command": "f1-mcp" }
  }
}
```

## Optional extras

```bash
pip install "f1-mcp[transcribe]"   # team radio transcripts (free, runs locally; first use downloads a ~150 MB model)
pip install "f1-mcp[fastf1]"       # laps, tyres and stints for 2018-2022 via FastF1 (first load of a race takes up to a minute)
```

**FastF1 needs an F1 account now.** F1's timing archive started refusing anonymous requests (HTTP 401), so FastF1 can only load sessions that are already in its cache unless you sign in with a Formula 1 account (FastF1 reads `F1_USERNAME` and `F1_PASSWORD`; see FastF1's docs). Without one, `get_historical_lap_times` still gives lap times from 1996, without tyre data.

Team radio audio belongs to F1. The transcription tool fetches clips only from F1's own static host, keeps the audio in a temporary file just long enough to transcribe it, deletes it, and caches only the text. Transcripts are machine-generated and can be wrong: treat them as notes, not quotes. For better accuracy set `F1_MCP_WHISPER_MODEL=small.en` (about 460 MB, slower).

## Ready to post

`prepare_post` checks a finished clip against TikTok, Reels or Shorts (vertical, length, size, audio), makes a cover image, tidies your hashtags and writes a paste-ready text file next to the video. Its limits are conservative on purpose, because the apps change their rules and guides disagree. It never uploads anything.

## Limits and fair use

Everything runs on your own computer, so there is no shared server to overload.

- **History (1950 to the latest race)** is answered from a local copy of [F1DB](https://github.com/f1db/f1db). The first history question downloads about 16 MB, checks it against the release's SHA-256 checksum, and stores it in `~/.cache/f1-mcp/f1db`. After that, history questions use no network and no rate limits. It checks for a newer release every 6 hours and updates after each race weekend.
- **Fallback:** if the download fails (offline, GitHub down) or F1DB doesn't have a race yet, the tools fall back to Jolpica-F1.
- **Lap-by-lap data (2023+)** comes from OpenF1, which is free for historical data. Real-time data needs a paid OpenF1 subscription and isn't supported.

| | Jolpica-F1 (fallback) | OpenF1 |
| --- | --- | --- |
| Free limits | 4 requests/second, 500 requests/hour (they say limits may shrink) | 3 requests/second, 30 requests/minute |

What f1-mcp does to stay inside those limits:

- Spaces requests out and retries with backoff on HTTP 429/5xx.
- Stops at 450 Jolpica requests per hour and tells you how long to wait.
- Keeps OpenF1 under 30 requests a minute (it waits for a free slot), so the first replay of a race can take a little longer.
- Caches results on disk in `~/.cache/f1-mcp` (set `F1_MCP_CACHE` to move it), capped at 500 MB: the least recently used answers are deleted first (`F1_MCP_CACHE_MB` to change). Delete the folder to reset.
- Validates inputs and caps video length (5-60 s) and replay windows (10 laps).
- `query_f1_database` is read-only: one SELECT at a time, 500 rows, 15 seconds, values up to 1 MB, replies cut at about 200 KB.

Good to know:

- Videos need [ffmpeg](https://ffmpeg.org/) and are saved to `~/f1-mcp-output` (`F1_MCP_OUT` to change).
- F1DB can lag a live race by up to a day. Every F1DB answer says which release it came from.
- Live-session data is not supported on the free OpenF1 tier.

## Narrated videos

Ask for a narrated clip and Claude runs two steps. First `create_track_replay_with_beats` (a race) or `create_speed_trace_video` (a qualifying duel) renders the clip and returns a timed list of what happens: lights out, lap changes, position changes, safety cars, flags, penalties and pit stops, or where each driver won and lost time. Claude writes a hype script with one line per beat. Then `add_narration` speaks each line at the right moment, burns in captions and mixes optional music.

- Voices are Microsoft Edge neural voices through the free `edge-tts` package. **The script text is sent to Microsoft's online text-to-speech service**; the video never leaves your machine. Try `en-US-GuyNeural`, `en-US-AndrewNeural` or `en-GB-RyanNeural`.
- Music is optional and you supply it. Use royalty-free tracks you have rights to. A common trick is to post with the voice only and add a trending sound inside TikTok.
- Only clips rendered by this server (in the output folder) can be narrated. `music_path` can be any local mp3/wav/m4a/ogg/flac file; it is only mixed into the clip on your machine.
- Captions use the Arial font. On Linux without Arial, libass substitutes a similar font, so line widths can differ slightly.

## Credits and legal

Data comes from [F1DB](https://github.com/f1db/f1db) (licensed [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/), attribution required), [Jolpica-F1](https://github.com/jolpica/jolpica-f1) and [OpenF1](https://openf1.org). Please consider supporting them. If you publish videos or data made with this tool, credit F1DB as the history source. Team radio audio belongs to F1: share links and short paraphrases, not the audio. This project is unofficial and not affiliated with Formula 1, the FIA or Formula One Licensing B.V. F1-related trademarks belong to their owners.

**Non-commercial use only.** Jolpica-F1 and OpenF1 license their data under [CC BY-NC-SA 4.0](https://creativecommons.org/licenses/by-nc-sa/4.0/), and Formula 1's own content (including team radio) is for personal, non-commercial use. Making and posting fan videos is fine; monetised videos (creator funds, sponsorships, ads) need permission from those providers first. F1DB (CC-BY-4.0) allows commercial use with credit. Videos already carry a "data: ..." credit line: keep it when you post. Do not add F1 or team logos.

## Why this exists

Built with Claude Code by a beginner who started with no idea what an MCP server was. If that's you too, the code is small and readable on purpose: `f1_mcp/server.py` is the list of tools, and each other file does one job.

## Roadmap

See [ROADMAP.md](ROADMAP.md) for what is planned and [ARCHITECTURE.md](ARCHITECTURE.md) for how the code is organised. Ideas and PRs welcome.

## License

MIT. Not affiliated with Formula 1 or the FIA.

TDQS

B3.4/5.0

Scored across 34 tools

Disambiguation4/5

Most tools target clearly distinct resource+action pairs, and the era/source splits (get_driver_lap_times for 2023+, get_historical_lap_times for 1996-2022, get_historical_laps for FastF1) are explicitly described so an agent can choose correctly. A few pairs are still easy to confuse: create_track_map_replay vs create_track_replay_with_beats (nearly identical output, one adds a beat sheet), and get_speed_trace vs compare_fastest_laps partially overlap.

Naming Consistency4/5

Names follow a consistent verb_noun snake_case pattern throughout (get_, create_, compare_, analyze_, detect_, describe_, query_, prepare_, add_). Minor deviation: create_track_replay_with_beats appends a qualifier while its sibling create_track_map_replay does not, making the two names unusually similar for differing behaviors.

Tool Count3/5

34 tools is heavy and exceeds the comfortable range, but the surface spans genuinely different domains (historical DB, live OpenF1 telemetry, video rendering, and social prep) so many tools earn their place. Still, the six video-rendering tools and three lap-time sources push it past what most agents can hold comfortably.

Completeness5/5

Coverage is excellent: results, qualifying, sprint, standings, schedule, pit stops, tyre strategy and degradation, radio (with transcription), lap times, weather, race control, overtakes, undercuts, and gaps, plus a describe/query F1 database escape hatch for anything else. The video+narration+post-prep pipeline also closes the content-creation lifecycle with no obvious dead ends.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues