58 lines
1.5 KiB
Markdown
58 lines
1.5 KiB
Markdown
|
|
# CrystalBattle Unity MCP
|
||
|
|
|
||
|
|
This local MCP server exposes selected CrystalBattle Unity Editor commands to Codex.
|
||
|
|
|
||
|
|
## Architecture
|
||
|
|
|
||
|
|
- Codex connects to this MCP server over stdio.
|
||
|
|
- The MCP server calls the Unity Editor bridge at `http://127.0.0.1:17777`.
|
||
|
|
- The Unity Editor bridge executes Unity API work on the editor main thread.
|
||
|
|
|
||
|
|
## Unity Setup
|
||
|
|
|
||
|
|
Open `CrystalBattle_Client` in Unity. The bridge starts automatically after scripts compile.
|
||
|
|
|
||
|
|
Manual controls are available from the bridge panel:
|
||
|
|
|
||
|
|
```text
|
||
|
|
Tools/Codex Unity MCP/Bridge Panel
|
||
|
|
```
|
||
|
|
|
||
|
|
The panel shows the current connection status, endpoint, listener thread state, pending command count, total request count, recent command, and cached log count. It also includes buttons to start, stop, restart, copy the endpoint, and print status to the Unity Console.
|
||
|
|
|
||
|
|
## Install Dependencies
|
||
|
|
|
||
|
|
From this directory:
|
||
|
|
|
||
|
|
```powershell
|
||
|
|
pnpm install
|
||
|
|
```
|
||
|
|
|
||
|
|
If `pnpm` is not on `PATH`, use the Codex bundled runtime:
|
||
|
|
|
||
|
|
```powershell
|
||
|
|
& "C:\Users\admin\.cache\codex-runtimes\codex-primary-runtime\dependencies\bin\pnpm.cmd" install
|
||
|
|
```
|
||
|
|
|
||
|
|
## Tools
|
||
|
|
|
||
|
|
- `unity_health`
|
||
|
|
- `unity_refresh_assets`
|
||
|
|
- `unity_execute_menu_item`
|
||
|
|
- `unity_get_console_logs`
|
||
|
|
- `unity_generate_ui_prefab`
|
||
|
|
- `unity_export_prefab_to_json`
|
||
|
|
|
||
|
|
## Environment
|
||
|
|
|
||
|
|
Optional:
|
||
|
|
|
||
|
|
```text
|
||
|
|
UNITY_MCP_BRIDGE_URL=http://127.0.0.1:17777
|
||
|
|
```
|
||
|
|
|
||
|
|
## Codex Config
|
||
|
|
|
||
|
|
The workspace includes `.codex/config.toml` with a `crystalbattle-unity` MCP server entry.
|
||
|
|
Restart Codex after dependency installation so the new MCP server is discovered.
|