@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.
Files changed (85) hide show
  1. package/package.json +1 -1
  2. package/src/core/config.js +27 -0
  3. package/src/core/projectInfo.js +17 -2
  4. package/src/core/toolManifest.json +79 -79
  5. package/src/core/unityConnection.js +74 -7
  6. package/src/handlers/analysis/FindByComponentToolHandler.js +1 -1
  7. package/src/handlers/analysis/GetComponentValuesToolHandler.js +1 -1
  8. package/src/handlers/analysis/GetObjectReferencesToolHandler.js +1 -1
  9. package/src/handlers/asset/AssetDatabaseManageToolHandler.js +1 -1
  10. package/src/handlers/asset/AssetDependencyAnalyzeToolHandler.js +1 -1
  11. package/src/handlers/asset/AssetImportSettingsManageToolHandler.js +1 -1
  12. package/src/handlers/asset/AssetMaterialCreateToolHandler.js +1 -1
  13. package/src/handlers/asset/AssetMaterialModifyToolHandler.js +1 -1
  14. package/src/handlers/asset/AssetPrefabCreateToolHandler.js +1 -1
  15. package/src/handlers/asset/AssetPrefabExitModeToolHandler.js +1 -1
  16. package/src/handlers/asset/AssetPrefabInstantiateToolHandler.js +1 -1
  17. package/src/handlers/asset/AssetPrefabModifyToolHandler.js +1 -1
  18. package/src/handlers/asset/AssetPrefabOpenToolHandler.js +1 -1
  19. package/src/handlers/asset/AssetPrefabSaveToolHandler.js +1 -1
  20. package/src/handlers/compilation/CompilationGetStateToolHandler.js +1 -1
  21. package/src/handlers/component/ComponentAddToolHandler.js +1 -1
  22. package/src/handlers/component/ComponentFieldSetToolHandler.js +1 -1
  23. package/src/handlers/component/ComponentGetTypesToolHandler.js +1 -1
  24. package/src/handlers/component/ComponentListToolHandler.js +1 -1
  25. package/src/handlers/component/ComponentModifyToolHandler.js +1 -1
  26. package/src/handlers/component/ComponentRemoveToolHandler.js +1 -1
  27. package/src/handlers/console/ConsoleClearToolHandler.js +1 -1
  28. package/src/handlers/console/ConsoleReadToolHandler.js +1 -1
  29. package/src/handlers/editor/EditorLayersManageToolHandler.js +21 -25
  30. package/src/handlers/editor/EditorQuitToolHandler.js +1 -1
  31. package/src/handlers/editor/EditorSelectionManageToolHandler.js +1 -1
  32. package/src/handlers/editor/EditorTagsManageToolHandler.js +1 -1
  33. package/src/handlers/editor/EditorToolsManageToolHandler.js +1 -1
  34. package/src/handlers/editor/EditorWindowsManageToolHandler.js +1 -1
  35. package/src/handlers/gameobject/GameObjectCreateToolHandler.js +2 -2
  36. package/src/handlers/gameobject/GameObjectDeleteToolHandler.js +2 -2
  37. package/src/handlers/gameobject/GameObjectFindToolHandler.js +19 -5
  38. package/src/handlers/gameobject/GameObjectGetHierarchyToolHandler.js +2 -2
  39. package/src/handlers/gameobject/GameObjectModifyToolHandler.js +2 -2
  40. package/src/handlers/menu/MenuItemExecuteToolHandler.js +1 -1
  41. package/src/handlers/package/PackageManagerToolHandler.js +2 -2
  42. package/src/handlers/package/RegistryConfigToolHandler.js +1 -1
  43. package/src/handlers/playmode/PlaymodeGetStateToolHandler.js +1 -1
  44. package/src/handlers/playmode/PlaymodePauseToolHandler.js +2 -2
  45. package/src/handlers/playmode/PlaymodePlayToolHandler.js +2 -2
  46. package/src/handlers/playmode/PlaymodeStopToolHandler.js +2 -2
  47. package/src/handlers/playmode/PlaymodeWaitForStateToolHandler.js +1 -1
  48. package/src/handlers/scene/SceneCreateToolHandler.js +1 -1
  49. package/src/handlers/scene/SceneListToolHandler.js +1 -1
  50. package/src/handlers/scene/SceneLoadToolHandler.js +1 -1
  51. package/src/handlers/scene/SceneSaveToolHandler.js +1 -1
  52. package/src/handlers/screenshot/ScreenshotAnalyzeToolHandler.js +1 -1
  53. package/src/handlers/screenshot/ScreenshotCaptureToolHandler.js +1 -1
  54. package/src/handlers/script/ScriptSymbolsGetToolHandler.js +39 -21
  55. package/src/handlers/settings/SettingsGetToolHandler.js +1 -1
  56. package/src/handlers/settings/SettingsUpdateToolHandler.js +1 -1
  57. package/src/handlers/system/SystemGetCommandStatsToolHandler.js +1 -1
  58. package/src/handlers/system/SystemPingToolHandler.js +2 -2
  59. package/src/handlers/system/SystemRefreshAssetsToolHandler.js +2 -2
  60. package/src/handlers/test/TestGetStatusToolHandler.js +1 -1
  61. package/src/handlers/test/TestRunToolHandler.js +1 -1
  62. package/src/handlers/ui/UIClickElementToolHandler.js +1 -1
  63. package/src/handlers/ui/UIFindElementsToolHandler.js +1 -1
  64. package/src/handlers/ui/UIGetElementStateToolHandler.js +1 -1
  65. package/src/handlers/ui/UISetElementValueToolHandler.js +1 -1
  66. package/src/handlers/ui/UISimulateInputToolHandler.js +1 -1
  67. package/src/handlers/video/VideoCaptureForToolHandler.js +6 -6
  68. package/src/handlers/video/VideoCaptureStartToolHandler.js +1 -1
  69. package/src/handlers/video/VideoCaptureStatusToolHandler.js +1 -1
  70. package/src/handlers/video/VideoCaptureStopToolHandler.js +2 -2
  71. package/src/tools/analysis/analyzeSceneContents.js +2 -2
  72. package/src/tools/analysis/findByComponent.js +2 -2
  73. package/src/tools/analysis/getAnimatorState.js +6 -6
  74. package/src/tools/analysis/getComponentValues.js +2 -2
  75. package/src/tools/analysis/getGameObjectDetails.js +2 -2
  76. package/src/tools/analysis/getInputActionsState.js +2 -2
  77. package/src/tools/analysis/getObjectReferences.js +2 -2
  78. package/src/tools/input/inputActionsEditor.js +9 -9
  79. package/src/tools/scene/createScene.js +3 -3
  80. package/src/tools/scene/getSceneInfo.js +2 -2
  81. package/src/tools/scene/listScenes.js +3 -3
  82. package/src/tools/scene/loadScene.js +3 -3
  83. package/src/tools/scene/saveScene.js +3 -3
  84. package/src/tools/system/ping.js +5 -5
  85. package/src/core/unityCommandType.js +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akiojin/unity-mcp-server",
3
- "version": "3.2.1",
3
+ "version": "4.1.2",
4
4
  "description": "MCP server and Unity Editor bridge — enables AI assistants to control Unity for AI-assisted workflows",
5
5
  "type": "module",
6
6
  "main": "src/core/server.js",
@@ -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';
@@ -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) return null;
40
+ if (dir === root) break;
27
41
  dir = path.dirname(dir);
28
42
  }
29
43
  } catch {
30
- return null;
44
+ // Ignore errors (e.g., permission denied)
31
45
  }
46
+ return null;
32
47
  };
33
48
 
34
49
  const resolveDefaultCodeIndexRoot = projectRoot => {