@akiojin/unity-mcp-server 3.2.1 → 4.1.2
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/package.json +1 -1
- package/src/core/config.js +27 -0
- package/src/core/projectInfo.js +17 -2
- package/src/core/toolManifest.json +79 -79
- package/src/core/unityConnection.js +74 -7
- package/src/handlers/analysis/FindByComponentToolHandler.js +1 -1
- package/src/handlers/analysis/GetComponentValuesToolHandler.js +1 -1
- package/src/handlers/analysis/GetObjectReferencesToolHandler.js +1 -1
- package/src/handlers/asset/AssetDatabaseManageToolHandler.js +1 -1
- package/src/handlers/asset/AssetDependencyAnalyzeToolHandler.js +1 -1
- package/src/handlers/asset/AssetImportSettingsManageToolHandler.js +1 -1
- package/src/handlers/asset/AssetMaterialCreateToolHandler.js +1 -1
- package/src/handlers/asset/AssetMaterialModifyToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabCreateToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabExitModeToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabInstantiateToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabModifyToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabOpenToolHandler.js +1 -1
- package/src/handlers/asset/AssetPrefabSaveToolHandler.js +1 -1
- package/src/handlers/compilation/CompilationGetStateToolHandler.js +1 -1
- package/src/handlers/component/ComponentAddToolHandler.js +1 -1
- package/src/handlers/component/ComponentFieldSetToolHandler.js +1 -1
- package/src/handlers/component/ComponentGetTypesToolHandler.js +1 -1
- package/src/handlers/component/ComponentListToolHandler.js +1 -1
- package/src/handlers/component/ComponentModifyToolHandler.js +1 -1
- package/src/handlers/component/ComponentRemoveToolHandler.js +1 -1
- package/src/handlers/console/ConsoleClearToolHandler.js +1 -1
- package/src/handlers/console/ConsoleReadToolHandler.js +1 -1
- package/src/handlers/editor/EditorLayersManageToolHandler.js +21 -25
- package/src/handlers/editor/EditorQuitToolHandler.js +1 -1
- package/src/handlers/editor/EditorSelectionManageToolHandler.js +1 -1
- package/src/handlers/editor/EditorTagsManageToolHandler.js +1 -1
- package/src/handlers/editor/EditorToolsManageToolHandler.js +1 -1
- package/src/handlers/editor/EditorWindowsManageToolHandler.js +1 -1
- package/src/handlers/gameobject/GameObjectCreateToolHandler.js +2 -2
- package/src/handlers/gameobject/GameObjectDeleteToolHandler.js +2 -2
- package/src/handlers/gameobject/GameObjectFindToolHandler.js +19 -5
- package/src/handlers/gameobject/GameObjectGetHierarchyToolHandler.js +2 -2
- package/src/handlers/gameobject/GameObjectModifyToolHandler.js +2 -2
- package/src/handlers/menu/MenuItemExecuteToolHandler.js +1 -1
- package/src/handlers/package/PackageManagerToolHandler.js +2 -2
- package/src/handlers/package/RegistryConfigToolHandler.js +1 -1
- package/src/handlers/playmode/PlaymodeGetStateToolHandler.js +1 -1
- package/src/handlers/playmode/PlaymodePauseToolHandler.js +2 -2
- package/src/handlers/playmode/PlaymodePlayToolHandler.js +2 -2
- package/src/handlers/playmode/PlaymodeStopToolHandler.js +2 -2
- package/src/handlers/playmode/PlaymodeWaitForStateToolHandler.js +1 -1
- package/src/handlers/scene/SceneCreateToolHandler.js +1 -1
- package/src/handlers/scene/SceneListToolHandler.js +1 -1
- package/src/handlers/scene/SceneLoadToolHandler.js +1 -1
- package/src/handlers/scene/SceneSaveToolHandler.js +1 -1
- package/src/handlers/screenshot/ScreenshotAnalyzeToolHandler.js +1 -1
- package/src/handlers/screenshot/ScreenshotCaptureToolHandler.js +1 -1
- package/src/handlers/script/ScriptSymbolsGetToolHandler.js +39 -21
- package/src/handlers/settings/SettingsGetToolHandler.js +1 -1
- package/src/handlers/settings/SettingsUpdateToolHandler.js +1 -1
- package/src/handlers/system/SystemGetCommandStatsToolHandler.js +1 -1
- package/src/handlers/system/SystemPingToolHandler.js +2 -2
- package/src/handlers/system/SystemRefreshAssetsToolHandler.js +2 -2
- package/src/handlers/test/TestGetStatusToolHandler.js +1 -1
- package/src/handlers/test/TestRunToolHandler.js +1 -1
- package/src/handlers/ui/UIClickElementToolHandler.js +1 -1
- package/src/handlers/ui/UIFindElementsToolHandler.js +1 -1
- package/src/handlers/ui/UIGetElementStateToolHandler.js +1 -1
- package/src/handlers/ui/UISetElementValueToolHandler.js +1 -1
- package/src/handlers/ui/UISimulateInputToolHandler.js +1 -1
- package/src/handlers/video/VideoCaptureForToolHandler.js +6 -6
- package/src/handlers/video/VideoCaptureStartToolHandler.js +1 -1
- package/src/handlers/video/VideoCaptureStatusToolHandler.js +1 -1
- package/src/handlers/video/VideoCaptureStopToolHandler.js +2 -2
- package/src/tools/analysis/analyzeSceneContents.js +2 -2
- package/src/tools/analysis/findByComponent.js +2 -2
- package/src/tools/analysis/getAnimatorState.js +6 -6
- package/src/tools/analysis/getComponentValues.js +2 -2
- package/src/tools/analysis/getGameObjectDetails.js +2 -2
- package/src/tools/analysis/getInputActionsState.js +2 -2
- package/src/tools/analysis/getObjectReferences.js +2 -2
- package/src/tools/input/inputActionsEditor.js +9 -9
- package/src/tools/scene/createScene.js +3 -3
- package/src/tools/scene/getSceneInfo.js +2 -2
- package/src/tools/scene/listScenes.js +3 -3
- package/src/tools/scene/loadScene.js +3 -3
- package/src/tools/scene/saveScene.js +3 -3
- package/src/tools/system/ping.js +5 -5
- package/src/core/unityCommandType.js +0 -10
package/package.json
CHANGED
package/src/core/config.js
CHANGED
|
@@ -115,6 +115,12 @@ const baseConfig = {
|
|
|
115
115
|
description: 'MCP server for Unity Editor integration'
|
|
116
116
|
},
|
|
117
117
|
|
|
118
|
+
// Compatibility / safety checks
|
|
119
|
+
compat: {
|
|
120
|
+
// warn|error|off
|
|
121
|
+
versionMismatch: 'warn'
|
|
122
|
+
},
|
|
123
|
+
|
|
118
124
|
// Logging settings
|
|
119
125
|
logging: {
|
|
120
126
|
level: 'info',
|
|
@@ -171,6 +177,7 @@ function loadEnvConfig() {
|
|
|
171
177
|
const projectRoot = envString('UNITY_PROJECT_ROOT');
|
|
172
178
|
|
|
173
179
|
const logLevel = envString('UNITY_MCP_LOG_LEVEL');
|
|
180
|
+
const versionMismatch = envString('UNITY_MCP_VERSION_MISMATCH');
|
|
174
181
|
|
|
175
182
|
const httpEnabled = parseBoolEnv(process.env.UNITY_MCP_HTTP_ENABLED);
|
|
176
183
|
const httpPort = parseIntEnv(process.env.UNITY_MCP_HTTP_PORT);
|
|
@@ -197,6 +204,10 @@ function loadEnvConfig() {
|
|
|
197
204
|
out.logging = { level: logLevel };
|
|
198
205
|
}
|
|
199
206
|
|
|
207
|
+
if (versionMismatch) {
|
|
208
|
+
out.compat = { versionMismatch };
|
|
209
|
+
}
|
|
210
|
+
|
|
200
211
|
if (httpEnabled !== undefined || httpPort !== undefined) {
|
|
201
212
|
out.http = {};
|
|
202
213
|
if (httpEnabled !== undefined) out.http.enabled = httpEnabled;
|
|
@@ -247,6 +258,22 @@ function validateAndNormalizeConfig(cfg) {
|
|
|
247
258
|
}
|
|
248
259
|
}
|
|
249
260
|
|
|
261
|
+
// compat.versionMismatch
|
|
262
|
+
if (cfg.compat?.versionMismatch) {
|
|
263
|
+
const raw = String(cfg.compat.versionMismatch).trim().toLowerCase();
|
|
264
|
+
const normalized =
|
|
265
|
+
raw === 'warning' ? 'warn' : raw === 'none' || raw === 'ignore' ? 'off' : raw;
|
|
266
|
+
const allowed = new Set(['warn', 'error', 'off']);
|
|
267
|
+
if (!allowed.has(normalized)) {
|
|
268
|
+
console.error(
|
|
269
|
+
`[unity-mcp-server] WARN: Invalid UNITY_MCP_VERSION_MISMATCH (${cfg.compat.versionMismatch}); using default warn`
|
|
270
|
+
);
|
|
271
|
+
cfg.compat.versionMismatch = 'warn';
|
|
272
|
+
} else {
|
|
273
|
+
cfg.compat.versionMismatch = normalized;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
250
277
|
// unity hosts
|
|
251
278
|
if (typeof cfg.unity.unityHost !== 'string' || cfg.unity.unityHost.trim() === '') {
|
|
252
279
|
cfg.unity.unityHost = 'localhost';
|
package/src/core/projectInfo.js
CHANGED
|
@@ -18,17 +18,32 @@ const looksLikeUnityProjectRoot = dir => {
|
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
const inferUnityProjectRootFromDir = startDir => {
|
|
21
|
+
// First, search immediate child directories (1 level deep)
|
|
22
|
+
try {
|
|
23
|
+
const entries = fs.readdirSync(startDir, { withFileTypes: true });
|
|
24
|
+
for (const entry of entries) {
|
|
25
|
+
if (!entry.isDirectory()) continue;
|
|
26
|
+
// Skip hidden directories and common non-project directories
|
|
27
|
+
if (entry.name.startsWith('.') || entry.name === 'node_modules') continue;
|
|
28
|
+
const childDir = path.join(startDir, entry.name);
|
|
29
|
+
if (looksLikeUnityProjectRoot(childDir)) return childDir;
|
|
30
|
+
}
|
|
31
|
+
} catch {
|
|
32
|
+
// Fall through to upward search
|
|
33
|
+
}
|
|
34
|
+
// If not found in children, walk up to find a Unity project
|
|
21
35
|
try {
|
|
22
36
|
let dir = startDir;
|
|
23
37
|
const { root } = path.parse(dir);
|
|
24
38
|
while (true) {
|
|
25
39
|
if (looksLikeUnityProjectRoot(dir)) return dir;
|
|
26
|
-
if (dir === root)
|
|
40
|
+
if (dir === root) break;
|
|
27
41
|
dir = path.dirname(dir);
|
|
28
42
|
}
|
|
29
43
|
} catch {
|
|
30
|
-
|
|
44
|
+
// Ignore errors (e.g., permission denied)
|
|
31
45
|
}
|
|
46
|
+
return null;
|
|
32
47
|
};
|
|
33
48
|
|
|
34
49
|
const resolveDefaultCodeIndexRoot = projectRoot => {
|