unity-mcp
FrameworkCoplayDev/unity-mcp
Bridges AI assistants with Unity Editor for asset and scene management.
Overview
MCP for Unity connects LLMs like Claude and GPT to the Unity Editor via the Model Context Protocol. It provides 47 tools for creating scenes, editing scripts, managing assets, and automating game development workflows. Open source under MIT license.
README Preview
\n \n \n \n \n\n\n\n\n[English](README.md) [简体中文](docs/i18n/README-zh.md) | [Discord](https://discord.gg/y4p8KfzrN4) [Wiki](https://coplaydev.github.io/unity-mcp/)\n\n#### Proudly sponsored and maintained by [Aura](https://www.tryaura.dev/) — the AI assistant for Unreal & Unity.\n##### And don't miss [Godot AI](https://github.com/hi-godot/godot-ai), the new open source project from the makers of MCP for Unity.\n\n\n\nCreate your Unity apps with LLMs. MCP for Unity bridges AI assistants — Claude, Codex, VS Code, local LLMs, and more — with your Unity Editor via Model Context Protocol. Give your LLM the tools to manage assets, control scenes, edit scripts, run tests, and automate your game dev workflows.\n\n\n \n\n\n---\n\n\n\nRecent Updates\n\n* **[v10.0.0](https://github.com/CoplayDev/unity-mcp/releases/tag/v10.0.0)** (2026-06-30)\n* **[v9.7.3](https://github.com/CoplayDev/unity-mcp/releases/tag/v9.7.3)** (2026-06-15)\n* **[v9.7.1](https://github.com/CoplayDev/unity-mcp/releases/tag/v9.7.1)** (2026-05-24)\n* **[v9.7.0](https://github.com/CoplayDev/unity-mcp/releases/tag/v9.7.0)** (2026-05-22)\n* **[v9.6.8](https://github.com/CoplayDev/unity-mcp/releases/tag/v9.6.8)** (2026-04-27)\n\nFull history: [Release Notes](https://coplaydev.github.io/unity-mcp/releases).\n\n\n\n\n---\n\n## What it does\n\nControl the Unity Editor in natural language from any MCP client — create scenes & GameObjects, edit C# scripts, manage assets, run tests, profile, and build. 47 focused MCP tool entrypoints, any client, free & MIT.\n\n**[Browse the full tool catalog →](https://coplaydev.github.io/unity-mcp/reference/tools/)**\n\n---\n\n## Quickstart\n\n**Requirements:** Unity **2021.3 LTS → 6.x** · Python **3.10+** (via [`uv`](https://docs.astral.sh/uv/)). Works with **any MCP client** — Claude Desktop & Code, Cursor, VS Code, Windsurf, Cline, Gemini CLI, and more.\n\n1. **Install** — Unity → Package Manager → Add from git URL:\n `https://gith
FAQ (5)
TroubleshootingHow do I fix CS0234: The type or namespace name 'Formatting' does not exist in 'Microsoft.CodeAnalysis' in Unity 6?
This error occurs with MCP for Unity v10.0.0 when USE_ROSLYN is enabled because ManageScript.cs uses Microsoft.CodeAnalysis.Formatting, but MCPForUnity.Editor.asmdef does not reference the Roslyn Workspaces assembly.
Preferred fix: update MCP for Unity to a version containing the fix that removes the Workspaces-layer formatting dependency.
Manual workaround: open MCPForUnity.Editor.asmdef and add Microsoft.CodeAnalysis.CSharp.Workspaces.dll to precompiledReferences:
"precompiledReferences": [
"Newtonsoft.Json.dll",
"Microsoft.CodeAnalysis.dll",
"Microsoft.CodeAnalysis.CSharp.dll",
"Microsoft.CodeAnalysis.CSharp.Workspaces.dll",
"System.Collections.Immutable.dll",
"System.Reflection.Metadata.dll",
"System.Runtime.CompilerServices.Unsafe.dll"
]
Make sure the DLL is actually present in the project, then save the asmdef and let Unity recompile. If the one-click installer does not provide Microsoft.CodeAnalysis.CSharp.Workspaces.dll, use the updated package version or disable USE_ROSLYN instead of referencing a missing DLL.
TroubleshootingHow do I fix "SerializedProperty 'sprite' not found" when setting SpriteRenderer.sprite with manage_components set_property in MCP for Unity?
This happens because MCP for Unity looks for the serialized field using the public C# property name (sprite), but Unity's built-in SpriteRenderer stores it in the native backing field m_Sprite. The same failure can occur for other built-in object-reference properties whose serialized field names use the m_ prefix.
Immediate workaround: set the property with execute_code instead of set_property:
var sr = gameObject.GetComponent<SpriteRenderer>();
sr.sprite = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/Sprites/WhiteSquare.png");
EditorUtility.SetDirty(sr);
If you only have a GUID:
var path = AssetDatabase.GUIDToAssetPath("YOUR-ASSET-GUID");
var sr = gameObject.GetComponent<SpriteRenderer>();
sr.sprite = AssetDatabase.LoadAssetAtPath<Sprite>(path);
EditorUtility.SetDirty(sr);
Permanent code fix: in MCPForUnity/Editor/Helpers/ComponentOps.cs, update the SetViaSerializedProperty lookup to fall back to Unity's native m_ field naming convention:
SerializedProperty prop = so.FindProperty(propertyName)
?? so.FindProperty(normalizedName)
?? so.FindProperty("m_" + char.ToUpperInvariant(propertyName[0]) + propertyName.Substring(1));
A more robust fix is to iterate the SerializedObject top-level properties and match the requested name case-insensitively after stripping the m_ prefix. Reported on MCP for Unity main with Unity 6000.3.13f1.
TroubleshootingHow to fix 'NotImplementedException' at EditorUtility.InstanceIDToObject when reading MCP for Unity GameObject resources on Unity 6000.6?
Upgrade com.coplaydev.unity-mcp to version 10.3.0 or newer; the fix is available in the latest beta/main branch. Unity 6000.6 gutted EditorUtility.InstanceIDToObject(int), so MCP for Unity 10.2.0 fails when calling mcpforunity://scene/gameobject/{id} or .../components. As a temporary workaround, avoid the GameObject resource and resolve objects through execute_code by traversing the active scene:
var roots = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
var all = roots.SelectMany(r => r.GetComponentsInChildren<Transform>(true)).Select(t => t.gameObject);
var target = all.FirstOrDefault(go => go.GetInstanceID() == instanceId);
Use the returned object to inspect components instead of the broken instance-ID resource.
TroubleshootingHow do I fix MCP for Unity hanging forever when reading components from a GameObject with SplineContainer knots or Unity.Mathematics structs?
This affects MCP for Unity 10.1.2, 10.2.0, and the beta mentioned in the issue when using Unity 6000.0.73f1, com.unity.splines 2.8.4, com.unity.mathematics 1.3.2, and Newtonsoft Json 3.2.2. The editor hangs because Newtonsoft.Json serializes public swizzle properties on Unity.Mathematics types such as float2, float3, float4, and quaternion. Each swizzle returns another struct with more swizzles, creating a combinatorial serialization loop. Empty splines return normally because they do not expose BezierKnot values.
Fix it by adding a JsonConverter for value types in the Unity.Mathematics namespace that serializes only public instance fields, for example float3 as {x,y,z} and quaternion as {value}. Register the converter in GameObjectSerializer._outputSerializer.Converters, preferably inserting it at index 0. Equivalent fixes are a contract resolver that skips properties marked [EditorBrowsable(EditorBrowsableState.Never)], or a per-component token cap in GetComponentData so one runaway component fails instead of freezing Unity.
Temporary workaround: at load time, use reflection to insert the Unity.Mathematics field-only converter into GameObjectSerializer._outputSerializer.Converters. Until patched, avoid calling mcpforunity://scene/gameobject/{id}/components on GameObjects containing non-empty SplineContainer components or other components exposing float2/float3/float4/quaternion fields. If the editor becomes unresponsive, the 30-second bridge timeout does not release the Unity main thread, so Unity must be restarted. A PR titled "fix: serialize Unity.Mathematics structs by their fields, not their swizzles" provides the upstream fix; use a patched build or release once available.
TroubleshootingHow to fix Unity MCP `read_console` returning 0 entries when Debug.Log messages exist?
read_console uses Unity's internal LogEntries.StartGettingEntries() / GetEntryInternal() APIs, which inherit the Console window's toolbar severity filters and search text. If the Log/Warning/Error toggle buttons are off, the API returns zero entries even though success is true and the messages exist in Editor.log.
**Immediate workaround**
1. Open the Unity **Console** window.
2. Enable the **Log**, **Warning**, and **Error** toggle buttons in the toolbar.
3. Clear the Console search/filter box.
4. Call read_console again.
You can also re-enable the severity flags from Editor C# code, such as through execute_code:
using UnityEditor;
using System.Reflection;
var logEntriesType = typeof(Editor).Assembly.GetType("UnityEditor.LogEntries");
var setFlag = logEntriesType.GetMethod(
"SetConsoleFlag",
BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic
);
setFlag.Invoke(null, new object[] { 1 << 7, true }); // Log
setFlag.Invoke(null, new object[] { 1 << 8, true }); // Warning
setFlag.Invoke(null, new object[] { 1 << 9, true }); // Error
var setFilter = logEntriesType.GetMethod(
"SetFilteringText",
BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic
);
setFilter?.Invoke(null, new object[] { "" });
Then retry read_console with types: ["log"] or types: ["all"].
**Permanent fix:** patch ReadConsole.GetConsoleEntries to save the current consoleFlags and filtering text, temporarily force LogLevelLog (1 << 7), LogLevelWarning (1 << 8), and LogLevelError (1 << 9) on and clear the search filter while iterating, then restore the original state. A less invasive option is to return a warning such as "note": "Console window filters are hiding log/warning entries" when requested severity levels are masked.
Observed in MCP for Unity v10.0.0 and Unity 6000.3.9f1.