Skip to main content
Glama
pefman
by pefman

MCP Grand Prix

LLM駆動型の3DレーシングゲームのMVPです。LLMエージェントが共有サーキット上でFormula 1カーを走らせ、ハイブリッドレースループ(戦略立案、物理シミュレーション、短いリアクティブな意思決定ウィンドウ)を経て進みます。その間、ブラウザの観戦クライアントがレースをライブで見守ります。

このプロジェクトは、ゲームの状態と戦略ツールをLLMエージェントに公開するMCPサーバーであり、加えてThree.jsの観戦ダッシュボードと、少数のスクリプト/LLMエージェント群から構成されます。

アーキテクチャ

┌────────────┐   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 — サーバー権威型のゲームコア。すべてのゲーム状態を保持し、決定的かつ冪等なツールメソッド(startRacesubmitPhaseStrategyreactToEventstep)を公開します。同じメソッドはMCP経由で実際のLLMにも提供され、プロセス内のスクリプトエージェントにも提供されるため、呼び出し元に関わらず挙動は同一です。

  • src/mcp/server.ts — エンジンのツールをエージェントに公開するMCP(JSON-RPC/SSE)サーバー。

  • src/game/raceRunner.ts — ハイブリッドレースループ(戦略 → シミュレーション → リアクティブウィンドウ)をティックごとに駆動します。

  • src/server/ — HTTP + WebSocketサーバーと観客向けフィード。

  • www/ — ブラウザ上の観戦クライアント(Three.js)。

Related MCP server: fastf1-mcp

レースループ

  1. 戦略フェーズ — 各ラップで、全エージェントが StrategyPacket(タイヤコンパウンド、ドライブモード、燃料、任意のピットラップ)を提出します。

  2. シミュレーションフェーズ — エンジンはティックごとに物理演算を進めます。

  3. リアクティブウィンドウ — トリガーイベント(接戦、セーフティカー、天候、タイヤの摩耗)がラップ途中の短いウィンドウを開き、関係するエージェントが(push / save / pit_now / attack / defend)で応答します。

クイックスタート

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

観戦ダッシュボードを http://localhost:3000 で開き、レースを開始します:

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

ブラウザはWebSocket(/ws)で同じホスト/ポートに接続し、ライブ更新を受け取ります。

CLIからスクリプトレースを実行する

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

設定(環境変数)

変数

デフォルト

目的

PORT

3000

HTTP + 観戦用WebSocketポート

MCP_PORT

9090

MCP JSON-RPC/SSEポート

SPECTATOR_PORT

HTTPポートのフォールバック(PORT 未設定時)

PORT はサーバーレスプラットフォームとの互換性のために使用されます(例:Vercel が PORT を設定します)。

スクリプト

スクリプト

説明

npm run build

TypeScript をコンパイル(srcdist

npm run dev

tsx でサーバーを実行(ビルドステップなし)

npm start

ビルド済みサーバーを実行

npm run agents

スクリプトによるデモレースを起動

npm test

ユニットテストを実行(Vitest)

npm run test:e2e

Playwright のエンドツーエンドスイートを実行

npm run lint

tsc --noEmit で型チェック

テスト

  • ユニットテストnpm test)は、実エンジンコアに対して、レースエンジンの公開コントラクト — ライフサイクル、戦略提出、リアクティブ応答、フルレース完了 — をカバーします。

  • エンドツーエンドnpm run test:e2e)はサーバーを起動してレースを開始し、ブラウザがマシンとライブ順位表を描画すること、レースが進行して勝者とともに完了すること、そしてリアクティブウィンドウのUIが表示されることを検証します。

MCPツール

サーバーは4つのMCPツールを公開します(src/mcp/server.ts を参照):

ツール

説明

get_race_state

現在のレース状態の全体:車両、位置、ギャップ、タイヤ、燃料、ラップ、イベント。

submit_phase_strategy

現在の戦略ウィンドウに対する車両の戦略を提出します(冪等)。

react_to_event

車両に対して開かれているリアクティブウィンドウに応答します(冪等)。

get_race_log

戦略決定とリアクティブ行動のサーバーデバッグログ。

実際のLLMエージェントはMCPクライアント(SSE)として接続し、これらのツールを呼び出します。スクリプトエージェントはエンジンのメソッドをプロセス内で呼び出します。startRace と毎ティックの step はレースランナー内部のものであり、MCPツールとしては公開されません。

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