agentleFS
CoderGamesterCoderGamester/mcp-unity/AGENTS.md

mcp-unity

AGENTS.md1.9k starsChanged 3 months agoMITView on GitHub

Node resolves bridge configuration in this order: - explicit environment values: UNITY_PORT, UNITY_HOST, UNITY_REQUEST_TIMEOUT; - MCP_UNITY_SETTINGS_PATH when set; - ProjectSettings/McpUnitySettings.json discovered above the installed Node module, then above the current working directory. Node resolves authentication s

Trending

Quiet since June.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 1 mentionApr 2026: 0 mentionsMay 2026: 0 mentionsJun 2026: 2 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the CoderGamester/mcp-unity repository that our weekly crawl found: only 6 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about CoderGamester/mcp-unity

The biggest 5 of 6 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 6

Talked about on GitHub and Bluesky (6 times).

On GitHub · 5

On Bluesky · 1

  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.

    Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repository2 other files it gives its agents.

The file

We split this AGENTS.md into the rules it gives an agent

10 rules. About 0 are common, 2 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Ensure the server is running (auto-start is controlled by McpUnitySettings.AutoStartServer).

    line 39
  2. Distinctive:

    If no valid setting is found, Node falls back to:

    line 73
  3. Very specific:

    If Unity is on another machine, set AllowRemoteConnections=true in Unity and set UNITY_HOST=<unity_machine_ip_or_hostname> for the Node …

    line 79
  4. Very specific:

    Add Editor/Tools/<YourTool>Tool.cs inheriting McpToolBase.

    line 89
  5. Very specific:

    Use a zod schema for params.

    line 99
  6. Very specific:

    Add Server~/src/resources/<yourResource>.ts, register in Server~/src/index.ts.

    line 113
  7. Very specific:

    Schema compatibility across clients: avoid reusing the same nested Zod object instance for multiple sibling fields (for example position, …

    line 133
  8. Distinctive:

    Update this file when:

    line 189
  9. Very specific:

    Keep it high-signal: where to edit code, how to run/build/debug, and the invariants that prevent subtle breakage.

    line 193
  10. Very specific:

    If project skills are added, keep their content only in .agents/skills/<skill>/ and expose each to Claude Code through a relative …

    line 195

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

MCP Unity — AI Agent Guide (MCP Package)

Purpose (what this repo is)

MCP Unity exposes Unity Editor capabilities to MCP-enabled clients by running:

  • Unity-side “client” (C# Editor scripts): a WebSocket server inside the Unity Editor that executes tools/resources.
  • Node-side “server” (TypeScript): an MCP stdio server that registers MCP tools/resources and forwards requests to Unity over WebSocket.

How it works (high-level data flow)

  • MCP client ⇄ (stdio / MCP SDK) ⇄ Node server (Server~/src/index.ts)
  • Node server ⇄ (WebSocket JSON-RPC-ish) ⇄ Unity Editor (Editor/UnityBridge/McpUnityServer.cs + McpUnitySocketHandler.cs)
  • Tool/Resource names must match exactly across Node and Unity (typically lower_snake_case).

Key defaults & invariants

  • Unity WebSocket endpoint: ws://localhost:8090/McpUnity by default.
  • Config file: ProjectSettings/McpUnitySettings.json (written/read by Unity; read opportunistically by Node).
  • Authentication token: Library/McpUnity/bridge-token (256-bit hex secret; never commit or copy into project settings).
  • Handshake security: clients authenticate as mcp-unity:<token> with HTTP Basic and must omit Origin; every supplied Origin is rejected.
  • Execution thread: Tool/resource execution is dispatched via EditorCoroutineUtility and runs on the Unity main thread. Keep synchronous work short; use async patterns for long work.

Repo layout (where to change what)

/
├── Editor/                       # Unity Editor package code (C#)
│   ├── Tools/                    # Tools (inherit McpToolBase)
│   ├── Resources/                # Resources (inherit McpResourceBase)
│   ├── UnityBridge/              # WebSocket server + message routing
│   ├── Services/                 # Test/log services used by tools/resources
│   └── Utils/                    # Shared helpers (config, logging, workspace integration)
├── Server~/                      # Node MCP server (TypeScript, ESM)
│   ├── src/index.ts              # Registers tools/resources/prompts with MCP SDK
│   ├── src/tools/                # MCP tool definitions (zod schema + handler)
│   ├── src/resources/            # MCP resource definitions
│   └── src/unity/mcpUnity.ts      # WebSocket client that talks to Unity

Quickstart (local dev)

  • Unity side
    • Open the Unity project that has this package installed.
    • Ensure the server is running (auto-start is controlled by McpUnitySettings.AutoStartServer).
    • Settings persist in ProjectSettings/McpUnitySettings.json.
  • Node side (build)
    • cd Server~ && npm run build
    • The MCP entrypoint is Server~/build/index.js (published as an MCP stdio server).
  • Node side (debug/inspect)
    • cd Server~ && npm run inspector to use the MCP Inspector.

Configuration (Unity ↔ Node bridge)

The Unity settings file is the shared contract:

  • Path: ProjectSettings/McpUnitySettings.json
  • Fields
    • Port (default 8090): Unity WebSocket server port.
    • RequestTimeoutSeconds (default 10): Node request timeout.
    • AllowBatchModeServer (default false): permits a persistent MCP host in Unity -batchmode; package installation remains disabled in batch mode.
    • AllowRemoteConnections (default false): Unity binds to 0.0.0.0 when enabled; otherwise localhost.
    • AllowPackageInstallation (default false): permits add_package; keep disabled unless both client and package source are trusted.
    • EnableInfoLogs: Unity console logging verbosity.
    • NpmExecutablePath: optional npm path for Unity-driven install/build.

Node resolves bridge configuration in this order:

  • explicit environment values: UNITY_PORT, UNITY_HOST, UNITY_REQUEST_TIMEOUT;
  • MCP_UNITY_SETTINGS_PATH when set;
  • ProjectSettings/McpUnitySettings.json discovered above the installed Node module, then above the current working directory.

Node resolves authentication separately and fails closed in this order:

  • MCP_UNITY_AUTH_TOKEN;
  • the file named by MCP_UNITY_AUTH_TOKEN_PATH;
  • Library/McpUnity/bridge-token beside the discovered Unity project.

An explicitly configured missing, empty, or malformed token never falls back. Generated client configs set both MCP_UNITY_SETTINGS_PATH and MCP_UNITY_AUTH_TOKEN_PATH.

If no valid setting is found, Node falls back to:

  • host: localhost
  • port: 8090
  • timeout: 10s

Remote connection note:

  • If Unity is on another machine, set AllowRemoteConnections=true in Unity and set UNITY_HOST=<unity_machine_ip_or_hostname> for the Node process.
  • Remote transport is plaintext ws://; restrict it to a trusted network, VPN, or SSH tunnel. Use MCP_UNITY_AUTH_TOKEN when the remote bridge cannot read the project token file.

Persistent headless host note:

  • Batch mode is disabled by default. Enable AllowBatchModeServer or launch Unity with MCP_UNITY_ALLOW_BATCH_MODE=true for a long-lived headless MCP host; npm installation/build remains skipped in batch mode.

Adding a new capability

Add a tool

  1. Unity (C#)
    • Add Editor/Tools/<YourTool>Tool.cs inheriting McpToolBase.
    • Set Name to the MCP tool name (recommended: lower_snake_case).
    • Implement:
      • Execute(JObject parameters) for synchronous work, or
      • set IsAsync = true and implement ExecuteAsync(JObject parameters, TaskCompletionSource<JObject> tcs) for long-running operations.
    • Register it in Editor/UnityBridge/McpUnityServer.cs (RegisterTools()).
  2. Node (TypeScript)
    • Add Server~/src/tools/<yourTool>Tool.ts.
    • Register the tool in Server~/src/index.ts.
    • Use a zod schema for params; forward to Unity using the same method string:
      • mcpUnity.sendRequest({ method: toolName, params: {...} })
  3. Build
    • cd Server~ && npm run build

Add a resource

  1. Unity (C#)
    • Add Editor/Resources/<YourResource>Resource.cs inheriting McpResourceBase.
    • Set Name (method string) and Uri (e.g. unity://...).
    • Implement Fetch(...) or FetchAsync(...).
    • Register in Editor/UnityBridge/McpUnityServer.cs (RegisterResources()).
  2. Node (TypeScript)
    • Add Server~/src/resources/<yourResource>.ts, register in Server~/src/index.ts.
    • Forward to Unity via mcpUnity.sendRequest({ method: resourceName, params: {} }).

Logging & debugging

  • Unity
    • Uses McpUnity.Utils.McpLogger (info logs gated by EnableInfoLogs).
    • Connection lifecycle is managed in Editor/UnityBridge/McpUnityServer.cs (domain reload & playmode transitions stop/restart the server).
  • Node
    • Logging is controlled by env vars:
      • LOGGING=true enables console logging.
      • LOGGING_FILE=true writes log.txt in the Node process working directory.

Common pitfalls

  • Port mismatch: Unity default is 8090; update docs/config if you change it.
  • Name mismatch: Node toolName/resourceName must equal Unity Name exactly, or Unity responds unknown_method.
  • Long main-thread work: synchronous Execute() blocks the Unity editor; use async patterns for heavy operations.
  • Remote connections: Unity must bind 0.0.0.0 (AllowRemoteConnections=true) and Node must target the correct host (UNITY_HOST).
  • Unity domain reload: the server stops during script reloads and may restart; avoid relying on persistent in-memory state across reloads.
  • Multiplayer Play Mode: Clone instances automatically skip server startup; only the main editor hosts the MCP server.
  • Schema compatibility across clients: avoid reusing the same nested Zod object instance for multiple sibling fields (for example position, rotation, scale). Some MCP clients fail on local refs like #/properties/position; prefer creating a fresh nested schema per field.

Release/version bump checklist

  • Update versions consistently:
    • Unity package package.json (version)
    • Node server Server~/package.json (version)
    • Node lockfile, MCP protocol metadata, dashboard metadata, and McpUnitySettings.ServerVersion
  • Rebuild Node output: cd Server~ && npm run build

Available tools (current)

  • execute_menu_item — Execute Unity menu items
  • select_gameobject — Select GameObjects in hierarchy
  • update_gameobject — Update or create GameObject properties
  • update_component — Update or add components on GameObjects
  • add_package — Install packages via Package Manager (disabled by default; requires AllowPackageInstallation=true)
  • run_tests — Run Unity Test Runner tests
  • send_console_log — Send logs to Unity console
  • add_asset_to_scene — Add assets to scene
  • create_prefab — Create prefabs with optional scripts
  • create_scene — Create and save new scenes
  • load_scene — Load scenes (single or additive)
  • delete_scene — Delete scenes and remove from Build Settings
  • save_scene — Save current scene (with optional Save As)
  • get_scene_info — Get active scene info and loaded scenes list
  • get_play_mode_status — Get Unity play mode status (isPlaying, isPaused)
  • set_play_mode_status — Control Unity play mode (play, pause, stop, step)
  • unload_scene — Unload scene from hierarchy
  • get_gameobject — Get detailed GameObject info
  • get_console_logs — Retrieve Unity console logs
  • recompile_scripts — Recompile all project scripts
  • duplicate_gameobject — Duplicate GameObjects with optional rename/reparent
  • delete_gameobject — Delete GameObjects from scene
  • reparent_gameobject — Change GameObject parent in hierarchy
  • create_material — Create materials with specified shader
  • assign_material — Assign materials to Renderer components
  • modify_material — Modify material properties (colors, floats, textures)
  • get_material_info — Get material details including all properties

Available apps (current)

  • show_unity_dashboard — Open the Unity dashboard MCP App in VS Code

Available resources (current)

  • unity://menu-items — List of available menu items
  • unity://scenes-hierarchy — Current scene hierarchy
  • unity://gameobject/{id} — GameObject details by ID or path
  • unity://logs — Unity console logs
  • unity://packages — Installed and available packages
  • unity://assets — Asset database information
  • unity://tests/{testMode} — Test Runner test information
  • ui://unity-dashboard — Unity dashboard MCP App UI

Available prompts (current)

  • unity_dashboard — Opens Unity dashboard MCP app with guided information about features
  • gameobject_handling_strategy — Provides structured workflow for GameObject operations

Update policy (for agents)

  • Update this file when:
    • tools/resources/prompts are added/removed/renamed,
    • config shape or default ports/paths change,
    • the bridge protocol changes (request/response contract).
  • Keep it high-signal: where to edit code, how to run/build/debug, and the invariants that prevent subtle breakage.
  • AGENTS.md is the single source of project guidance. Its sibling CLAUDE.md must contain the exact bytes @AGENTS.md\n; never duplicate these rules there.
  • If project skills are added, keep their content only in .agents/skills/<skill>/ and expose each to Claude Code through a relative .claude/skills/<skill> symlink targeting ../../.agents/skills/<skill>. Never use copied content or absolute links, so clones and worktrees remain self-contained.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.