Unity MCP Server

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 Server

A Model Context Protocol (MCP) server for Unity game development, enabling AI assistants to interact with Unity projects through a set of specialized tools.

Overview

The Unity MCP Server provides a bridge between AI assistants (like Cursor AI or Claude) and Unity projects. It offers tools for:

  • Reading and searching files in Unity projects
  • Parsing Unity scenes and prefabs
  • Analyzing C# code and detecting errors
  • Running automated tests in batch mode
  • Generating scripts from templates
  • Validating shaders
  • And more...

The server is designed to run with Unity in batch mode, allowing for operations that require the Unity engine without needing the Editor GUI.

Installation

Prerequisites

  • Node.js 16+
  • Unity 2022.3 LTS or newer (recommended)

Setup

  1. Clone this repository:
    git clone https://github.com/GrandMasterK414/unity-smithery-mcp.git cd unity-smithery-mcp
  2. Install dependencies:
    npm install
  3. Build the project:
    npm run build

Configuration

The server uses the config package for configuration. Edit config/default.json to adjust settings:

{ "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"] } }

Usage

Starting the Server

npm start

To run in Smithery mode:

npm run smithery:start

Using with AI Assistants

This server is primarily designed to work with AI assistants through tools defined in the MCP specification. For Cursor or Smithery.ai integration, follow their documentation to connect to this MCP server.

Available Tools

Tool NameDescription
open_fileReads the contents of a file in the Unity project
search_filesSearches for text patterns in project files
list_assetsLists project assets of a certain type or in a folder
get_project_infoGets high-level information about the Unity project
parse_sceneParses a Unity scene file to extract game objects hierarchy
parse_prefabParses a Unity prefab file to extract components
find_in_scenesFinds scenes containing a specific GameObject or component
analyze_cs_codeCompiles C# code to find compiler errors
find_referencesFinds references to a C# class or method
generate_scriptCreates a new C# script file from a template
validate_shaderCompiles a shader and reports errors
inspect_yamlInspects a YAML asset file
run_testsRuns Unity's automated tests in batch mode
simulate_playmodeExperimental - runs a scene in play mode for a short duration

Docker Support

A Dockerfile is included for containerized deployment. Build the Docker image:

docker build -t unity-mcp-server .

Run the container:

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

Smithery.ai Integration

This server can be deployed on Smithery.ai using the provided smithery.yaml configuration.

License

MIT

Contributing

Contributions are welcome! Please open an issue or submit a pull request.

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

A protocol server that bridges AI assistants with Unity projects, allowing them to analyze code, parse scenes, generate scripts, and perform other Unity operations through specialized tools.

  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