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.
To set up the Unity MCP Server, you need to:
The plugin can be installed in your Unity project using one of these methods:
openupm add com.ivanmurzak.unity.mcp
Choose one of these MCP clients to communicate with the server:
You only need to install one of these clients as your interface for communicating with the AI.
Window/AI Game Developer (Unity-MCP)Configure button for your chosen MCP clientFor 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
claude mcp add ai-game-developer <command>
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.
Explain my scene hierarchy
Create 3 cubes in a circle with radius 2
Create metallic golden material and attach it to a sphere gameObject
The MCP Server supports various deployment options:
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
docker run -e UNITY_MCP_PORT=123 -p 123:123 ivanmurzakdev/unity-mcp-server
You can run the MCP server directly from its binary executable:
./unity-mcp-server --port 8080 --plugin-timeout 10000 --client-transport stdio
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.";
}
}
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.
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.
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.
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"
]
}
}
}
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.
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.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json%APPDATA%\Claude\claude_desktop_config.json~/.config/Claude/claude_desktop_config.json2. 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