UnityMCPIntegration

Enable AI Agents to Control Unity

GitHub Stars

90

User Rating

Not Rated

Favorites

0

Views

81

Forks

19

Issues

4

Installation
Difficulty
Intermediate
Estimated Time
10-20 minutes
Requirements
Unity 2021.3 or later
Node.js 18+

Installation

Installation

Prerequisites

Unity: 2021.3 or later
Node.js: 18 or higher

Installation Steps

1. Install Unity Package

Option A: Package Manager (Git URL)
1Open the Unity Package Manager (Window > Package Manager)
2Click the + button and select Add package from git URL...
3Enter the repository URL: https://github.com/quazaai/UnityMCPIntegration.git
4Click Add
Option B: Import Custom Package
1Clone this repository or [download it as a unityPackage](https://github.com/quazaai/UnityMCPIntegration/releases)
2In Unity, go to Assets > Import Package > Custom Package
3Select the UnityMCPIntegration.unitypackage file

2. Set up the MCP Server

Option A: Run the server directly
1Navigate to mcpServer
bash
   cd /Library/PackageCache/com.quaza.unitymcp@
   

Configuration

Configuration

Basic Configuration

MCP Server Setup

Configure the MCP server as follows:
json
{
  "mcpServers": {
    "unity-mcp": {
      "command": "node",
      "args": ["path/to/server.js"]
    }
  }
}

Environment Variables

Set the following environment variables as needed:
bash
export API_KEY="your-api-key"
export DEBUG="true"

Security Settings

Store API keys in secure configuration files
Set appropriate file access permissions

Examples

Examples

Basic Usage

Programmatic Usage

javascript
// JavaScript example (Node.js)
const { MCPClient } = require('@modelcontextprotocol/client');

const client = new MCPClient();
await client.connect();

// Execute tool
const result = await client.callTool('toolName', {
  parameter1: 'value1',
  parameter2: 'value2'
});

console.log(result);

Advanced Examples

Automation Script

bash
#!/bin/bash

Batch processing example

for file in *.txt; do mcp-tool process "$file" done

Use Cases

A scenario where AI agents manipulate objects in the scene in real-time.
Executing automated test scripts within the Unity Editor.
Use case where AI suggests and executes changes to project settings.
A system where AI monitors errors and logs, notifying developers.

Additional Resources