Skip to content

Commit 643d7c5

Browse files
author
Miguel Cartier
committed
docs: update Unity version requirement in README files
docs: add AGENTS.md file for AI agent's assistant
1 parent 7a061ae commit 643d7c5

File tree

6 files changed

+76
-3
lines changed

6 files changed

+76
-3
lines changed

AGENTS.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# MCP Unity - AI Agent Guide
2+
3+
## 1. Project Overview
4+
**MCP Unity** bridges AI assistants (Cursor, Claude, Windsurf) to the Unity Editor via the Model Context Protocol (MCP). It allows agents to inspect scenes, manipulate GameObjects, run tests, and manage packages directly within Unity.
5+
6+
## 2. Architecture
7+
- **Dual Architecture**:
8+
- **Server (Node.js/TypeScript)**: Runs as the MCP server (stdio), handles protocol messages, and forwards requests to Unity via WebSocket.
9+
- **Client (Unity/C#)**: Runs inside Unity Editor, listens for WebSocket commands, executes Editor API calls, and returns results.
10+
- **Communication**: JSON-RPC over WebSocket (default port 8080).
11+
12+
## 3. Directory Structure
13+
```
14+
/
15+
├── Editor/ # Unity C# Editor Code (The "Client")
16+
│ ├── Tools/ # Tool implementations (McpToolBase)
17+
│ ├── Resources/ # Resource implementations (McpResourceBase)
18+
│ ├── UnityBridge/ # WebSocket server & message handling
19+
│ └── Services/ # Core services (Logs, Tests)
20+
├── Server~/ # Node.js MCP Server Code (The "Server")
21+
│ ├── src/tools/ # MCP Tool definitions (mirrors Editor/Tools)
22+
│ ├── src/resources/ # MCP Resource definitions
23+
│ └── src/unity/ # WebSocket client logic
24+
└── docs/ # Documentation images
25+
26+
## 4. Key Files
27+
- `McpUnitySocketHandler.cs` — WebSocket message routing
28+
- `McpUnityServer.cs` — Unity-side server lifecycle
29+
- `McpUnity.ts` — Node.js client connecting to Unity
30+
- `index.ts` — MCP server entry, tool/resource registration
31+
```
32+
33+
## 5. Coding Standards
34+
- **Unity**: Unity 6 standards.
35+
- **C#**: C# 9.0 features allowed.
36+
- **Namespaces**: Explicit namespaces (e.g., `McpUnity.Tools`). No global `using`.
37+
- **Async**: Use `IsAsync = true` in tools/resources for main thread operations (Editor API).
38+
39+
## 6. Development Workflow
40+
To add a new capability (e.g., "RotateObject"):
41+
42+
1. **Unity (C#)**:
43+
- Create `Editor/Tools/RotateObjectTool.cs` inheriting `McpToolBase`.
44+
- Implement `Execute` (sync) or `ExecuteAsync` (if touching Editor API).
45+
- Register in `McpUnityServer.cs` (if not auto-discovered).
46+
47+
2. **Server (TS)**:
48+
- Create `Server~/src/tools/rotateObjectTool.ts`.
49+
- Define input schema (zod) and tool handler.
50+
- Forward request to Unity via `McpUnity.instance.callTool("RotateObject", args)`.
51+
52+
3. **Build**:
53+
- Unity compiles automatically.
54+
- Server: `cd Server~ && npm run build`.
55+
56+
## 7. Update Policy
57+
- **Update this file** when architecture changes, whenever tools/resources are added/renamed/removed, or when new core patterns are introduced.
58+
- **Keep concise**: Focus on high-level patterns for AI context.
59+

AGENTS.md.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README-ja.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ MCP Unityは、Unityの`Library/PackedCache`フォルダーをワークスペー
110110
> **例:** "プロジェクトで利用可能なすべてのテストをリスト"
111111
112112
## 要件
113-
- Unity 2022.3以降 - [サーバーをインストール](#install-server)するため
113+
- Unity 6以降 - [サーバーをインストール](#install-server)するため
114114
- Node.js 18以降 - [サーバーを起動](#start-server)するため
115115
- npm 9以降 - [サーバーをデバッグ](#debug-server)するため
116116

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ The following tools are available for manipulating and querying Unity scenes and
114114
> **Example prompt:** "List all available tests in my Unity project"
115115
116116
## Requirements
117-
- Unity 2022.3 or later - to [install the server](#install-server)
117+
- Unity 6 or later - to [install the server](#install-server)
118118
- Node.js 18 or later - to [start the server](#start-server)
119119
- npm 9 or later - to [debug the server](#debug-server)
120120

README_zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ MCP Unity 通过将 Unity `Library/PackedCache` 文件夹添加到您的工作
111111
> **示例提示:** "列出我 Unity 项目中所有可用的测试"
112112
113113
## 要求
114-
- Unity 2022.3 或更高版本 - 用于[安装服务器](#install-server)
114+
- Unity 6 或更高版本 - 用于[安装服务器](#install-server)
115115
- Node.js 18 或更高版本 - 用于[启动服务器](#start-server)
116116
- npm 9 或更高版本 - 用于[调试服务器](#debug-server)
117117

server.json.meta

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)