Unity-MCP

by tsavo

Not rated
GitHub

About

A bridge between the Unity game engine and AI assistants using the Model Context Protocol (MCP).

Details

Author
tsavo
Categories
Developer Tools, Other

Setup

Install Unity-MCP in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/tsavo/Unity-MCP

Follow the installation instructions in the repository README, then restart your MCP client.

A bridge between Unity and AI assistants using the Model Context Protocol (MCP).

Unity-MCP is an open-source implementation of the Model Context Protocol for Unity game development. It enables AI assistants to interact with Unity game environments through a standardized interface, allowing for AI-assisted game development, automated testing, scene analysis, and runtime debugging.

The architecture has been simplified to use AILogger for persistence, removing the need for a separate server component:

AI Assistant <-> Unity-MCP STDIO Client <-> Unity Client <-> AILogger

- AI Assistant: Communicates with the Unity-MCP STDIO Client using the MCP protocol
- Unity-MCP STDIO Client: Forwards commands to the Unity Client and stores results in AILogger
- Unity Client: Executes commands in Unity and returns results
- AILogger: Stores logs and results for later retrieval

The Unity-MCP STDIO Client communicates directly with the Unity Client, which provides endpoints for both code execution and queries. The query tool transforms queries into code execution by wrapping them in areturnstatement.

- Execute C# code in the Unity runtime environment
- Inspect game objects and their components
- Analyze scene hierarchies and structures
- Run tests and receive results
- Invoke methods on game objects and components
- Modify game state during runtime

- Unity Editor Extension: An Editor extension that persists beyond game execution cycles
- Docker Container: A containerized version that communicates with Unity over the network
- NPX Package: A Node.js package that can be installed and run via NPX

- MCP Architecture: Overview of the MCP architecture and namespaces
-
MCP STDIO Client: Information about the MCP STDIO client and its logging capabilities
-
Query Tool: Detailed information about the query tool and how it works
-
AILogger Integration: Detailed information about the AILogger integration
-
API Reference: Detailed information about the API endpoints
-
Installation Guide: Step-by-step instructions for installing and setting up Unity-MCP
-
Development Guide: Information about the development environment and workflow
-
Hot Reloading Guide: Detailed information about hot reloading in the development environment
-
Hot Reloading Quick Reference: Quick reference guide for hot reloading commands and tips
-
Contributing Guide: Guidelines for contributing to the project

To get started with Unity-MCP, follow these steps:

git clone https://github.com/TSavo/Unity-MCP.git cd Unity-MCP

This will start the MCP STDIO client that communicates with Unity and uses AILogger for persistence.

Note: Make sure AILogger is running onhttp://localhost:3030or set the AI_LOGGER_URL environment variable to point to your AILogger instance.

# Run all tests npm test # Run only unit tests npm run test:unit # Run only e2e tests npm run test:e2e # Run tests with a specific pattern npm test -- --testNamePattern="should return the server manifest" npm run test:unit -- --testNamePattern="should return the server manifest" npm run test:e2e -- --testNamePattern="should discover the test server"

For more detailed instructions, see theInstallation Guide.

To connect the Unity-MCP bridge to an AI assistant, you need to create an MCP configuration file:

{ "mcpServers": { "unity-ai-bridge": { "url": "http://localhost:8080/sse" } } }

Place this file in the appropriate location for your AI assistant. For Claude, this would typically be in the Claude Desktop app's configuration directory.

The Unity-MCP bridge provides the following tools:
- execute_code: Execute C# code directly in Unity.
- query: Execute a query using dot notation to access objects, properties, and methods.
- get_logs: Retrieve logs from AILogger.
- get_log_by_name: Retrieve a specific log from AILogger.

You can execute C# code in Unity using theexecute_codetool. The code will be executed in the Unity runtime environment, and the result will be stored in AILogger for later retrieval.

{ "jsonrpc": "2.0", "id": 1, "method": "tools/call", "params": { "name": "execute_code", "arguments": { "code": "Debug.Log(\"Hello from Unity!\"); return GameObject.FindObjectsOfType<GameObject>().Length;", "timeout": 5000 } } }
{ "jsonrpc": "2.0", "id": 1, "result": { "content": [ { "type": "text", "text": "{\"status\":\"success\",\"logName\":\"unity-execute-1712534400000\",\"result\":{\"success\":true,\"result\":42,\"logs\":[\"Hello from Unity!\"],\"executionTime\":123}}" } ] } }

You can query Unity objects using thequerytool. This allows you to access objects, properties, and methods using dot notation.

{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "query", "arguments": { "query": "Camera.main.transform.position", "timeout": 5000 } } }
{ "jsonrpc": "2.0", "id": 2, "result": { "content": [ { "type": "text", "text": "{\"status\":\"success\",\"logName\":\"unity-query-1712534400000\",\"result\":{\"success\":true,\"result\":{\"x\":0,\"y\":1,\"z\":-10},\"executionTime\":45}}" } ] } }

You can retrieve the results of previous operations from AILogger using theget_log_by_nametool.

{ "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "get_log_by_name", "arguments": { "log_name": "unity-execute-1712534400000", "limit": 1 } } }
{ "jsonrpc": "2.0", "id": 3, "result": { "content": [ { "type": "text", "text": "{\"status\":\"success\",\"name\":\"unity-execute-1712534400000\",\"entries\":[{\"id\":\"123e4567-e89b-12d3-a456-426614174000\",\"name\":\"unity-execute-1712534400000\",\"data\":{\"result\":{\"success\":true,\"result\":42,\"logs\":[\"Hello from Unity!\"],\"executionTime\":123},\"timestamp\":\"2025-04-08T00:00:00.000Z\"},\"timestamp\":\"2025-04-08T00:00:00.000Z\"}]}" } ] } }

Once the AI assistant has access to the Unity tool, you can ask it to perform tasks like:

Can you execute the following C# code in Unity? GameObject.Find("Player").transform.position = new Vector3(0, 1, 0);

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

An MCP server for Unity, enabling AI assistants to interact with projects in real-time, access scene data, and execute code.

Manipulate Adventure Game Studio (AGS) compiled room (.crm) files to enable AI-powered game development.

Godot Engine integration: 17 tools for game development

An MCP server for AI coding assistants to control, inspect, and modify Bevy applications using the Bevy Remote Protocol (BRP).

Control, inspect, and mutate Bevy applications with AI coding assistants via the Bevy Remote Protocol (BRP).

A server for Ebitengine games that provides debugging and recording tools by capturing game state.

Fennara MCP connects AI agents like Codex, Cursor, Claude Code, and Claude Desktop to Godot-aware tools for real Godot projects. It focuses on feedback from Godot: GDScript diagnostics, scene validation, runtime errors, scene inspection, node properties, screenshots, SemanticSearch, and patch-and-rerun workflows.

an open-source MCP server that unifies Roblox Studio, Unity, Unreal Engine, and Blender into a single AI control plane for game development workflows.

7 tools for 3D game development — character viewers, level editors, physics games, particle effects, 3D inventories with SceneView. 156 tests.

The intelligent MCP server for AI-assisted Godot 4 development. 35 tools for spatial intelligence, code understanding, flow tracing, and visual debugging. 22 free, full suite $19.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.