Unity MCP Server
by GrandMasterK414
A comprehensive Model Context Protocol (MCP) server for Unity game development that provides tools for project management, scene editing, prefab creation, script generation, and more. It offers full compatibility with the Smithery.ai platform.
Last updated: N/A
Unity MCP Server for Smithery.ai
A comprehensive Model Context Protocol (MCP) server for Unity game development that provides tools for project management, scene editing, prefab creation, script generation, and more.
Features
- Project Management: Create and open Unity projects
- Scene Editing: Create and modify Unity scenes
- Prefab Creation: Generate prefabs with customizable components
- Script Generation: Create C# scripts using various templates (MonoBehaviour, ScriptableObject, EditorWindow)
- Smithery.ai Integration: Full compatibility with Smithery.ai platform
Getting Started
Prerequisites
- Node.js 18 or higher
- Unity installed (for actual Unity operations)
Installation
- Clone the repository:
git clone https://github.com/GrandMasterK414/unity-mcp-server.git
cd unity-mcp-server
- Install dependencies:
npm install
- Build the project:
npm run build
Running the Server
Local Development
npm run dev
Smithery.ai Deployment
npm run smithery:start
Or using Docker:
docker-compose up -d
Configuration
The server can be configured through environment variables:
SMITHERY
: Set to "true" to enable Smithery mode (uses WebSocket transport)PORT
: WebSocket server port (default: 3000)UNITY_PROJECTS_PATH
: Directory to store Unity projectsSCRIPT_ROOT
: Directory to store script templates
API Tools
Create Unity Project
Creates a new Unity project with specified configuration.
{
"name": "MyGameProject",
"path": "./projects",
"unityVersion": "2022.3.5f1"
}
Open Unity Project
Opens an existing Unity project.
{
"path": "./projects/MyGameProject"
}
Create Unity Scene
Creates a new Unity scene.
{
"name": "MainLevel",
"projectPath": "./projects/MyGameProject"
}
Create Unity Prefab
Creates a new Unity prefab.
{
"name": "EnemyCharacter",
"projectPath": "./projects/MyGameProject",
"components": ["Rigidbody", "MeshRenderer", "BoxCollider"]
}
Generate Unity Script
Generates a new C# script for Unity.
{
"name": "PlayerController",
"projectPath": "./projects/MyGameProject",
"scriptType": "MonoBehaviour",
"template": "// Optional custom template content"
}
Docker Support
The server can be deployed using Docker:
# Build the Docker image
docker build -t unity-mcp-server .
# Run the container
docker run -p 3000:3000 -d unity-mcp-server
License
This project is licensed under the MIT License - see the LICENSE file for details.