Skip to main content
Glama
pefman
by pefman

MCP Grand Prix

An MVP of an LLM-driven 3D racing game. LLM agents steer Formula 1 cars over a shared circuit through a hybrid race loop — strategic planning, physics simulation, and short reactive decision windows — while a browser spectator client watches the race live.

The project is an MCP server exposing game-state and strategy tools to LLM agents, plus a Three.js spectator dashboard and a small fleet of scripted/LLM agents.

Architecture

┌────────────┐   MCP (SSE)   ┌───────────────┐   tool calls   ┌──────────────┐
│  LLM agents│ ────────────▶ │  src/mcp      │ ◀───────────── │  RaceEngine  │
│ (LLM or    │               │  server.ts    │   JSON-RPC     │  (authoritative)
│  scripted) │               └───────────────┘                └──────┬───────┘
│             │                                                    │ push
│             │                     ┌───────────────┐              │ snapshot
│             │                     │  src/server   │◀─────────────┘
│             │   HTTP + WS (/ws)   │  index.ts     │
└────────────┘ ◀────────────────── │  spectator    │
        Browser spectator        └───────────────┘
        (Three.js, www/client.js)
  • src/game/raceEngine.ts — the server-authoritative game core. Owns all game state and exposes deterministic, idempotent tool methods (startRace, submitPhaseStrategy, reactToEvent, step). The same methods are served to real LLMs over MCP and to in-process scripted agents, so behaviour is identical regardless of who is calling.

  • src/mcp/server.ts — the MCP (JSON-RPC/SSE) server exposing the engine's tools to agents.

  • src/game/raceRunner.ts — drives the hybrid race loop (strategy → simulation → reactive windows) tick by tick.

  • src/server/ — the HTTP + WebSocket server and spectator feed.

  • www/ — the browser spectator client (Three.js).

Related MCP server: fastf1-mcp

Race loop

  1. Strategy Phase — every lap, all agents submit a StrategyPacket (tire compound, drive mode, fuel save, optional pit lap).

  2. Simulation Phase — the engine advances physics each tick.

  3. Reactive Windows — trigger events (close battles, safety cars, weather, tire wear) open short mid-lap windows where involved agents respond (push / save / pit_now / attack / defend).

Quick start

npm install
npm run build   # prebuild copies three.js into www/lib
npm start       # serves the spectator app + MCP server

Open the spectator dashboard at http://localhost:3000 and start a race:

curl -X POST http://localhost:3000/race

The browser connects to the same host/port over WebSocket (/ws) for live updates.

Run a scripted race from the CLI

npm run agents        # launches 4 scripted agents in a full race (demo)

Configuration (environment variables)

Variable

Default

Purpose

PORT

3000

HTTP + spectator WebSocket port

MCP_PORT

9090

MCP JSON-RPC/SSE port

SPECTATOR_PORT

Fallback for the HTTP port (if PORT unset)

PORT is used so the app is compatible with serverless platforms (e.g. Vercel sets PORT).

Scripts

Script

Description

npm run build

Compile TypeScript (srcdist)

npm run dev

Run the server with tsx (no build step)

npm start

Run the built server

npm run agents

Launch a scripted demo race

npm test

Run unit tests (Vitest)

npm run test:e2e

Run the Playwright end-to-end suite

npm run lint

Type-check with tsc --noEmit

Testing

  • Unit tests (npm test) cover the race engine's public contract — lifecycle, strategy submission, reactive responses, and full-race completion — against the real engine core.

  • End-to-end (npm run test:e2e) boots the server, starts a race, and asserts the browser renders cars and a live leaderboard, that the race progresses and finishes with a winner, and that reactive-window UI appears.

MCP tools

The server exposes four MCP tools (see src/mcp/server.ts):

Tool

Description

get_race_state

Full current race state: cars, positions, gaps, tires, fuel, laps, events.

submit_phase_strategy

Submit a car's strategy for the current strategy window (idempotent).

react_to_event

Respond to an open reactive window for a car (idempotent).

get_race_log

The server's debug log of strategy decisions and reactive actions.

Real LLM agents connect as MCP clients (SSE) to call these tools; scripted agents call the engine's methods in-process. startRace and the per-tick step are internal to the race runner rather than exposed as MCP tools.

F
license - not found
Not graded
quality - not tested
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    C
    quality
    D
    maintenance
    Enables AI assistants to access real-time iRacing telemetry, race information, camera control, pit operations, and replay features through the MCP protocol.
    17
    1
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    A local MCP server that gives Claude (or any MCP-compatible AI client) access to Formula 1 race data. Load any session from 2018 onwards, ask questions in natural language, and get answers backed by real telemetry, timing, and strategy data.
    17
    1
    MIT

View all related MCP servers

Related MCP Connectors

  • MCP server exposing the Backtest360 engine API as tools for AI agents.

  • Build, validate, and deploy multi-agent AI solutions from any AI environment.

  • MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pefman/mcpGrandPrix'

If you have feedback or need assistance with the MCP directory API, please join our Discord server