Version: 1.4.2
Nexus Unity is a Unity Editor automation package with two public interfaces:
- A local HTTP JSON-RPC server running inside the Unity Editor.
- A Python MCP bridge that exposes consolidated
unity_tools for AI clients.
MCPServerowns server lifecycle, loopback networking, session recovery, request limits, log capture, and main-thread dispatch.MCPServerMethodsowns raw JSON-RPC dispatch. Raw method names are unprefixed and discoverable throughlist_tools.nexus_unity_bridge.pyis the MCP entry point. It importsnexus_bridge/, exposes the consolidated MCP schema, and routes MCP tool calls to raw Unity JSON-RPC methods.- Unity API calls execute on the Unity main thread unless they are explicit health or idle checks that can safely run on the listener thread.
Open Window > Nexus Unity and click Start Server. The default port is 8081 and can be changed in Edit > Project Settings > Nexus Unity.
The server:
- Binds to loopback use only.
- Restarts after Unity domain reloads when the previous session was running.
- Tracks session id, session generation, last heartbeat, play mode, compile/import state, and last error.
- Provides
get_server_status,ping_main_thread,wait_for_asset_import_idle,wait_for_editor_idle,get_test_results,get_tool_usage_stats, andreset_tool_usage_statsfor robust automation loops.
Nexus Unity exposes one Unity menu entry: Window > Nexus Unity.
Server: local server lifecycle, URL copy, server health, and bridge deployment status.Integrations: MCP setup cards for Codex, Claude Desktop, Claude Code, Gemini, Antigravity, Cursor, VS Code/Cline/Roo, Windsurf, and generic JSON clients.Resources: documentation, API reference, changelog, package folder access, and collapsed maintainer diagnostics.Settings: Nexus Unity editor preferences, including Console logging verbosity.
The main control panel is a compact UI Toolkit window with Server, Integrations, Resources, and Settings tabs. Test-only actions are hidden by default under Resources > Advanced / Diagnostics, while user-facing setup actions remain visible. Server and bridge blocks remain stacked vertically; their internal action rows stretch and wrap responsively, and integration cards expose status, auto setup, copyable config, and config-location actions where supported.
Console logging defaults to Important, which keeps the Unity Console focused on server lifecycle, setup results, warnings, and errors. All shows verbose Nexus Unity diagnostics, and Custom shows info logs only for selected categories: Server, Integrations, API, UI Automation, Diagnostics, Audit, and Runtime. These settings affect Nexus Unity service messages only; user project logs and Unity errors are not suppressed.
The Integrations tab builds all snippets from the resolved Python interpreter and the project-root bridge path nexus_unity_bridge.py. Auto setup deploys the bridge first. JSON-style clients use mcpServers.nexus-unity, VS Code-compatible clients use .vscode/mcp.json with servers.nexus-unity, Claude Code uses a project-root .mcp.json with mcpServers.nexus-unity, and Codex uses [mcp_servers.nexus-unity] in TOML.
Claude Code and Claude Desktop are distinct products with distinct config locations. The Claude Code card registers nexus-unity in <projectRoot>/.mcp.json (via the claude CLI when it is on PATH, otherwise by writing the file directly); the Claude Desktop card writes the desktop app config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS, %APPDATA%\Claude\claude_desktop_config.json on Windows). Claude Code does not read the desktop config.
- The Python interpreter is resolved in the order
python3, thenpython, then the Windowspylauncher. On Windows, wherepython3is frequently absent fromPATH, the generated config falls back to a discoveredpython.exeorpy. Ensure a Python 3 interpreter is installed and onPATH. - CLI-managed clients (Codex, Gemini, Antigravity, and the Claude Code CLI path) are discovered with
whichon macOS/Linux andwhereon Windows. The matching CLI must be on thePATHof the environment that launched the Unity Editor forAuto Setupto detect it; otherwise useCopy Configor the file-based card.
Integration status checks compare the package bridge with the project-root deployed bridge and the client config path. A card reports Outdated when the config points at another Unity project, the deployed bridge is missing, or the deployed bridge version differs from the package bridge version. Running Auto Setup redeploys nexus_unity_bridge.py plus nexus_bridge/, rewrites the client entry, and requires restarting the external MCP client session.
When Nexus Unity writes an existing user or project config, it preserves unrelated server entries and creates a timestamped backup next to the original file.
Nexus Unity is a local developer tool and should be used only with trusted local clients.
- HTTP and WebSocket requests must target loopback hosts.
- Browser origins are validated to reduce CSRF and DNS rebinding exposure; non-loopback origins are rejected.
- File operations resolve paths and enforce the Unity project root boundary.
- Request payload size is capped to reduce memory exhaustion risk.
- Raw write operations are intentionally powerful; prefer
unity_write_and_compilethrough the MCP bridge for code edits.
Package path:
python3 Packages/com.forkhorizon.nexus.unity/Editor/nexus_unity_bridge.pyManual or root-deployed path:
python3 nexus_unity_bridge.pyBridge connection settings can be overridden with NEXUS_UNITY_URL, NEXUS_UNITY_PORT, and NEXUS_UNITY_TIMEOUT_SECONDS. A positional port argument is still supported for existing MCP client configs, and invalid port values fall back to the positional port or default port. Bridge logging defaults to DEBUG and can be changed with NEXUS_UNITY_LOG_LEVEL.
Direct CLI mode is available for diagnostics and scripts:
python3 nexus_unity_bridge.py scene_manager action=list
python3 nexus_unity_bridge.py hierarchy_manager action=create_primitive primitive_type=Cube position='[0,1,0]'CLI arguments must use key=value; JSON-looking values are parsed before routing the call.
The bridge is modular:
nexus_unity_bridge.py: MCP loop and CLI entry point.nexus_bridge/_logging.py: shared bridge logger.nexus_bridge/_transport.py: Unity JSON-RPC URL, port, timeout, and HTTP transport helpers.nexus_bridge/client.py: HTTP JSON-RPC client.nexus_bridge/routing.py: manager routing and macro behavior.nexus_bridge/schemas.py: public MCP tool schemas and static read-only MCP resources.
When deploying from the Unity UI, Nexus Unity copies both nexus_unity_bridge.py and the full nexus_bridge/ package to the project root so the bridge can run from a stable path.
Raw HTTP JSON-RPC:
- Use unprefixed method names, for example
get_server_status,list_tools,read_logs, andwrite_file. - Intended for diagnostics, custom integrations, and direct automation.
- The complete raw catalog is returned by
list_tools. - Runtime schemas intentionally include compatibility fields where needed; for example
update_componentaccepts bothpropertiesand the legacyjson_datapayload,create_sceneacceptspath/open_if_exists,create_primitiveaccepts transform/material fields, andcreate_materialaccepts an optional explicit assetpathplus visible color fields. - Agent diagnostics include
get_test_resultsfor UnityTestResults*.xmlsummaries,get_tool_usage_stats/reset_tool_usage_statsfor scoped in-memory call counters and timing, andui_get_window_rect/ui_set_window_rect/ui_capture_window_snapshotfor resize-based editor UI QA.
MCP bridge:
- Uses
unity_prefixed manager tools, for exampleunity_scene_manager,unity_asset_manager, andunity_write_and_compile. - Intended for AI clients and day-to-day automation.
- Reduces schema size while preserving access to the supported raw capabilities.
- Manager tools accept common raw-action aliases where agents naturally try them, for example
unity_scene_manager action=list_scenesandunity_hierarchy_manager action=create_gameobject. - Invalid manager actions include the valid action names in the error message.
unity_hierarchy_managercan create primitives with name, parent, transform, and material path; it can also rename, set transforms, and pass throughcreate_hierarchy.unity_editor_controllerincludesrun_tests_wait, which waits in the Python bridge by polling rawget_test_resultsinstead of blocking the Unity main thread.unity_editor_controlleralso exposesget_tool_usage_statsandreset_tool_usage_statsso diagnostics are not split between raw and manager workflows.unity_ui_automationpasses throughdeepfor UI hierarchy reads,class_namefor queries, and window rect/snapshot actions for layout checks.
The current development line preserves backward compatibility while correcting public contracts found during API stress validation:
unity_write_and_compileis the supported public MCP macro for write, wait, and compiler-feedback workflows. Any old documentation wording that saysunity_apply_code_changeshould be treated as stale.update_componentshould use apropertiesobject for new callers;json_dataremains accepted for existing callers.create_sceneaccepts optionalpathandopen_if_existsfor deterministic scene assets.create_primitiveaccepts optionalname,parent_id,position,rotation,scale, andmaterial_path.set_transformacceptsposition,rotation/eulerAngles, andscale/localScale.create_materialaccepts an optional explicitpathplusbase_color/colorandemission_color, so automation can isolate generated materials in a known project folder and make them visibly distinct.write_fileandwrite_files_batchcreate missing parent directories after path validation.invoke_method.argumentsis documented and exposed as a JSON array schema.click_object_in_gameaccepts eitherinstance_idor hierarchypath.- Unity 6.x compatibility is maintained across editor object identity API changes. External JSON payloads continue to use integer-shaped
instance_idvalues, while Nexus maps them toEntityIdinternally and falls back to Unity 6.3-compatible hierarchy event and object-reference instance ID APIs when Unity 6.4+ members are unavailable. get_test_results, scoped tool usage stats, and editor-window rect/snapshot automation are public raw diagnostics for agent-driven development.
Use unity_write_and_compile for code edits. It writes one or more files, waits for Unity reload/import work, and returns compiler errors from the Unity Console. Use unity_wait when a workflow needs to block until compilation, import, play mode, or editor idle state is reached.
For scene work, prefer manager tools:
unity_scene_managerunity_hierarchy_managerunity_component_managerunity_search_managerunity_asset_managerunity_editor_controllerunity_ui_automation
Nexus Unity uses GitHub Actions as the contributor enforcement gate. The Validate package workflow runs on a maintainer-owned self-hosted Mac runner, not GitHub-hosted runners. It runs the PR target policy, Static validation, Python unit tests, Documentation quality AI, and Unity package smoke jobs on trusted pushes and pull requests.
Contributor pull requests target development. The main branch is release-only and should receive changes only when maintainers prepare or publish a release.
Direct pushes to main and development are blocked for everyone, including maintainers. Trusted maintainers merge pull requests through GitHub; release changes reach main only through a release pull request from development or release/*. External fork pull requests currently emit a PR target policy warning and continue through the same CI pipeline; maintainers should review forked code carefully before merge. When an internal rerun is needed, the manual Approve external PR for CI workflow can copy a reviewed fork PR to a trusted trusted/pr-N branch and trigger validation there.
Commit authors should use an email address verified on their GitHub account, preferably the GitHub no-reply address shown in account email settings. GitHub contributor statistics depend on account-linked commit identities, so commits made with placeholder or unverified emails may not be attributed even when the pull request is merged. The repository .mailmap records known historical identity mappings for local Git reporting; future commits should still be made with the correct verified email.
The local runner must have self-hosted, macOS, ARM64, and nexus-unity-ci labels. The AI documentation job additionally requires nexus-doc-ai. The runner environment must provide python3, dotnet, Unity 6000.4.3f1 at /Applications/Unity/Hub/Editor/6000.4.3f1/Unity.app/Contents/MacOS/Unity, and Ollama on http://127.0.0.1:11434. Workflow-level concurrency uses group nexus-unity-ci with queue: max, so trusted CI runs are processed one at a time and up to 100 pending runs can wait instead of being canceled.
For local feedback, contributors can run bash scripts/install-git-hooks.sh once per checkout. This configures Git to use the tracked .githooks/pre-push hook, which runs scripts/prepush-validate.sh --quick before push. The quick hook always performs package metadata validation, Python bridge compilation, Unity .meta pairing checks, Python bridge unit tests, NexusQualityGate tests, and the deterministic Roslyn quality gate. It uses NEXUS_UNITY_HOOK_LIVE=auto by default: reachable Unity servers run the read-only live smoke check, while temporary server timeouts print NOTICE and do not block the push. Use NEXUS_UNITY_HOOK_LIVE=required when a live server must be enforced, or NEXUS_UNITY_HOOK_LIVE=off for static-only local feedback.
NexusQualityGate lives under tools~/ so Unity ignores the .NET/Roslyn source while GitHub Actions and local scripts can build it. The deterministic gate scans production C# source under Editor/ and Runtime/, fails public/protected types and methods without meaningful XML documentation, fails files over 450 lines, and fails methods over 150 lines. It warns for files over 300 lines and methods over 50 lines.
The required AI quality review runs on the same maintainer-owned runner and requires the additional nexus-doc-ai label. The workflow defaults to the local qwen3-coder:30b-a3b-q4_K_M model. The AI rubric is pragmatic: it fails misleading, filler, or materially incomplete docs, but it does not require every private helper, minor edge case, or implementation detail.
The same job also runs NexusQualityGate --checklist-ai required. That mode reads .github/pull_request_template.md, reviews every checkbox item as an independent local-Ollama prompt, and emits a separate NQG310 annotation with a next action when the repository evidence, CI wiring, docs, or tracked-file inventory clearly contradicts the checklist item. It is intentionally evidence-based: runtime results such as Unity package compilation can be supplied by separate CI jobs, while clear safety issues like tracked generated caches, missing public-doc updates, or unsafe local-only changes are blocked by the checklist AI review.
The reviewer sends NEXUS_DOC_AI_KEEP_ALIVE to Ollama on each request, defaults it to 30s, and unloads the model at the end of the review. The workflow also has an always() cleanup step that unloads the same model even when validation fails. For pull requests, the job executes the quality tool from the trusted base branch and treats the pull request checkout as input data. While bootstrapping quality-gate changes, it falls back to the candidate tool when the trusted base branch does not contain NexusQualityGate yet or has not learned the --checklist-ai option.
The Unity smoke job creates a temporary project under $RUNNER_TEMP, installs the candidate package through file:$GITHUB_WORKSPACE, imports it with the local Unity editor, scans the Unity log for C# compiler errors and orphan/immutable .meta warnings, and verifies that required package dependencies resolved in packages-lock.json without Unity Project Auditor packages.
Full local integration validation is explicit:
bash scripts/prepush-validate.sh --integrationIntegration validation requires the Unity project to be open and the Nexus Unity server to be running on http://127.0.0.1:8081/.
For a focused agent tooling check, run python3 scripts/agent-tooling-smoke.py. It exercises server status, raw catalog discovery, scoped usage stats, Nexus Unity window UI automation, snapshot capture, and bridge-side run_tests_wait without writing repo-tracked files.
Before release, maintainers should run a public API stress audit that compares raw list_tools output with the MCP bridge catalog, exercises read-only and mutating tool groups in a disposable namespace, and verifies cleanup of generated assets and PlayerPrefs keys.
- Server does not start: change the port in project settings and restart the server window.
- MCP client cannot import
nexus_bridge: redeploy the bridge fromWindow > Nexus Unity > Server, or point the client directly at the package path. - Tool returns
Method not found: compare the raw Unity catalog fromlist_toolswith the MCP catalog inAPI_REFERENCE.MD. - File write denied: ensure the target path resolves inside the Unity project root.
- Compile loop times out: call
get_server_status,read_logs, andunity_waitwitheditor_idle. - Auto Setup reports success but the client does not connect: confirm you used the card for the client you actually run (Claude Code reads
.mcp.json, not the Claude Desktop config), then reload the client (/mcpin Claude Code) after starting the Nexus server. - Bridge fails to launch on Windows: verify a Python 3 interpreter is on
PATH(python --versionorpy --version); the generated config usespython3,python, orpyin that order. - Gemini/Antigravity card shows
Not foundor disabled Auto Setup: the CLI is not on the Editor'sPATH. Install it and ensurewhere <cli>(Windows) orwhich <cli>(macOS/Linux) resolves, or useCopy Config.
- Public repo:
https://github.com/ForkHorizon/NexusUnity.git. - Package id:
com.forkhorizon.nexus.unity. - Public release version:
1.4.2. - License:
GPL-3.0-only. - Required release docs:
SECURITY.md,CONTRIBUTING.md, andRELEASE.md. - Repository funding metadata lives in
.github/FUNDING.ymland configures the GitHub Sponsor button forDaliys. - Do not ship generated caches, local agent folders,
.jules/,.DS_Store, Python bytecode, or native bridge binaries without corresponding source and build instructions. - Keep contributor tooling and package-internal tests under Unity-ignored folders such as
tools~/andTests~/without.metafiles; Unity will not import those folders, and root~.metaentries break immutable PackageCache installs. - Do not declare Unity Project Auditor packages as Nexus dependencies. Nexus audit support uses reflection when a host project explicitly installs compatible Project Auditor rules; direct dependencies can add duplicate immutable
.metaGUID warnings or no-module Console spam during clean installs.
Nexus Unity follows semantic versioning for public releases, but the development branch should not bump the package version for every merged fix. Keep package.json and visible docs at the latest shipped public version until a release is being prepared.
Unity Package Manager requires MAJOR.MINOR.PATCH values in package.json, and GitHub release tags and titles use the same semantic version. Use forms like 1.4.2 for the package version, v1.4.2 for tags, and 1.4.2 for release titles.
During normal development:
- Add all user-visible API, behavior, docs, and validation changes to
[Unreleased]inCHANGELOG.md. - Do not change
package.jsonfrom1.4.2unless the change is part of a release-preparation commit. - Prefer compatibility fixes over breaking changes; if a breaking change is unavoidable, document the migration path before release.
During release preparation:
- Choose the next semantic version based on accumulated changes.
- Move
[Unreleased]entries into the new dated release section. - Update
package.json, README badges/install examples,DOCUMENTATION.MD, andAPI_REFERENCE.MD. - Tag the release with the matching semantic GitHub version, for example
v1.4.2for package version1.4.2.