Connect a Coding Agent to Unity Context Safely
Snapshot
~80 sec
A Unity MCP connection is a local chain of boundaries, not blanket permission. An AI client starts a stdio relay, the relay crosses a local IPC bridge into the open Unity Editor, and the Editor exposes registered tools. Prove each boundary with read-only work before considering mutation.
You will learn
- Trace a request from an AI client through the relay and Editor bridge to a registered Unity tool.
- Separate a successful connection from permission to invoke a mutating tool.
- Verify the setup with bounded, read-only console and scene-hierarchy requests.
Target outcome
You can connect a compatible coding agent to Unity context and verify it without granting unnecessary write authority.
Visual walkthrough
Visual walkthrough
~7 min
Four boundaries in one local connection
AI client
The host that chooses a tool and applies its own configuration and approval controls.
Stdio relay
A local MCP server process launched by the client. It translates protocol messages into bridge requests.
Editor bridge
The Unity-side process that accepts an approved local client over named pipes or a Unix socket.
Registered tool
One bounded capability exposed by the Editor. A listed tool is available, not automatically authorized for every use.
Follow one request into the Unity Editor
The current Unity MCP design uses stdio between the AI client and relay, then local IPC between the relay and the Editor bridge. The Editor registry resolves the requested capability.
AI client
Selects a configured server and proposes a tool call.
stdioStdio relay
Runs locally in MCP mode for this client session.
--mcpbridgesLocal IPC
Uses a named pipe or Unix socket rather than a public endpoint.
pending approvalUnity Editor bridge
Shows direct clients as pending until the connection is accepted.
resolvesTool registry
Finds an enabled built-in or custom tool by its declared contract.
executes and returnsBounded result
Returns console entries, hierarchy data, or the declared effect.
The current Unity MCP design uses stdio between the AI client and relay, then local IPC between the relay and the Editor bridge. The Editor registry resolves the requested capability. Reading order
- AI client
Selects a configured server and proposes a tool call.
- Stdio relay
Runs locally in MCP mode for this client session.
--mcp - Local IPC
Uses a named pipe or Unix socket rather than a public endpoint.
- Unity Editor bridge
Shows direct clients as pending until the connection is accepted.
- Tool registry
Finds an enabled built-in or custom tool by its declared contract.
- Bounded result
Returns console entries, hierarchy data, or the declared effect.
Connection explanations
- AI client → Stdio relay (stdio)
The host launches the configured relay and exchanges MCP messages over standard input and output.
- Stdio relay → Local IPC (bridges)
The relay converts the MCP request into a local bridge request.
- Local IPC → Unity Editor bridge (pending approval)
A direct external client must be accepted in Unity before it can invoke Editor tools.
- Unity Editor bridge → Tool registry (resolves)
The accepted connection reaches only tools that the Editor has registered and enabled.
- Tool registry → Bounded result (executes and returns)
The selected tool returns its bounded result; the connection does not grant undeclared capabilities.
Read the configuration as a contract, not a copied path
Conceptual shape only. The client, operating system, package version, and Unity integration UI determine the real configuration location and relay path. Re-check their current documentation instead of pasting one machine's path.
Languagejson { "mcpServers": { "unity-editor": { "command": "<relay executable selected for this OS>", "args": ["--mcp"] } } }Code annotations
Lines 2-6
One named local server
The host associates a stable server name with the relay command it should launch.
Effect: The same Unity capability can be discovered without treating a filesystem path as universal.
Lines 4-5
Platform path plus MCP mode
Choose the relay executable that Unity installed for this operating system and start it in MCP mode.
Effect: The relay speaks MCP over stdio and connects to the local Editor bridge.
Connection proof versus mutation authority
Approach Invented request Required authority Beginner verification Summarize console warningsRead a bounded set of warnings from an invented practice project. Group the latest warning messages by type and report their counts without changing the project. Connection approval plus access to the specific read-only console tool. The summary matches the visible Console window and reports no write action. Inspect an invented scene hierarchyRead names and component types under a generic PracticeRoom root. List the CameraRig, LightRig, and TargetDummy children with their attached component types. Connection approval plus access to the bounded hierarchy or scene-read tool. The returned tree matches Unity's Hierarchy and Inspector without creating or editing an object. Create or change an objectA connected client proposes a mutating scene tool. Add a disabled Empty object under PracticeRoom with a specific name. A separate host-side tool approval and an enabled Unity write tool, after the exact arguments are reviewed. A visible Hierarchy change, a reviewable scene diff, and a deliberate save or rollback decision. Use three gates before any write
A green connection indicator proves transport. It does not prove that a proposed mutation is necessary, authorized, or correct.
Connection gate
Bridge running, direct client accepted, tools visible.
does not implyApproval gate
Review the selected tool, arguments, and whether it can mutate.
requires evidenceVerification gate
Compare the result with Unity state, tests, and a reviewable diff.
A green connection indicator proves transport. It does not prove that a proposed mutation is necessary, authorized, or correct. Reading order
- Connection gate
Bridge running, direct client accepted, tools visible.
- Approval gate
Review the selected tool, arguments, and whether it can mutate.
- Verification gate
Compare the result with Unity state, tests, and a reviewable diff.
Connection explanations
- Connection gate → Approval gate (does not imply)
Transport success only makes tools reachable; each mutating call still needs an explicit authority decision.
- Approval gate → Verification gate (requires evidence)
Approval permits an attempt, while verification decides whether its observable result is acceptable.
Name the missing permission
An invented client is accepted by Unity, the bridge is running, and scene tools are listed. The agent now proposes creating a GameObject. Has the connection already authorized that mutation?
Expected reasoning
No. The accepted connection proves that the transport and Unity bridge recognize the client. The host must still allow the specific mutating tool call, the Unity write tool must be enabled, and a person should review the arguments and verification plan. Start with console or hierarchy reads before granting scene mutation.
Go deeper
- Unity MCP overviewUnity's official overview of its MCP package, server, and supported context.
- Unity MCP get startedUnity's official installation and connection workflow.