Introduction
Having an AI write C# and then reviewing the Git diff before returning to Unity is no longer unusual.
Unity work, however, rarely ends with a source-code change. A task may also require editing the Hierarchy, configuring Components, saving a Prefab, switching or saving a Scene, waiting for compilation, and checking the Console after a Domain Reload. An AI that can only inspect repository files cannot directly observe all of that Editor state.
Unity's official Unity MCP Server is intended to close that gap. It allows an external MCP client to connect to the Unity Editor and work with capabilities related to Scenes, GameObjects, Assets, scripts, and the Console.
This article explains how to start using the official Unity MCP Server from Codex without immediately giving the model broad write access. It focuses on connection setup, permission boundaries, failure recovery, and a repeatable evaluation method built around three tasks:
- Read the Unity Console and apply a minimal compile-error fix.
- Create, edit, and save a disposable sandbox Scene.
- Create a Prefab with a precisely defined structure.
The order is deliberate. Start with a mostly read-oriented Console workflow, continue with a disposable Scene, and only then create a persistent Prefab Asset. Each stage should proceed only after the previous stage proves that the target Editor, exposed tools, and verification loop are under control.
The goal is not to watch one successful demo and conclude that the integration is production-ready. A useful evaluation must distinguish first-attempt success, automatic recovery, human intervention, unintended changes, timeouts, and Editor hangs.
Important: This article does not contain measured success rates or elapsed-time results. It is an evaluation and safety-design guide based on official documentation checked on July 21, 2026. Paths, UI labels, and described behavior come from documentation rather than the author's own execution results. Decide whether the integration is suitable for production only after measuring it with fixed versions and a representative project.
What “Unity's Official MCP” Means Here
This article covers the Unity MCP Server included in the com.unity.ai.assistant package. It does not cover community MCP servers with similar names.
As of July 21, 2026, Unity's documentation describes Assistant 2.14.0-pre.1 and requires Unity 6 (6000.0) or later. Unity AI is in Open Beta, and the setup requires a project connected to Unity Cloud plus an active Trial or Subscription. Unity's official introductory blog states that using the MCP Server itself does not consume Unity AI credits.
Because this is Beta and pre-release software, pin the package version used for every evaluation.
The official Unity MCP overview describes this architecture:
Codex (MCP client)
│ MCP over stdio
Unity Relay (~/.unity/relay/)
│ local IPC
│ Windows: named pipe
│ macOS/Linux: Unix socket
Unity Editor (MCP Bridge)
├─ built-in tools
└─ custom tools
Codex starts the Relay process. The Relay then connects to the MCP Bridge running inside the Unity Editor.
In Assistant 2.14.0-pre.1, the following menu entries point in opposite directions:
-
AI > Assistant MCP Extensions: Unity Assistant consumes external MCP servers. -
AI > Unity MCP Server: Unity exposes Unity capabilities to an external client such as Codex.
That distinction is easy to miss.
The labels also vary between package versions. For example, Assistant 2.7.0-pre.3 documentation used names such as AI > MCP Client and AI > Unity MCP. When following older screenshots or blog posts, identify the direction of the connection instead of relying on an exact menu string.
There is another naming distinction worth preserving:
-
Unity_ManageSceneandUnity_ReadConsoleare examples of tool names exposed to the client. -
get_componentsis described in Unity's troubleshooting documentation as an operation name.
Do not assume an operation belongs to a particular tool without checking the schema discovered by Codex in the actual environment.
Freeze the Evaluation Environment
MCP behavior can change with the Unity version, Assistant package, Codex version, operating system, and project state. A success rate without that context is not useful.
Record at least the following:
| Item | Example |
|---|---|
| OS | Windows 11 24H2 |
| Unity | 6000.x.xf1 |
| Assistant package | 2.14.0-pre.1 |
| Codex | Exact CLI or IDE-extension version |
| Model | Exact model selected for the run |
| Project | New Unity 6 URP project |
| Git state | Reset to the same commit before every attempt |
| Open Unity Editors | One, or explicitly identify the target |
| Console state | Cleared before each run |
| MCP debug logs | Enabled |
Use a small evaluation repository or a disposable worktree, not a copy of an active production project.
Every attempt should begin from the same commit, Scene, Console state, and permission configuration. Keep the attempt number, prompt, tool calls, debug logs, and Git diff linked together.
Do not mix ordinary runs that reuse Library with runs that intentionally clear caches. Those are different conditions and should be reported separately.
Unity-Side Setup
The basic requirements are Unity 6 or later and the com.unity.ai.assistant package.
After opening the Editor:
- Open
Edit > Project Settings > AI > Unity MCP Server. - Confirm that
Unity BridgereportsRunning. - Enable
Show Debug Logs. - Check
Validation Level. - Enable only the tools required for the current task.
The official setup documentation for Assistant 2.14.0-pre.1 states that the Bridge normally starts when the Editor loads and that the Relay executable is placed under the user's .unity/relay directory. Treat that as documented behavior, then verify the Running state and actual Relay file in the target environment.
If the Bridge remains Stopped, inspect:
- Unity Console compile errors
- Package installation state
- Whether the Relay binary exists
- MCP debug logs
In Assistant 2.14.0-pre.1, Validation Level controls the validation strength of Unity_ManageScript and offers basic, standard, comprehensive, and strict. For code-editing evaluation, starting with strict is reasonable, while recording any speed difference.
This setting does not represent one universal validation level for every Scene and Prefab operation. Confirm its exact scope in the configuration reference for the package version being tested.
Register the Unity MCP Server in Codex
According to the Codex MCP documentation, Codex can register a stdio MCP server in ~/.codex/config.toml or in .codex/config.toml inside a trusted project.
For the first connection check, expose only Unity_ReadConsole:
[mcp_servers.unity]
command = "/absolute/path/to/unity-relay"
args = [
"--mcp",
"--project-path",
"/absolute/path/to/UnityMcpLab",
]
startup_timeout_sec = 20
tool_timeout_sec = 120
default_tools_approval_mode = "prompt"
enabled_tools = ["Unity_ReadConsole"]
The example above uses operating-system-neutral placeholders. Replace both paths with absolute paths from the evaluation machine.
On Windows, TOML literal strings make paths easier to read because backslashes do not need to be doubled:
command = 'C:\Users\name\.unity\relay\relay_win.exe'
args = ["--mcp", "--project-path", 'C:\work\UnityMcpLab']
The Assistant 2.14.0-pre.1 documentation provides the following Relay path examples. They are documentation examples, not observations from this article's author. Confirm them with Locate Server and the actual filesystem.
| OS | Documented example |
|---|---|
| macOS Apple Silicon | ~/.unity/relay/relay_mac_arm64.app/Contents/MacOS/relay_mac_arm64 |
| macOS Intel | ~/.unity/relay/relay_mac_x64.app/Contents/MacOS/relay_mac_x64 |
| Windows | %USERPROFILE%\.unity\relay\relay_win.exe |
| Linux | ~/.unity/relay/relay_linux |
Some clients do not expand ~, so use an absolute path for command.
The server can also be registered with the CLI:
codex mcp add unity -- \
/absolute/path/to/unity-relay \
--mcp \
--project-path /absolute/path/to/UnityMcpLab
Important: This CLI command registers the MCP server only. It does not establish the read-only tool allowlist shown above. After running it, open the resulting
config.toml—normally~/.codex/config.toml—and explicitly add or verifyenabled_tools = ["Unity_ReadConsole"]anddefault_tools_approval_mode = "prompt"before starting the evaluation.
After registration, use codex mcp list and /mcp in the interactive session to inspect the connection and the tools actually exposed to Codex.
A useful permission progression is:
| Stage | Tools exposed to Codex | Purpose |
|---|---|---|
| Connection check |
Unity_ReadConsole only |
Verify target Editor, approval, Relay, and Console access |
| Script fix | Console read plus the script-editing tool found in the environment | Apply one minimal code change |
| Scene edit | Scene and GameObject tools found in the environment | Edit only a sandbox Scene |
| Prefab creation | GameObject/Component tools plus Asset/Prefab saving tools found in the environment | Save one Prefab under an approved folder |
The labels “script-editing tool,” “Scene/GameObject tool,” and “Asset/Prefab-saving tool” are conceptual descriptions. They are not guaranteed official tool names. Use the Unity Tools list and the schemas discovered through /mcp, then copy only the exact names shown in that environment into enabled_tools.
Do not guess a Prefab-saving tool name from an article. If the built-in tools cannot satisfy the requirement, record the task as unsupported with built-ins and evaluate a Custom Tool separately.
Always Select the Target When Multiple Editors Are Open
According to the Assistant 2.14.0-pre.1 setup guide, the Relay may connect to the first Unity Editor it discovers when no target is specified.
That is dangerous for developers who keep multiple projects, samples, or test Editors open at the same time.
Select the target with one of these approaches:
-
--project-path <path>orUNITY_PROJECT_PATH -
--instance-id <pid>orUNITY_INSTANCE_ID
Prefer --project-path for a persistent configuration. A process ID changes whenever the Editor restarts, so it is more useful for temporary diagnosis than long-lived setup.
“Edit the test Scene” is not a safe instruction if Codex might be connected to another client's project.
Connected Clients is the UI label used in the documentation for the target package version. During evaluation, capture both the Codex-side connection state and the Unity-side client display so that the selected project can be verified later.
Approve the First Connection in Unity
The official flow requires Unity-side approval for the first direct connection from an external MCP client.
The Assistant 2.14.0-pre.1 package documentation says that clients appear under Pending Connections, where Allow approves the connection and Revoke Access rejects it. An approved client can reconnect automatically in later sessions.
Unity's May 11, 2026 blog post uses Accept for the same approval action. Other versions may also use different page or button labels.
Do not search only for one exact word. Find the approval action for the client shown under the target version's pending-connections UI, and record the actual label used by the installed version.
This approval boundary matters, but it is not fine-grained authorization. It means “this Codex client may connect.” It does not by itself mean “Prefab creation is allowed but Scene deletion is forbidden.” Operation-level limits need additional layers.
Classify Results into Four Outcomes
Do not use the model's “Done” message as the success criterion. Judge the result from Unity's actual state.
| Outcome | Definition |
|---|---|
| First-attempt success | The initial instruction satisfies every condition without an extra save or verification instruction |
| Automatic recovery | The model re-observes the failure and completes the task within at most two additional tool calls, without human intervention |
| Human-assisted success | A person selects, deletes, restarts the Bridge, edits directly, or otherwise intervenes before completion |
| Failure | Retry limit exceeded, unintended change occurred, Editor stopped, or the run was rolled back with Git |
Do not merge human-assisted success into automatic success. A final state that a person repaired does not erase the failed automation attempt.
Metrics to Record
Run each task ten times from the same initial state. Allow no more than two recovery attempts. Stop a run immediately after an unintended change, target mismatch, or Editor hang.
Record:
- First-attempt success
- Automatic recovery
- Human intervention
- Elapsed time
- Number of tool calls
- Timeouts
- Out-of-scope diffs
- Editor hangs or crashes
- Number of changed files
- Tool configuration: built-in or Custom Tool
- Exact tool names and important arguments
The following formulas keep the categories separate:
First-attempt success rate = first-attempt successes / all attempts
Recovery-inclusive success rate =
(first-attempt successes + automatic recoveries) / all attempts
Human-intervention rate = human-assisted attempts / all attempts
Side-effect rate = attempts with unintended changes / all attempts
Ten runs are not enough to estimate universal model performance. They are a small, repeatable unit for discovering serious failures in one environment and comparing package or configuration changes.
Do not combine runs that use different allowlists, cache conditions, or built-in/Custom Tool configurations into the same denominator.
Evaluation Task 1: Read the Console and Fix a Compile Error
Start with a read-only connection check
Before allowing any code edit, keep:
enabled_tools = ["Unity_ReadConsole"]
Ask Codex to summarize the number of Errors and Warnings and show the first few entries. Do not count this connection check among the ten code-fix attempts.
Proceed only after confirming all of the following:
- The correct Editor is connected.
- Unity has approved the client.
- Codex discovers only
Unity_ReadConsolefor this stage. - Console reading works.
Then add the exact script-editing tool discovered in the environment to the allowlist.
Test input
Create Assets/MCPTest/Scripts/Health.cs with one missing semicolon:
using UnityEngine;
public sealed class Health : MonoBehaviour
{
[SerializeField] private int maxHp = 100;
public int CurrentHp { get; private set; }
private void Awake()
{
CurrentHp = maxHp
}
}
The challenge is not C# syntax. It is whether the workflow can:
- Read the Unity Console.
- Identify the correct source location.
- Apply the smallest possible change.
- Wait for Unity to import and compile.
- Read the Console again.
- Confirm that compile Errors are zero.
- Leave unrelated Warnings untouched.
Prompt
Read the Unity Console and apply only the minimum change required to fix the compile error.
Constraints:
- Do not change the API design, names, fields, or access modifiers.
- Do not fix Warnings unrelated to the Error.
- Wait for Unity compilation to finish.
- Read the Console again and verify that compile Errors are zero.
- Report the changed file and line.
When the Bridge cannot start
Unity's MCP troubleshooting documentation notes that compile errors can prevent the MCP Bridge from starting. The evaluation therefore needs two explicit paths:
| Bridge state | Procedure |
|---|---|
| Running |
Unity_ReadConsole → minimal edit → wait for compile → read Console again |
| Stopped | Use Codex's ordinary repository editing to fix only the blocking error → let Unity compile → start the Bridge → read Console |
It is acceptable to divide responsibilities: normal file editing for the source change, Unity MCP for observing the Editor result.
Success requires:
- Zero compile Errors after recompilation
- No diff beyond the expected semicolon
- A second Console read after compilation
- The correct recovery path for the Bridge state
Use two difficulty stages
The missing semicolon is Stage A: it verifies the connection and feedback loop.
Stage B should use a slightly more semantic but still deterministic error. For example, assign GetComponent<Rigidbody2D>() to a Rigidbody field and define the only accepted fix as GetComponent<Rigidbody>().
Predefine the expected diff and acceptance conditions. Do not use an ambiguous bug when evaluating the reliability of the Editor loop.
Saving the file is not completion. Observe Asset Import, compilation, and the post-Domain-Reload Console state.
Evaluation Task 2: Edit a Sandbox Scene
Required Scene
Create and save:
Assets/MCPTest/Scenes/MCP_Sandbox.unity
with this Hierarchy:
MCP_Sandbox (Scene)
├─ Environment
│ ├─ Floor
│ └─ Directional Light
├─ Main Camera
└─ SpawnPoint
Acceptance conditions:
- The Scene is saved at the exact path.
-
Environment,Main Camera, andSpawnPointare at the Scene root. -
Environmenthas Position and Rotation set to zero and Scale set to one. -
Flooris a child ofEnvironmentand has Cube rendering Components plus aBoxCollider. -
Floor.localPosition = (0, -0.5, 0). -
Floor.localScale = (10, 1, 10). -
Directional Lighthas aLightComponent with the Directional type. -
SpawnPointhas only a Transform andposition = (0, 1, -4). -
Main Camerahas aCameraComponent and theMainCameratag. - The Scene is saved and no other Scene changes.
- The Console has no Errors.
Prompt
Use Unity MCP to create Assets/MCPTest/Scenes/MCP_Sandbox.unity with the following state.
Hierarchy:
- Environment
- Floor
- Directional Light
- Main Camera
- SpawnPoint
Settings:
- Environment Position/Rotation = 0 and Scale = 1.
- Create Floor as a Cube with localPosition = (0, -0.5, 0)
and localScale = (10, 1, 10).
- Directional Light must contain a Directional Light component.
- SpawnPoint must contain only a Transform and use position = (0, 1, -4).
- Main Camera must contain a Camera and use Tag = MainCamera.
Constraints:
- Do not edit an existing Scene.
- If a Scene already exists at the target path, stop without overwriting it.
- UI and Canvas objects are outside this evaluation task.
After saving, re-read the active Scene path, Hierarchy, Components, Transforms,
Light Type, Camera Tag, save state, and Console Errors.
What to inspect
A Scene may look correct while still being dirty and unsaved. After saving, re-read the Scene path and Hierarchy. In a multi-Scene setup, verify the Active Scene and the owning Scene of every created GameObject.
World and local coordinates must remain explicit. Parenting can change the effective result, so the prompt and the acceptance test should both distinguish position from localPosition.
Exclude UI Hierarchies for This Version
Unity's troubleshooting documentation for Assistant 2.14.0-pre.1 warns that running the documented get_components operation on GameObjects in a Canvas or UI hierarchy may stop or crash the Editor. The listed affected Components include:
CanvasCanvasScalerGraphicRaycasterRectTransform
get_components is the operation name used in the documentation. Confirm which discovered tool and input schema produce that operation in the installed version.
For this evaluation:
- Do not retrieve Components from UI hierarchies.
- Do not broadly enumerate the entire Scene.
- Limit queries to a known root.
- Save every tool call and its arguments.
- If the Editor hangs, identify the last call and stop the run.
Add UI only after the relevant Issue Tracker entry and release notes show that the problem is fixed for the pinned version.
Evaluation Task 3: Create a Prefab
Expand the allowlist first
The read-only configuration:
enabled_tools = ["Unity_ReadConsole"]
cannot create a Prefab.
Before the task, inspect the actual environment and add only the tools required for:
- GameObject creation
- Component configuration
- Asset or Prefab saving
If no built-in saving tool can satisfy the task, record “unsupported with built-in tools” and move the Custom Tool attempt into a separate result group.
Required Prefab
Create:
Assets/MCPTest/Prefabs/Crate.prefab
Crate
├─ Visual
└─ Handle
Acceptance conditions:
- Root name is
Crate. - The root contains only Transform,
BoxCollider, andRigidbody. -
Rigidbody.mass = 10. -
Visualcontains only Transform,MeshFilter, andMeshRenderer. -
Visualdoes not retain aBoxCollideradded byCreatePrimitive. -
Handlecontains only a Transform. -
Handle.localPosition = (0, 0.6, 0). - The Prefab is saved at the exact path.
- No temporary GameObject remains in the Scene.
- Reopening the saved Prefab preserves the structure and values.
- The Console has no Errors.
Prompt
Use Unity MCP to create Assets/MCPTest/Prefabs/Crate.prefab.
Requirements:
- Root name: Crate
- Add BoxCollider and Rigidbody to the root.
- Set Rigidbody.mass to 10.
- Child Visual must contain only the Cube MeshFilter and MeshRenderer.
- If CreatePrimitive added a BoxCollider to Visual, remove it before saving.
- Child Handle must contain only a Transform.
- Set Handle.localPosition to (0, 0.6, 0).
- Do not leave a temporary GameObject in the Scene.
- If a Prefab already exists at the target path, stop without overwriting it.
After saving, re-read the Prefab and report the Hierarchy, Components, mass,
localPosition, save path, and Console Errors. Do not classify the task as
successful if any unspecified Component remains.
The evaluated workflow includes creation, configuration, save, cleanup, and re-open verification.
Treat all of the following as failures:
- A temporary Scene object remains.
- A required value was never set.
- World and local coordinates were confused.
- An existing Asset was overwritten.
- An extra Collider remains on
Visual. - The saved Prefab was never reopened and checked.
After a failed attempt, observe the current Asset and Scene state before changing anything. Repair one condition at a time.
For repeated production use, consider replacing a series of generic calls with a narrow Custom Tool such as CreateOrValidatePrefab that provides a dryRun mode, path allowlist, and explicit overwrite policy.
Evaluation Record Template
Copy this table for Console, Scene, and Prefab tasks and fill ten rows for each configuration.
| Run | Tool setup | Tools used | First | Recovery | Human | Time | Calls | Timeout | Out-of-scope diff | Notes |
|---|---|---|---|---|---|---|---|---|---|---|
| 1 | ||||||||||
| 2 | ||||||||||
| 3 | ||||||||||
| 4 | ||||||||||
| 5 | ||||||||||
| 6 | ||||||||||
| 7 | ||||||||||
| 8 | ||||||||||
| 9 | ||||||||||
| 10 |
Summarize the results separately:
| Task | Tool setup | First-attempt success | Recovery-inclusive success | Human-intervention rate | Side-effect rate | Median time | Editor stops |
|---|---|---|---|---|---|---|---|
| Console fix | Built-in / ordinary editing | — | — | — | — | — | — |
| Scene edit | Built-in only | — | — | — | — | — | — |
| Prefab creation | Built-in only | — | — | — | — | — | — |
| Prefab creation | With Custom Tool | — | — | — | — | — | — |
Do not report only the average. Record median time, maximum time, timeouts, and Editor stops separately. Keep built-in and Custom Tool runs in different result groups.
Preserve evidence
For an internal adoption decision or a public report, save evidence for both successful and failed runs:
- Unity MCP Server settings
- Codex tool list
- Prefab Hierarchy and Inspector
- Console before and after the code fix
- Scene Hierarchy after editing
- Debug logs or tool-call details for failures
Associate every screenshot and log with a run number. Before publishing, mask user names, absolute paths, project names, credentials, and other confidential data.
Suggested pilot thresholds
The following are proposed internal thresholds, not Unity or OpenAI requirements:
- At least 80% first-attempt success
- At least 95% success including automatic recovery
- Zero unintended changes
- Zero Editor hangs or crashes
- No more than one human-assisted run per ten attempts
- Faster median completion than the same task performed manually
For Scene and Prefab work, side effects matter more than speed. Nine fast successes do not compensate for one run that damages another Scene.
For Console fixes, give the highest weight to a minimal diff and post-compilation verification.
Define Recovery as a State Machine
A free-form “try again” prompt makes the recovery process different on every run. Fix the workflow to a small state machine:
Observe → Plan → Act one step → Wait → Verify
↑ │
└──────── known temporary failure ─┘
├─ success: Stop
└─ destructive risk: Stop and roll back
| State | Action |
|---|---|
| Observe | Read the Active Scene, target Asset, Hierarchy, Console, Bridge state, and Git diff |
| Plan | Choose one next operation and define the state that should follow it |
| Act one step | Limit the change to one GameObject, one Component, or one-file diff |
| Wait | Wait for import, compilation, Domain Reload, or save completion |
| Verify | Judge the acceptance conditions from newly retrieved Unity state and Git diff |
| Stop / roll back | Stop immediately after target mismatch, unintended change, Editor stop, or overwrite risk |
After a timeout, return to Observe. Do not immediately send the same write operation again.
Common stop conditions:
- The connected project or target Scene is not the expected one.
- An existing Asset may be overwritten.
- A non-target Scene, Asset, or script changed.
- The Unity Editor stopped or crashed and the final call cannot be identified.
- State cannot be re-read after a timeout, so execution status is unknown.
- An unapproved tool or Custom Tool was called.
Task-specific sections should add only their own acceptance conditions instead of redefining this common list.
Use Four Permission Layers
Unity's connection approval alone is not sufficient. Combine four layers.
Layer 1: Git and the work environment
Use a dedicated branch or worktree, a clean baseline commit, and one task per commit. Begin with a sandbox Scene rather than a production Scene. Inspect the result in Unity as well as in serialized YAML diffs.
Layer 2: Codex sandbox and approvals
The Codex sandbox controls local command access. Approval policy controls when human confirmation is required.
Unity MCP tool calls are a separate path from shell editing, so the sandbox is not the only boundary. Do not begin with sandbox_mode = "danger-full-access" or disabled approval. For shell operations, start with --sandbox workspace-write --ask-for-approval on-request or the equivalent configuration, while keeping MCP tool approval in prompt mode.
Layer 3: Codex MCP tool restrictions
Use enabled_tools, disabled_tools, and approval modes to expose only the tools needed for the current task.
For the connection check, expose only Unity_ReadConsole. For write operations, add only exact tool names verified through the installed environment.
Layer 4: Unity MCP Server and narrow Custom Tools
Disable unnecessary tools on the Unity side as well.
For repeated workflows, prefer a narrow Custom Tool that enforces:
- Approved folders
- Approved Scenes
- Overwrite policy
- Maximum object count
- Dry-run support
- Undo
- Validation
Examples include CreateEnemySpawnPoint or ValidatePrefabReferences rather than a generic “modify anything” endpoint.
Local IPC Does Not Mean All Data Stays Local
The Relay-to-Editor connection uses local IPC, but Codex reasoning may still involve remote services.
Before using the integration with production data, review:
- OpenAI plan and workspace data controls
- Unity AI terms and data settings
- Client confidentiality requirements
- Whether Console logs may contain credentials or personal data
- Storage location and retention of MCP debug logs and Codex history
“Communication with the Editor is local” is not enough to conclude that confidential project data can be sent through the workflow.
Be Careful with Batch Mode Auto-Approval
Auto-approve in Batch Mode allows an MCP client running in Batch Mode to connect without the normal interactive approval step.
That can be useful in CI, but it removes an important boundary. Do not enable it at the beginning of an evaluation.
A safe progression is:
- Human-supervised local evaluation
- Read-only automation
- Narrow write operations in an isolated runner
If Batch Mode auto-approval is eventually enabled, require:
- Disposable runners
- A fixed repository and fixed write locations
- A strict tool allowlist
- Automated diff validation
- No direct writes to the main branch
Custom Tools Are the Path to Production Use
Built-in tools are useful for small experiments. Repeated production workflows are often safer when they are consolidated into narrow Custom Tools registered through Unity's official extension mechanism.
For Prefab creation, instead of allowing the model to compose many generic operations, expose something like:
CreateValidatedPrefab(sourceDefinition, outputPath, overwritePolicy, dryRun)
Its implementation can:
- Validate the output path and overwrite policy.
- Create and configure objects inside one Undo group.
- Save the Prefab.
- Reopen the saved Asset.
- Run a project-specific validator.
- Destroy temporary objects.
- Return a structured result.
The important shift is to treat Unity's official MCP not as “natural language can do anything in the Editor,” but as a standard interface through which an AI can reach carefully designed internal Editor tools.
That makes the failure surface and ownership boundary much smaller.
Write Prompts as Input Specifications
The recovery state machine defines what happens after a failure. The prompt defines what is allowed to change.
A useful prompt specifies five things:
| Item | What to include |
|---|---|
| Target | Project, Scene, Asset path, and root GameObject |
| Completion | Save, reopen, values, and Console verification |
| Prohibitions | No overwrite, no other Scene, no UI query, and similar limits |
| Change size | One creation, setting, or code change at a time |
| Verification | Newly retrieved Unity state, not model self-report |
Do not ask only, “Did it work?”
Ask for concrete evidence:
Reopen the saved Prefab and return its Hierarchy, Components, values, save path, and Console state.
The purpose is to turn an ambiguous natural-language request into executable acceptance criteria.
Treat Timeouts as Unknown State
Unity tool calls can be delayed while the Editor imports Assets, builds, compiles scripts, or reloads the domain.
Record these as separate events:
- Relay startup
- Bridge connection
- Tool discovery
- Import or compilation
- Domain Reload
- Tool-internal hang
Do not hide the cause by increasing every timeout indiscriminately.
A timed-out write call does not prove that nothing happened. The operation may have completed while the response was lost.
Before retrying, re-read:
- The target Asset
- The Hierarchy
- The Git diff
- The Console
Repeated Custom Tools should ideally be idempotent through existing-state checks or a request ID.
Conclusion
Unity's official MCP Server provides an official connection surface from Codex to Unity Editor state, including Scenes, GameObjects, Assets, scripts, and the Console.
That access is useful, but it is not automatically safe. A production-minded setup must control the target Editor, exposed tools, save behavior, re-read verification, and timeout recovery.
Before adoption, repeat the Console, sandbox Scene, and Prefab tasks from the same initial state. Measure first-attempt success, automatic recovery, human intervention, unintended changes, and Editor stops separately.
Begin with read-only Console observation. Expand access only to a disposable Scene, then to Prefab creation. Treat any out-of-scope modification as more important than raw speed.
Only workflows that meet the team's threshold should become candidates for routine use. Everything else can remain observation-only.
The most practical mental model is not “let natural language control the whole Editor.” It is:
Use allowlists and narrow Custom Tools to make Unity MCP a controlled entry point into well-defined Editor automation.
References
The following sources were checked on July 21, 2026. Paths, labels, Validation Level values, and known issues in this article are based on these primary sources. Unity AI and the Assistant package are Beta/pre-release software, so recheck the exact version before evaluation.
- Unity AI Open Beta: How to get started with MCP
- AI client integration with Unity (MCP) | Unity Assistant 2.7
- Unity AI
- AI client integration with Unity (MCP) | Unity Assistant 2.14
- Get started with Unity MCP | Unity Assistant 2.14
- Unity MCP Server configuration page reference
- Troubleshoot Unity MCP bridge issues
- Register custom MCP tools
- Model Context Protocol | Codex
- Codex configuration reference
- Agent approvals and security | Codex
- How your data is used to improve model performance | OpenAI
Top comments (0)