
UnityMCP 是一个强大的 Unity 编辑器插件,实现了模型上下文协议(MCP),实现了 Unity 与 AI 助手之间的无缝集成。
概览
UnityMCP 是一款强大的 Unity 编辑器插件,实现了模型上下文协议(MCP),实现了 Unity 与 AI 助手之间的无缝集成。它提供实时编辑器状态监控、远程命令执行和全面的日志功能。 该项目由两个主要组成部分组成: 一个 Unity 编辑器插件,提供:- 用于连接状态和监控的调试窗口 - 用于实时通信的 WebSocket 客户端 - C# 代码执行引擎 - 全面的日志系统 - 编辑器状态跟踪与序列化 一个基于TypeScript的MCP服务器,通过标准化工具展示Unity编辑器的功能: 1. get_editor_state - 检索当前的 Unity 编辑器状态 - 包含活跃的 GameObjects、选择状态、播放模式状态 - 提供场景层级和项目结构 - 支持不同的输出格式(原始文件、仅脚本、无脚本) 2.
概述(AI 翻译)
UnityMCP 是一款强大的 Unity 编辑器插件,实现了模型上下文协议(MCP),实现了 Unity 与 AI 助手之间的无缝集成。它提供实时编辑器状态监控、远程命令执行和全面的日志功能。
建筑
该项目由两个主要组成部分组成:
1.Unity 插件(UnityMCPPlugin)
一个提供以下功能的Unity编辑器插件:
- 用于连接状态和监控的调试窗口
- WebSocket客户端,用于实时通信
- C# 代码执行引擎
- 综合测井系统
- 编辑器状态跟踪与序列化
2.MCP 服务器(unity-mcp-server)
一个基于TypeScript的MCP服务器,通过标准化工具展示Unity编辑器的功能:
可用工具
get_editor_state
- 检索当前Unity编辑器状态
- 包含活跃的GameObjects、选择状态、游戏模式状态
- 提供场景层级和项目结构
- 支持多种输出格式(Raw,仅脚本,无脚本)
execute_editor_command
- 直接在Unity编辑器中执行C#代码
- 完全访问 UnityEngine 和 UnityEditor API
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
UnityMCP 
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
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
-
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)
-
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
-
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:
安装
npx -y @smithery/cli install @Arodoid/unitymcp --client claude