Skip to content

Unity MCP acts as a bridge, allowing AI assistants (like Claude, Cursor) to interact directly with your Unity Editor via a local MCP (Model Context Protocol) Client. Give your LLM tools to manage assets, control scenes, edit scripts, and automate tasks within Unity.

License

Notifications You must be signed in to change notification settings

CoplayDev/unity-mcp

Repository files navigation

MCP for Unity

English 简体中文

Proudly sponsored and maintained by Coplay -- the best AI assistant for Unity.

Discord Unity Asset Store python

Create your Unity apps with LLMs! MCP for Unity bridges AI assistants (Claude, Cursor, VS Code, etc.) with your Unity Editor via the Model Context Protocol. Give your LLM tools to manage assets, control scenes, edit scripts, and automate tasks.

MCP for Unity building a scene


Quick Start

Prerequisites

1. Install the Unity Package

In Unity: Window > Package Manager > + > Add package from git URL...

Tip

https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity

Need a stable/fixed version? Use a tagged URL (requires uninstall to update):

https://github.com/CoplayDev/unity-mcp.git?path=/MCPForUnity#v9.0.3
Other install options (Asset Store, OpenUPM)

Unity Asset Store:

  1. Visit MCP for Unity on the Asset Store
  2. Click Add to My Assets, then import via Window > Package Manager

OpenUPM:

openupm add com.coplaydev.unity-mcp

2. Start the Server & Connect

  1. In Unity: Window > MCP for Unity
  2. Click Start Server (launches HTTP server on localhost:8080)
  3. Select your MCP Client from the dropdown and click Configure
  4. Look for 🟢 "Connected ✓"
  5. Connect your client: Some clients (Cursor, Windsurf, Antigravity) require enabling an MCP toggle in settings, while others (Claude Desktop, Claude Code) auto-connect after configuration.

That's it! Try a prompt like: "Create a red, blue and yellow cube" or "Build a simple player controller"


Features & Tools

Key Features

  • Natural Language Control — Instruct your LLM to perform Unity tasks
  • Powerful Tools — Manage assets, scenes, materials, scripts, and editor functions
  • Automation — Automate repetitive Unity workflows
  • Extensible — Works with various MCP Clients

Available Tools

manage_assetmanage_editormanage_gameobjectmanage_componentsmanage_materialmanage_prefabsmanage_scenemanage_scriptmanage_scriptable_objectmanage_shadermanage_vfxbatch_executefind_gameobjectsfind_in_fileread_consolerefresh_unityrun_testsget_test_jobexecute_menu_itemapply_text_editsscript_apply_editsvalidate_scriptcreate_scriptdelete_scriptget_sha

Available Resources

custom_toolsunity_instancesmenu_itemsget_testsgameobjectgameobject_componentseditor_stateeditor_selectioneditor_prefab_stageproject_infoproject_tagsproject_layers

Performance Tip: Use batch_execute for multiple operations — it's 10-100x faster than individual calls!

Manual Configuration

If auto-setup doesn't work, add this to your MCP client's config file:

HTTP (default — works with Claude Desktop, Cursor, Windsurf):

{
  "mcpServers": {
    "unityMCP": {
      "url": "http://localhost:8080/mcp"
    }
  }
}

VS Code:

{
  "servers": {
    "unityMCP": {
      "type": "http",
      "url": "http://localhost:8080/mcp"
    }
  }
}
Stdio configuration (legacy)

macOS/Linux:

{
  "mcpServers": {
    "unityMCP": {
      "command": "uv",
      "args": ["run", "--directory", "/Users/YOUR_USERNAME/Library/AppSupport/UnityMCP/UnityMcpServer/src", "server.py", "--transport", "stdio"]
    }
  }
}

Windows:

{
  "mcpServers": {
    "unityMCP": {
      "command": "C:/Users/YOUR_USERNAME/AppData/Local/Microsoft/WinGet/Links/uv.exe",
      "args": ["run", "--directory", "C:/Users/YOUR_USERNAME/AppData/Local/UnityMCP/UnityMcpServer/src", "server.py", "--transport", "stdio"]
    }
  }
}
Multiple Unity Instances

MCP for Unity supports multiple Unity Editor instances. To target a specific one:

  1. Ask your LLM to check the unity_instances resource
  2. Use set_active_instance with the Name@hash (e.g., MyProject@abc123)
  3. All subsequent tools route to that instance
Roslyn Script Validation (Advanced)

For Strict validation that catches undefined namespaces, types, and methods:

  1. Install NuGetForUnity
  2. Window > NuGet Package Manager → Install Microsoft.CodeAnalysis v4.14.0
  3. Also install SQLitePCLRaw.core and SQLitePCLRaw.bundle_e_sqlite3
  4. Add USE_ROSLYN to Player Settings > Scripting Define Symbols
  5. Restart Unity
Manual DLL installation (if NuGetForUnity isn't available)
  1. Download Microsoft.CodeAnalysis.CSharp.dll and dependencies from NuGet
  2. Place DLLs in Assets/Plugins/ folder
  3. Ensure .NET compatibility settings are correct
  4. Add USE_ROSLYN to Scripting Define Symbols
  5. Restart Unity
Troubleshooting
  • Unity Bridge Not Connecting: Check Window > MCP for Unity status, restart Unity
  • Server Not Starting: Verify uv --version works, check the terminal for errors
  • Client Not Connecting: Ensure the HTTP server is running and the URL matches your config

Detailed setup guides:

Still stuck? Open an Issue or Join Discord

Contributing

See README-DEV.md for development setup. For custom tools, see CUSTOM_TOOLS.md.

  1. Fork → Create issue → Branch (feature/your-idea) → Make changes → PR
Telemetry & Privacy

Anonymous, privacy-focused telemetry (no code, no project names, no personal data). Opt out with DISABLE_TELEMETRY=true. See TELEMETRY.md.


License: MIT — See LICENSE | Need help? Discord | Issues


Star History

Star History Chart

Unity AI Tools by Coplay

Coplay offers 2 AI tools for Unity:

  • MCP for Unity is available freely under the MIT license.
  • Coplay is a premium Unity AI assistant that sits within Unity and is more than the MCP for Unity.

(These tools have different tech stacks. See this blog post comparing Coplay to MCP for Unity.)

Coplay

Disclaimer

This project is a free and open-source tool for the Unity Editor, and is not affiliated with Unity Technologies.

About

Unity MCP acts as a bridge, allowing AI assistants (like Claude, Cursor) to interact directly with your Unity Editor via a local MCP (Model Context Protocol) Client. Give your LLM tools to manage assets, control scenes, edit scripts, and automate tasks within Unity.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 37

Languages