EYamanS/mcp-unity-server
If you are the rightful owner of mcp-unity-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The MCP Unity Server is an AI-powered integration for Unity Editor, enabling game generation, scene manipulation, and workflow automation through Model Context Protocol.
MCP Unity Server
AI-powered Unity Editor integration via Model Context Protocol. Generate games, manipulate scenes, and automate Unity workflows directly from Cursor/Claude!
🎮 What is This?
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
🚀 Quick Start
1. Install MCP Server
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.
2. Install Unity Bridge
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
3. Start Using
- 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
✨ Example Usage
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
🎯 Features
30+ Game Generation Tools
|
GameObjects
Components
Physics
|
Assets
Rendering
UI
Scene
|
📚 Available Tools
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!
🏗️ Architecture
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
📦 Installation
Prerequisites
- Node.js 18+ (Download)
- Unity 2020.3+ (tested on Unity 6)
- Cursor with MCP support
- Newtonsoft.Json in Unity (usually pre-installed)
Setup
- 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 Panelshows ● Connected
🎨 Example Projects
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
🛠️ Development
# 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
📖 Documentation
- - Complete API documentation
- - Design & patterns
- - Detailed Unity setup
🤝 Contributing
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
🐛 Troubleshooting
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
📋 Requirements
- 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)
📝 License
MIT License - see file
🙏 Credits
Built with:
- Model Context Protocol by Anthropic
- Unity Editor
- Cursor
🌟 Star History
If this helps you build games faster, give it a star! ⭐
Made with ❤️ for Unity developers who want AI superpowers