
Unity Code MCP is a MCP server that enables AI agents to work on Unity project autonomously, by providing tools to compile code and run tests in Unity Editor.
概览
Unity Code MCP is a coding focused Model Context Protocol (MCP) server that enables AI agents to write Unity code autonomously. Unity Code MCP is a high-performance, coding-focused MCP server built in Rust. It handles Unity's compilation cycles gracefully while providing only the essential tools needed for autonomous code development: compilation feedback and test execution. This MCP server enables AI agents to develop Unity code autonomously with exceptional speed and reliability - write code, compile, fix compile errors, test, fix bugs, repeat, just like how a human would. - : Streamlined tools designed for efficient AI agent coding workflows - : Built in Rust for exceptional speed, minimal memory usage, and lightning-fast response times. Uses only 1MB memory when the workspace is not a Unity Project, and only 10MB when it is and Unity Editor is open for the project. Also, the communication with Unity Editor is based on UDP, so it's minimal load for your system.
README
以下为原文 README 节选,完整内容请查看原文。
Unity Code MCP
Description
Unity Code MCP is a coding focused Model Context Protocol (MCP) server that enables AI agents to write Unity code autonomously.
🎯 Why Unity Code MCP?
Unity Code MCP is a high-performance, coding-focused MCP server built in Rust. It handles Unity’s compilation cycles gracefully while providing only the essential tools needed for autonomous code development: compilation feedback and test execution.
This MCP server enables AI agents to develop Unity code autonomously with exceptional speed and reliability - write code, compile, fix compile errors, test, fix bugs, repeat, just like how a human would.
✨ Key Features
- 🤖 Coding-Optimized: Streamlined tools designed for efficient AI agent coding workflows
- ⚡ Lightweight and High Performance: Built in Rust for exceptional speed, minimal memory usage, and lightning-fast response times. Uses only 1MB memory when the workspace is not a Unity Project, and only 10MB when it is and Unity Editor is open for the project. Also, the communication with Unity Editor is based on UDP, so it’s minimal load for your system.
- 🎯 Efficient Communication: Minimal token usage with essential operations, only returns relevant information
- 🧪 Test-Driven: Comprehensive test execution and reporting capabilities
- 📦 Self-Contained: Single binary with no runtime dependencies (no Node.js, Python, or .NET required)
🛠️ MCP Server Tools
Unity Code MCP provides 2 tools for autonomous code development:
1. Asset Database Refresh
- Triggers Unity compilation and asset processing
- Returns compile errors and other non compile warning and errors only include the logs during the refresh
- Handles domain reload gracefully
Asset database refresh tool in action:
2. Test Execution
- Runs Unity tests with comprehensive reporting
- Provides detailed stack traces and logs for failures
- Supports both EditMode and PlayMode tests
Test execution tool in action:
🚀 Autonomous AI agent workflow example
Once configured, AI agents can develop Unity code completely autonomously:
User: "Create a player controller that moves with WASD keys and has jump functionality. Make sure it's fully tested."
AI: I'll create a complete player controller with movement and jumping, then write comprehensive tests.
1. [AI writes PlayerController.cs with movement logic]
2. [AI calls: refresh_asset_database]
→ Result: "Compilation failed: CS0246: The type or namespace name 'Rigidbody' could not be found"
3. [AI fixes the missing using UnityEngine; statement]
4. [AI calls: refresh_asset_database]
→ Result: "Compilation successful, no errors"
5. [AI writes PlayerControllerTests.cs with movement and jump tests]
6. [AI calls: run_tests]
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
{
"mcpServers": {
"unity-code": {
"command": "/path/to/unity-code-mcp",
"env": {
"UNITY_PROJECT_PATH": "${workspaceFolder}"
}
}
}
}