diff --git a/Packages/manifest.json b/Packages/manifest.json index efd6108..8445ccd 100644 --- a/Packages/manifest.json +++ b/Packages/manifest.json @@ -1,5 +1,6 @@ { "dependencies": { + "com.coplaydev.unity-mcp": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main", "com.unity.ai.navigation": "2.0.13", "com.unity.collab-proxy": "2.12.4", "com.unity.ide.rider": "3.0.38", diff --git a/Packages/packages-lock.json b/Packages/packages-lock.json index ff17595..d32be9c 100644 --- a/Packages/packages-lock.json +++ b/Packages/packages-lock.json @@ -1,5 +1,22 @@ { "dependencies": { + "com.coplaydev.unity-mcp": { + "version": "https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#main", + "depth": 0, + "source": "git", + "dependencies": { + "com.unity.modules.animation": "1.0.0", + "com.unity.modules.imageconversion": "1.0.0", + "com.unity.modules.physics": "1.0.0", + "com.unity.modules.physics2d": "1.0.0", + "com.unity.modules.uielements": "1.0.0", + "com.unity.modules.screencapture": "1.0.0", + "com.unity.modules.unitywebrequest": "1.0.0", + "com.unity.nuget.newtonsoft-json": "3.0.2", + "com.unity.test-framework": "1.1.31" + }, + "hash": "11836003a5e2ffcb7715ecec7e1fbb9d9cdb5bb8" + }, "com.unity.ai.navigation": { "version": "2.0.13", "depth": 0, @@ -91,6 +108,13 @@ "dependencies": {}, "url": "https://packages.unity.com" }, + "com.unity.nuget.newtonsoft-json": { + "version": "3.2.2", + "depth": 1, + "source": "registry", + "dependencies": {}, + "url": "https://packages.unity.com" + }, "com.unity.render-pipelines.core": { "version": "17.5.0", "depth": 1, diff --git a/ProjectSettings/ShaderGraphSettings.asset b/ProjectSettings/ShaderGraphSettings.asset index e66042a..ce8c243 100644 --- a/ProjectSettings/ShaderGraphSettings.asset +++ b/ProjectSettings/ShaderGraphSettings.asset @@ -13,6 +13,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: shaderVariantLimit: 128 + overrideShaderVariantLimit: 0 customInterpolatorErrorThreshold: 32 customInterpolatorWarningThreshold: 16 customHeatmapValues: {fileID: 0} diff --git a/docs/mcp-setup.md b/docs/mcp-setup.md index e905762..228eff7 100644 --- a/docs/mcp-setup.md +++ b/docs/mcp-setup.md @@ -8,10 +8,22 @@ ## Current values (this machine) -- **Windows host IP as seen from WSL:** `172.27.208.1` (the WSL default gateway; confirm with `ip route show default`). This can change across WSL restarts — if MCP stops connecting, re-check it and update `.mcp.json`. -- **MCP HTTP port:** `8080` (CoplayDev default). If something else on Windows already uses 8080, change it in the Unity panel and in `.mcp.json`. -- **`.mcp.json`** (committed) → `{"unity": {"type":"http","url":"http://172.27.208.1:8080/mcp"}}` +**✅ WORKING CONFIG (verified 2026-07-10, mcp-for-unity-server v3.4.4):** +- **Windows host IP as seen from WSL:** `172.27.208.1` (the WSL default gateway; confirm with `ip route show default`). Can change across WSL restarts — if MCP stops connecting, re-check it and update `.mcp.json`. +- **MCP server:** binds `127.0.0.1:8067` (set the port in the *MCP for Unity* window; HTTP transport). **Do NOT use 8080** — see gotcha below. +- **WSL bridge:** Windows `netsh portproxy` `0.0.0.0:8068 → 127.0.0.1:8067` (+ firewall allow on 8068). A **distinct** listen port (8068) is required — a proxy on `0.0.0.0:8067` would collide with the server's `127.0.0.1:8067` bind. +- **`.mcp.json`** (committed) → `{"unity": {"type":"http","url":"http://172.27.208.1:8068/mcp"}}` - **`.claude/settings.local.json`** (local) pre-enables the `unity` server. +- **Verify from WSL:** `curl -s -X POST http://172.27.208.1:8068/mcp -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"probe","version":"0"}}}'` → should return an `initialize` result naming `mcp-for-unity-server`. + +**⚠️ Gotcha — the port 8080 trap (why this took a few tries):** binding `8080` failed with Windows `[Errno 13] ... forbidden by its access permissions` (WSAEACCES). That's because **WSL2 runs on Hyper-V/WinNAT, which reserves large TCP port ranges**, and 8080 fell inside one. The server silently started then shut down; the "open 8080" was only the dead portproxy accepting + resetting. Fix = pick a port **outside** the reserved ranges (check `netsh interface ipv4 show excludedportrange protocol=tcp`) — we used `8067`. Bridge with a *different* proxy port (`8068`) to avoid the loopback/all-interfaces bind collision. + +**Bridge commands (admin PowerShell), for reference / re-setup:** +```powershell +netsh interface portproxy add v4tov4 listenaddress=0.0.0.0 listenport=8068 connectaddress=127.0.0.1 connectport=8067 +New-NetFirewallRule -DisplayName "Unity MCP 8068" -Direction Inbound -Action Allow -Protocol TCP -LocalPort 8068 +netsh interface portproxy show all +``` ## One-time setup (do on Windows, in the Unity Editor) diff --git a/memory.md b/memory.md index e3affc9..740ed2f 100644 --- a/memory.md +++ b/memory.md @@ -18,7 +18,7 @@ Durable memory for this project. Read at session start, update before session en - [ ] **Build Milestone 1** — networked shared bot, each player one tread (see `docs/prototype-plan.md`). The immediate work. - [x] **Project location decided** — unified on `F:\jankenstein` (git + Unity + docs together), symlinked from `~/claude/projects/jankenstein`. Unity `.gitignore`/`.gitattributes` in place. - [ ] **Create the Unity project** in `F:\jankenstein` (Unity LTS) and add the **NGO + Relay + Lobby** packages. -- [ ] **Stand up the Unity MCP** — config is seeded (`.mcp.json`, `docs/mcp-setup.md`); remaining host-side steps: install the CoplayDev package, Start it in HTTP mode, open the WSL bridge (0.0.0.0 bind or portproxy on :8080), then verify `mcp__unity__*` tools connect from WSL. +- [x] **Unity MCP working** — CoplayDev server on `127.0.0.1:8067`, portproxy `8068→8067`, `.mcp.json` → `172.27.208.1:8068/mcp`; handshake verified. (Load the `unity` tools by starting Claude *from the project folder*.) - [ ] **Netcode architecture (deferred, the real risk)** — dedicated server-authoritative state sync (Robocraft 2 blueprint) vs Photon Quantum lockstep (Stumble Guys precedent). Decide *after* the fun is proven + the 25-player physics spike. Netcode target ≈ 25–30 primary rigid bodies + gremlins/debris. - [ ] **The 25-player physics/netcode spike** — two ~30-joint bots colliding at arena scale, ≥100 ms latency, min-spec. The make-or-break gate before scaling up. - [ ] Remaining **design** questions (detail in `DESIGN.md`): build-coupling tightness, hidden per-player agenda, at-scale voting, part taxonomy, scavenge-contest rules, art style, progression (cosmetic-only), final name (working title JANKENSTEIN; alts BODGEBOTS / SCRAPYARD SCRUM / CLANKERS / RUSTBUCKETS / JALOPY WARS). @@ -29,7 +29,7 @@ Durable memory for this project. Read at session start, update before session en - **Promoted from `ideas/jankenstein` to a real project.** Scaffolded the WSL-side project home (this repo): filled `CLAUDE.md`, seeded this `memory.md` from the idea's `plan.md`, carried the full design record over as `DESIGN.md`, added `docs/prototype-plan.md`. Idea folder archived to `archive/ideas/jankenstein`. - Decided to build a **basic networked prototype first** (user wants to test the coordination feel with real friends — local split-screen won't capture the social/voice-chat core). Stack: **Unity NGO + Relay**, host-authoritative, throwaway netcode. Milestone 1 = one shared bot, each player one tread. - **Consolidated the project + seeded Unity MCP config** (`.mcp.json` → `unity` HTTP server at `172.27.208.1:8080/mcp`, `.claude/settings.local.json`, `docs/mcp-setup.md` runbook), Unity `.gitignore`/`.gitattributes` (no LFS yet). -- **Renamed JANKENSTEIN → JANKENBOTS and unified folders.** User created the Unity project at `F:\jankenbots\jankenbots` (named it jankenbots). Moved the seeded repo (git history + docs + `.mcp.json`) **into** the Unity project root so it's one folder; renamed the Forgejo repo `jankenstein → jankenbots` + updated the remote; re-pointed the symlink to `~/claude/projects/jankenbots`. Unity project is a fresh URP/Input-System template (has `Assets/`, `SampleScene`, `InputSystem_Actions`). **MCP status:** bridge is up (host `:8080` reachable from WSL) but the MCP HTTP server behind it isn't answering an `initialize` yet — user to confirm it's Started in HTTP mode on 8080 in the *MCP for Unity* window; then start a fresh Claude session from the project folder to load the `unity` tools. **Next:** verify MCP, then build Milestone 1. +- **Renamed JANKENSTEIN → JANKENBOTS and unified folders.** User created the Unity project at `F:\jankenbots\jankenbots` (named it jankenbots). Moved the seeded repo (git history + docs + `.mcp.json`) **into** the Unity project root so it's one folder; renamed the Forgejo repo `jankenstein → jankenbots` + updated the remote; re-pointed the symlink to `~/claude/projects/jankenbots`. Unity project is a fresh URP/Input-System template (has `Assets/`, `SampleScene`, `InputSystem_Actions`). **MCP status: ✅ WORKING (verified 2026-07-10, mcp-for-unity-server v3.4.4).** Server binds `127.0.0.1:8067` (HTTP mode), bridged to WSL via `netsh portproxy 0.0.0.0:8068→127.0.0.1:8067`; Claude reaches `http://172.27.208.1:8068/mcp` (`.mcp.json`). **Key gotcha:** 8080 is unusable — it's in a Hyper-V/WinNAT reserved range (WSL2), bind fails with WSAEACCES/Errno 13; use a non-reserved port + a *distinct* proxy port. Full detail in `docs/mcp-setup.md`. **Next:** start a fresh Claude session from the project folder (loads the `unity` tools at session start), then build Milestone 1. ## External references