UnityMCP

442

UnityMCP is a robust Unity Editor plugin that fully leverages the Model Context Protocol (MCP) for integration between Unity and AI assistants. It offers tools such as editor state monitoring, command execution, and log retrieval, enhancing development workflows for Unity projects with real-time capabilities.

Overview

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

  1. Unity Plugin (UnityMCPPlugin)

    • 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)

    • TypeScript-based MCP server that exposes Unity Editor functionality

Available Tools

  • get_editor_state: Retrieves current Unity Editor state
  • execute_editor_command: Executes C# code directly in the Unity Editor
  • get_logs: Retrieves and filters Unity Editor logs

Installation

  • Prerequisites: Unity 2022.3 or later, Node.js 18 or later, npm 9 or later
  • Unity Plugin Setup: Copy UnityMCPPlugin folder to Unity project's Assets and access via top menu

Usage

  • Start the MCP Server and connect from Unity using the Debug Window
  • Use example commands to interact with Unity objects and play mode

Development

  • Build the server using npm
  • Watch for changes and inspect MCP communication

Technical Details

  • WebSocket-based communication, security features, and error handling