Unity MCP server

Server + Plugin for Unity Editor and Unity game. The Plugin allows to connect to MCP clients like Claude Desktop or others.
Back to servers
Setup instructions
Provider
Ivan Murzak
Release date
Apr 15, 2025
Language
C#
Stats
546 stars

The Unity MCP Server provides a bridge between Large Language Models (LLMs) and Unity, allowing AI to interact with your Unity project through simple text commands. It implements the Model Context Protocol (MCP) to enable AI assistants to understand and use Unity's functionality.

Installation and Setup

To set up the Unity MCP Server, you need to:

  1. Install the Unity MCP Plugin
  2. Install an MCP Client
  3. Configure the MCP Client to connect to your Unity project

Installing Unity MCP Plugin

The plugin can be installed in your Unity project using one of these methods:

Using OpenUPM

openupm add com.ivanmurzak.unity.mcp

Installing an MCP Client

Choose one of these MCP clients to communicate with the server:

  • Claude Code (highly recommended)
  • Claude Desktop
  • GitHub Copilot in VS Code
  • Cursor
  • Windsurf
  • Any other MCP-compatible client

You only need to install one of these clients as your interface for communicating with the AI.

Configuring the MCP Client

Automatic Configuration

  1. Open your Unity project
  2. Navigate to Window/AI Game Developer (Unity-MCP)
  3. Click the Configure button for your chosen MCP client

Manual Configuration Using Command Line

  1. Choose the appropriate command for your platform:

For Windows x64:

"<unityProjectPath>/Library/mcp-server/win-x64/unity-mcp-server.exe" port=<port> client-transport=stdio

For macOS (Apple Silicon):

"<unityProjectPath>/Library/mcp-server/osx-arm64/unity-mcp-server" port=<port> client-transport=stdio
  1. Add the MCP server to your client. For example, with Claude Code:
claude mcp add ai-game-developer <command>

Using the MCP Server

Once configured, you can communicate with the AI through your MCP client. Simply type commands in natural language, and the AI will understand what you want to do in Unity.

Example Commands

Explain my scene hierarchy
Create 3 cubes in a circle with radius 2
Create metallic golden material and attach it to a sphere gameObject

Advanced Server Configuration

The MCP Server supports various deployment options:

Docker Deployment

docker run -p 8080:8080 ivanmurzakdev/unity-mcp-server

For STDIO transport mode:

docker run -t -e UNITY_MCP_CLIENT_TRANSPORT=stdio -p 8080:8080 ivanmurzakdev/unity-mcp-server

Custom Port Configuration

docker run -e UNITY_MCP_PORT=123 -p 123:123 ivanmurzakdev/unity-mcp-server

Binary Executable

You can run the MCP server directly from its binary executable:

./unity-mcp-server --port 8080 --plugin-timeout 10000 --client-transport stdio

Customizing the MCP Server

You can extend the server's functionality by creating custom MCP Tools:

[McpPluginToolType]
public class Tool_GameObject
{
    [McpPluginTool
    (
        "MyCustomTask",
        Title = "Create a new GameObject"
    )]
    [Description("Explain here to LLM what is this, when it should be called.")]
    public string CustomTask
    (
        [Description("Explain to LLM what is this.")]
        string inputData
    )
    {
        // Background thread code
        return MainThread.Instance.Run(() =>
        {
            // Main thread code (for Unity API interactions)
            return "[Success] Operation completed.";
        });
    }
}

Custom prompts can also be added to guide the AI:

[McpPluginPromptType]
public static class Prompt_ScriptingCode
{
    [McpPluginPrompt(Name = "add-event-system", Role = Role.User)]
    [Description("Implement UnityEvent-based communication system between GameObjects.")]
    public string AddEventSystem()
    {
        return "Create event system using UnityEvents, UnityActions, or custom event delegates for decoupled communication between game systems and components.";
    }
}

Runtime Usage

You can also use the MCP server during runtime in your games:

// Start the plugin
UnityMcpPlugin.BuildAndStart();

// Connect to the server with retry
UnityMcpPlugin.Connect();

// Disconnect when no longer needed
UnityMcpPlugin.Disconnect();

This enables AI-powered features in your game, such as AI opponents or dynamic content generation.

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "unity-mcp" '{"command":"dotnet","args":["run","--project","path/to/unity-mcp"]}'

See the official Claude Code MCP documentation for more details.

For 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 > Tools & Integrations and click "New MCP Server".

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

{
    "mcpServers": {
        "unity-mcp": {
            "command": "dotnet",
            "args": [
                "run",
                "--project",
                "path/to/unity-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 explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "unity-mcp": {
            "command": "dotnet",
            "args": [
                "run",
                "--project",
                "path/to/unity-mcp"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

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