AI-powered static analysis for Unity projects
This Model Context Protocol (MCP) server provides intelligent code analysis for Unity, detecting common patterns, component relationships, and programming insights to augment developer workflows.
- 🎮 Unity-Specific Pattern Detection - Identifies 8+ common Unity patterns (Singleton, Coroutine, ScriptableObject etc.)
- 🤝 Component Relationship Mapping - Visualizes MonoBehaviour dependencies and interactions
- 📊 Quantitative Metrics - Provides statistics on pattern usage across projects
- 🔍 Structured Documentation Access - AI-optimized Unity documentation retrieval
- ⚙️ Automatic Configuration - Resolves Unity installations based on project settings
Our pattern detection system uses a plugin architecture where new Unity patterns can be detected by implementing the IUnityPatternDetector interface. The registry automatically discovers and integrates all detectors found in the system.
The dual-path configuration system supports both automatic Unity installation detection and manual overrides. This adaptive approach ensures compatibility with future Unity versions and custom deployment scenarios.
The documentation engine provides a clean abstraction layer over Unity's documentation, offering multiple endpoints optimized for AI consumption. New documentation formats and search strategies can be added via our standardized plugin API.
Before you begin, ensure you have the .NET 8.0 SDK or a newer version installed.
The following instructions apply to both Windows and macOS.
From the root directory of the repository, run the following command to build the project and restore dependencies:
dotnet buildTo start the server, execute the following command from the root directory:
dotnet runThe server will now be running and ready to accept requests from an MCP client.
The server is configured using the appsettings.json file, which must be placed in the project's root directory. This file allows you to specify paths required for the analysis tools to function correctly.
All settings are located within the UnityAnalysisSettings object in appsettings.json.
-
ProjectPath(Required): The absolute path to the root of the Unity project you intend to analyze.- Example:
"C:\\Users\\YourUser\\Documents\\MyUnityProject"
- Example:
-
InstallRoot(Optional): The path to the directory containing your Unity Editor version folders. This is typically theEditorfolder inside your Unity Hub installation directory. This setting is used with the project's detected version to automatically locate the correct Unity Editor.- Example:
"C:\\Program Files\\Unity\\Hub\\Editor"
- Example:
-
EditorPath(Optional): A direct and explicit path to a specific Unity Editor installation folder. If provided, this path takes priority over theInstallRootsetting. This is useful for development or if your editor is in a non-standard location.- Example:
"C:\\UnityEditors\\2022.3.15f1"
- Example:
To function, the analyzer must be able to locate the Unity Editor installation. You must configure either InstallRoot (so the editor can be found automatically) or provide a direct EditorPath.
{ "UnityAnalysisSettings": { "InstallRoot": "/Applications/Unity/Hub/Editor/", "EditorPath": "", "ProjectPath": "C:\\Path\\To\\Your\\UnityProject" } } You can interact with the server using the MCP Inspector, which provides a web-based interface.
# Navigate to your MCP server project directory # (The directory containing Unity_Intelligence_MCP.csproj) cd path/to/Unity_Intelligence_MCP # Install and run the MCP Inspector npx @modelcontextprotocol/inspector dotnet runFollow the instructions in your terminal. You will be prompted to open a URL in your web browser to access the inspector.
From the web interface, you can select a tool like analyze_unity_project. The tool will use the ProjectPath configured in your appsettings.json to run the analysis.