Cover image
Try Now
2025-03-19

3 years

Works with Finder

17

Github Watches

45

Github Forks

415

Github Stars

UnityMCP

smithery badge

Pull Requests Badge Issues Badge

Stars Badge Forks Badge

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

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:

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

cd unity-mcp-server
npm install
npm run build

Usage

Starting the Server

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

// 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

cd unity-mcp-server
npm run build

Watching for Changes

npm run watch

Inspecting MCP Communication

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

相关推荐

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

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

  • Alexandru Strujac
  • Efficient thumbnail creator for YouTube videos

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

  • Beria Joey
  • 你的职业规划师,不走弯路就问我。Sponsor:小红书“ ItsJoe就出行 ”

  • Benedikt Ess
  • FindetundanalysiertOnlineProdukteeinschlielichAmazonnachVolumenBewertungenundPreis

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

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

  • GeyserMC
  • 与Minecraft客户端/服务器通信的库。

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

  • 1Panel-dev
  • 🔥1Panel提供了直观的Web接口和MCP服务器,用于在Linux服务器上管理网站,文件,容器,数据库和LLMS。

  • awslabs
  • AWS MCP服务器 - 将AWS最佳实践直接带入您的开发工作流程的专门MCP服务器

  • WangRongsheng
  • 🧑‍🚀 llm 资料总结(数据处理、模型训练、模型部署、 o1 模型、mcp 、小语言模型、视觉语言模型)|摘要世界上最好的LLM资源。

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

  • GLips
  • MCP服务器向像光标这样的AI编码代理提供FIGMA布局信息

  • idosal
  • 结束幻觉! GITMCP是任何GitHub项目的免费,开源的远程MCP服务器

    Reviews

    3 (1)
    Avatar
    user_2cHCS0Rf
    2025-04-17

    As a dedicated user of UnityMCP, I can confidently say this tool by Arodoid is a game-changer for Unity developers. The seamless integration and user-friendly interface make managing multiple core projects easier and more efficient. Highly recommend checking it out on GitHub!