How justinpbarnett/unity-mcp works
High-Level Overview
• Overall purpose: A bidirectional bridge between the Unity Editor (C#) and a Python server that interfaces with LLM MCP clients (e.g., Claude Desktop).
• Recognize the project as a hybrid full-stack integration between Unity and Python, enabling asset management, scene control, and editor automation.
Top-Level Components
• Unity Editor (Client Side)
• Contains scripts and tools (located under the Editor folder) that manage asset operations, command dispatching, and various editor utilities.
• Key subdirectories: Data, Helpers, Models, Tools, and Windows.
• Python Server (Server Side)
• Found within the Python folder, it includes the server script (server.py), configuration (config.py), and supportive tools for executing mirror functionality of the Editor tools.
• Dependencies like uv (see uv.lock) are set up to maintain runtime and dependency management.
• MCP Communication Layer
• Acts as the protocol bridge (facilitated through the UnityMCPBridge in the Editor and related Python scripts) ensuring bidirectional command and response flows.
Component Relationships and Interactions
• Data Flow:
• Unity Editor sends commands (via tools and models) over the MCP protocol to the Python server.
• Python server processes commands and replies, enabling real-time actions within Unity (asset manipulation, scene control, etc.).
▸ From Unity Editor Components (C#) to the Python Server.
▸ From the Python Server back to Unity Editor.
• Internal Structure:
• Within the Unity Editor, arrange components hierarchically:
– Top: Main MCP Bridge and Editor Window.
– Next: Tools (CommandRegistry, ManageAsset, etc.) and Models representing the MCP configuration.
– Base: Helper utilities and data classes.
• In the Python server, show the main server module (server.py), configuration, and ancillary tool scripts.
Important Architectural Patterns & Design Principles
• Separation of concerns: Clear distinction between the Editor’s client-side components and the Python server.
• Modularity: Structured directories (e.g., Editor’s Models vs. Tools) indicate well-organized modules.
• Bidirectional communication: Emphasize the use of MCP to facilitate command and response cycles.
• Dependency management: Note external tools like uv package manager and Python version dependencies.