Skip to content

jinwoo-lee-github/unity-mcp-tools

Repository files navigation

Unity MCP Tools

Reusable Unity Editor MCP tools for deterministic editor automation.

This package keeps its assembly, namespace, and MCP tool names project-neutral so the tools can be reused across Unity projects.

What This Package Does

Unity MCP Tools adds focused Editor-only tools that make Unity automation easier for MCP clients and AI coding agents.

The first feature set is built around prefab-first UI and asset workflows:

  • wait for Unity to finish importing assets and compiling scripts before continuing an automation step;
  • inspect prefab hierarchy and components before making changes;
  • validate prefab assets for missing scripts;
  • edit RectTransform layout with named anchor presets instead of arbitrary anchor values;
  • keep prefab edits explicit, repeatable, and easy to review.

This package is not a UI builder. Builders are still useful when a project needs to create or regenerate a large known hierarchy. These MCP tools are intended for smaller deterministic operations where the target prefab, object path, and requested change are clear.

Requirements

  • Unity 6 or newer
  • com.unity.ai.assistant with Unity MCP enabled
  • MCP clients connected to the Unity Editor bridge

Install

Unity Package Manager

  1. Open Unity Package Manager.
  2. Select + > Add package from git URL....
  3. Enter:
https://github.com/jinwoo-lee-github/unity-mcp-tools.git

The package is located at the repository root, so no ?path= suffix is required. If you are installing from a fork, replace the URL with your fork URL.

Manifest

You can also add it directly to Packages/manifest.json:

{
  "dependencies": {
    "com.sorigames.unity-mcp-tools": "https://github.com/jinwoo-lee-github/unity-mcp-tools.git"
  }
}

If Unity does not resolve com.unity.ai.assistant automatically, install Unity AI Assistant first and enable pre-release package visibility if your Unity version requires it.

After Install

  1. Wait for Unity to reload scripts.
  2. Open Unity Assistant settings and make sure MCP is enabled.
  3. Check the MCP tool list for the tools below.
  4. If a tool is listed but disabled, enable it in the MCP settings before calling it from an MCP client.

Included Tools

MCP tool Purpose
WaitForEditorIdle Waits until Unity finishes asset updates and script compilation.
UnityMcpTools_InspectPrefab Returns a prefab hierarchy, component list, and basic diagnostics.
UnityMcpTools_ValidatePrefab Validates that a prefab exists and reports missing script counts.
UnityMcpTools_SetRectTransformPreset Applies a named RectTransform anchor preset to an object inside a prefab.

Tool Details

WaitForEditorIdle

Use this after adding scripts, changing package dependencies, importing assets, or saving prefabs. It waits until Unity is no longer compiling or updating and can optionally verify that an asset path exists.

Typical use:

{
  "TimeoutSeconds": 60,
  "StableMilliseconds": 500,
  "AssetPath": "Assets/MyPrefab.prefab"
}

UnityMcpTools_InspectPrefab

Use this before editing a prefab. It returns the prefab root, child hierarchy, component type names, total component count, and missing script count.

Typical use:

{
  "PrefabPath": "Assets/UI/MainWindow.prefab",
  "IncludeInactive": true,
  "MaxDepth": 64
}

UnityMcpTools_ValidatePrefab

Use this after a prefab edit or package import. It confirms the prefab can be loaded and reports missing script count.

Typical use:

{
  "PrefabPath": "Assets/UI/MainWindow.prefab"
}

UnityMcpTools_SetRectTransformPreset

Use this for deterministic UI layout edits inside a prefab. The tool loads prefab contents, finds a child by slash-separated object path, applies a named anchor preset, optionally sets position and size, then saves the prefab.

Typical use:

{
  "PrefabPath": "Assets/UI/MainWindow.prefab",
  "ObjectPath": "MainWindow/Header/CurrencyGroup",
  "Preset": "TopCenter",
  "X": 0,
  "Y": -80,
  "Width": 360,
  "Height": 72
}

RectTransform Presets

UnityMcpTools_SetRectTransformPreset avoids arbitrary custom anchors. It supports these named presets:

MiddleCenter
TopCenter
BottomCenter
LeftMiddle
RightMiddle
TopLeft
TopRight
BottomLeft
BottomRight
StretchFull
StretchHorizontalTop
StretchHorizontalBottom
StretchVerticalLeft
StretchVerticalRight

Aliases such as center_middle, middle_center, center_top, and top_center are accepted.

Workflow Direction

Use this package for small, explicit MCP operations that are easy for an AI client to reason about:

  • inspect a prefab before editing it;
  • set a target object's layout by named intent, not arbitrary anchor values;
  • wait for Unity to finish importing or compiling before reading console state;
  • validate that a prefab does not contain missing scripts.

UI builders can still be useful for creating or regenerating large known hierarchies. MCP tools should handle focused queries and edits where the target, owner prefab, and parameters are explicit.

Naming Policy

  • Package ID: com.sorigames.unity-mcp-tools
  • Assembly: UnityMcpTools.Editor
  • Namespace: UnityMcpTools.Editor
  • Tool names: WaitForEditorIdle and UnityMcpTools_*

Keep the assembly, namespace, and tool names generic so project code can reuse the package without rebranding.

About

No description, website, or topics provided.

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages