unity-mcp-cli 0.65.0 → 0.66.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/CHANGELOG.md +60 -0
- package/README.md +35 -1
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +11 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/bootstrap-local.d.ts +17 -0
- package/dist/commands/bootstrap-local.js +83 -0
- package/dist/commands/bootstrap-local.js.map +1 -0
- package/dist/commands/configure.js +37 -45
- package/dist/commands/configure.js.map +1 -1
- package/dist/commands/install-plugin.js +41 -23
- package/dist/commands/install-plugin.js.map +1 -1
- package/dist/commands/open.d.ts +20 -0
- package/dist/commands/open.js +45 -8
- package/dist/commands/open.js.map +1 -1
- package/dist/commands/remove-plugin.js +21 -9
- package/dist/commands/remove-plugin.js.map +1 -1
- package/dist/commands/setup-mcp.js +32 -81
- package/dist/commands/setup-mcp.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/configure.d.ts +10 -0
- package/dist/lib/configure.js +85 -0
- package/dist/lib/configure.js.map +1 -0
- package/dist/lib/install-plugin.d.ts +8 -0
- package/dist/lib/install-plugin.js +68 -0
- package/dist/lib/install-plugin.js.map +1 -0
- package/dist/lib/logger.d.ts +7 -0
- package/dist/lib/logger.js +18 -0
- package/dist/lib/logger.js.map +1 -0
- package/dist/lib/progress.d.ts +7 -0
- package/dist/lib/progress.js +16 -0
- package/dist/lib/progress.js.map +1 -0
- package/dist/lib/remove-plugin.d.ts +7 -0
- package/dist/lib/remove-plugin.js +51 -0
- package/dist/lib/remove-plugin.js.map +1 -0
- package/dist/lib/setup-mcp.d.ts +12 -0
- package/dist/lib/setup-mcp.js +141 -0
- package/dist/lib/setup-mcp.js.map +1 -0
- package/dist/lib/types.d.ts +132 -0
- package/dist/lib/types.js +8 -0
- package/dist/lib/types.js.map +1 -0
- package/dist/lib/validation.d.ts +37 -0
- package/dist/lib/validation.js +50 -0
- package/dist/lib/validation.js.map +1 -0
- package/dist/lib.d.ts +5 -0
- package/dist/lib.js +18 -0
- package/dist/lib.js.map +1 -0
- package/dist/utils/manifest.d.ts +31 -3
- package/dist/utils/manifest.js +27 -11
- package/dist/utils/manifest.js.map +1 -1
- package/package.json +20 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `unity-mcp-cli` will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.67.0] - 2026-04-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Library API.** The package now exposes its core commands as a typed,
|
|
13
|
+
side-effect-free library alongside the existing CLI binary.
|
|
14
|
+
Consumers can do:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import { installPlugin, removePlugin, configure, setupMcp } from 'unity-mcp-cli';
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Available functions:
|
|
21
|
+
- `installPlugin(opts)` — install the Unity-MCP plugin into a Unity project
|
|
22
|
+
- `removePlugin(opts)` — remove the Unity-MCP plugin from a Unity project
|
|
23
|
+
- `configure(opts)` — enable/disable MCP tools, prompts, resources
|
|
24
|
+
- `setupMcp(opts)` — write an agent MCP config file
|
|
25
|
+
- `listAgentIds()` — list every supported agent id
|
|
26
|
+
|
|
27
|
+
All functions return a typed `{ success, ... }` result (never throw past the
|
|
28
|
+
public boundary) and accept an optional `onProgress(event)` callback that
|
|
29
|
+
fires for `start`, `dependencies-resolved`, `manifest-patched`, and
|
|
30
|
+
`done` phases.
|
|
31
|
+
|
|
32
|
+
- **`package.json` `exports` field.** The package now ships with a
|
|
33
|
+
conditional-exports map:
|
|
34
|
+
- `"."` — the library entry (`dist/lib.js`)
|
|
35
|
+
- `"./cli"` — the CLI entry (`dist/cli.js`), identical behaviour to
|
|
36
|
+
the `unity-mcp-cli` binary
|
|
37
|
+
|
|
38
|
+
### Changed
|
|
39
|
+
|
|
40
|
+
- Command handlers (`install-plugin`, `remove-plugin`, `configure`,
|
|
41
|
+
`setup-mcp`) are now thin Commander wrappers that delegate to the
|
|
42
|
+
library functions. Terminal output and exit codes are unchanged from
|
|
43
|
+
the user's perspective.
|
|
44
|
+
|
|
45
|
+
- `utils/manifest.ts` functions now accept an optional `logger` argument
|
|
46
|
+
so the library can run silently while the CLI preserves its chalk-
|
|
47
|
+
styled output. `addPluginToManifest` and `removePluginFromManifest`
|
|
48
|
+
also return structured result objects; return values are purely
|
|
49
|
+
additive and the existing call sites are unaffected.
|
|
50
|
+
|
|
51
|
+
### Notes
|
|
52
|
+
|
|
53
|
+
- No breaking changes to the CLI binary. `unity-mcp-cli install-plugin
|
|
54
|
+
./MyProject` and friends still work exactly as before.
|
|
55
|
+
- The library entry point has no top-level side effects: importing
|
|
56
|
+
`unity-mcp-cli` never writes to stdout/stderr and never parses argv.
|
|
57
|
+
An `import 'unity-mcp-cli'` or dynamic `import('unity-mcp-cli')`
|
|
58
|
+
call is safe to do anywhere.
|
|
59
|
+
|
|
60
|
+
[0.67.0]: https://github.com/IvanMurzak/Unity-MCP/releases/tag/cli-0.67.0
|
package/README.md
CHANGED
|
@@ -235,12 +235,16 @@ unity-mcp-cli install-unity --path ./MyGame
|
|
|
235
235
|
Open a Unity project in the Unity Editor. By default, sets MCP connection environment variables if connection options are provided. Use `--no-connect` to open without MCP connection.
|
|
236
236
|
|
|
237
237
|
```bash
|
|
238
|
+
# Explicit path
|
|
238
239
|
unity-mcp-cli open ./MyGame
|
|
240
|
+
|
|
241
|
+
# From inside the Unity project folder — path defaults to the current directory
|
|
242
|
+
cd ./MyGame && unity-mcp-cli open
|
|
239
243
|
```
|
|
240
244
|
|
|
241
245
|
| Option | Env Variable | Required | Description |
|
|
242
246
|
|---|---|---|---|
|
|
243
|
-
| `[path]` | — |
|
|
247
|
+
| `[path]` | — | No | Path to the Unity project (positional or `--path`). Defaults to the current working directory. |
|
|
244
248
|
| `--unity <version>` | — | No | Specific Unity Editor version to use (defaults to version from project settings, falls back to highest installed) |
|
|
245
249
|
| `--no-connect` | — | No | Open without MCP connection environment variables |
|
|
246
250
|
| `--url <url>` | `UNITY_MCP_HOST` | No | MCP server URL to connect to |
|
|
@@ -553,3 +557,33 @@ Commands that manage editors or create projects use the **Unity Hub CLI** (`--he
|
|
|
553
557
|
> For the full Unity-MCP project documentation, see the [main README](https://github.com/IvanMurzak/Unity-MCP/blob/main/README.md).
|
|
554
558
|
|
|
555
559
|

|
|
560
|
+
|
|
561
|
+
# Library API (v0.67.0+)
|
|
562
|
+
|
|
563
|
+
In addition to the CLI binary, `unity-mcp-cli` exposes its core commands as a typed, side-effect-free library so other Node.js / TypeScript tools can embed the same install / configure flow without shelling out.
|
|
564
|
+
|
|
565
|
+
```ts
|
|
566
|
+
import { installPlugin, removePlugin, configure, setupMcp } from 'unity-mcp-cli';
|
|
567
|
+
|
|
568
|
+
const result = await installPlugin({
|
|
569
|
+
unityProjectPath: './MyUnityProject',
|
|
570
|
+
// version: '0.67.0', // optional — defaults to latest from OpenUPM
|
|
571
|
+
onProgress: (event) => {
|
|
572
|
+
// phase is one of: 'start' | 'dependencies-resolved' | 'manifest-patched' | 'done'
|
|
573
|
+
console.log(event.phase, event.message);
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
if (!result.success) {
|
|
578
|
+
console.error('Install failed:', result.error?.message);
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
console.log(`Installed v${result.installedVersion}`);
|
|
583
|
+
for (const warning of result.warnings) console.warn(warning);
|
|
584
|
+
for (const step of result.nextSteps) console.log(step);
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
Each function returns a typed `{ success, ... }` result object; errors are never thrown past the public boundary. The library entry has no top-level side effects — `import 'unity-mcp-cli'` never parses argv and never writes to stdout or stderr.
|
|
588
|
+
|
|
589
|
+
See [`CHANGELOG.md`](CHANGELOG.md#0670---2026-04-21) for the full list of exported functions and types.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './index.js';
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// CLI entry for `unity-mcp-cli`, exported at the `./cli` subpath.
|
|
2
|
+
//
|
|
3
|
+
// Importing this file runs the Commander-based CLI exactly as the
|
|
4
|
+
// `unity-mcp-cli` binary does — it parses argv, dispatches subcommands,
|
|
5
|
+
// and exits the process.
|
|
6
|
+
//
|
|
7
|
+
// Consumers that want the programmatic, side-effect-free surface
|
|
8
|
+
// should import the package root (`import { installPlugin } from
|
|
9
|
+
// "unity-mcp-cli"`) — NOT this file.
|
|
10
|
+
import './index.js';
|
|
11
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,kEAAkE;AAClE,wEAAwE;AACxE,yBAAyB;AACzB,EAAE;AACF,iEAAiE;AACjE,iEAAiE;AACjE,qCAAqC;AAErC,OAAO,YAAY,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { type UnityConnectionConfig } from '../utils/config.js';
|
|
3
|
+
/**
|
|
4
|
+
* Produce a new config object with local-mode fields pinned to `url` / `token`.
|
|
5
|
+
* Preserves all other keys from `current` (immutable update — does not mutate `current`).
|
|
6
|
+
*
|
|
7
|
+
* The plugin-side ConnectionMode enum only accepts "Custom" (local) or "Cloud".
|
|
8
|
+
* We intentionally normalize any integer (0 → Custom, 1 → Cloud) representation
|
|
9
|
+
* to the canonical string "Custom" so the on-disk file is explicit.
|
|
10
|
+
*/
|
|
11
|
+
export declare function pinLocalModeConfig(current: Readonly<UnityConnectionConfig>, url: string, token: string): UnityConnectionConfig;
|
|
12
|
+
/**
|
|
13
|
+
* Returns true iff `current` already reflects local mode with matching url + token.
|
|
14
|
+
* Used to make bootstrap-local a no-op when nothing would change on disk.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAlreadyPinned(current: Readonly<UnityConnectionConfig>, url: string, token: string): boolean;
|
|
17
|
+
export declare const bootstrapLocalCommand: Command;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright (c) 2025 Ivan Murzak. All rights reserved.
|
|
2
|
+
// Licensed under the Apache License, Version 2.0.
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import * as path from 'path';
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as ui from '../utils/ui.js';
|
|
7
|
+
import { verbose } from '../utils/ui.js';
|
|
8
|
+
import { resolveAndValidateProjectPath } from '../utils/connection.js';
|
|
9
|
+
import { readConfig, writeConfig, } from '../utils/config.js';
|
|
10
|
+
/**
|
|
11
|
+
* Produce a new config object with local-mode fields pinned to `url` / `token`.
|
|
12
|
+
* Preserves all other keys from `current` (immutable update — does not mutate `current`).
|
|
13
|
+
*
|
|
14
|
+
* The plugin-side ConnectionMode enum only accepts "Custom" (local) or "Cloud".
|
|
15
|
+
* We intentionally normalize any integer (0 → Custom, 1 → Cloud) representation
|
|
16
|
+
* to the canonical string "Custom" so the on-disk file is explicit.
|
|
17
|
+
*/
|
|
18
|
+
export function pinLocalModeConfig(current, url, token) {
|
|
19
|
+
return {
|
|
20
|
+
...current,
|
|
21
|
+
connectionMode: 'Custom',
|
|
22
|
+
host: url,
|
|
23
|
+
token,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns true iff `current` already reflects local mode with matching url + token.
|
|
28
|
+
* Used to make bootstrap-local a no-op when nothing would change on disk.
|
|
29
|
+
*/
|
|
30
|
+
export function isAlreadyPinned(current, url, token) {
|
|
31
|
+
// Accept both "Custom" (string) and 0 (legacy int) as already-local.
|
|
32
|
+
// Anything else (including "Cloud", 1, or unset) means we still need to pin.
|
|
33
|
+
const mode = current.connectionMode;
|
|
34
|
+
if (mode !== 'Custom' && mode !== 0)
|
|
35
|
+
return false;
|
|
36
|
+
return current.host === url && current.token === token;
|
|
37
|
+
}
|
|
38
|
+
export const bootstrapLocalCommand = new Command('bootstrap-local')
|
|
39
|
+
.description('Pin a Unity project\'s MCP config to local mode with the given URL/token. Idempotent.')
|
|
40
|
+
.argument('[path]', 'Unity project path (defaults to cwd)')
|
|
41
|
+
.option('--path <path>', 'Unity project path (defaults to cwd)')
|
|
42
|
+
.requiredOption('--url <url>', 'Local MCP server URL to pin (e.g. http://localhost:5140/)')
|
|
43
|
+
.requiredOption('--token <token>', 'Local MCP bearer token to pin')
|
|
44
|
+
.option('--dry-run', 'Report what would change without writing to disk')
|
|
45
|
+
.action(async (positionalPath, options) => {
|
|
46
|
+
const projectPath = resolveAndValidateProjectPath(positionalPath, options);
|
|
47
|
+
// commander's requiredOption guarantees url/token are defined before the action runs.
|
|
48
|
+
const url = options.url.replace(/\/$/, '');
|
|
49
|
+
const token = options.token;
|
|
50
|
+
verbose(`Project path: ${projectPath}`);
|
|
51
|
+
verbose(`Target URL: ${url}`);
|
|
52
|
+
verbose(`Target token: ${'*'.repeat(Math.min(token.length, 8))}... (length ${token.length})`);
|
|
53
|
+
const configPath = path.join(projectPath, 'UserSettings', 'AI-Game-Developer-Config.json');
|
|
54
|
+
const existedBefore = fs.existsSync(configPath);
|
|
55
|
+
// Use readConfig (not getOrCreateConfig) so --dry-run truly has no side effects.
|
|
56
|
+
// When the file doesn't exist we pin onto an empty base; this mirrors a fresh
|
|
57
|
+
// worktree where the plugin has not yet written its default Cloud config.
|
|
58
|
+
const current = readConfig(projectPath) ?? {};
|
|
59
|
+
if (isAlreadyPinned(current, url, token)) {
|
|
60
|
+
ui.success(`MCP config already pinned to local mode (${url}). No changes written.`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const next = pinLocalModeConfig(current, url, token);
|
|
64
|
+
if (options.dryRun) {
|
|
65
|
+
ui.heading('bootstrap-local (dry run)');
|
|
66
|
+
ui.label('Config file', configPath);
|
|
67
|
+
ui.label('connectionMode', `${String(current.connectionMode ?? 'unset')} → Custom`);
|
|
68
|
+
ui.label('host', `${String(current.host ?? 'unset')} → ${url}`);
|
|
69
|
+
ui.label('token', `${current.token ? '<previous>' : '<unset>'} → <supplied>`);
|
|
70
|
+
ui.info('No changes written (--dry-run).');
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
writeConfig(projectPath, next);
|
|
74
|
+
ui.heading('bootstrap-local');
|
|
75
|
+
ui.label('Config file', configPath);
|
|
76
|
+
ui.label('connectionMode', 'Custom');
|
|
77
|
+
ui.label('host', url);
|
|
78
|
+
ui.label('token', '<supplied>');
|
|
79
|
+
ui.success(existedBefore
|
|
80
|
+
? 'Config updated to pin local mode.'
|
|
81
|
+
: 'Config created and pinned to local mode.');
|
|
82
|
+
});
|
|
83
|
+
//# sourceMappingURL=bootstrap-local.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap-local.js","sourceRoot":"","sources":["../../src/commands/bootstrap-local.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,kDAAkD;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EACL,UAAU,EACV,WAAW,GAEZ,MAAM,oBAAoB,CAAC;AAS5B;;;;;;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CAAC,CAAC;QAC3C,OAAO;IACT,CAAC;IAED,WAAW,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAE/B,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAC9B,EAAE,CAAC,KAAK,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACpC,EAAE,CAAC,KAAK,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;IACrC,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtB,EAAE,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IAChC,EAAE,CAAC,OAAO,CACR,aAAa;QACX,CAAC,CAAC,mCAAmC;QACrC,CAAC,CAAC,0CAA0C,CAC/C,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
import * as path from 'path';
|
|
3
|
-
import * as fs from 'fs';
|
|
4
|
-
import { getOrCreateConfig, writeConfig, updateFeatures } from '../utils/config.js';
|
|
5
3
|
import * as ui from '../utils/ui.js';
|
|
6
4
|
import { verbose } from '../utils/ui.js';
|
|
5
|
+
import { configure } from '../lib/configure.js';
|
|
7
6
|
function parseCommaSeparated(value) {
|
|
8
7
|
return value.split(',').map((s) => s.trim()).filter(Boolean);
|
|
9
8
|
}
|
|
9
|
+
function buildAction(enable, disable, enableAll, disableAll) {
|
|
10
|
+
if (!enable && !disable && !enableAll && !disableAll)
|
|
11
|
+
return undefined;
|
|
12
|
+
return {
|
|
13
|
+
enableNames: enable,
|
|
14
|
+
disableNames: disable,
|
|
15
|
+
enableAll,
|
|
16
|
+
disableAll,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
10
19
|
export const configureCommand = new Command('configure')
|
|
11
20
|
.description('Configure MCP tools, prompts, and resources in AI-Game-Developer-Config.json')
|
|
12
21
|
.argument('[path]', 'Path to the Unity project')
|
|
@@ -31,63 +40,46 @@ export const configureCommand = new Command('configure')
|
|
|
31
40
|
process.exit(1);
|
|
32
41
|
}
|
|
33
42
|
const projectPath = path.resolve(resolvedPath);
|
|
34
|
-
|
|
35
|
-
|
|
43
|
+
verbose(`Loading config for project: ${projectPath}`);
|
|
44
|
+
// `--list` must be read-only: previously this command short-
|
|
45
|
+
// circuited before applying any enable/disable flags. Preserve
|
|
46
|
+
// that semantics by suppressing the mutating actions whenever
|
|
47
|
+
// `options.list` is set, regardless of other flags.
|
|
48
|
+
const toolsAction = buildAction(options.enableTools, options.disableTools, options.enableAllTools, options.disableAllTools);
|
|
49
|
+
const promptsAction = buildAction(options.enablePrompts, options.disablePrompts, options.enableAllPrompts, options.disableAllPrompts);
|
|
50
|
+
const resourcesAction = buildAction(options.enableResources, options.disableResources, options.enableAllResources, options.disableAllResources);
|
|
51
|
+
const result = await configure({
|
|
52
|
+
unityProjectPath: projectPath,
|
|
53
|
+
tools: options.list ? undefined : toolsAction,
|
|
54
|
+
prompts: options.list ? undefined : promptsAction,
|
|
55
|
+
resources: options.list ? undefined : resourcesAction,
|
|
56
|
+
});
|
|
57
|
+
if (!result.success) {
|
|
58
|
+
ui.error(result.error?.message ?? 'Unknown error');
|
|
36
59
|
process.exit(1);
|
|
37
60
|
}
|
|
38
|
-
|
|
39
|
-
const config = getOrCreateConfig(projectPath);
|
|
40
|
-
if (options.list) {
|
|
61
|
+
if (options.list && result.snapshot) {
|
|
41
62
|
ui.heading('Current configuration');
|
|
42
|
-
ui.label('Host',
|
|
43
|
-
ui.label('Keep Connected', String(
|
|
44
|
-
ui.label('Transport',
|
|
45
|
-
ui.label('Auth',
|
|
63
|
+
ui.label('Host', result.snapshot.host ?? 'not set');
|
|
64
|
+
ui.label('Keep Connected', String(result.snapshot.keepConnected ?? false));
|
|
65
|
+
ui.label('Transport', result.snapshot.transportMethod ?? 'streamableHttp');
|
|
66
|
+
ui.label('Auth', result.snapshot.authOption ?? 'none');
|
|
46
67
|
const printFeatures = (featureLabel, features) => {
|
|
47
|
-
|
|
48
|
-
|
|
68
|
+
ui.heading(featureLabel);
|
|
69
|
+
if (features.length === 0) {
|
|
49
70
|
ui.info('(none configured - all enabled by default)');
|
|
50
71
|
return;
|
|
51
72
|
}
|
|
52
|
-
ui.heading(featureLabel);
|
|
53
73
|
for (const f of features) {
|
|
54
74
|
ui.featureRow(f.name, f.enabled);
|
|
55
75
|
}
|
|
56
76
|
};
|
|
57
|
-
printFeatures('Tools',
|
|
58
|
-
printFeatures('Prompts',
|
|
59
|
-
printFeatures('Resources',
|
|
77
|
+
printFeatures('Tools', result.snapshot.tools);
|
|
78
|
+
printFeatures('Prompts', result.snapshot.prompts);
|
|
79
|
+
printFeatures('Resources', result.snapshot.resources);
|
|
60
80
|
return;
|
|
61
81
|
}
|
|
62
|
-
// Apply tool changes
|
|
63
|
-
if (options.enableTools || options.disableTools || options.enableAllTools || options.disableAllTools) {
|
|
64
|
-
updateFeatures(config, 'tools', {
|
|
65
|
-
enableNames: options.enableTools,
|
|
66
|
-
disableNames: options.disableTools,
|
|
67
|
-
enableAll: options.enableAllTools,
|
|
68
|
-
disableAll: options.disableAllTools,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// Apply prompt changes
|
|
72
|
-
if (options.enablePrompts || options.disablePrompts || options.enableAllPrompts || options.disableAllPrompts) {
|
|
73
|
-
updateFeatures(config, 'prompts', {
|
|
74
|
-
enableNames: options.enablePrompts,
|
|
75
|
-
disableNames: options.disablePrompts,
|
|
76
|
-
enableAll: options.enableAllPrompts,
|
|
77
|
-
disableAll: options.disableAllPrompts,
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
// Apply resource changes
|
|
81
|
-
if (options.enableResources || options.disableResources || options.enableAllResources || options.disableAllResources) {
|
|
82
|
-
updateFeatures(config, 'resources', {
|
|
83
|
-
enableNames: options.enableResources,
|
|
84
|
-
disableNames: options.disableResources,
|
|
85
|
-
enableAll: options.enableAllResources,
|
|
86
|
-
disableAll: options.disableAllResources,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
82
|
verbose('Writing updated configuration');
|
|
90
|
-
writeConfig(projectPath, config);
|
|
91
83
|
ui.success('Configuration updated successfully.');
|
|
92
84
|
});
|
|
93
85
|
//# 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,
|
|
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,gBAAgB,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,WAAW,CAClB,MAA4B,EAC5B,OAA6B,EAC7B,SAA8B,EAC9B,UAA+B;IAE/B,IAAI,CAAC,MAAM,IAAI,CAAC,OAAO,IAAI,CAAC,SAAS,IAAI,CAAC,UAAU;QAAE,OAAO,SAAS,CAAC;IACvE,OAAO;QACL,WAAW,EAAE,MAAM;QACnB,YAAY,EAAE,OAAO;QACrB,SAAS;QACT,UAAU;KACX,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,OAA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} from '../utils/manifest.js';
|
|
5
3
|
import * as ui from '../utils/ui.js';
|
|
6
4
|
import { verbose } from '../utils/ui.js';
|
|
5
|
+
import { installPlugin } from '../lib/install-plugin.js';
|
|
7
6
|
export const installPluginCommand = new Command('install-plugin')
|
|
8
7
|
.description('Install Unity-MCP plugin into a Unity project')
|
|
9
8
|
.argument('[path]', 'Path to the Unity project')
|
|
@@ -16,31 +15,50 @@ export const installPluginCommand = new Command('install-plugin')
|
|
|
16
15
|
process.exit(1);
|
|
17
16
|
}
|
|
18
17
|
const projectPath = path.resolve(resolvedPath);
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
// Wire the library's progress events back into the CLI's chalk-
|
|
19
|
+
// styled ui so the terminal experience stays identical.
|
|
20
|
+
let spinner;
|
|
21
|
+
if (!options.pluginVersion) {
|
|
22
|
+
spinner = ui.startSpinner('Resolving latest plugin version...');
|
|
24
23
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
const result = await installPlugin({
|
|
25
|
+
unityProjectPath: projectPath,
|
|
26
|
+
version: options.pluginVersion,
|
|
27
|
+
onProgress: (event) => {
|
|
28
|
+
if (event.phase === 'dependencies-resolved' && spinner) {
|
|
29
|
+
spinner.success(`Resolved plugin version: ${event.version}`);
|
|
30
|
+
spinner = undefined;
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (event.phase === 'manifest-patched') {
|
|
34
|
+
// Preserve the historical `ui.success("Updated …")` vs
|
|
35
|
+
// `ui.info("manifest.json is already up to date.")` split
|
|
36
|
+
// that the shared manifest helpers used to print directly.
|
|
37
|
+
if (event.message.startsWith('Updated ')) {
|
|
38
|
+
ui.success(event.message);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
ui.info(event.message);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
if (!result.success) {
|
|
47
|
+
if (spinner) {
|
|
35
48
|
spinner.error('Failed to resolve plugin version');
|
|
36
|
-
|
|
37
|
-
process.exit(1);
|
|
49
|
+
spinner = undefined;
|
|
38
50
|
}
|
|
51
|
+
ui.error(result.error?.message ?? 'Unknown error');
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
verbose(`Plugin version: ${result.installedVersion} (explicit: ${!!options.pluginVersion})`);
|
|
55
|
+
if (result.manifestPath) {
|
|
56
|
+
verbose(`Manifest path: ${result.manifestPath}`);
|
|
57
|
+
}
|
|
58
|
+
ui.info(`Installing Unity-MCP plugin v${result.installedVersion} into: ${projectPath}`);
|
|
59
|
+
for (const warning of result.warnings) {
|
|
60
|
+
ui.warn(warning);
|
|
39
61
|
}
|
|
40
|
-
verbose(`Plugin version: ${version} (explicit: ${isExplicitVersion})`);
|
|
41
|
-
verbose(`Manifest path: ${manifestPath}`);
|
|
42
|
-
ui.info(`Installing Unity-MCP plugin v${version} into: ${projectPath}`);
|
|
43
|
-
addPluginToManifest(projectPath, version, isExplicitVersion);
|
|
44
62
|
ui.success('Done! Open the project in Unity Editor to complete installation.');
|
|
45
63
|
});
|
|
46
64
|
//# sourceMappingURL=install-plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"install-plugin.js","sourceRoot":"","sources":["../../src/commands/install-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"install-plugin.js","sourceRoot":"","sources":["../../src/commands/install-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC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commands/open.d.ts
CHANGED
|
@@ -1,2 +1,22 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
export interface ResolveProjectPathResult {
|
|
3
|
+
/** Absolute, resolved path to the project directory. */
|
|
4
|
+
projectPath: string;
|
|
5
|
+
/** True if no path was supplied and we fell back to `process.cwd()`. */
|
|
6
|
+
usedCwdFallback: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Resolve the project path from the positional argument, `--path` option, or
|
|
10
|
+
* the current working directory when neither is provided.
|
|
11
|
+
*
|
|
12
|
+
* Exported for unit testing.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolveOpenProjectPath(positionalPath: string | undefined, optionPath: string | undefined, cwd: string): ResolveProjectPathResult;
|
|
15
|
+
/**
|
|
16
|
+
* Returns true if `projectPath` looks like a Unity project — i.e. it contains
|
|
17
|
+
* an `Assets/` directory and a `ProjectSettings/ProjectVersion.txt` file.
|
|
18
|
+
*
|
|
19
|
+
* Exported for unit testing.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isUnityProjectDir(projectPath: string): boolean;
|
|
2
22
|
export declare const openCommand: Command;
|
package/dist/commands/open.js
CHANGED
|
@@ -6,10 +6,35 @@ import { findUnityProcess } from '../utils/unity-process.js';
|
|
|
6
6
|
import * as ui from '../utils/ui.js';
|
|
7
7
|
import { verbose } from '../utils/ui.js';
|
|
8
8
|
import { readConfig, isCloudMode, writeConfig } from '../utils/config.js';
|
|
9
|
+
/**
|
|
10
|
+
* Resolve the project path from the positional argument, `--path` option, or
|
|
11
|
+
* the current working directory when neither is provided.
|
|
12
|
+
*
|
|
13
|
+
* Exported for unit testing.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveOpenProjectPath(positionalPath, optionPath, cwd) {
|
|
16
|
+
const explicit = positionalPath ?? optionPath;
|
|
17
|
+
const resolvedPath = explicit ?? cwd;
|
|
18
|
+
return {
|
|
19
|
+
projectPath: path.resolve(resolvedPath),
|
|
20
|
+
usedCwdFallback: explicit === undefined,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns true if `projectPath` looks like a Unity project — i.e. it contains
|
|
25
|
+
* an `Assets/` directory and a `ProjectSettings/ProjectVersion.txt` file.
|
|
26
|
+
*
|
|
27
|
+
* Exported for unit testing.
|
|
28
|
+
*/
|
|
29
|
+
export function isUnityProjectDir(projectPath) {
|
|
30
|
+
const hasAssets = fs.existsSync(path.join(projectPath, 'Assets'));
|
|
31
|
+
const hasProjectVersion = fs.existsSync(path.join(projectPath, 'ProjectSettings', 'ProjectVersion.txt'));
|
|
32
|
+
return hasAssets && hasProjectVersion;
|
|
33
|
+
}
|
|
9
34
|
export const openCommand = new Command('open')
|
|
10
35
|
.description('Open a Unity project in Unity Editor, optionally passing MCP connection env vars when connection options (--url, --token, etc.) are provided. Use --no-connect to suppress all MCP env vars.')
|
|
11
|
-
.argument('[path]', 'Path to the Unity project')
|
|
12
|
-
.option('--path <path>', 'Path to the Unity project')
|
|
36
|
+
.argument('[path]', 'Path to the Unity project (defaults to current directory)')
|
|
37
|
+
.option('--path <path>', 'Path to the Unity project (defaults to current directory)')
|
|
13
38
|
.option('--unity <version>', 'Specific Unity Editor version to use')
|
|
14
39
|
.option('--no-connect', 'Open without MCP connection environment variables')
|
|
15
40
|
.option('--url <url>', 'MCP server URL to connect to (sets UNITY_MCP_HOST)')
|
|
@@ -20,16 +45,28 @@ export const openCommand = new Command('open')
|
|
|
20
45
|
.option('--transport <method>', 'Transport method: streamableHttp or stdio (sets UNITY_MCP_TRANSPORT)')
|
|
21
46
|
.option('--start-server <value>', 'Set to true/false to control server auto-start (sets UNITY_MCP_START_SERVER)', undefined)
|
|
22
47
|
.action(async (positionalPath, options) => {
|
|
23
|
-
const
|
|
24
|
-
if (!resolvedPath) {
|
|
25
|
-
ui.error('Path is required. Usage: unity-mcp-cli open <path> or --path <path>');
|
|
26
|
-
process.exit(1);
|
|
27
|
-
}
|
|
28
|
-
const projectPath = path.resolve(resolvedPath);
|
|
48
|
+
const { projectPath, usedCwdFallback } = resolveOpenProjectPath(positionalPath, options.path, process.cwd());
|
|
29
49
|
if (!fs.existsSync(projectPath)) {
|
|
30
50
|
ui.error(`Project path does not exist: ${projectPath}`);
|
|
31
51
|
process.exit(1);
|
|
32
52
|
}
|
|
53
|
+
// Validate the directory looks like a Unity project. We require the
|
|
54
|
+
// presence of both `Assets/` and `ProjectSettings/ProjectVersion.txt`
|
|
55
|
+
// to avoid launching the Editor against an unrelated folder — this
|
|
56
|
+
// matters most when the user omits the path and we fall back to cwd.
|
|
57
|
+
if (!isUnityProjectDir(projectPath)) {
|
|
58
|
+
if (usedCwdFallback) {
|
|
59
|
+
ui.error(`Current directory is not a Unity project: ${projectPath}`);
|
|
60
|
+
ui.info('Run this command from a Unity project folder, or pass a path: unity-mcp-cli open <path>');
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
ui.error(`Not a Unity project (missing Assets/ or ProjectSettings/ProjectVersion.txt): ${projectPath}`);
|
|
64
|
+
}
|
|
65
|
+
process.exit(1);
|
|
66
|
+
}
|
|
67
|
+
if (usedCwdFallback) {
|
|
68
|
+
verbose(`No path provided — using current directory: ${projectPath}`);
|
|
69
|
+
}
|
|
33
70
|
verbose(`open invoked for project: ${projectPath}`);
|
|
34
71
|
verbose(`--no-connect: ${options.connect === false}`);
|
|
35
72
|
// Check if Unity is already running with this project
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open.js","sourceRoot":"","sources":["../../src/commands/open.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,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAC1H,OAAO,EAAE,gBAAgB,EAAE,MAAM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