Skip to main content
Glama

rct2-agent

MCP サーバーと OpenRCT2 プラグインの組み合わせで、プレイ中にエージェントがパークをサイドカー管理できるようにします。パークの状態を読み取り、ビジネス面(価格、スタッフ、マーケティング、ローン)を操作し、パークを視覚的に確認(スクリーンショット)し、時間を制御できます。あくまで管理のみ — エージェントはビジネスを調整し、建設を 推奨 できますが、実際に建設することはありません。

連携の仕組み

Claude Code (WSL)
      │ stdio (MCP)
      ▼
MCP server  ── dist/server.mjs, run by Windows node.exe
      │ TCP 127.0.0.1:7860  (newline-delimited JSON)
      ▼
Plugin (intransient) ── loaded inside OpenRCT2, LISTENS on the port
      │
      ▼
   OpenRCT2 game

サーバーは Windows の node.exe で実行されます(WSL には node がないため)。そのため、サーバーとプラグインはどちらも同じ Windows の localhost 上に置かれ、WSL↔Windows 間のネットーワークは発生しません。プラグインは接続を待ち受けます(常駐するので、パークのロードをまたいでも生存し続けます)。サーバーはダイヤルインで接続し、必要に応じて再接続します。

Related MCP server: LÖVE2D MCP Server

要件

  • OpenRCT2 0.5.4+ (QuickJS エンジン — Promises/ES2023 に必要)。

  • Windows 版 Node.js(この環境では C:\Program Files\nodejs\node.exe にあります)。

ビルドとインストール

WSL から、Windows のツールチェーンを使用します:

# helper wrappers (or just call node.exe / npm-cli.js directly)
NODE="/mnt/c/Program Files/nodejs/node.exe"
NPM=("$NODE" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js")

"${NPM[@]}" install
"${NPM[@]}" run build          # builds dist/rct2-agent.plugin.js + dist/server.mjs
"${NPM[@]}" run install:plugin # copies the plugin into your OpenRCT2 plugin folder

install:plugin のコピー先は C:\Users\casey\OneDrive\Documents\OpenRCT2\plugin\rct2-agent.plugin.js (RCT2_PLUGIN_DIR で上書きできます)。

MCP サーバーの設定

すぐ使えるプロジェクト設定が .mcp.json にあります。Claude Code では、プロジェクトディレクトリから起動するだけで自動的に認識されます(プロンプトが表示されたら承認してください)。または、明示的に追加することもできます:

claude mcp add rct2-agent --scope project \
  -- "/mnt/c/Program Files/nodejs/node.exe" \
     "C:\\Users\\casey\\OneDrive\\Desktop\\dead code projects\\rct2-agent\\dist\\server.mjs"

実行

  1. OpenRCT2 を起動し、シナリオを読み込みます。プラグインが読み込まれたことを確認してください — ゲーム内コンソールに [rct2-agent] listening on 127.0.0.1:7860 が表示されます。

  2. このフォルダで Claude Code を起動します。MCP サーバーは最初のツール呼び出し時に接続します。

  3. エージェントにパークの管理を依頼します。コアループは 計測→操作→待機→再計測 です: ベースラインを読み、変更を加え、advance_days(7) を実行し、再計測します。

ツール(一覧)

読み取り(目): get_park_summary, get_finance_report, list_rides, get_ride, list_shops, get_guest_overview, sample_guest_thoughts, list_staff, get_scenario

操作(手): set_ride_price, set_shop_price, set_park_entry_fee, open_ride, close_ride, set_inspection_interval, start_marketing_campaign, set_research_funding, hire_staff, fire_staff, set_staff_patrol, set_loan

表示(視覚): capture_view, capture_ride, find_location

時間: get_clock, set_game_speed, pause, resume, advance_days

保存: snapshot, list_snapshots

動作上の注意

  • お金はツールの境界では通常のドル単位で扱われます。内部的には OpenRCT2 が十分の一単位で保存しており、src/shared/protocol.ts (MONEY_FACTOR) で変換されます。値が 10 倍ずれているように見えたら、それが唯一の調整箇所です。

  • capture_view / set_staff_patrol / find_location の座標はタイル単位です(内部でマップ単位の値に変換されます)。

  • advance_days は、一時停止を解除して最大速度で実行し、目標の日付に到達すると自動で一時停止します。その後、新しい時刻を返します。処理が完了するまでブロックします。

  • スナップショット は save/agent/<play>/<label>.park に保存されます。復元はゲーム内の手動ロードが必要です — プラグイン API ではパークの保存はできますが、ロードはできません。

  • 書き込みはゲームアクション経由なので、ゲーム自身の制限が適用されます(例: ライドの価格上限)。拒否されたアクションはツールエラーとして返されます。

開発

  • npm run typecheck — tsc による型チェック、出力なし。

  • node scripts/smoke.mjs — ビルドしたプラグインをスタブのゲームに読み込み、実際のソケット経由でハンドラをテストします。

  • node scripts/mcp-smoke.mjs — ビルドした MCP サーバーを起動し、本当の MCP JSON-RPC でフェイクプラグインに対しドライブします。

構成

src/shared/protocol.ts   wire protocol + money conversion + method names
src/plugin/main.ts       the intransient in-game plugin (TCP listener + handlers)
src/server/rct-client.ts reconnecting TCP client to the plugin
src/server/index.ts      MCP server: tool definitions -> plugin methods
esbuild.mjs              builds both bundles
scripts/                 install + smoke tests

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    B
    maintenance
    Enables AI assistants to interact with running games in real time — introspecting game state, simulating keyboard and mouse input to actually play, capturing screenshots, executing Lua code, hot-reloading files, and receiving push notifications when state changes.
    8
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Enables AI agents and streamers to monitor and control Oxygen Not Included gameplay through MCP, including world editing, colony alerts, building orders, navigation, dupe management, and game speed control.
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Lets AI agents build, run and live-test FiveM servers by sending server and client console commands over RCON and devcon, driving the game window with keyboard, mouse and screenshot automation, and invoking in-game natives, exports and NUI callbacks through a companion bridge resource.
    79 npm
    15
    MIT