中文 | 日本語 | Español
Unity MCP is an AI-powered game development assistant for Editor & Runtime. Connect Claude, Cursor, & Windsurf to Unity via MCP. Automate workflows, generate code, and enable AI within your games.
Unlike other tools, this plugin works inside your compiled game, allowing for real-time AI debugging and player-AI interaction.
💬 Join our Discord Server - Ask questions, showcase your work, and connect with other developers!
- ✔️ AI agents - Use the best agents from Anthropic, OpenAI, Microsoft, or any other provider with no vendor lock-in
- ✔️ Tools - A wide range of default MCP Tools for operating in Unity Editor
- ✔️ Skills - Generate skills for AI based on operating system, Unity version, plugins in the project
- ✔️ Code and Tests - Develop game mechanics and test them with AI agents
- ✔️ Runtime (in-game) - Use LLMs directly inside your compiled game for dynamic NPC behavior or debugging
- ✔️ Debug support - Let AI debug and fix the problems in a project
- ✔️ Natural conversation - Chat with AI like you would with a human
- ✔️ Flexible deployment - Works locally (stdio) and remotely (http) via configuration
- ✔️ Extensible - Create custom Tools in your project code
https://github.com/user-attachments/assets/228baf4d-4f00-4dce-939d-fb985ebdd8dd
OR use cli
# 1. Install unity-mcp-cli
npm install -g unity-mcp-cli
# 2. Install "AI Game Developer" in Unity project
unity-mcp-cli install-plugin ./MyUnityProject
# 3. Sign in to ai-game.dev (opens your browser — OAuth device flow)
unity-mcp-cli login
# 4. Open Unity project (auto-connects and generates skills)
unity-mcp-cli open ./MyUnityProject
Skills and Tools Reference
Since 1.0.0 the plugin exposes a small set of tools, and most Editor work goes through RQL, a query language over the Editor's data: rql-query reads, rql-mutate changes, and rql-schema describes the sources, types and calls (start there when unsure). The one-tool-per-action tools of earlier versions (gameobject-create, scene-save, console-get-logs and others) were replaced by RQL in #1017. See docs/default-mcp-tools.md for the full reference.
🧰 Browse the full MCP tools registry online: ai-game.dev/docs/tools
Shown to the AI agent by default: rql-query, rql-mutate, rql-schema, screenshot-isolated, script-execute, tests-run, unity-tool-list. The other tools are installed but hidden from the agent's tool list (a hidden tool still runs when called by name). Show them with tool-set-visibility, in the AI Game Developer window, or with unity-mcp-cli configure <path> --enable-tools <ids>.
rql-query - Read Editor data with an RQL query, e.g. roots | recurse children | select name active
rql-mutate - Change Editor data or call Editor operations, e.g. editor | call CreateGameObject({name: "Ground", primitive: "Plane"})
rql-schema - Describe the sources, types, members and calls RQL can use, and print the topic guides
- Sources:
scenes, roots, objects (every GameObject in the loaded scenes), selection, prefab (the prefab open in prefab mode), editor (create GameObjects, materials, folders and scenes; open and save scenes and prefabs; copy, move and delete assets; execute menu items; …), settings, console (captured Editor log entries), shaders, componentTypes, tests, testResults, profiler, lighting; assets by path with unity.asset("Assets/…")
screenshot-isolated - Render a GameObject in isolation from a chosen angle (optional composite 2x2 view)
screenshot-scene-view - Captures a screenshot from the Unity Editor Scene View (hidden by default)
screenshot-game-view - Captures a screenshot from the Unity Editor Game View (hidden by default)
screenshot-camera - Captures a screenshot from a camera and returns it as an image (hidden by default)
script-execute - Compiles and executes C# code dynamically using Roslyn
script-read - Reads the content of a script file (hidden by default)
script-update-or-create - Updates or creates script file with the provided C# code (hidden by default)
script-delete - Delete the script file(s) (hidden by default)
tests-run - Execute Unity tests (EditMode/PlayMode): any RQL selection over the tests source as one run, results filtered with RQL
package-list, package-search, package-add, package-remove - Unity Package Manager packages (hidden by default)
unity-tool-list - List every tool and whether the agent sees it
tool-set-visibility - Show or hide tools in the agent's tool list (hidden by default)
tool-set-enabled-state - Deprecated alias of tool-set-visibility (hidden by default)
- RQL source
profiler (via rql-query / rql-mutate) - memory, rendering, script and frame snapshots, module flags; Start, Stop, ClearFrames, EnableModule, Save, Load
- RQL source
lighting (via rql-query / rql-mutate) - the active scene's environment (ambient, fog, skybox, sun, reflections; undoable), its Lighting Settings asset and the bake: CreateSettings, UseSettings, Bake, CancelBake, ClearBakedData, BakeReflectionProbes
LightProbeGroup.PlaceGrid(size, spacing) - fill a box with evenly spaced light probes; ReflectionProbe.Bake() - bake a Custom probe next to its scene
Contents
More Documentation
| Document | Description |
|---|
| Default MCP Tools | Full reference of all built-in tools with descriptions |
| MCP Server Setup | Server configuration, environment variables, remote hosting |
| Docker Deployment | Step-by-step Docker deployment guide |
| Development Guide | Architecture, code style, CI/CD — for contributors |
| Wiki | Getting started, tutorials, API reference, FAQ |
| CLI Tool | Install plugins, configure, and connect via command line |
AI Workflow Examples
Communicate with the AI (LLM) in your AI agent. Ask it to do anything you want. The better you describe your task or idea, the better it will perform the job.
Some AI agents allow you to choose different LLM models. Pay attention to this feature, as some models may work much better than others.
Example prompts:
Explain my scene hierarchy
Create 3 spheres on top of each other
Create metallic golden material and attach it to a new sphere gameObject
Make sure Agent mode is enabled if using VS Code with Copilot
Disabling update notifications for the whole team
The plugin shows an update popup at Editor startup when a newer version is available on OpenUPM. By default, each team member sees this popup until they individually click "Do not show again" (which is a per-user setting stored on their machine).
For multi-person Unity projects where one engineer owns plugin versioning, you can disable the popup for the entire team by opening Edit ▸ Project Settings ▸ AI Game Developer and enabling "Disable update notifications for the entire team". The setting is persisted to ProjectSettings/AI-Game-Developer-UpdateSettings.asset and only needs to be set once per project — commit that file and every team member who pulls the commit will have the popup suppressed.
The same toggle is also reachable via Tools ▸ AI Game Developer ▸ Updates ▸ Disable Update Notifications (Team) in the menu bar.
Advanced Features for LLM
Unity MCP provides advanced tools that enable the LLM to work faster and more effectively, avoiding mistakes and self-correcting when errors occur. Everything is designed to achieve your goals efficiently.
Core Capabilities
- ✔️ Agent-ready tools - Find anything you need in 1-2 steps
- ✔️ Instant compilation - C# code compilation & execution using
Roslyn for faster iteration
- ✔️ Full asset access - Read/write access to assets and C# scripts
- ✔️ Intelligent feedback - Well-described positive and negative feedback for proper issue understanding
Reflection-Powered Features
- ✔️ Object references - Provide references to existing objects for instant C# code
- ✔️ Project data access - Get full access to entire project data in a readable format
- ✔️ Granular modifications - Populate & modify any piece of data in the project
- ✔️ Method discovery - Find any method in the entire codebase, including compiled DLL files
- ✔️ Method execution - Call any method in the entire codebase
- ✔️ Advanced parameters - Provide any property for method calls, even references to existing objects in memory
- ✔️ Live Unity API - Unity API instantly available - even when Unity changes, you get the fresh API
- ✔️ Self-documenting - Access human-readable descriptions of any
class, method, or property via Description attributes
Customize Tools
Unity MCP supports custom MCP Tool, MCP Resource, and MCP Prompt development by project owners. The MCP server takes data from the Unity MCP Plugin and exposes it to a client. Anyone in the MCP communication chain will receive information about new MCP features, which the LLM may decide to use at some point.
Add custom Tool
To add a custom Tool, you need:
- A class with the
AiToolType attribute
- A method in the class with the
AiTool attribute
- Optional: Add a
Description attribute to each method argument to help the LLM understand it
- Optional: Use
string? optional = null properties with ? and default values to mark them as optional for the LLM
Note that the line MainThread.Instance.Run(() => allows you to run code on the main thread, which is required for interacting with Unity's API. If you don't need this and running the tool in a background thread is acceptable, avoid using the main thread for efficiency purposes.
[AiToolType]
public class Tool_GameObject
{
[AiTool
(
"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
)
{
// do anything in background thread
return MainThread.Instance.Run(() =>
{
// do something in main thread if needed
return $"[Success] Operation completed.";
});
}
}
Add custom MCP Prompt
MCP Prompt allows you to inject custom prompts into the conversation with the LLM. It supports two sender roles: User and Assistant. This is a quick way to instruct the LLM to perform specific tasks. You can generate prompts using custom data, providing lists or any other relevant information.
[AiPromptType]
public static class Prompt_ScriptingCode
{
[AiPrompt(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 (in-game)
Use Unity MCP in your game/app. Use Tools, Resources or Prompts. By default there are no tools, you would need to implement your custom.
// Build MCP plugin
var mcpPlugin = UnityMcpPluginRuntime.Initialize(builder =>
{
builder.WithConfig(config =>
{
config.Host = "http://localhost:8080";
config.Token = "your-token";
});
// Automatically register all tools from the current assembly
builder.WithToolsFromAssembly(Assembly.GetExecutingAssembly());
})
.Build();
await mcpPlugin.Connect(); // Start active connection with retry to the MCP server
await mcpPlugin.Disconnect(); // Stop active connection and close existed connection
Sample: AI powered Chess game bot
There is a classic Chess game. Lets outsource to LLM the bot logic. Bot should do the turn using game rules.
Mark game-only tools [AiToolType(Target = ToolTarget.Runtime)] (using com.IvanMurzak.McpPlugin.Common;): only the game registers them, and the MCP server sends their calls to the running game even while the Editor is connected.
[AiToolType(Target = ToolTarget.Runtime)]
public static class ChessGameAI
{
[AiTool("chess-do-turn", Title = "Do the turn")]
[Description("Do the turn in the chess game. Returns true if the turn was accepted, false otherwise.")]
public static Task<bool> DoTurn(int figureId, Vector2Int position)
{
return MainThread.Instance.RunAsync(() => ChessGameController.Instance.DoTurn(figureId, position));
}
[AiTool("chess-get-board", Title = "Get the board")]
[Description("Get the current state of the chess board.")]
public static Task<BoardData> GetBoard()
{
return MainThread.Instance.RunAsync(() => ChessGameController.Instance.GetBoardData());
}
}
Why runtime usage is needed?
There are many use cases, lets imagine you are working on a Chess game with bot. You may outsource the bot decision making to LLM by writing few lines of code.
Unity MCP Server setup
Unity MCP Server supports many different launch options and Docker deployment. Both transport protocols are supported: streamableHttp and stdio. If you need to customize or deploy Unity MCP Server to a cloud, this section is for you. Read more...
Variables
Doesn't matter what launch option you choose, all of them support custom configuration using both Environment Variables and Command Line Arguments. It would work with default values, if you just need to launch it, don't waste your time for the variables. Just make sure Unity Plugin also has default values, especially the --port, they should be equal.
| Environment Variable | Command Line Args | Description |
|---|
MCP_PLUGIN_PORT | --port | Client -> Server <- Plugin connection port (default: 8080) |
MCP_PLUGIN_CLIENT_TIMEOUT | --plugin-timeout | Plugin -> Server connection timeout (ms) (default: 10000) |
MCP_PLUGIN_TOOL_TIMEOUT | --tool-timeout | How long the Server waits for one tool call (ms). A tool call is sent to the Plugin once, never re-sent (default: 300000, or --plugin-timeout if larger; servers built on McpPlugin 8.11.0+) |
MCP_PLUGIN_CLIENT_TRANSPORT | --client-transport | Client -> Server transport type: stdio or streamableHttp (default: streamableHttp) |
MCP_AUTHORIZATION | --authorization | Authentication mode for incoming Client connections: none, oauth, or token (default: none; the legacy required mode was removed) |
MCP_PLUGIN_TOKEN | --token | Bearer token required from the Client when authorization is token (default: unset) |
MCP_PLUGIN_IDLE_TIMEOUT_SECONDS | --idle-timeout-seconds | Shut down the server after this many seconds with no connections (default: 600) |
Command line args support also the option with a single - prefix (-port) and an option without prefix at all (port).
For analytics and authorization webhook variables (MCP_PLUGIN_WEBHOOK_*), see docs/mcp-server.md.
Choosing a transport: Use stdio when the MCP client launches the server binary directly (local use — this is the most common setup). Use streamableHttp when running the server as a standalone process or in Docker/cloud, and connecting over HTTP.
Plugin Variables
The Unity MCP Plugin reads the following environment variables (and command-line arguments) on startup to override values from the saved config file. Overrides are applied in memory only and are never written to the config file (UserSettings/AI-Game-Developer-Config.json), so the saved values (for example connectionMode or transportMethod) still show what was chosen in the AI Game Developer window. To change a setting permanently, change it in the window, in an Editor started without that override (while an override is active, a change to the same setting in the window is not kept).
| Environment Variable | Command Line Arg | Values | Description |
|---|
UNITY_MCP_CLOUD_URL | -url | URL string | Override the MCP Server URL (UNITY_MCP_HOST is a legacy alias) |
UNITY_MCP_CONNECTION_MODE | -UNITY_MCP_CONNECTION_MODE | Cloud / Custom | Force the connection mode (a loopback URL implies Custom) |
UNITY_MCP_KEEP_CONNECTED | -UNITY_MCP_KEEP_CONNECTED | true / false | Force enable or disable the active connection |
UNITY_MCP_AUTH_OPTION | -auth | none / oauth / token | Force set the authentication mode (legacy required migrates to token) |
UNITY_MCP_TOKEN | -token | string | Force set the authentication token |
UNITY_MCP_TRANSPORT | -UNITY_MCP_TRANSPORT | stdio / streamableHttp | Force the client transport the plugin configures |
UNITY_MCP_START_SERVER | -UNITY_MCP_START_SERVER | true / false | Force whether the plugin keeps a local server process running |
UNITY_MCP_TOOLS | -UNITY_MCP_TOOLS | comma-separated tool IDs | Show only the listed tools to MCP clients (tools/list); all others are hidden (a hidden tool still runs when called by name). Unknown IDs are logged as errors. |
UNITY_MCP_CREDENTIALS_DIR | — (environment only) | absolute folder path | Read (and refresh) the machine credential store from this folder instead of ~/.ai-game-dev. For development/test Editors whose launcher signs in under another profile (the AI Game Dev App's local dev stand); a path, never a token. A relative value is logged and ignored |
Command-line args take precedence over environment variables. Both override the saved config file value. The short flags -url, -token, and -auth are aliases; the full -UNITY_MCP_* arg names are also accepted.
Example (CI/CD batch mode):
Unity.exe -batchmode -nographics \
-UNITY_MCP_CLOUD_URL=http://localhost:8080 \
-UNITY_MCP_KEEP_CONNECTED=true \
-UNITY_MCP_AUTH_OPTION=token \
-UNITY_MCP_TOKEN=my-secret-token
Docker 📦
Make sure Docker is installed. And please make sure Docker Desktop is launched if you are at Windows operation system.
Read advanced Docker configuration instructions.
streamableHttp Transport
docker run -p 8080:8080 aigamedeveloper/mcp-server
{
"mcpServers": {
"ai-game-developer": {
"url": "http://localhost:8080"
}
}
}
Replace url with your real endpoint if it is hosted in cloud.
stdio Transport
For using this variant, MCP Client should launch the MCP Server in the docker. It is achievable through the modified MCP Client configuration.
docker run -t -e MCP_PLUGIN_CLIENT_TRANSPORT=stdio -p 8080:8080 aigamedeveloper/mcp-server
{
"mcpServers": {
"ai-game-developer": {
"command": "docker",
"args": [
"run",
"-t",
"-e",
"MCP_PLUGIN_CLIENT_TRANSPORT=stdio",
"-p",
"8080:8080",
"aigamedeveloper/mcp-server"
]
}
}
}
Custom port
docker run -e MCP_PLUGIN_PORT=123 -p 123:123 aigamedeveloper/mcp-server
{
"mcpServers": {
"ai-game-developer": {
"url": "http://localhost:123"
}
}
}
Replace url with your real endpoint if it is hosted in cloud
Binary executable
You may launch Unity MCP Server directly from a binary file. You would need to have a binary compiled specifically for your CPU architecture. Check GitHub Release Page, it contains pre-compiled binaries for all CPU architectures.
./gamedev-mcp-server --port 8080 --plugin-timeout 10000 --client-transport stdio
Replace <project> with your Unity project path.
{
"mcpServers": {
"ai-game-developer": {
"command": "<project>/Library/mcp-server/win-x64/gamedev-mcp-server.exe",
"args": [
"--port=8080",
"--plugin-timeout=10000",
"--client-transport=stdio"
]
}
}
}
How Unity MCP Architecture Works
Unity MCP serves as a bridge between LLMs and Unity. It exposes and explains Unity's tools to the LLM, which then understands the interface and utilizes the tools according to user requests.
Connect Unity MCP to LLM clients such as Claude or Cursor using the integrated AI Connector window. Custom clients are also supported.
The system is highly extensible - you can define custom MCP Tools, MCP Resource or MCP Prompt directly in your Unity project codebase, exposing new capabilities to AI or automation clients. This makes Unity MCP a flexible foundation for building advanced workflows, rapid prototyping, and integrating AI-driven features into your development process.
What is MCP
MCP - Model Context Protocol. In a few words, that is USB Type-C for AI, specifically for LLM (Large Language Model). It teaches LLM how to use external features. Such as Unity Engine in this case, or even your custom C# method in your code. Official documentation.
What is AI agent
It is an application with a chat window. It may have smart agents to operate better, it may have embedded advanced MCP Tools. In general well done MCP Client is 50% of the AI success of executing a task. That is why it is very important to choose the best one for usage.
What is MCP Server
It is a bridge between MCP Client and "something else", in this particular case it is Unity Engine. This project includes MCP Server.
What is MCP Tool
MCP Tool is a function or method that the LLM can call to interact with Unity. These tools act as the bridge between natural language requests and actual Unity operations. When you ask the AI to "create a cube" or "change material color," it uses MCP Tools to execute these actions.
Key characteristics:
- Executable functions that perform specific operations
- Typed parameters with descriptions to help the LLM understand what data to provide
- Return values that give feedback about the operation's success or failure
- Thread-aware - can run on main thread for Unity API calls or background thread for heavy processing
When to use Tool
- Automate repetitive tasks - Create tools for common operations you do frequently
- Complex operations - Bundle multiple Unity API calls into a single, easy-to-use tool
- Project-specific workflows - Build tools that understand your project's specific structure and conventions
- Error-prone tasks - Create tools that include validation and error handling
- Custom game logic - Expose your game's systems to AI for dynamic content creation
Examples:
- Creating and configuring GameObjects with specific components
- Batch processing assets (textures, materials, prefabs)
- Setting up lighting and post-processing effects
- Generating level geometry or placing objects procedurally
- Configuring physics settings or collision layers
What is MCP Resource
MCP Resource provides read-only access to data within your Unity project. Unlike MCP Tools that perform actions, Resources allow the LLM to inspect and understand your project's current state, assets, and configuration. Think of them as "sensors" that give the AI context about your project.
Key characteristics:
- Read-only access to project data and Unity objects
- Structured information presented in a format the LLM can understand
- Real-time data that reflects the current state of your project
- Contextual awareness helping the AI make informed decisions
When to use MCP Resource
- Project analysis - Let AI understand your project structure, assets, and organization
- Debugging assistance - Provide current state information for troubleshooting
- Intelligent suggestions - Give AI context to make better recommendations
- Documentation generation - Automatically create documentation based on project state
- Asset management - Help AI understand what assets are available and their properties
Examples:
- Exposing scene hierarchy and GameObject properties
- Listing available materials, textures, and their settings
- Showing script dependencies and component relationships
- Displaying current lighting setup and render pipeline configuration
- Providing information about audio sources, animations, and particle systems
What is MCP Prompt
MCP Prompt allows you to inject pre-defined prompts into the conversation with the LLM. These are smart templates that can provide context, instructions, or knowledge to guide the AI's behavior. Prompts can be static text or dynamically generated based on your project's current state.
Key characteristics:
- Contextual guidance that influences how the AI responds
- Role-based - can simulate different personas (User requests or Assistant knowledge)
- Dynamic content - can include real-time project data
- Reusable templates for common scenarios and workflows
When to use MCP Prompt
- Provide domain knowledge - Share best practices and coding standards specific to your project
- Set coding conventions - Establish naming conventions, architecture patterns, and code style
- Give context about project structure - Explain how your project is organized and why
- Share workflow instructions - Provide step-by-step procedures for common tasks
- Inject specialized knowledge - Add information about specific Unity features, third-party assets, or custom systems
Examples:
- "Always use PascalCase for public methods and camelCase for private fields"
- "This project uses a custom event system located in Scripts/Events/"
- "When creating UI elements, always add them to the Canvas in Scene/UI/MainCanvas"
- "Performance is critical - prefer object pooling for frequently instantiated objects"
- "This project follows SOLID principles - explain any architecture decisions"
Uninstall 🧹
To completely remove the plugin from your Unity project:
- Open Window ▸ Package Manager, select the AI Game Developer — MCP package, and click Remove.
- Close Unity, then delete the
Assets/Plugins/NuGet folder (along with its Assets/Plugins/NuGet.meta file).
Contribution 💙💛
Contributions are highly appreciated. Bring your ideas and let's make game development simpler than ever before! Do you have an idea for a new Tool or feature, or did you spot a bug and know how to fix it?
Please give this project a star 🌟 if you find it useful!
- 👉 Read Development documentation
- 👉 Fork the project
- Clone the fork and open the
./Unity-MCP-Plugin folder in Unity
- Implement new things in the project, commit, push it to GitHub
- Create Pull Request targeting original Unity-MCP repository,
main branch.