MiAO-AI-Lab/MiAO-MCP-for-Unity
If you are the rightful owner of MiAO-MCP-for-Unity and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Unity-MCP is a bridge between LLM and Unity, facilitating the integration of AI models with Unity's tools and environment.
Unity MCP (Server + Plugin)
Unity Version | Editmode | Playmode | Standalone |
---|---|---|---|
2022.3.61f1 | |||
2023.2.20f1 | |||
6000.0.46f1 |
Unity-MCP is a bridge between LLM and Unity. It exposes and explains to LLM Unity's tools. LLM understands the interface and utilizes the tools in the way a user asks.
Connect Unity-MCP to LLM client such as Claude or Cursor using integrated AI Connector
window. Custom clients are supported as well.
The project is designed to let developers to add custom tools soon. After that the next goal is to enable the same features in player's build. For not it works only in Unity Editor.
The system is extensible: you can define custom tool
s directly in your Unity project codebase, exposing new capabilities to the AI or automation clients. This makes Unity-MCP a flexible foundation for building advanced workflows, rapid prototyping, or integrating AI-driven features into your development process.
β New Core Features
π 1. Workflow Middleware Architecture
Architecture Overview:
AI Agent β MCP Protocol β McpServer (Workflow Middleware) β Unity Runtime
β
RPC Gateway β ModelUse/Unity etc.
β
Workflow Orchestration Engine
Workflow Architecture
Layer 1: RPC Gateway
- β
Dynamic Unity Tool Discovery - Runtime discovery via
ToolRouter_ListAll
RPC - β Tool Calls - Auto-generated tool proxies
- β
Unified Interface - All RPC calls through unified
IRpcGateway
interface
Layer 2: Workflow Orchestration
- β
Expression Syntax Support -
${input.param}
,${step.result}
- β Conditional Execution - Step conditions and retry policies
- β
Multiple Step Types -
rpc_call
,model_use
,data_transform
2. AI Model Integration & ModelUse API
Provides Unity with complete AI model usage API:
- Bidirectional Communication: Unity Runtime β MCP Server β Agent
- Reverse Model Calls: Unity can actively request Agent's AI model capabilities
- Model Type Support: Text, vision, code analysis and other AI models
- Unified API Interface: Unified access to various AI services through ModelUse API
3. Interactive User Input System
- β Ask User Input Tool - Interactive user input collection
- β Undo & Redo System - Complete undo/redo functionality for GameObject operations
4. Tool System
Added numerous tool features
AI Tools
GameObject
GameObject.Components
Editor
Editor.Selection
Prefabs
Package
Animation
Timeline Manager
Environmental Query System
Skeleton Analysis & Visualization
Interactive Tools
|
Assets
Scene
Camera
Materials
Shader
Scripts
Scriptable Object
Debug
Component
AI Model Tools
Physics Tools
Layer Tools
|
π TODO Roadmap
Architecture LayerMcpServer Aggregator
Workflow Engine
AI Tool LayerAnimation & Rigging
Advanced EQS
Visual Programming
UI & UX Tools
Asset LayerAsset Intelligence
|
Legend: β = Implemented & available, π² = Planned / Not yet implemented
- Editor Automation: Provides rich APIs for automating Unity Editor operations
- AI Integration: Supports connection and interaction with AI models
- Asset Management: Provides tools for managing and manipulating Unity assets
- Animation Tools: Tools for reading and modifying animation clips
- Timeline Tools: Tools for manipulating Unity Timeline assets
- Component Operations: Provides APIs for accessing and modifying game object components
- Selection Tools: Used to get and set selections in the Unity Editor
- EQS Tools: Environmental Query System tools for intelligent spatial queries, location selection, and object placement
- RayCast Tools: Physics raycasting tools supporting multiple ray types (ray, sphere, box, capsule) and collision detection modes
- Console Logs: Get Console logs with a filter
- Streamlined and compressed the number of tools, ensuring that the model's performance doesn't degrade due to excessive tool calls.
Installation
- Install .NET 9.0
- Git Clone this repository locally and place it in Unity's Packages directory with the path Packages/com.miao.mcp/{repository content}
- Manually add to manifest.json:
{
"scopedRegistries": [
{
"name": "package.openupm.com",
"url": "https://package.openupm.com",
"scopes": [
"org.nuget"
]
}
]
}
Usage
- Make sure your project path doesn't have a space symbol " ".
- β
C:/MyProjects/Project
- β
C:/My Projects/Project
- Open Unity project, go π
Window/MCP Hub
.
- Install MCP client
- Install Cursor (recommended)
- Install Claude
- Sign-in into MCP client
- Click
Configure
at your MCP client.
- Restart your MCP client.
- Make sure
AI Connector
is "Connected" or "Connecting..." after restart. - Test AI connection in your Client (Cursor, Claude Desktop). Type any question or task into the chat. Something like:
Explain my scene hierarchy
AI Configuration (Optional)
Add custom tool
β οΈ It only works with MCP client that supports dynamic tool list update.
Unity-MCP is designed to support custom tool
development by project owner. MCP server takes data from Unity plugin and exposes it to a Client. So anyone in the MCP communication chain would receive the information about a new tool
. Which LLM may decide to call at some point.
To add a custom tool
you need:
- To have a class with attribute
McpPluginToolType
. - To have a method in the class with attribute
McpPluginTool
. - [optional] Add
Description
attribute to each method argument to let LLM to understand it. - [optional] Use
string? optional = null
properties with?
and default value to mark them asoptional
for LLM.
Take a look that the line
MainThread.Instance.Run(() =>
it allows to run the code in Main thread which is needed to interact with Unity API. If you don't need it and running the tool in background thread is fine for the tool, don't use Main thread for efficiency purpose.
[McpPluginToolType]
public class Tool_GameObject
{
[McpPluginTool
(
"MyCustomTask",
Title = "Create a new GameObject"
)]
[Description("Explain here to LLM what is this, when it should be called.")]
public string CustomTask
(
[Description("Explain to LLM what is this.")]
string inputData
)
{
// do anything in background thread
return MainThread.Instance.Run(() =>
{
// do something in main thread if needed
return $"[Success] Operation completed.";
});
}
}
Add custom in-game tool
β οΈ Not yet supported. The work is in progress
π― Middleware Workflow
Workflow Definition Syntax:
{
"id": "simple_equipment_binding",
"steps": [
{
"id": "find_character",
"type": "rpc_call",
"connector": "unity",
"operation": "GameObject_Find",
"parameters": { "name": "${input.characterName}" }
},
{
"id": "validate_character",
"type": "model_use",
"connector": "model_use",
"operation": "text",
"parameters": { "prompt": "Validate: ${find_character.result}" }
}
]
}
Contribution
Feel free to add new tool
into the project.
- Fork the project.
- Implement new
tool
in your forked repository. - Create Pull Request into original Unity-MCP repository.
Attribution
This project is based on the original open-source project by Ivan Murzak and has been extensively modified and extended by MiAO.
Original Project
- Author: Ivan Murzak
- Original Repository: https://github.com/IvanMurzak/Unity-MCP
- License: Apache License 2.0
Modifications and Extensions
- Modified by: MiAO (ai@miao.company)
- Year: 2025
- Major Changes: [List major modifications here]
We thank the original author Ivan Murzak for his contributions to the open-source community!
License
This project is licensed under the Apache License 2.0 - see the file for details.
The project includes components from the original work by Ivan Murzak, also licensed under Apache License 2.0.