
UnityMCP 
UnityMCP is a powerful Unity Editor plugin that implements the Model Context Protocol (MCP), enabling seamless integration between Unity and AI assistants. It provides real-time editor state monitoring, remote command execution, and comprehensive logging capabilities.
Architecture
The project consists of two main components:
1. Unity Plugin (UnityMCPPlugin)
A Unity Editor plugin that provides:
- Debug window for connection status and monitoring
- WebSocket client for real-time communication
- C# code execution engine
- Comprehensive logging system
- Editor state tracking and serialization
2. MCP Server (unity-mcp-server)
A TypeScript-based MCP server that exposes Unity Editor functionality through standardized tools:
Available Tools
-
get_editor_state
- Retrieves current Unity Editor state
- Includes active GameObjects, selection state, play mode status
- Provides scene hierarchy and project structure
- Supports different output formats (Raw, scripts only, no scripts)
-
execute_editor_command
- Executes C# code directly in the Unity Editor
- Full access to UnityEngine and UnityEditor APIs
- Real-time execution with comprehensive error handling
- Command timeout protection
-
get_logs
- Retrieves and filters Unity Editor logs
- Supports filtering by type, content, and timestamp
- Customizable output fields
- Buffer management for optimal performance
Installation
Installing via Smithery
To install UnityMCP for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @Arodoid/unitymcp --client claude
Prerequisites
- Unity 2022.3 or later
- Node.js 18 or later
- npm 9 or later
Unity Plugin Setup
- Copy the
UnityMCPPlugin
folder to your Unity project's Assets directory - Open Unity Editor
- Access the plugin through Unity's top menu bar > UnityMCP > Debug Window
MCP Server Setup
cd unity-mcp-server
npm install
npm run build
Usage
Starting the Server
cd unity-mcp-server
node build/index.js
Connecting from Unity
- Open your Unity project
- Open the UnityMCP Debug Window (Window > UnityMCP > Debug Window)
- The plugin will automatically attempt to connect to the MCP server
- Monitor connection status and logs in the debug window
Example: Executing Commands
// Center the selected object
Selection.activeGameObject.transform.position = Vector3.zero;
// Toggle play mode
EditorApplication.isPlaying = !EditorApplication.isPlaying;
// Create a new cube
GameObject.CreatePrimitive(PrimitiveType.Cube);
Development
Building the Server
cd unity-mcp-server
npm run build
Watching for Changes
npm run watch
Inspecting MCP Communication
npm run inspector
Technical Details
Communication Protocol
- WebSocket-based communication on port 8080
- Bidirectional real-time updates
- JSON message format for all communications
- Automatic reconnection handling
Security Features
- Command execution timeout protection
- Error handling and validation
- Log buffer management
- Connection state monitoring
Error Handling
The system provides comprehensive error handling for:
- Connection issues
- Command execution failures
- Compilation errors
- Runtime exceptions
- Timeout scenarios
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0).
相关推荐
Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.
Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.
Advanced software engineer GPT that excels through nailing the basics.
Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.
The all-in-one Desktop & Docker AI application with built-in RAG, AI agents, No-code agent builder, MCP compatibility, and more.
Fair-code workflow automation platform with native AI capabilities. Combine visual building with custom code, self-host or cloud, 400+ integrations.
🧑🚀 全世界最好的LLM资料总结(Agent框架、辅助编程、数据处理、模型训练、模型推理、o1 模型、MCP、小语言模型、视觉语言模型) | Summary of the world's best LLM resources.
Bridge between Ollama and MCP servers, enabling local LLMs to use Model Context Protocol tools
Dify is an open-source LLM app development platform. Dify's intuitive interface combines AI workflow, RAG pipeline, agent capabilities, model management, observability features and more, letting you quickly go from prototype to production.
an easy-to-use dynamic service discovery, configuration and service management platform for building AI cloud native applications.
Reviews

user_2cHCS0Rf
As a dedicated user of UnityMCP, I can confidently say this tool by Arodoid is a game-changer for Unity developers. The seamless integration and user-friendly interface make managing multiple core projects easier and more efficient. Highly recommend checking it out on GitHub!