Cover image
Try Now
2025-03-22

使AI代理能够控制统一

3 years

Works with Finder

3

Github Watches

7

Github Forks

35

Github Stars

🚀 Advacned Unity MCP Integration

MCP smithery badge Unity Node.js TypeScript WebSockets

Stars Forks License

Unity MCP Inspector

This package provides a seamless integration between Model Context Protocol (MCP) and Unity Editor, allowing AI assistants to understand and interact with your Unity projects in real-time. With this integration, AI assistants can access information about your scene hierarchy, project settings, and execute code directly in the Unity Editor context.

📚 Features

  • Browse and manipulate project files directly
  • Access real-time information about your Unity project
  • Understand your scene hierarchy and game objects
  • Execute C# code directly in the Unity Editor
  • Monitor logs and errors
  • Control the Editor's play mode
  • Wait For Code Execution

🚀 Getting Started

Prerequisites

  • Unity 2021.3 or later
  • Node.js 18+ (for running the MCP server)

Installation

1. Install Unity Package

You have several options to install the Unity package:

Option A: Package Manager (Git URL)

  1. Open the Unity Package Manager (Window > Package Manager)
  2. Click the + button and select Add package from git URL...
  3. Enter the repository URL: https://github.com/quazaai/UnityMCPIntegration.git
  4. Click Add

Option B: Import Custom Package

  1. Clone this repository or download it as a unityPackage
  2. In Unity, go to Assets > Import Package > Custom Package
  3. Select the UnityMCPIntegration.unitypackage file

2. Set up the MCP Server

You have two options to run the MCP server:

Option A: Run the server directly

  1. Navigate to the mcpServer (likely <path-to-project>\Library\PackageCache\com.quaza.unitymcp@d2b8f1260bca\mcpServer\) directory
  2. Install dependencies:
    npm install
    
  3. Run the server:
    node build/index.js
    

Option B: Add to MCP Host configuration

Add the server to your MCP Host configuration for Claude Desktop, Custom Implementation etc

{
  "mcpServers": {
    "unity-mcp-server": {
      "command": "node",
      "args": [
        "path-to-project>\\Library\\PackageCache\\com.quaza.unitymcp@d2b8f1260bca\\mcpServer\\mcpServer\\build\\index.js"
      ],
      "env": {
        "MCP_WEBSOCKET_PORT": "5010"
      }
    }
  }
}

Demo Video

YouTube

Installing via Smithery

To install Unity MCP Integration for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @quazaai/unitymcpintegration --client claude

🔧 Usage

Debugging and Monitoring

You can open the MCP Debug window in Unity to monitor the connection and test features:

  1. Go to Window > MCP Debug
  2. Use the debug window to:
    • Check connection status
    • Test code execution
    • View logs
    • Monitor events

Available Tools

The Unity MCP integration provides several tools to AI assistants:

Unity Editor Tools
  • get_editor_state: Get comprehensive information about the Unity project and editor state
  • get_current_scene_info: Get detailed information about the current scene
  • get_game_objects_info: Get information about specific GameObjects in the scene
  • execute_editor_command: Execute C# code directly in the Unity Editor
  • get_logs: Retrieve and filter Unity console logs
  • verify_connection: Check if there's an active connection to Unity Editor
Filesystem Tools
  • read_file: Read contents of a file in your Unity project
  • read_multiple_files: Read multiple files at once
  • write_file: Create or overwrite a file with new content
  • edit_file: Make targeted edits to existing files with diff preview
  • list_directory: Get a listing of files and folders in a directory
  • directory_tree: Get a hierarchical view of directories and files
  • search_files: Find files matching a search pattern
  • get_file_info: Get metadata about a specific file or directory
  • find_assets_by_type: Find all assets of a specific type (e.g. Material, Prefab)
  • list_scripts: Get a listing of all C# scripts in the project

File paths can be absolute or relative to the Unity project's Assets folder. For example, "Scenes/MyScene.unity" refers to <project>/Assets/Scenes/MyScene.unity.

🛠️ Architecture

The integration consists of two main components:

  1. Unity Plugin (C#): Resides in the Unity Editor and provides access to Editor APIs
  2. MCP Server (TypeScript/Node.js): Implements the MCP protocol and communicates with the Unity plugin

Communication between them happens via WebSocket, transferring JSON messages for commands and data.

File System Access

The Unity MCP integration now includes powerful filesystem tools that allow AI assistants to:

  • Browse, read, and edit files in your Unity project
  • Create new files and directories
  • Search for specific files or asset types
  • Analyze your project structure
  • Make targeted code changes with diff previews

All file operations are restricted to the Unity project directory for security. The system intelligently handles both absolute and relative paths, always resolving them relative to your project's Assets folder for convenience.

Example usages:

  • Get a directory listing: list_directory(path: "Scenes")
  • Read a script file: read_file(path: "Scripts/Player.cs")
  • Edit a configuration file: edit_file(path: "Resources/config.json", edits: [{oldText: "value: 10", newText: "value: 20"}], dryRun: true)
  • Find all materials: find_assets_by_type(assetType: "Material")

👥 Contributing

Contributions are welcome! Here's how you can contribute:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Make your changes
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Open a Pull Request

Development Setup

Unity Side:

  • Open the project in Unity
  • Modify the C# scripts in the UnityMCPConnection/Editor directory

Server Side:

  • Navigate to the mcpServer directory
  • Install dependencies: npm install
  • Make changes to the TypeScript files in the src directory
  • Build the server: npm run build
  • Run the server: node build/index.js

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

📞 Support

If you encounter any issues or have questions, please file an issue on the GitHub repository.

相关推荐

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • lumpenspace
  • Take an adjectivised noun, and create images making it progressively more adjective!

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • https://zenepic.net
  • Embark on a thrilling diplomatic quest across a galaxy on the brink of war. Navigate complex politics and alien cultures to forge peace and avert catastrophe in this immersive interstellar adventure.

  • apappascs
  • 发现市场上最全面,最新的MCP服务器集合。该存储库充当集中式枢纽,提供了广泛的开源和专有MCP服务器目录,并提供功能,文档链接和贡献者。

  • ShrimpingIt
  • MCP系列GPIO Expander的基于Micropython I2C的操作,源自ADAFRUIT_MCP230XX

  • jae-jae
  • MCP服务器使用剧作《无头浏览器》获取网页内容。

  • ravitemer
  • 一个功能强大的Neovim插件,用于管理MCP(模型上下文协议)服务器

  • patruff
  • Ollama和MCP服务器之间的桥梁,使本地LLMS可以使用模型上下文协议工具

  • pontusab
  • 光标与风浪冲浪社区,查找规则和MCP

  • av
  • 毫不费力地使用一个命令运行LLM后端,API,前端和服务。

  • appcypher
  • 很棒的MCP服务器 - 模型上下文协议服务器的策划列表

  • Mintplex-Labs
  • 带有内置抹布,AI代理,无代理构建器,MCP兼容性等的多合一桌面和Docker AI应用程序。

  • chongdashu
  • 使用模型上下文协议(MCP),启用Cursor,Windsurf和Claude Desktop等AI助手客户,以通过自然语言控制虚幻引擎。

    Reviews

    5 (1)
    Avatar
    user_P9lZBFek
    2025-04-17

    UnityMCPIntegration by quazaai is an outstanding addition to any Unity developer's toolkit. The seamless integration and comprehensive documentation make it incredibly easy to use, even for those new to MCP applications. The support provided via the product's GitHub page ensures any issues are promptly addressed. Highly recommend for developers looking to enhance their Unity projects!