AI-powered Unity Editor integration via Model Context Protocol. Generate games, manipulate scenes, and automate Unity workflows directly from Cursor/Claude!
An MCP (Model Context Protocol) server that connects AI assistants like Claude/Cursor to Unity Editor, enabling:
- ๐ค AI-powered game generation - "Create a platformer level with enemies"
- ๐จ Scene manipulation - Create, modify, delete GameObjects via natural language
- โ๏ธ Component configuration - Setup physics, materials, lighting with AI
- ๐ฆ Asset management - Generate prefabs, materials, scripts automatically
- ๐ผ๏ธ UI generation - Create complete UI systems instantly
- ๐ Script generation - Auto-generate MonoBehaviour/NetworkBehaviour scripts
Option A: Use with npx (No installation needed)
{
"mcpServers": {
"unity": {
"command": "npx",
"args": ["-y", "mcp-unity-server-yamansivrikaya"]
}
}
}
Option B: From GitHub
{
"mcpServers": {
"unity": {
"command": "npx",
"args": ["-y", "github:EYamanS/mcp-unity-server"]
}
}
}
Add the above to your .cursor/mcp.json
file.
Prerequisites:
- Unity 2020.3+
- Newtonsoft.Json package (see installation guide)
Installation:
# Clone or download this repo
git clone https://github.com/EYamanS/mcp-unity-server.git
# Copy Unity bridge to your project
cp -r mcp-unity-server/UnityMCP/* /path/to/YourUnityProject/Assets/Editor/UnityMCP/
Install Newtonsoft.Json in Unity:
- Open Package Manager:
Window > Package Manager
- Click
+
โAdd package by name
- Enter:
com.unity.nuget.newtonsoft-json
- Click
Add
- Restart Cursor to load MCP server
- Open Unity Editor with your project
- Verify connection:
Window > Unity MCP > Control Panel
(should show green โ) - Start creating! Ask AI to generate game objects
Ask your AI assistant:
"Create a simple platformer level in Unity with a player sphere that has physics, a ground plane, some cube obstacles positioned randomly, a camera at (0, 5, -10) looking at the player, and directional lighting"
The AI will automatically:
- Create primitives for ground and obstacles
- Setup player with Rigidbody and collider
- Add and position camera
- Create directional light
- Position everything correctly
- Save the scene
GameObjects
Components
Physics
|
Assets
Rendering
UI
Scene
|
GameObject Operations (11 tools)
unity_create_gameobject
- Create empty GameObjectunity_delete_gameobject
- Delete GameObjectunity_clone_gameobject
- Duplicate with all componentsunity_set_gameobject_transform
- Set position/rotation/scaleunity_set_gameobject_active
- Enable/disableunity_set_gameobject_parent
- Change parentunity_set_gameobject_tag
- Set tagunity_set_gameobject_layer
- Set layerunity_create_primitive
- Create Cube, Sphere, etc.unity_batch_create_gameobjects
- Create multiple at onceunity_get_gameobject_info
- Get full details
Component Operations (4 tools)
unity_add_component
- Add component to GameObjectunity_remove_component
- Remove componentunity_get_component_properties
- Get all propertiesunity_set_component_property
- Set any property value
Physics Tools (2 tools)
unity_configure_rigidbody
- Setup mass, drag, gravityunity_configure_collider
- Setup Box/Sphere/Capsule/Mesh colliders
Material System (4 tools)
unity_create_material
- Create new materialunity_list_materials
- List all materialsunity_set_material_property
- Set color, texture, etc.unity_assign_material
- Assign to renderer
Prefab Workflow (3 tools)
unity_list_prefabs
- List all prefabsunity_instantiate_prefab
- Spawn in sceneunity_create_prefab
- Save GameObject as prefab
UI Generation (3 tools)
unity_create_canvas
- Create UI Canvasunity_create_ui_element
- Create Button/Text/Image/Panel/InputField/Sliderunity_set_rect_transform
- Configure anchors, size, position
See UnityMCP/TOOLS_REFERENCE.md for complete API reference
Plus tools for: Lighting, Camera, Scene Management, Script Generation, Audio, Particles, Terrain, Animation, Console, and more!
Clean, modular design following SOLID principles:
โโโโโโโโโโโโโโโ
โ Cursor โ (AI Assistant)
โโโโโโโโฌโโโโโโโ
โ stdio (MCP Protocol)
โผ
โโโโโโโโโโโโโโโโโโโ
โ Node.js MCP โ (This Server)
โ Server โ
โโโโโโโโฌโโโโโโโโโโโ
โ WebSocket (port 8765)
โผ
โโโโโโโโโโโโโโโโโโโ
โ Unity C# Bridgeโ (18 Tool Classes)
โโโโโโโโฌโโโโโโโโโโโ
โ Unity Editor API
โผ
โโโโโโโโโโโโโโโโโโโ
โ Unity Editor โ (Your Game)
โโโโโโโโโโโโโโโโโโโ
Unity Bridge Structure:
- Partial Classes: Organized by responsibility
- 18 Specialized Tools: Each category in its own file
- Router Pattern: Central dispatch to appropriate handler
- Shared Utilities: Common operations abstracted
- Node.js 18+ (Download)
- Unity 2020.3+ (tested on Unity 6)
- Cursor with MCP support
- Newtonsoft.Json in Unity (usually pre-installed)
- Configure Cursor - Add to
.cursor/mcp.json
:
{
"mcpServers": {
"unity": {
"command": "npx",
"args": ["-y", "github:EYamanS/mcp-unity-server"]
}
}
}
- Install Unity Bridge:
git clone https://github.com/EYamanS/mcp-unity-server.git
cp -r mcp-unity-server/UnityMCP/* /path/to/YourUnityProject/Assets/Editor/UnityMCP/
-
Restart Cursor
-
Verify: In Unity, check
Window > Unity MCP > Control Panel
shows โ Connected
Generate a Simple Platformer
Create a platformer level with:
- Player sphere at (0, 2, 0) with rigidbody and sphere collider
- Ground plane at origin scaled to 20x1x20
- 5 cube obstacles positioned randomly
- Camera at (0, 5, -10) looking at origin
- Directional light from above
- Red material on player
- Blue material on ground
Generate UI System
Create a main menu UI with:
- Canvas in screen space overlay mode
- Background panel covering full screen
- Title text at top saying "My Game"
- Three buttons stacked vertically: Play, Settings, Quit
- Each button 200x50 pixels
Generate Physics Playground
Create a physics sandbox:
- Large cube as ground with box collider
- 10 spheres dropped from random heights with rigidbodies
- Each sphere with random colored material
- Camera positioned to see the action
# Clone repository
git clone https://github.com/EYamanS/mcp-unity-server.git
cd mcp-unity-server
# Install dependencies
npm install
# Build
npm run build
# Test locally
npm run dev
- Tools Reference - Complete API documentation
- Unity Bridge Architecture - Design & patterns
- Unity Installation Guide - Detailed Unity setup
Contributions welcome! To add new tools:
- Node.js side: Add tool definition in
src/index.ts
- Unity side: Create tool class in
UnityMCP/Tools/YourTool.cs
- Router: Add routing in
UnityMCP/UnityMCPBridge.Router.cs
- Document: Update
UnityMCP/TOOLS_REFERENCE.md
MCP server not connecting:
- Check Cursor MCP logs in output panel
- Verify Node.js 18+ is installed
- Restart Cursor completely
Unity not connecting:
- Check Unity Console for WebSocket errors
- Verify bridge files are in
Assets/Editor/UnityMCP/
- Port 8765 must be free
- Check
Window > Unity MCP > Control Panel
Tools not working:
- Ensure both Node and Unity bridges are up to date
- Rebuild Unity bridge if you made changes
- Check Unity Console for detailed error messages
- Node.js: 18.0.0 or higher
- Unity: 2020.3+ (tested on Unity 6)
- Cursor: Latest version with MCP support
- Newtonsoft.Json: For Unity (usually included)
MIT License - see LICENSE file
Built with:
- Model Context Protocol by Anthropic
- Unity Editor
- Cursor
If this helps you build games faster, give it a star! โญ
Made with โค๏ธ for Unity developers who want AI superpowers