mcp-unity

MCP Unity: Integrate AI models with Unity for automated game development tasks.

mcp-unity
mcp-unity Capabilities Showcase

mcp-unity Solution Overview

MCP-Unity is a powerful MCP server designed to seamlessly integrate the Unity game engine with AI coding assistants like Claude, Windsurf, and Cursor. Acting as a bridge between Unity and a Node.js server implementing the MCP protocol, it empowers AI agents to interact directly with your Unity projects.

Key features include the ability to execute menu commands, select game objects, update component properties, manage packages, run tests, and display messages within the Unity Editor. It also provides access to valuable resources like the scene hierarchy, asset database, and console logs. By exposing Unity's functionalities and data to AI models, MCP-Unity streamlines development workflows, enabling AI-driven automation, intelligent code completion, and enhanced debugging. This integration is achieved through a combination of Unity packages and a Node.js server, facilitating a robust and extensible AI-assisted Unity development experience.

mcp-unity Key Capabilities

IDE Integration via Cache

MCP Unity enhances AI coding assistants by automatically integrating with VSCode-like IDEs through access to the Unity Library/PackedCache folder. This integration provides AI models with improved code intelligence, enabling better autocompletion and type information for Unity packages. By understanding project dependencies, AI assistants can offer more accurate and context-aware suggestions, significantly improving the coding experience. For example, when an AI is asked to modify a script that uses a specific Unity package, it can now accurately understand the package's functions and properties, leading to fewer errors and more efficient code generation. This feature streamlines the development workflow by providing AI tools with the necessary context to assist developers effectively.

Execute Unity Editor Actions

The execute_menu_item tool allows AI agents to directly trigger functions within the Unity Editor that are marked with the MenuItem attribute. This functionality enables AI to automate tasks that would typically require manual interaction with the Unity interface. For instance, an AI could be instructed to "Create a new empty GameObject" by executing the corresponding menu item. This tool significantly expands the capabilities of AI assistants, allowing them to perform complex actions such as creating objects, modifying project settings, and triggering custom editor scripts. The technical implementation involves identifying the correct menu item path and then programmatically invoking the associated function within the Unity Editor environment.

GameObject Manipulation

MCP Unity provides tools for AI agents to interact with GameObjects in the Unity scene. The select_gameobject tool allows AI to select specific GameObjects by path or instance ID, while the update_component tool enables AI to modify component fields or add new components to GameObjects. For example, an AI could be instructed to "Add a Rigidbody component to the Player object and set its mass to 5". This level of control allows AI to dynamically adjust scene elements, enabling automated level design, parameter tuning, and interactive simulations. The underlying mechanism involves using Unity's scripting API to access and modify GameObject properties and components.

Resource Access and Management

MCP Unity exposes various resources that provide AI agents with information about the Unity project. These resources include lists of available menu items (unity://menu-items), the scene hierarchy (unity://hierarchy), detailed information about GameObjects (unity://gameobject/{id}), console logs (unity://logs), installed packages (unity://packages), assets (unity://assets), and tests (unity://tests/{testMode}). For example, an AI could use the unity://assets resource to "Find all texture assets in my project". This access to project information allows AI to make informed decisions and perform tasks such as asset management, debugging, and automated testing. The resources are accessed via standardized URIs, providing a consistent interface for AI agents to query project data.