Unity

by arodoid

415 stars
Not rated
GitHub

About

Enables real-time interaction with Unity Editor projects for tasks like automated level design, asset management, and debugging assistance through C# command execution and editor state retrieval.

Details

Author
arodoid
Repository
jackwrichards/UnityMCP
GitHub stars
415
License
Other
Categories
Productivity, Design, Developer Tools, AI, Infrastructure, Security, Project Management, Frontend

- Command execution timeout protection
- Error handling and validation
- Log buffer management
- Connection state monitoring

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Unity
    Command (node, npx, python, etc.) npx
    Arguments
    • Argument 1 -y
    • Argument 2 @highlight/mcp-server

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

To install UnityMCP for Claude Desktop automatically via Smithery:

``bash
npx -y @smithery/cli install @Arodoid/unitymcp --client claude


1. Copy the
UnityMCPPlugin folder to your Unity project's Assets directory
2. Open Unity Editor
3. Access the plugin through Unity's top menu bar > UnityMCP > Debug Window

bash
cd unity-mcp-server
npm install
npm run build
``

get_editor_state

Retrieves current Unity Editor state including active GameObjects, selection state, play mode status, 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 with full access to UnityEngine and UnityEditor APIs. Provides real-time execution with comprehensive error handling and command timeout protection.

get_logs

Retrieves and filters Unity Editor logs, supporting filtering by type, content, and timestamp. Offers customizable output fields and buffer management for optimal performance.

1. 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)

2. 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

3. get_logs
- Retrieves and filters Unity Editor logs
- Supports filtering by type, content, and timestamp
- Customizable output fields
- Buffer management for optimal performance

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "unity": {
            "env": {},
            "args": [
                "-y",
                "@highlight/mcp-server"
            ],
            "command": "npx"
        }
    }
}

Linux

{
    "env": [],
    "args": [
        "-y",
        "@highlight/mcp-server"
    ],
    "command": "npx"
}

Macos

{
    "env": [],
    "args": [
        "-y",
        "@highlight/mcp-server"
    ],
    "command": "npx"
}

Windows

{
    "env": [],
    "args": [
        "/c",
        "npx",
        "-y",
        "@highlight/mcp-server"
    ],
    "command": "cmd"
}
# UnityMCP [![](https://img.shields.io/badge/LinkedIn-0077B5?style=flat&logo=linkedin&logoColor=white 'LinkedIn')](https://www.linkedin.com/in/jack-w-richards/) [![](https://badge.mcpx.dev?type=server 'MCP Server')](https://modelcontextprotocol.io/introduction) [![smithery badge](https://smithery.ai/badge/@Arodoid/unitymcp)](https://smithery.ai/server/@Arodoid/unitymcp) [![](https://img.shields.io/github/last-commit/Arodoid/UnityMCP 'Last Commit')](https://github.com/CoderGamester/mcp-unity/commits/main) <a href="https://github.com/Arodoid/UnityMCP/pulls"><img src="https://img.shields.io/github/issues-pr/Arodoid/UnityMCP" alt="Pull Requests Badge"/></a> <a href="https://github.com/Arodoid/UnityMCP/issues"><img src="https://img.shields.io/github/issues/Arodoid/UnityMCP" alt="Issues Badge"/></a> [![](https://img.shields.io/badge/License-MIT-red.svg 'MIT License')](https://opensource.org/licenses/MIT) <a href="https://github.com/Arodoid/UnityMCP/stargazers"><img src="https://img.shields.io/github/stars/Arodoid/UnityMCP" alt="Stars Badge"/></a> <a href="https://github.com/Arodoid/UnityMCP/network/members"><img src="https://img.shields.io/github/forks/Arodoid/UnityMCP" alt="Forks Badge"/></a> 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. ![UnityMCP](https://github.com/user-attachments/assets/53965337-75b8-4f0e-88d2-b2a4069546f4) ## 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 1. `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) 2. `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 3. `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](https://smithery.ai/server/@Arodoid/unitymcp): ```bash 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 1. Copy the `UnityMCPPlugin` folder to your Unity project's Assets directory 2. Open Unity Editor 3. Access the plugin through Unity's top menu bar > UnityMCP > Debug Window ### MCP Server Setup ```bash cd unity-mcp-server npm install npm run build ``` ## Usage ### Starting the Server ```bash cd unity-mcp-server node build/index.js ``` ### Connecting from Unity 1. Open your Unity project 2. Open the UnityMCP Debug Window (Window > UnityMCP > Debug Window) 3. The plugin will automatically attempt to connect to the MCP server 4. Monitor connection status and logs in the debug window ### Example: Executing Commands ```csharp // 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 ```bash cd unity-mcp-server npm run build ``` ### Watching for Changes ```bash npm run watch ``` ### Inspecting MCP Communication ```bash 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 1. Fork the repository 2. Create your feature branch (`git checkout -b feature/amazing-feature`) 3. Commit your changes (`git commit -m 'Add amazing feature'`) 4. Push to the branch (`git push origin feature/amazing-feature`) 5. Open a Pull Request ## License This project is licensed under the Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0).
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.