unity-mcp-cli 0.51.6 → 0.53.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +333 -0
- package/bin/{unity-mcp.js → unity-mcp-cli.js} +2 -2
- package/dist/commands/configure.js +22 -15
- package/dist/commands/configure.js.map +1 -1
- package/dist/commands/connect.js +37 -14
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/create-project.js +25 -13
- package/dist/commands/create-project.js.map +1 -1
- package/dist/commands/install-plugin.js +15 -6
- package/dist/commands/install-plugin.js.map +1 -1
- package/dist/commands/install-unity.d.ts +2 -0
- package/dist/commands/install-unity.js +59 -0
- package/dist/commands/install-unity.js.map +1 -0
- package/dist/commands/open.js +21 -11
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/remove-plugin.d.ts +2 -0
- package/dist/commands/remove-plugin.js +27 -0
- package/dist/commands/remove-plugin.js.map +1 -0
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/utils/config.js +5 -5
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/manifest.d.ts +6 -0
- package/dist/utils/manifest.js +40 -13
- package/dist/utils/manifest.js.map +1 -1
- package/dist/utils/ui.d.ts +50 -0
- package/dist/utils/ui.js +136 -0
- package/dist/utils/ui.js.map +1 -0
- package/dist/utils/unity-editor.d.ts +2 -2
- package/dist/utils/unity-editor.js +26 -8
- package/dist/utils/unity-editor.js.map +1 -1
- package/dist/utils/unity-hub.d.ts +16 -1
- package/dist/utils/unity-hub.js +244 -13
- package/dist/utils/unity-hub.js.map +1 -1
- package/docs/README.es.md +333 -0
- package/docs/README.ja.md +333 -0
- package/docs/README.zh-CN.md +333 -0
- package/package.json +50 -44
- package/dist/commands/install-editor.d.ts +0 -2
- package/dist/commands/install-editor.js +0 -46
- package/dist/commands/install-editor.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
<div align="center" width="100%">
|
|
2
|
+
<h1>Unity MCP — <i>CLI</i></h1>
|
|
3
|
+
|
|
4
|
+
[](https://www.npmjs.com/package/unity-mcp-cli)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://github.com/IvanMurzak/Unity-MCP/blob/main/LICENSE)
|
|
7
|
+
[](https://stand-with-ukraine.pp.ua)
|
|
8
|
+
|
|
9
|
+
<img src="https://github.com/IvanMurzak/Unity-MCP/raw/main/docs/img/promo/ai-developer-banner-glitch.gif" alt="AI Game Developer" title="Unity MCP CLI" width="100%">
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<b>[中文](https://github.com/IvanMurzak/Unity-MCP/blob/main/cli/docs/README.zh-CN.md) | [日本語](https://github.com/IvanMurzak/Unity-MCP/blob/main/cli/docs/README.ja.md) | [Español](https://github.com/IvanMurzak/Unity-MCP/blob/main/cli/docs/README.es.md)</b>
|
|
14
|
+
|
|
15
|
+
Cross-platform CLI tool for **[Unity MCP](https://github.com/IvanMurzak/Unity-MCP)** — create projects, install plugins, configure MCP tools, and launch Unity with active MCP connections. All from a single command line.
|
|
16
|
+
|
|
17
|
+
## 
|
|
18
|
+
|
|
19
|
+
- :white_check_mark: **Create projects** — scaffold new Unity projects via Unity Editor
|
|
20
|
+
- :white_check_mark: **Install editors** — install any Unity Editor version from the command line
|
|
21
|
+
- :white_check_mark: **Install plugin** — add Unity-MCP plugin to `manifest.json` with all required scoped registries
|
|
22
|
+
- :white_check_mark: **Remove plugin** — remove Unity-MCP plugin from `manifest.json`
|
|
23
|
+
- :white_check_mark: **Configure** — enable/disable MCP tools, prompts, and resources
|
|
24
|
+
- :white_check_mark: **Connect** — launch Unity with MCP environment variables for automated server connection
|
|
25
|
+
- :white_check_mark: **Cross-platform** — Windows, macOS, and Linux
|
|
26
|
+
- :white_check_mark: **Version-aware** — never downgrades plugin versions, resolves latest from OpenUPM
|
|
27
|
+
|
|
28
|
+

|
|
29
|
+
|
|
30
|
+
# Quick Start
|
|
31
|
+
|
|
32
|
+
Run any command instantly with `npx` — no installation required:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npx unity-mcp-cli install-plugin /path/to/unity/project
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Or install globally:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g unity-mcp-cli
|
|
42
|
+
unity-mcp-cli install-plugin /path/to/unity/project
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
> **Requirements:** [Node.js](https://nodejs.org/) >= 18. [Unity Hub](https://unity.com/download) is installed automatically if not found.
|
|
46
|
+
|
|
47
|
+

|
|
48
|
+
|
|
49
|
+
# Contents
|
|
50
|
+
|
|
51
|
+
- [Quick Start](#quick-start)
|
|
52
|
+
- [Commands](#commands)
|
|
53
|
+
- [`create-project`](#create-project) — Create a new Unity project
|
|
54
|
+
- [`install-unity`](#install-unity) — Install Unity Editor via Unity Hub
|
|
55
|
+
- [`open`](#open) — Open a Unity project in the Editor
|
|
56
|
+
- [`install-plugin`](#install-plugin) — Install Unity-MCP plugin into a project
|
|
57
|
+
- [`remove-plugin`](#remove-plugin) — Remove Unity-MCP plugin from a project
|
|
58
|
+
- [`configure`](#configure) — Configure MCP tools, prompts, and resources
|
|
59
|
+
- [`connect`](#connect) — Launch Unity with MCP connection
|
|
60
|
+
- [Full Automation Example](#full-automation-example)
|
|
61
|
+
- [How It Works](#how-it-works)
|
|
62
|
+
|
|
63
|
+

|
|
64
|
+
|
|
65
|
+
# Commands
|
|
66
|
+
|
|
67
|
+
## `create-project`
|
|
68
|
+
|
|
69
|
+
Create a new Unity project using the Unity Editor.
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
npx unity-mcp-cli create-project /path/to/new/project
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
| Option | Required | Description |
|
|
76
|
+
|---|---|---|
|
|
77
|
+
| `[path]` | Yes | Path where the project will be created (positional or `--path`) |
|
|
78
|
+
| `--unity <version>` | No | Unity Editor version to use (defaults to highest installed) |
|
|
79
|
+
|
|
80
|
+
**Example — create a project with a specific editor version:**
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
npx unity-mcp-cli create-project ./MyGame --unity 2022.3.62f1
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+

|
|
87
|
+
|
|
88
|
+
## `install-unity`
|
|
89
|
+
|
|
90
|
+
Install a Unity Editor version via Unity Hub CLI.
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
npx unity-mcp-cli install-unity --version 6000.3.1f1
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
| Option | Required | Description |
|
|
97
|
+
|---|---|---|
|
|
98
|
+
| `--version <version>` | No | Unity Editor version to install |
|
|
99
|
+
| `--path <path>` | No | Read the required version from an existing project |
|
|
100
|
+
|
|
101
|
+
If neither option is provided, the command lists currently installed editors.
|
|
102
|
+
|
|
103
|
+
**Example — install the editor version that a project needs:**
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
npx unity-mcp-cli install-unity --path ./MyGame
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+

|
|
110
|
+
|
|
111
|
+
## `open`
|
|
112
|
+
|
|
113
|
+
Open a Unity project in the Unity Editor.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npx unity-mcp-cli open ./MyGame
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
| Option | Required | Description |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `[path]` | Yes | Path to the Unity project (positional or `--path`) |
|
|
122
|
+
| `--unity <version>` | No | Specific Unity Editor version to use (defaults to version from project settings, falls back to highest installed) |
|
|
123
|
+
|
|
124
|
+
The editor process is spawned in detached mode — the CLI returns immediately.
|
|
125
|
+
|
|
126
|
+

|
|
127
|
+
|
|
128
|
+
## `install-plugin`
|
|
129
|
+
|
|
130
|
+
Install the Unity-MCP plugin into a Unity project's `Packages/manifest.json`.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
npx unity-mcp-cli install-plugin ./MyGame
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
| Option | Required | Description |
|
|
137
|
+
|---|---|---|
|
|
138
|
+
| `[path]` | Yes | Path to the Unity project (positional or `--path`) |
|
|
139
|
+
| `--plugin-version <version>` | No | Plugin version to install (defaults to latest from [OpenUPM](https://openupm.com/packages/com.ivanmurzak.unity.mcp/)) |
|
|
140
|
+
|
|
141
|
+
This command:
|
|
142
|
+
1. Adds the **OpenUPM scoped registry** with all required scopes
|
|
143
|
+
2. Adds `com.ivanmurzak.unity.mcp` to `dependencies`
|
|
144
|
+
3. **Never downgrades** — if a higher version is already installed, it is preserved
|
|
145
|
+
|
|
146
|
+
**Example — install a specific plugin version:**
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
npx unity-mcp-cli install-plugin ./MyGame --plugin-version 0.51.6
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
> After running this command, open the project in Unity Editor to complete the package installation.
|
|
153
|
+
|
|
154
|
+

|
|
155
|
+
|
|
156
|
+
## `remove-plugin`
|
|
157
|
+
|
|
158
|
+
Remove the Unity-MCP plugin from a Unity project's `Packages/manifest.json`.
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
npx unity-mcp-cli remove-plugin ./MyGame
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Option | Required | Description |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `[path]` | Yes | Path to the Unity project (positional or `--path`) |
|
|
167
|
+
|
|
168
|
+
This command:
|
|
169
|
+
1. Removes `com.ivanmurzak.unity.mcp` from `dependencies`
|
|
170
|
+
2. **Preserves scoped registries and scopes** — other packages may depend on them
|
|
171
|
+
3. **No-op** if the plugin is not installed
|
|
172
|
+
|
|
173
|
+
> After running this command, open the project in Unity Editor to apply the change.
|
|
174
|
+
|
|
175
|
+

|
|
176
|
+
|
|
177
|
+
## `configure`
|
|
178
|
+
|
|
179
|
+
Configure MCP tools, prompts, and resources in `UserSettings/AI-Game-Developer-Config.json`.
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
npx unity-mcp-cli configure ./MyGame --list
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
| Option | Required | Description |
|
|
186
|
+
|---|---|---|
|
|
187
|
+
| `[path]` | Yes | Path to the Unity project (positional or `--path`) |
|
|
188
|
+
| `--list` | No | List current configuration and exit |
|
|
189
|
+
| `--enable-tools <names>` | No | Enable specific tools (comma-separated) |
|
|
190
|
+
| `--disable-tools <names>` | No | Disable specific tools (comma-separated) |
|
|
191
|
+
| `--enable-all-tools` | No | Enable all tools |
|
|
192
|
+
| `--disable-all-tools` | No | Disable all tools |
|
|
193
|
+
| `--enable-prompts <names>` | No | Enable specific prompts (comma-separated) |
|
|
194
|
+
| `--disable-prompts <names>` | No | Disable specific prompts (comma-separated) |
|
|
195
|
+
| `--enable-all-prompts` | No | Enable all prompts |
|
|
196
|
+
| `--disable-all-prompts` | No | Disable all prompts |
|
|
197
|
+
| `--enable-resources <names>` | No | Enable specific resources (comma-separated) |
|
|
198
|
+
| `--disable-resources <names>` | No | Disable specific resources (comma-separated) |
|
|
199
|
+
| `--enable-all-resources` | No | Enable all resources |
|
|
200
|
+
| `--disable-all-resources` | No | Disable all resources |
|
|
201
|
+
|
|
202
|
+
**Example — enable specific tools and disable all prompts:**
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
npx unity-mcp-cli configure ./MyGame \
|
|
206
|
+
--enable-tools gameobject-create,gameobject-find \
|
|
207
|
+
--disable-all-prompts
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Example — enable everything:**
|
|
211
|
+
|
|
212
|
+
```bash
|
|
213
|
+
npx unity-mcp-cli configure ./MyGame \
|
|
214
|
+
--enable-all-tools \
|
|
215
|
+
--enable-all-prompts \
|
|
216
|
+
--enable-all-resources
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+

|
|
220
|
+
|
|
221
|
+
## `connect`
|
|
222
|
+
|
|
223
|
+
Open a Unity project and connect it to a specific MCP server via environment variables. Every option maps to a `UNITY_MCP_*` environment variable that the Unity plugin reads on startup.
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
npx unity-mcp-cli connect \
|
|
227
|
+
--path ./MyGame \
|
|
228
|
+
--url http://localhost:8080
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
| Option | Env Variable | Required | Description |
|
|
232
|
+
|---|---|---|---|
|
|
233
|
+
| `--url <url>` | `UNITY_MCP_HOST` | Yes | MCP server URL to connect to |
|
|
234
|
+
| `--path <path>` | — | Yes | Path to the Unity project |
|
|
235
|
+
| `--keep-connected` | `UNITY_MCP_KEEP_CONNECTED` | No | Force keep the connection alive |
|
|
236
|
+
| `--token <token>` | `UNITY_MCP_TOKEN` | No | Authentication token |
|
|
237
|
+
| `--auth <option>` | `UNITY_MCP_AUTH_OPTION` | No | Auth mode: `none` or `required` |
|
|
238
|
+
| `--tools <names>` | `UNITY_MCP_TOOLS` | No | Comma-separated list of tools to enable |
|
|
239
|
+
| `--transport <method>` | `UNITY_MCP_TRANSPORT` | No | Transport method: `streamableHttp` or `stdio` |
|
|
240
|
+
| `--start-server <value>` | `UNITY_MCP_START_SERVER` | No | Set to `true` or `false` to control MCP server auto-start in Unity Editor (only applies to `streamableHttp` transport) |
|
|
241
|
+
| `--unity <version>` | — | No | Specific Unity Editor version to use (defaults to version from project settings, falls back to highest installed) |
|
|
242
|
+
|
|
243
|
+
This command launches the Unity Editor with the corresponding `UNITY_MCP_*` environment variables so the plugin picks them up automatically on startup. The environment variables override values from the project's `UserSettings/AI-Game-Developer-Config.json` config file at runtime.
|
|
244
|
+
|
|
245
|
+
**Example — connect with authentication and specific tools:**
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
npx unity-mcp-cli connect \
|
|
249
|
+
--path ./MyGame \
|
|
250
|
+
--url http://my-server:8080 \
|
|
251
|
+
--token my-secret-token \
|
|
252
|
+
--auth required \
|
|
253
|
+
--keep-connected \
|
|
254
|
+
--tools gameobject-create,gameobject-find,script-execute
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Example — connect with stdio transport (server managed by AI agent):**
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
npx unity-mcp-cli connect \
|
|
261
|
+
--path ./MyGame \
|
|
262
|
+
--url http://localhost:8080 \
|
|
263
|
+
--transport stdio \
|
|
264
|
+
--start-server false
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
**Example — connect with streamableHttp and auto-start server:**
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
npx unity-mcp-cli connect \
|
|
271
|
+
--path ./MyGame \
|
|
272
|
+
--url http://localhost:8080 \
|
|
273
|
+
--transport streamableHttp \
|
|
274
|
+
--start-server true \
|
|
275
|
+
--keep-connected
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+

|
|
279
|
+
|
|
280
|
+
# Full Automation Example
|
|
281
|
+
|
|
282
|
+
Set up a complete Unity MCP project from scratch in one script:
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# 1. Create a new Unity project
|
|
286
|
+
npx unity-mcp-cli create-project ./MyAIGame --unity 6000.3.1f1
|
|
287
|
+
|
|
288
|
+
# 2. Install the Unity-MCP plugin
|
|
289
|
+
npx unity-mcp-cli install-plugin ./MyAIGame
|
|
290
|
+
|
|
291
|
+
# 3. Enable all MCP tools
|
|
292
|
+
npx unity-mcp-cli configure ./MyAIGame --enable-all-tools
|
|
293
|
+
|
|
294
|
+
# 4. Open the project with MCP connection
|
|
295
|
+
npx unity-mcp-cli connect \
|
|
296
|
+
--path ./MyAIGame \
|
|
297
|
+
--url http://localhost:8080 \
|
|
298
|
+
--keep-connected
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+

|
|
302
|
+
|
|
303
|
+
# How It Works
|
|
304
|
+
|
|
305
|
+
### Deterministic Port
|
|
306
|
+
|
|
307
|
+
The CLI generates a **deterministic port** for each Unity project based on its directory path (SHA256 hash mapped to port range 50000–59999). This matches the port generation in the Unity plugin, ensuring the server and plugin automatically agree on the same port without manual configuration.
|
|
308
|
+
|
|
309
|
+
### Plugin Installation
|
|
310
|
+
|
|
311
|
+
The `install-plugin` command modifies `Packages/manifest.json` directly:
|
|
312
|
+
- Adds the [OpenUPM](https://openupm.com/) scoped registry (`package.openupm.com`)
|
|
313
|
+
- Registers all required scopes (`com.ivanmurzak`, `extensions.unity`, `org.nuget.*`)
|
|
314
|
+
- Adds the `com.ivanmurzak.unity.mcp` dependency with version-aware updates (never downgrades)
|
|
315
|
+
|
|
316
|
+
### Configuration File
|
|
317
|
+
|
|
318
|
+
The `configure` command reads and writes `UserSettings/AI-Game-Developer-Config.json`, which controls:
|
|
319
|
+
- **Tools** — MCP tools available to AI agents
|
|
320
|
+
- **Prompts** — pre-defined prompts injected into LLM conversations
|
|
321
|
+
- **Resources** — read-only data exposed to AI agents
|
|
322
|
+
- **Connection settings** — host URL, auth token, transport method, timeouts
|
|
323
|
+
|
|
324
|
+
### Unity Hub Integration
|
|
325
|
+
|
|
326
|
+
Commands that manage editors or create projects use the **Unity Hub CLI** (`--headless` mode). If Unity Hub is not installed, the CLI **downloads and installs it automatically**:
|
|
327
|
+
- **Windows** — silent install via `UnityHubSetup.exe /S` (may require administrator privileges)
|
|
328
|
+
- **macOS** — downloads the DMG, mounts it, and copies `Unity Hub.app` to `/Applications`
|
|
329
|
+
- **Linux** — downloads `UnityHub.AppImage` to `~/Applications/`
|
|
330
|
+
|
|
331
|
+
> For the full Unity-MCP project documentation, see the [main README](https://github.com/IvanMurzak/Unity-MCP/blob/main/README.md).
|
|
332
|
+
|
|
333
|
+

|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import '../dist/index.js';
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import '../dist/index.js';
|
|
@@ -2,12 +2,14 @@ import { Command } from 'commander';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import { getOrCreateConfig, writeConfig, updateFeatures } from '../utils/config.js';
|
|
5
|
+
import * as ui from '../utils/ui.js';
|
|
5
6
|
function parseCommaSeparated(value) {
|
|
6
7
|
return value.split(',').map((s) => s.trim()).filter(Boolean);
|
|
7
8
|
}
|
|
8
9
|
export const configureCommand = new Command('configure')
|
|
9
10
|
.description('Configure MCP tools, prompts, and resources in AI-Game-Developer-Config.json')
|
|
10
|
-
.
|
|
11
|
+
.argument('[path]', 'Path to the Unity project')
|
|
12
|
+
.option('--path <path>', 'Path to the Unity project')
|
|
11
13
|
.option('--enable-tools <names>', 'Enable specific tools (comma-separated)', parseCommaSeparated)
|
|
12
14
|
.option('--disable-tools <names>', 'Disable specific tools (comma-separated)', parseCommaSeparated)
|
|
13
15
|
.option('--enable-all-tools', 'Enable all tools')
|
|
@@ -21,28 +23,33 @@ export const configureCommand = new Command('configure')
|
|
|
21
23
|
.option('--enable-all-resources', 'Enable all resources')
|
|
22
24
|
.option('--disable-all-resources', 'Disable all resources')
|
|
23
25
|
.option('--list', 'List current configuration')
|
|
24
|
-
.action(async (options) => {
|
|
25
|
-
const
|
|
26
|
+
.action(async (positionalPath, options) => {
|
|
27
|
+
const resolvedPath = positionalPath ?? options.path;
|
|
28
|
+
if (!resolvedPath) {
|
|
29
|
+
ui.error('Path is required. Usage: unity-mcp-cli configure <path> or --path <path>');
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
const projectPath = path.resolve(resolvedPath);
|
|
26
33
|
if (!fs.existsSync(projectPath)) {
|
|
27
|
-
|
|
34
|
+
ui.error(`Project path does not exist: ${projectPath}`);
|
|
28
35
|
process.exit(1);
|
|
29
36
|
}
|
|
30
37
|
const config = getOrCreateConfig(projectPath);
|
|
31
38
|
if (options.list) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const printFeatures = (
|
|
39
|
+
ui.heading('Current configuration');
|
|
40
|
+
ui.label('Host', config.host ?? 'not set');
|
|
41
|
+
ui.label('Keep Connected', String(config.keepConnected ?? false));
|
|
42
|
+
ui.label('Transport', config.transportMethod ?? 'streamableHttp');
|
|
43
|
+
ui.label('Auth', config.authOption ?? 'none');
|
|
44
|
+
const printFeatures = (featureLabel, features) => {
|
|
38
45
|
if (!features || features.length === 0) {
|
|
39
|
-
|
|
46
|
+
ui.heading(featureLabel);
|
|
47
|
+
ui.info('(none configured - all enabled by default)');
|
|
40
48
|
return;
|
|
41
49
|
}
|
|
42
|
-
|
|
50
|
+
ui.heading(featureLabel);
|
|
43
51
|
for (const f of features) {
|
|
44
|
-
|
|
45
|
-
console.log(` ${status} ${f.name}`);
|
|
52
|
+
ui.featureRow(f.name, f.enabled);
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
55
|
printFeatures('Tools', config.tools);
|
|
@@ -78,6 +85,6 @@ export const configureCommand = new Command('configure')
|
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
87
|
writeConfig(projectPath, config);
|
|
81
|
-
|
|
88
|
+
ui.success('Configuration updated successfully.');
|
|
82
89
|
});
|
|
83
90
|
//# sourceMappingURL=configure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/commands/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"configure.js","sourceRoot":"","sources":["../../src/commands/configure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KA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eAAe,IAAI,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,mBAAmB,EAAE,CAAC;QACrH,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;YAClC,WAAW,EAAE,OAAO,CAAC,eAAe;YACpC,YAAY,EAAE,OAAO,CAAC,gBAAgB;YACtC,SAAS,EAAE,OAAO,CAAC,kBAAkB;YACrC,UAAU,EAAE,OAAO,CAAC,mBAAmB;SACxC,CAAC,CAAC;IACL,CAAC;IAED,WAAW,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;IACjC,EAAE,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC"}
|
package/dist/commands/connect.js
CHANGED
|
@@ -2,35 +2,41 @@ import { Command } from 'commander';
|
|
|
2
2
|
import * as path from 'path';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import { findEditorPath, getProjectEditorVersion, launchEditor } from '../utils/unity-editor.js';
|
|
5
|
+
import * as ui from '../utils/ui.js';
|
|
5
6
|
export const connectCommand = new Command('connect')
|
|
6
7
|
.description('Open Unity and enforce MCP connection to a specified server URL via environment variables')
|
|
7
|
-
.requiredOption('--
|
|
8
|
+
.requiredOption('--path <path>', 'Path to the Unity project')
|
|
8
9
|
.requiredOption('--url <url>', 'MCP server URL to connect to')
|
|
9
10
|
.option('--tools <names>', 'Comma-separated list of tools to enable (sets UNITY_MCP_TOOLS)')
|
|
10
11
|
.option('--token <token>', 'Auth token (sets UNITY_MCP_TOKEN)')
|
|
11
12
|
.option('--auth <option>', 'Auth option: none or required (sets UNITY_MCP_AUTH_OPTION)')
|
|
12
13
|
.option('--keep-connected', 'Force keep connected (sets UNITY_MCP_KEEP_CONNECTED=true)')
|
|
13
|
-
.option('--
|
|
14
|
+
.option('--transport <method>', 'Transport method: streamableHttp or stdio (sets UNITY_MCP_TRANSPORT)')
|
|
15
|
+
.option('--start-server <value>', 'Set to true/false to control server auto-start (sets UNITY_MCP_START_SERVER)', undefined)
|
|
16
|
+
.option('--unity <version>', 'Specific Unity Editor version to use')
|
|
14
17
|
.action(async (options) => {
|
|
15
|
-
const projectPath = path.resolve(options.
|
|
18
|
+
const projectPath = path.resolve(options.path);
|
|
16
19
|
if (!fs.existsSync(projectPath)) {
|
|
17
|
-
|
|
20
|
+
ui.error(`Project path does not exist: ${projectPath}`);
|
|
18
21
|
process.exit(1);
|
|
19
22
|
}
|
|
20
23
|
// Determine editor version
|
|
21
|
-
let version = options.
|
|
24
|
+
let version = options.unity;
|
|
22
25
|
if (!version) {
|
|
23
26
|
version = getProjectEditorVersion(projectPath) ?? undefined;
|
|
24
27
|
if (version) {
|
|
25
|
-
|
|
28
|
+
ui.info(`Detected editor version from project: ${version}`);
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
|
-
const
|
|
31
|
+
const spinner = ui.startSpinner('Locating Unity Editor...');
|
|
32
|
+
const editorPath = await findEditorPath(version);
|
|
29
33
|
if (!editorPath) {
|
|
34
|
+
spinner.fail('Unity Editor not found');
|
|
30
35
|
const versionMsg = version ? ` (version ${version})` : '';
|
|
31
|
-
|
|
36
|
+
ui.error(`Unity Editor not found${versionMsg}. Install it with: unity-mcp-cli install-unity --version <version>`);
|
|
32
37
|
process.exit(1);
|
|
33
38
|
}
|
|
39
|
+
spinner.succeed('Unity Editor located');
|
|
34
40
|
// Build environment variables for MCP connection
|
|
35
41
|
const env = {
|
|
36
42
|
UNITY_MCP_HOST: options.url,
|
|
@@ -46,19 +52,36 @@ export const connectCommand = new Command('connect')
|
|
|
46
52
|
}
|
|
47
53
|
if (options.auth) {
|
|
48
54
|
if (options.auth !== 'none' && options.auth !== 'required') {
|
|
49
|
-
|
|
55
|
+
ui.error('--auth must be "none" or "required"');
|
|
50
56
|
process.exit(1);
|
|
51
57
|
}
|
|
52
58
|
env['UNITY_MCP_AUTH_OPTION'] = options.auth;
|
|
53
59
|
}
|
|
54
|
-
|
|
55
|
-
|
|
60
|
+
if (options.transport) {
|
|
61
|
+
if (options.transport !== 'streamableHttp' && options.transport !== 'stdio') {
|
|
62
|
+
ui.error('--transport must be "streamableHttp" or "stdio"');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
env['UNITY_MCP_TRANSPORT'] = options.transport;
|
|
66
|
+
}
|
|
67
|
+
if (options.startServer !== undefined) {
|
|
68
|
+
const val = options.startServer.toLowerCase();
|
|
69
|
+
if (val !== 'true' && val !== 'false') {
|
|
70
|
+
ui.error('--start-server must be "true" or "false"');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
env['UNITY_MCP_START_SERVER'] = val;
|
|
74
|
+
}
|
|
75
|
+
ui.heading('Connection Details');
|
|
76
|
+
ui.label('MCP Server', options.url);
|
|
77
|
+
ui.label('Project', projectPath);
|
|
78
|
+
ui.label('Editor', editorPath);
|
|
79
|
+
ui.heading('Environment Variables');
|
|
56
80
|
for (const [key, value] of Object.entries(env)) {
|
|
57
81
|
const display = key === 'UNITY_MCP_TOKEN' ? '***' : value;
|
|
58
|
-
|
|
82
|
+
ui.label(key, display);
|
|
59
83
|
}
|
|
60
|
-
|
|
61
|
-
console.log(`Using editor: ${editorPath}`);
|
|
84
|
+
ui.divider();
|
|
62
85
|
launchEditor(editorPath, projectPath, env);
|
|
63
86
|
});
|
|
64
87
|
//# sourceMappingURL=connect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"connect.js","sourceRoot":"","sources":["../../src/commands/connect.ts"],"names":[],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C;QAC/C,MAAM,OAAO,GAAG,GAAG,KAAK,iBAAiB,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;QAC1D,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACzB,CAAC;IAED,EAAE,CAAC,OAAO,EAAE,CAAC;IACb,YAAY,CAAC,UAAU,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC,CAAC,CAAC"}
|
|
@@ -1,28 +1,40 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { ensureUnityHub, createProject, listInstalledEditors, findHighestEditor } from '../utils/unity-hub.js';
|
|
4
|
+
import * as ui from '../utils/ui.js';
|
|
4
5
|
export const createProjectCommand = new Command('create-project')
|
|
5
6
|
.description('Create a new Unity project')
|
|
6
|
-
.
|
|
7
|
-
.option('--
|
|
8
|
-
.
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
.argument('[path]', 'Path where the project will be created')
|
|
8
|
+
.option('--path <path>', 'Path where the project will be created')
|
|
9
|
+
.option('--unity <version>', 'Unity Editor version to use')
|
|
10
|
+
.action(async (positionalPath, options) => {
|
|
11
|
+
const resolvedPath = positionalPath ?? options.path;
|
|
12
|
+
if (!resolvedPath) {
|
|
13
|
+
ui.error('Path is required. Usage: unity-mcp-cli create-project <path> or --path <path>');
|
|
12
14
|
process.exit(1);
|
|
13
15
|
}
|
|
14
|
-
|
|
16
|
+
const spinner = ui.startSpinner('Locating Unity Hub...');
|
|
17
|
+
let hubPath;
|
|
18
|
+
try {
|
|
19
|
+
hubPath = await ensureUnityHub();
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
spinner.fail('Failed to locate Unity Hub');
|
|
23
|
+
throw err;
|
|
24
|
+
}
|
|
25
|
+
spinner.succeed('Unity Hub located');
|
|
26
|
+
let editorVersion = options.unity;
|
|
15
27
|
if (!editorVersion) {
|
|
16
|
-
// Use the latest installed editor
|
|
17
28
|
const editors = listInstalledEditors(hubPath);
|
|
18
29
|
if (editors.length === 0) {
|
|
19
|
-
|
|
30
|
+
ui.error('No Unity editors installed. Install one with: unity-mcp-cli install-unity --version <version>');
|
|
20
31
|
process.exit(1);
|
|
21
32
|
}
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
const highest = findHighestEditor(editors);
|
|
34
|
+
editorVersion = highest.version;
|
|
35
|
+
ui.info(`No Unity version specified, using highest installed: ${editorVersion}`);
|
|
24
36
|
}
|
|
25
|
-
const projectPath = path.resolve(
|
|
37
|
+
const projectPath = path.resolve(resolvedPath);
|
|
26
38
|
createProject(hubPath, projectPath, editorVersion);
|
|
27
39
|
});
|
|
28
40
|
//# sourceMappingURL=create-project.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-project.js","sourceRoot":"","sources":["../../src/commands/create-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"create-project.js","sourceRoot":"","sources":["../../src/commands/create-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/G,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAErC,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,OAAO,CAAC,gBAAgB,CAAC;KAC9D,WAAW,CAAC,4BAA4B,CAAC;KACzC,QAAQ,CAAC,QAAQ,EAAE,wCAAwC,CAAC;KAC5D,MAAM,CAAC,eAAe,EAAE,wCAAwC,CAAC;KACjE,MAA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