Thanks to visit codestin.com
Credit goes to github.com

Skip to content

A Unity MCP server that allows MCP clients like Claude Desktop or Cursor to perform Unity Editor actions.

License

Notifications You must be signed in to change notification settings

praxilabs/unity-mcp

Β 
Β 

Repository files navigation

Unity MCP Bridge ✨

Maintained by Praxilabs, the AI assistant for Unity.

python

Create your Unity apps with LLMs!

Unity MCP Bridge connects Unity with AI assistants through the Model Context Protocol (MCP), enabling you to create Unity applications using natural language commands.

πŸ€” How It Works

Unity MCP Bridge uses a three-component architecture to connect AI assistants with Unity:

[AI Assistant (Cursor/Claude)] ←→ [Unity MCP Server (Python)] ←→ [Unity MCP Bridge (Unity Package)]

πŸ”§ System Components

  1. AI Assistant (Cursor, Claude Desktop, etc.)

    • Sends natural language commands
    • Receives tool responses and Unity data
    • Manages conversation context
  2. Unity MCP Server (Python)

    • Translates MCP protocol to Unity commands
    • Manages tool execution and responses
    • Handles communication between AI and Unity
  3. Unity MCP Bridge (Unity Package)

    • Executes Unity operations (create objects, manage assets, etc.)
    • Provides real-time Unity data and status
    • Manages Unity Editor state

πŸ”„ Data Flow

  1. Command Flow: AI Assistant β†’ MCP Server β†’ Unity Bridge β†’ Unity Editor
  2. Response Flow: Unity Editor β†’ Unity Bridge β†’ MCP Server β†’ AI Assistant
  3. Real-time Updates: Unity state changes are automatically reported back

πŸ› οΈ Tool Execution

When you ask an AI to "create a red cube", the system:

  1. Parses the natural language request
  2. Maps it to appropriate Unity MCP tools
  3. Executes the commands in Unity
  4. Reports back the results and any errors

πŸš€ Quick Start

1. GitHub Setup (Required First)

πŸ“– See GitHub Setup Guide for detailed instructions.

2. Clone Repository

πŸ“– See GitHub Setup Guide for detailed instructions.

3. Install Unity Package

  • Open Unity Hub β†’ Create new 3D project
  • Window β†’ Package Manager β†’ + β†’ Add package from git URL
  • Enter: https://github.com/praxilabs/unity-mcp.git?path=/UnityMcpBridge

4. Install MCP Server

  • Go to Window β†’ Unity MCP β†’ Installation Manager
  • Click the Install Server button

5. Configure MCP Client

  • Install Cursor or Claude Desktop
  • Unity β†’ Window β†’ Unity MCP β†’ Auto Configure
  • Verify green status indicator 🟒

6. Test Setup

  • Try generating any logic using Unity MCP Bridges available tools you can find tools in the "πŸ› οΈ Overview on Tools" section, for a more detailed look go to Tool Reference .
  • πŸ“– For system architecture details, see System Explanation .

🎯 Using Cursor Rules Framework

The Unity MCP Bridge includes a comprehensive Cursor Rules framework that provides AI assistants with specialized knowledge for Unity development tasks.

What are Cursor Rules?

Cursor Rules are .mdc files that contain domain-specific knowledge and guidelines for AI assistants. They help the AI understand:

  • Unity-specific workflows and best practices
  • Graph logic patterns for XNode-based experiments
  • Tool usage guidelines and common scenarios
  • Error handling and troubleshooting approaches

Available Rule Categories

Core Rules (CursorRules/rules/Core/)

  • core.mdc - Fundamental Unity MCP concepts and patterns
  • concise.mdc - Guidelines for clear, minimal documentation
  • request.mdc - How to handle user requests effectively
  • retro.mdc - Retrospective analysis and improvement patterns

Graph Logic Rules (CursorRules/rules/MCP/GraphLogic/)

  • Control Flow - Managing sequence execution and branching
  • Click Nodes - Mouse interaction and UI element handling
  • Camera Nodes - Camera positioning and movement logic
  • UI Nodes - Popup messages, MCQs, and interface elements
  • Loop Nodes - Iteration and conditional execution
  • Progress Nodes - Experiment progression tracking
  • Table Nodes - Data management and record keeping
  • Tool Nodes - Collider toggling and utility operations
  • Utility Nodes - Delays, freezing, and system utilities
  • Misc Nodes - Animation and other specialized operations

