Unity MCP Server

  • Linux
  • Apple

Integrations

  • Supports containerized deployment of the MCP server, allowing the Unity tools to be run in an isolated environment with proper project mounting.

  • Offers integration through the repository hosting, with the server code available at a GitHub repository (unity-smithery-mcp).

  • Built on Node.js as a runtime environment, requiring Node.js 16+ to operate.

Unity MCP 服务器

用于 Unity 游戏开发的模型上下文协议 (MCP) 服务器,使 AI 助手能够通过一组专门的工具与 Unity 项目进行交互。

概述

Unity MCP 服务器在 AI 助手(例如 Cursor AI 或 Claude)和 Unity 项目之间架起了一座桥梁。它提供以下工具:

  • 在 Unity 项目中读取和搜索文件
  • 解析 Unity 场景和预制件
  • 分析 C# 代码并检测错误
  • 以批处理模式运行自动化测试
  • 从模板生成脚本
  • 验证着色器
  • 还有更多...

该服务器设计为以批处理模式与 Unity 一起运行,允许执行需要 Unity 引擎的操作而无需编辑器 GUI。

安装

先决条件

  • Node.js 16+
  • Unity 2022.3 LTS 或更新版本(推荐)

设置

  1. 克隆此存储库:
    git clone https://github.com/GrandMasterK414/unity-smithery-mcp.git cd unity-smithery-mcp
  2. 安装依赖项:
    npm install
  3. 构建项目:
    npm run build

配置

服务器使用config包进行配置。编辑config/default.json来调整设置:

{ "server": { "port": 3000, "host": "0.0.0.0" }, "unity": { "unityPath": "/path/to/Unity/Editor/Unity", "projectPath": "/path/to/your/unity/project", "timeoutMs": 60000, "batchMode": true }, "logging": { "level": "info", "file": "logs/mcp-server.log", "maxSize": 5242880, "maxFiles": 5 }, "security": { "allowedPaths": ["Assets", "ProjectSettings", "Packages"], "disallowedCommands": ["rm", "del", "format", "shutdown"] } }

用法

启动服务器

npm start

要在 Smithery 模式下运行:

npm run smithery:start

与人工智能助手一起使用

此服务器主要用于通过 MCP 规范中定义的工具与 AI 助手协同工作。如需集成 Cursor 或 Smithery.ai,请按照其文档连接到此 MCP 服务器。

可用工具

工具名称描述
open_file读取 Unity 项目中文件的内容
search_files在项目文件中搜索文本模式
list_assets列出特定类型或文件夹中的项目资产
get_project_info获取有关 Unity 项目的高级信息
parse_scene解析 Unity 场景文件以提取游戏对象层次结构
parse_prefab解析 Unity 预制文件以提取组件
find_in_scenes查找包含特定 GameObject 或组件的场景
analyze_cs_code编译 C# 代码以查找编译器错误
find_references查找对 C# 类或方法的引用
generate_script从模板创建一个新的 C# 脚本文件
validate_shader编译着色器并报告错误
inspect_yaml检查 YAML 资产文件
run_tests以批处理模式运行 Unity 的自动化测试
simulate_playmode实验 - 短时间以播放模式运行场景

Docker 支持

包含用于容器化部署的 Dockerfile。构建 Docker 镜像:

docker build -t unity-mcp-server .

运行容器:

docker run -p 3000:3000 -v /path/to/unity/project:/project unity-mcp-server

Smithery.ai 集成

可以使用提供的smithery.yaml配置将此服务器部署在 Smithery.ai 上。

执照

麻省理工学院

贡献

欢迎贡献!请打开一个问题或提交一个拉取请求。

-
security - not tested
F
license - not found
-
quality - not tested

连接 AI 助手和 Unity 项目的协议服务器,允许它们通过专门的工具分析代码、解析场景、生成脚本和执行其他 Unity 操作。

  1. Overview
    1. Installation
      1. Prerequisites
      2. Setup
    2. Configuration
      1. Usage
        1. Starting the Server
        2. Using with AI Assistants
      2. Available Tools
        1. Docker Support
          1. Smithery.ai Integration
            1. License
              1. Contributing

                Related MCP Servers

                • A
                  security
                  F
                  license
                  A
                  quality
                  A Model Context Protocol server that connects Claude and other AI assistants to your Notion workspace, allowing AIs to interact with databases, pages, and blocks.
                  Last updated -
                  12
                  64
                  7
                  JavaScript
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  A Model Context Protocol server that enables AI assistants like Claude to perform Python development tasks through file operations, code analysis, project management, and safe code execution.
                  Last updated -
                  1
                  Python
                  • Linux
                  • Apple
                • -
                  security
                  A
                  license
                  -
                  quality
                  A Unity Master Control Protocol implementation that allows AI agents to control and interact with Unity, enabling them to execute code, query editor state, modify GameObjects, and capture screenshots through a WebSocket-based communication system.
                  Last updated -
                  7
                  MIT License
                  • Linux
                  • Apple
                • -
                  security
                  A
                  license
                  -
                  quality
                  A server that enables AI assistants to understand and interact with Unity projects in real-time, providing access to scene hierarchy, project settings, and the ability to execute code directly in the Unity Editor.
                  Last updated -
                  40
                  MIT License
                  • Linux
                  • Apple

                View all related MCP servers

                ID: hy8ma6m3wa