Unity MCP server

Enables real-time interaction with Unity projects through a WebSocket-based system that retrieves scene hierarchies, project settings, and executes C# code directly in the Unity Editor.
Back to servers
Provider
Shahzad
Release date
Mar 20, 2025
Language
C#
Stats
49 stars

The Unity MCP Integration package allows AI assistants to interact with Unity projects in real-time, providing access to scene hierarchies, project settings, and the ability to execute code directly in the Unity Editor environment.

Prerequisites

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

Installation

Installing the Unity Package

Option A: Via 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 the repository or download it as a unityPackage
  2. In Unity, go to Assets > Import Package > Custom Package
  3. Select the UnityMCPIntegration.unitypackage file

Setting up the MCP Server

Option A: Run the server directly

  1. Navigate to the mcpServer directory (typically located at <path-to-project>\Library\PackageCache\com.quaza.unitymcp@d2b8f1260bca\mcpServer\)
  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 or custom implementations:

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

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

Monitor the connection and test features with the MCP Debug window:

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

Available Tools

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

Working with Files

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.

Example filesystem operations:

  • 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")

All file operations are restricted to the Unity project directory for security purposes.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later