How to Use Cursor Rules

  1. Automatic Application: Rules are automatically applied when using Cursor IDE with this project
  2. Context-Aware Suggestions: AI will suggest appropriate tools and patterns based on your request
  3. Best Practice Guidance: Rules ensure consistent, high-quality Unity development workflows
  4. Error Prevention: Built-in guidelines help avoid common Unity development pitfalls

Specialized Protocol Rules

@request.mdc - Feature Request Protocol

When you need to request new features, refactoring, or changes:

  • Structured Approach: Follows a 5-phase protocol from reconnaissance to final verification
  • System-Wide Analysis: Ensures all dependencies and impacts are considered
  • Zero-Trust Audit: Mandatory self-audit to prevent regressions
  • Evidence-Based: Requires empirical verification of all changes

@retro.mdc - Retrospective & Learning Protocol

After completing work, use this to:

  • Analyze Performance: Review the entire session for successes and failures
  • Distill Lessons: Extract durable, universal principles from the interaction
  • Update Doctrine: Integrate learnings into the AI's operational rules
  • Continuous Improvement: Evolve the AI's capabilities based on real experiences

@refresh.mdc - Bug Fix & Root Cause Analysis Protocol

For persistent bugs or issues:

  • Deep Diagnostics: Systematic investigation beyond surface-level fixes
  • Root Cause Focus: Identifies the absolute underlying cause, not just symptoms
  • Reproducible Testing: Creates minimal test cases to verify fixes
  • Regression Prevention: Ensures fixes don't introduce new problems

Example Usage

When you ask the AI to "create a click sequence that shows a popup", the rules framework will:

  • Suggest appropriate ClickStep and UINodes
  • Guide you through proper Control Flow setup
  • Recommend Progress tracking for experiment management
  • Ensure proper Error handling and validation

Prompt Engineering a better Prompt

There are multiple strategies to prompt a better prompt to the AI Model we are going to discuss some of them that are effective on test.

  1. Q & A Strategy: using the "Before you continue ask me about relevant questions about any think that is not clear, or should be more clearer" prompt design for example.
@request.mdc
i want you to create an experiment about 1, 2, 3 and 4
the steps are A, B, C and D.

before you continue to create the experiment ask me about any relevant questions to the experiment that will help you making a better experiment
ask me about any unclear terminology or any confusing steps that needs more explaination.
  1. Pros & Cons Strategy: if you are trying to compare between two things and want the model to specify which is better, you want him to list the pros and cons for each thing. then the ai will get biased towards the better solution according to the pros and cons it listed.

  2. Role Prompt Strategy: it involves putting the model in a role and make it act upon for example

"you are a bounty hunter and an ethical hacker, review my app to identify any security vulnerabilities".

Customizing Rules

  • Rules are located in CursorRules/rules/ directory
  • Each .mdc file contains specific domain knowledge
  • Modify rules to match your project's specific requirements
  • Rules follow markdown format with clear sections and examples

πŸ› οΈ Overview on Tools

Experiment & Graph Tools

Registry Management

Utility Tools

πŸ”§ System Requirements

  • Unity: 2022.3 LTS or newer
  • Python: 3.12 or newer
  • Operating System: Windows 10+, macOS 10.15+, or Linux
  • Memory: 8GB RAM minimum, 16GB recommended
  • MCP Client: Cursor IDE, Claude Desktop, or compatible client

πŸ†˜ Troubleshooting

Common Issues

  • Unity Bridge Not Connecting: Ensure Unity Editor is open and package is installed
  • MCP Client Not Connecting: Check server configuration and ports
  • Submodule Issues: See GitHub Setup Guide

πŸ“š Documentation

Getting Help

πŸ“„ License

MIT License. See LICENSE file.


About

A Unity MCP server that allows MCP clients like Claude Desktop or Cursor to perform Unity Editor actions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 87.4%
  • Python 11.3%
  • Batchfile 1.2%
  • Dockerfile 0.1%