@akiojin/unity-mcp-server 2.14.17 → 2.16.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.
Files changed (127) hide show
  1. package/LICENSE +0 -0
  2. package/README.md +142 -99
  3. package/package.json +4 -3
  4. package/src/core/codeIndex.js +0 -0
  5. package/src/core/codeIndexDb.js +0 -0
  6. package/src/core/config.js +50 -15
  7. package/src/core/indexWatcher.js +2 -3
  8. package/src/core/projectInfo.js +27 -20
  9. package/src/core/unityConnection.js +3 -2
  10. package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +1 -1
  11. package/src/handlers/analysis/FindByComponentToolHandler.js +2 -2
  12. package/src/handlers/analysis/GetAnimatorStateToolHandler.js +1 -1
  13. package/src/handlers/analysis/GetComponentValuesToolHandler.js +2 -2
  14. package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +1 -1
  15. package/src/handlers/analysis/GetInputActionsStateToolHandler.js +1 -1
  16. package/src/handlers/analysis/GetObjectReferencesToolHandler.js +2 -2
  17. package/src/handlers/asset/{AssetDatabaseToolHandler.js → AssetDatabaseManageToolHandler.js} +2 -2
  18. package/src/handlers/asset/{AssetDependencyToolHandler.js → AssetDependencyAnalyzeToolHandler.js} +2 -2
  19. package/src/handlers/asset/{AssetImportSettingsToolHandler.js → AssetImportSettingsManageToolHandler.js} +2 -2
  20. package/src/handlers/asset/{CreateMaterialToolHandler.js → AssetMaterialCreateToolHandler.js} +2 -2
  21. package/src/handlers/asset/{ModifyMaterialToolHandler.js → AssetMaterialModifyToolHandler.js} +2 -2
  22. package/src/handlers/asset/{CreatePrefabToolHandler.js → AssetPrefabCreateToolHandler.js} +2 -2
  23. package/src/handlers/asset/{ExitPrefabModeToolHandler.js → AssetPrefabExitModeToolHandler.js} +2 -2
  24. package/src/handlers/asset/{InstantiatePrefabToolHandler.js → AssetPrefabInstantiateToolHandler.js} +2 -2
  25. package/src/handlers/asset/{ModifyPrefabToolHandler.js → AssetPrefabModifyToolHandler.js} +2 -2
  26. package/src/handlers/asset/{OpenPrefabToolHandler.js → AssetPrefabOpenToolHandler.js} +2 -2
  27. package/src/handlers/asset/{SavePrefabToolHandler.js → AssetPrefabSaveToolHandler.js} +2 -2
  28. package/src/handlers/base/BaseToolHandler.js +0 -0
  29. package/src/handlers/compilation/{GetCompilationStateToolHandler.js → CompilationGetStateToolHandler.js} +2 -2
  30. package/src/handlers/component/{AddComponentToolHandler.js → ComponentAddToolHandler.js} +2 -2
  31. package/src/handlers/component/{GetComponentTypesToolHandler.js → ComponentGetTypesToolHandler.js} +2 -2
  32. package/src/handlers/component/{ListComponentsToolHandler.js → ComponentListToolHandler.js} +2 -2
  33. package/src/handlers/component/{ModifyComponentToolHandler.js → ComponentModifyToolHandler.js} +2 -2
  34. package/src/handlers/component/{RemoveComponentToolHandler.js → ComponentRemoveToolHandler.js} +2 -2
  35. package/src/handlers/console/{ClearConsoleToolHandler.js → ConsoleClearToolHandler.js} +2 -2
  36. package/src/handlers/console/{ReadConsoleToolHandler.js → ConsoleReadToolHandler.js} +2 -2
  37. package/src/handlers/editor/{LayerManagementToolHandler.js → EditorLayersManageToolHandler.js} +2 -2
  38. package/src/handlers/editor/{SelectionToolHandler.js → EditorSelectionManageToolHandler.js} +2 -2
  39. package/src/handlers/editor/{TagManagementToolHandler.js → EditorTagsManageToolHandler.js} +2 -2
  40. package/src/handlers/editor/{ToolManagementToolHandler.js → EditorToolsManageToolHandler.js} +2 -2
  41. package/src/handlers/editor/{WindowManagementToolHandler.js → EditorWindowsManageToolHandler.js} +2 -2
  42. package/src/handlers/gameobject/{CreateGameObjectToolHandler.js → GameObjectCreateToolHandler.js} +3 -3
  43. package/src/handlers/gameobject/{DeleteGameObjectToolHandler.js → GameObjectDeleteToolHandler.js} +3 -3
  44. package/src/handlers/gameobject/{FindGameObjectToolHandler.js → GameObjectFindToolHandler.js} +3 -3
  45. package/src/handlers/gameobject/{GetHierarchyToolHandler.js → GameObjectGetHierarchyToolHandler.js} +3 -3
  46. package/src/handlers/gameobject/{ModifyGameObjectToolHandler.js → GameObjectModifyToolHandler.js} +3 -3
  47. package/src/handlers/index.js +230 -213
  48. package/src/handlers/input/{AddInputActionToolHandler.js → InputActionAddToolHandler.js} +2 -2
  49. package/src/handlers/input/{CreateActionMapToolHandler.js → InputActionMapCreateToolHandler.js} +2 -2
  50. package/src/handlers/input/{RemoveActionMapToolHandler.js → InputActionMapRemoveToolHandler.js} +2 -2
  51. package/src/handlers/input/{RemoveInputActionToolHandler.js → InputActionRemoveToolHandler.js} +2 -2
  52. package/src/handlers/input/{AddInputBindingToolHandler.js → InputBindingAddToolHandler.js} +2 -2
  53. package/src/handlers/input/{CreateCompositeBindingToolHandler.js → InputBindingCompositeCreateToolHandler.js} +2 -2
  54. package/src/handlers/input/{RemoveAllBindingsToolHandler.js → InputBindingRemoveAllToolHandler.js} +2 -2
  55. package/src/handlers/input/{RemoveInputBindingToolHandler.js → InputBindingRemoveToolHandler.js} +2 -2
  56. package/src/handlers/input/{ManageControlSchemesToolHandler.js → InputControlSchemesManageToolHandler.js} +2 -2
  57. package/src/handlers/input/{GamepadSimulationHandler.js → InputGamepadSimulateToolHandler.js} +3 -3
  58. package/src/handlers/input/{KeyboardSimulationHandler.js → InputKeyboardSimulateToolHandler.js} +3 -3
  59. package/src/handlers/input/{MouseSimulationHandler.js → InputMouseSimulateToolHandler.js} +3 -3
  60. package/src/handlers/input/{InputSystemHandler.js → InputSystemControlToolHandler.js} +4 -4
  61. package/src/handlers/input/{TouchSimulationHandler.js → InputTouchSimulateToolHandler.js} +3 -3
  62. package/src/handlers/menu/{ExecuteMenuItemToolHandler.js → MenuItemExecuteToolHandler.js} +2 -2
  63. package/src/handlers/package/PackageManagerToolHandler.js +1 -1
  64. package/src/handlers/package/RegistryConfigToolHandler.js +1 -1
  65. package/src/handlers/playmode/{GetEditorStateToolHandler.js → PlaymodeGetStateToolHandler.js} +2 -2
  66. package/src/handlers/playmode/{PauseToolHandler.js → PlaymodePauseToolHandler.js} +3 -3
  67. package/src/handlers/playmode/{PlayToolHandler.js → PlaymodePlayToolHandler.js} +4 -4
  68. package/src/handlers/playmode/{StopToolHandler.js → PlaymodeStopToolHandler.js} +4 -4
  69. package/src/handlers/playmode/{WaitForEditorStateToolHandler.js → PlaymodeWaitForStateToolHandler.js} +3 -3
  70. package/src/handlers/scene/GetSceneInfoToolHandler.js +1 -1
  71. package/src/handlers/scene/{CreateSceneToolHandler.js → SceneCreateToolHandler.js} +2 -2
  72. package/src/handlers/scene/{ListScenesToolHandler.js → SceneListToolHandler.js} +2 -2
  73. package/src/handlers/scene/{LoadSceneToolHandler.js → SceneLoadToolHandler.js} +2 -2
  74. package/src/handlers/scene/{SaveSceneToolHandler.js → SceneSaveToolHandler.js} +2 -2
  75. package/src/handlers/screenshot/{AnalyzeScreenshotToolHandler.js → ScreenshotAnalyzeToolHandler.js} +2 -2
  76. package/src/handlers/screenshot/{CaptureScreenshotToolHandler.js → ScreenshotCaptureToolHandler.js} +2 -2
  77. package/src/handlers/script/{BuildCodeIndexToolHandler.js → CodeIndexBuildToolHandler.js} +4 -4
  78. package/src/handlers/script/CodeIndexUpdateToolHandler.js +234 -0
  79. package/src/handlers/script/{ScriptCreateClassFileToolHandler.js → ScriptCreateClassToolHandler.js} +2 -2
  80. package/src/handlers/script/ScriptEditSnippetToolHandler.js +272 -0
  81. package/src/handlers/script/ScriptEditStructuredToolHandler.js +0 -0
  82. package/src/handlers/script/ScriptIndexStatusToolHandler.js +2 -2
  83. package/src/handlers/script/ScriptPackagesListToolHandler.js +0 -0
  84. package/src/handlers/script/ScriptReadToolHandler.js +0 -0
  85. package/src/handlers/script/ScriptRefactorRenameToolHandler.js +0 -0
  86. package/src/handlers/script/ScriptRefsFindToolHandler.js +0 -0
  87. package/src/handlers/script/ScriptRemoveSymbolToolHandler.js +0 -0
  88. package/src/handlers/script/ScriptSearchToolHandler.js +0 -0
  89. package/src/handlers/script/ScriptSymbolFindToolHandler.js +0 -0
  90. package/src/handlers/script/ScriptSymbolsGetToolHandler.js +0 -0
  91. package/src/handlers/settings/{GetProjectSettingsToolHandler.js → SettingsGetToolHandler.js} +2 -2
  92. package/src/handlers/settings/{UpdateProjectSettingsToolHandler.js → SettingsUpdateToolHandler.js} +2 -2
  93. package/src/handlers/system/{GetCommandStatsToolHandler.js → SystemGetCommandStatsToolHandler.js} +2 -3
  94. package/src/handlers/system/{PingToolHandler.js → SystemPingToolHandler.js} +3 -3
  95. package/src/handlers/system/{RefreshAssetsToolHandler.js → SystemRefreshAssetsToolHandler.js} +3 -3
  96. package/src/handlers/test/TestGetStatusToolHandler.js +79 -0
  97. package/src/handlers/test/TestRunToolHandler.js +153 -0
  98. package/src/handlers/ui/{ClickUIElementToolHandler.js → UIClickElementToolHandler.js} +2 -2
  99. package/src/handlers/ui/{FindUIElementsToolHandler.js → UIFindElementsToolHandler.js} +2 -2
  100. package/src/handlers/ui/{GetUIElementStateToolHandler.js → UIGetElementStateToolHandler.js} +2 -2
  101. package/src/handlers/ui/{SetUIElementValueToolHandler.js → UISetElementValueToolHandler.js} +2 -2
  102. package/src/handlers/ui/{SimulateUIInputToolHandler.js → UISimulateInputToolHandler.js} +2 -2
  103. package/src/handlers/video/{CaptureVideoForToolHandler.js → VideoCaptureForToolHandler.js} +8 -8
  104. package/src/handlers/video/{CaptureVideoStartToolHandler.js → VideoCaptureStartToolHandler.js} +2 -2
  105. package/src/handlers/video/{CaptureVideoStatusToolHandler.js → VideoCaptureStatusToolHandler.js} +2 -2
  106. package/src/handlers/video/{CaptureVideoStopToolHandler.js → VideoCaptureStopToolHandler.js} +3 -3
  107. package/src/lsp/CSharpLspUtils.js +68 -10
  108. package/src/lsp/LspProcessManager.js +0 -0
  109. package/src/lsp/LspRpcClient.js +14 -0
  110. package/src/tools/analysis/analyzeSceneContents.js +3 -3
  111. package/src/tools/analysis/findByComponent.js +3 -3
  112. package/src/tools/analysis/getAnimatorState.js +6 -6
  113. package/src/tools/analysis/getComponentValues.js +3 -3
  114. package/src/tools/analysis/getGameObjectDetails.js +3 -3
  115. package/src/tools/analysis/getInputActionsState.js +4 -4
  116. package/src/tools/analysis/getObjectReferences.js +3 -3
  117. package/src/tools/input/inputActionsEditor.js +18 -18
  118. package/src/tools/scene/createScene.js +3 -3
  119. package/src/tools/scene/getSceneInfo.js +3 -3
  120. package/src/tools/scene/listScenes.js +3 -3
  121. package/src/tools/scene/loadScene.js +3 -3
  122. package/src/tools/scene/saveScene.js +3 -3
  123. package/src/tools/system/ping.js +5 -5
  124. package/src/tools/video/recordFor.js +2 -2
  125. package/src/tools/video/recordPlayMode.js +0 -0
  126. package/src/utils/csharpParse.js +0 -0
  127. package/src/utils/validators.js +0 -0
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
@@ -74,105 +74,148 @@ Add to your `claude_desktop_config.json`:
74
74
  }
75
75
  ```
76
76
 
77
- ## Available Tools (70 Tools)
78
-
79
- ### System & Core Tools (2 tools)
80
- - `ping` - Test connection to Unity Editor and verify server status
81
- - `refresh_assets` - Refresh Unity assets and trigger recompilation
82
-
83
- ### GameObject Management (5 tools)
84
- - `create_gameobject` - Create GameObjects with primitives, transforms, tags, and layers
85
- - `find_gameobject` - Find GameObjects by name, tag, layer with pattern matching
86
- - `modify_gameobject` - Modify GameObject properties (transform, name, active state, parent)
87
- - `delete_gameobject` - Delete single or multiple GameObjects with child handling
88
- - `get_hierarchy` - Get scene hierarchy with components and depth control
89
-
90
- ### Component System (5 tools)
91
- - `add_component` - Add Unity components to GameObjects with initial properties
92
- - `remove_component` - Remove components from GameObjects with safety checks
93
- - `modify_component` - Modify component properties with nested property support
94
- - `list_components` - List all components on a GameObject with type information
95
- - `get_component_types` - Discover available component types with filtering
96
-
97
- ### Scene Management (5 tools)
98
- - `create_scene` - Create new scenes with build settings integration
99
- - `load_scene` - Load scenes in Single or Additive mode
100
- - `save_scene` - Save current scene with Save As functionality
101
- - `list_scenes` - List all scenes in project with filtering options
102
- - `get_scene_info` - Get detailed scene information including GameObject counts
103
-
104
- ### Scene Analysis (7 tools)
105
- - `get_gameobject_details` - Deep inspection of GameObjects with component details
106
- - `analyze_scene_contents` - Comprehensive scene statistics and performance metrics
107
- - `get_component_values` - Get all properties and values of specific components
108
- - `find_by_component` - Find GameObjects by component type with scope filtering
109
- - `get_object_references` - Analyze references between objects and assets
110
- - `get_animator_state` - Get current Animator state, parameters, and transitions
111
- - `get_animator_runtime_info` - Get runtime Animator info (Play mode only)
112
-
113
- ### Asset Management (11 tools)
114
- - `create_prefab` - Create prefabs from GameObjects or templates
115
- - `modify_prefab` - Modify existing prefabs with property changes
116
- - `instantiate_prefab` - Instantiate prefabs in scenes with transform options
117
- - `open_prefab` - Open prefabs in Unity's prefab mode for editing
118
- - `exit_prefab_mode` - Exit prefab mode with save/discard options
119
- - `save_prefab` - Save prefab changes or apply instance overrides
120
- - `create_material` - Create new materials with shader and properties
121
- - `modify_material` - Modify material properties and shaders
122
- - `manage_asset_import_settings` - Manage asset import settings and presets
123
- - `manage_asset_database` - Asset database operations (find, move, copy, delete)
124
- - `analyze_asset_dependencies` - Analyze asset dependencies and find unused assets
125
-
126
- ### Script Management (6 tools)
127
- - `create_script` - Create new C# scripts with templates (MonoBehaviour, ScriptableObject, etc.)
128
- - `read_script` - Read script file contents with syntax highlighting
129
- - `update_script` - Modify existing scripts with validation
130
- - `delete_script` - Delete script files with dependency checking
131
- - `list_scripts` - List all scripts in project with filtering and metadata
132
- - `validate_script` - Validate script syntax and Unity compatibility
133
-
134
- ### Play Mode Controls (4 tools)
135
- - `play_game` - Start Unity play mode for testing
136
- - `pause_game` - Pause or resume Unity play mode
137
- - `stop_game` - Stop Unity play mode and return to edit mode
138
- - `get_editor_state` - Get current editor state and compilation status
139
-
140
- ### UI Automation (5 tools)
141
- - `find_ui_elements` - Locate UI elements by type, tag, or name
142
- - `click_ui_element` - Simulate clicking on UI elements (buttons, toggles)
143
- - `get_ui_element_state` - Get UI element properties and interaction state
144
- - `set_ui_element_value` - Set values for input fields, sliders, dropdowns
145
- - `simulate_ui_input` - Execute complex UI interaction sequences
146
-
147
- ### Input System Simulation (5 tools)
148
- - `simulate_keyboard` - Simulate keyboard input with key combos and text typing
149
- - `simulate_mouse` - Simulate mouse movement, clicks, drags, and scrolling
150
- - `simulate_gamepad` - Simulate gamepad buttons, sticks, triggers, and d-pad
151
- - `simulate_touch` - Simulate touch gestures (tap, swipe, pinch, multi-touch)
152
- - `get_current_input_state` - Get current state of all input devices
153
-
154
- ### Editor Operations (5 tools)
155
- - `execute_menu_item` - Execute Unity menu items programmatically
156
- - `clear_console` - Clear Unity console logs with filtering options
157
- - `read_console` - Read console logs with advanced filtering and search
158
- - `capture_screenshot` - Take screenshots of Game View or Scene View
159
- - `analyze_screenshot` - Analyze screenshot content with image analysis
160
-
161
- ### Editor Control & Automation (6 tools)
162
- - `manage_tags` - Manage Unity project tags (add, remove, list)
163
- - `manage_layers` - Manage Unity project layers with index conversion
164
- - `manage_selection` - Manage Editor selection (get, set, clear)
165
- - `manage_windows` - Manage Editor windows (list, focus, get state)
166
- - `manage_tools` - Manage Editor tools and plugins
167
- - `get_compilation_state` - Get current compilation state and errors
168
-
169
- ### Project Settings Management (2 tools)
170
- - `get_project_settings` - Read Unity project settings with granular control
171
- - Player, Graphics, Quality, Physics, Audio, Time settings
172
- - Build settings, Tags and layers configuration
173
- - `update_project_settings` - Safely update project settings
174
- - Requires explicit confirmation for safety
175
- - Supports partial updates to specific categories
77
+ ## Code Index Workflow
78
+
79
+ コードの自動編集を安定させるには、以下の 3 ステップでコードインデックスを運用してください。重いフルテストを回す必要はありません。
80
+
81
+ 1. **初回または大幅変更後に `code_index_build`**
82
+ プロジェクト内の `Assets/` と `Packages/` の C# をすべてスキャンし、`.unity/cache/code-index/code-index.db` にシンボルを格納します。
83
+ 2. **ファイル更新後は `code_index_update`**
84
+ 編集したファイルだけを配列で渡すと、LSP から最新シンボルを再取得してインデックスを差分更新します。長時間待ちになる `code_index_build` の再実行を避けられます。
85
+ 3. **シンボル取得時は `script_symbol_find`**
86
+ インデックスが利用可能なら高速に、未構築でも LSP にフォールバックして定義位置を取得できます。`script_edit_*` ツールに渡す `symbolName` 構築に活用してください。
87
+
88
+ > **Tip:** `code_index_update` JSON パラメータ `paths` に絶対パス/相対パスの配列を渡すだけで完了します。内部で存在チェックと LSP リトライを行うため、Unity を起動したままでも短時間で終わります。
89
+
90
+ ## Available Tools (Standardized Names)
91
+
92
+ ### System & Core Tools
93
+ - `system_ping` Test connection to Unity Editor and verify server status
94
+ - `system_refresh_assets` Refresh Unity assets and trigger recompilation
95
+ - `system_get_command_stats` Retrieve recent MCP command usage metrics
96
+
97
+ ### GameObject Management
98
+ - `gameobject_create` Create GameObjects with primitives, transforms, tags, and layers
99
+ - `gameobject_find` Find GameObjects by name, tag, or layer with pattern matching
100
+ - `gameobject_modify` Modify GameObject properties (transform, name, active state, parent)
101
+ - `gameobject_delete` Delete single or multiple GameObjects with child handling
102
+ - `gameobject_get_hierarchy` Inspect scene hierarchy with component details
103
+
104
+ ### Component System
105
+ - `component_add` Add Unity components to GameObjects with initial properties
106
+ - `component_remove` Remove components from GameObjects with safety checks
107
+ - `component_modify` Modify component properties with nested support
108
+ - `component_list` List all components on a GameObject with type information
109
+ - `component_get_types` Discover available component types with filtering
110
+
111
+ ### Scene Management
112
+ - `scene_create` — Create new scenes with build-settings integration
113
+ - `scene_load` Load scenes in Single or Additive mode
114
+ - `scene_save` Save the active scene (supports Save As)
115
+ - `scene_list` List scenes in the project with filtering options
116
+ - `scene_info_get` Retrieve detailed scene information including GameObject counts
117
+
118
+ ### Analysis & Diagnostics
119
+ - `analysis_scene_contents_analyze` Gather scene statistics and performance metrics
120
+ - `analysis_component_find` Locate GameObjects by component type with scope filtering
121
+ - `analysis_component_values_get` Inspect component properties and values
122
+ - `analysis_gameobject_details_get` Deep inspection of GameObjects and components
123
+ - `analysis_object_references_get` Trace references between objects and assets
124
+ - `analysis_animator_state_get` Inspect Animator layers, parameters, and transitions
125
+ - `analysis_animator_runtime_info_get` — Retrieve runtime Animator diagnostics (Play Mode)
126
+
127
+ ### Asset Management
128
+ - `asset_prefab_create` Create prefabs from GameObjects or blank templates
129
+ - `asset_prefab_instantiate` Instantiate prefabs with custom transforms
130
+ - `asset_prefab_modify` Apply property overrides to existing prefabs
131
+ - `asset_prefab_open` Open prefabs in Prefab Mode for editing
132
+ - `asset_prefab_exit_mode` Exit Prefab Mode with save/discard handling
133
+ - `asset_prefab_save` — Save prefab changes or apply instance overrides
134
+ - `asset_material_create` Create materials with shader and property setup
135
+ - `asset_material_modify` Update material properties and shaders
136
+ - `asset_import_settings_manage` Inspect or modify asset-import settings and presets
137
+ - `asset_database_manage` Perform asset database operations (find, move, copy, delete)
138
+ - `asset_dependency_analyze` Audit asset dependencies and identify unused assets
139
+
140
+ ### Script & Code Tools
141
+ - `script_read` Read script file contents with syntax-aware formatting
142
+ - `script_search` Search C# sources by substring/regex/glob filters
143
+ - `script_symbols_get` Enumerate symbols within a specific C# file
144
+ - `script_symbol_find` Locate symbol definitions across the project
145
+ - `script_refs_find` List references/usages for a symbol via C# LSP
146
+ - `script_edit_snippet` — Apply small text edits within C# files
147
+ - `script_edit_structured` Perform structured symbol edits via C# LSP extensions
148
+ - `script_create_class` Generate a new C# class file from parameters
149
+ - `script_remove_symbol` Delete symbols (types/members) with reference checks
150
+ - `script_refactor_rename` Rename symbols project-wide via LSP
151
+ - `script_packages_list` List installed packages relevant to scripting
152
+ - `script_index_status` Report status of the persistent code index
153
+
154
+ ### Code Index Utilities
155
+ - `code_index_build` フルスキャンでシンボルインデックスを再構築
156
+ - `code_index_update` 変更した C# ファイルのみ差分再インデックス
157
+
158
+ ### Play Mode Controls
159
+ - `playmode_play` Enter Play Mode
160
+ - `playmode_pause` — Pause or resume Play Mode
161
+ - `playmode_stop` Exit Play Mode back to Edit Mode
162
+ - `playmode_get_state` Inspect current play/edit/compilation state
163
+ - `playmode_wait_for_state` Await a target play/edit state
164
+
165
+ ### UI Automation
166
+ - `ui_find_elements` Locate UI elements by type, tag, or name
167
+ - `ui_click_element` Simulate clicking UI buttons, toggles, etc.
168
+ - `ui_get_element_state` — Inspect UI element properties and interactability
169
+ - `ui_set_element_value` Modify UI input values (sliders, fields, dropdowns)
170
+ - `ui_simulate_input` Execute complex multi-step UI interaction sequences
171
+
172
+ ### Input System Utilities
173
+ - `input_system_control` Dispatch keyboard/mouse/gamepad/touch operations
174
+ - `input_keyboard_simulate` Simulate keyboard input with combos or text
175
+ - `input_mouse_simulate` Simulate mouse movement, clicks, drags, and scrolling
176
+ - `input_gamepad_simulate` — Simulate gamepad buttons, sticks, and triggers
177
+ - `input_touch_simulate` — Simulate touch gestures (tap, swipe, pinch)
178
+ - `input_action_add` — Add actions to an Input Action map
179
+ - `input_action_remove` — Remove actions from an Input Action map
180
+ - `input_action_map_create` — Create new Input Action maps
181
+ - `input_action_map_remove` — Delete existing Input Action maps
182
+ - `input_binding_add` — Add bindings to an action (including composites)
183
+ - `input_binding_remove` — Remove a specific binding from an action
184
+ - `input_binding_remove_all` — Clear all bindings from an action
185
+ - `input_binding_composite_create` — Create composite bindings (e.g., 2D vectors)
186
+ - `input_control_schemes_manage` — Manage control schemes and device lists
187
+ - `input_actions_state_get` — Inspect current Input Actions asset configuration
188
+ - `input_actions_asset_analyze` — Produce structured summaries of Input Actions assets
189
+
190
+ ### Editor & Console Utilities
191
+ - `menu_item_execute` — Trigger Unity Editor menu items programmatically
192
+ - `console_clear` — Clear Unity console logs with filtering options
193
+ - `console_read` — Stream Unity console output with advanced filters
194
+ - `editor_tags_manage` — Manage project tags (add/remove/list)
195
+ - `editor_layers_manage` — Manage project layers with index conversion
196
+ - `editor_selection_manage` — Inspect or mutate the current editor selection
197
+ - `editor_windows_manage` — Enumerate or focus Unity editor windows
198
+ - `editor_tools_manage` — Manage editor tools and plugins
199
+ - `compilation_get_state` — Inspect current compilation state and errors
200
+
201
+ ### Project Settings & Packages
202
+ - `settings_get` — Read Unity project settings with granular control
203
+ - `settings_update` — Safely update project settings (requires confirmation)
204
+ - `package_manage` — List or manage Unity packages via Package Manager
205
+ - `package_registry_config` — Configure package registries/scopes
206
+
207
+ ### Asset Visualization & Capture
208
+ - `screenshot_capture` — Capture Game/Scene view screenshots
209
+ - `screenshot_analyze` — Run image analysis on captured screenshots
210
+ - `video_capture_start` — Begin recording the Game view to video
211
+ - `video_capture_stop` — Stop the current video recording
212
+ - `video_capture_status` — Inspect capture status / metadata
213
+ - `video_capture_for` — Record for a fixed duration before auto-stop
214
+
215
+ ### Testing & Diagnostics
216
+ - `test_run` — Run Unity tests (EditMode/PlayMode)
217
+ - `test_get_status` — Query test runner progress/results
218
+
176
219
 
177
220
  ## Requirements
178
221
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akiojin/unity-mcp-server",
3
- "version": "2.14.17",
3
+ "version": "2.16.1",
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",
@@ -42,10 +42,11 @@
42
42
  "license": "MIT",
43
43
  "dependencies": {
44
44
  "@modelcontextprotocol/sdk": "^0.6.1",
45
- "better-sqlite3": "^9.4.3"
45
+ "better-sqlite3": "^9.4.3",
46
+ "find-up": "^6.3.0"
46
47
  },
47
48
  "engines": {
48
- "node": ">=18.0.0"
49
+ "node": ">=18 <21"
49
50
  },
50
51
  "repository": {
51
52
  "type": "git",
File without changes
File without changes
@@ -1,5 +1,6 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
+ import { findUpSync } from 'find-up';
3
4
 
4
5
  /**
5
6
  * Shallow merge utility (simple objects only)
@@ -19,10 +20,26 @@ function merge(a, b) {
19
20
  /**
20
21
  * Base configuration for Unity Editor MCP Server
21
22
  */
23
+ const envUnityHost =
24
+ process.env.UNITY_UNITY_HOST ||
25
+ process.env.UNITY_BIND_HOST ||
26
+ process.env.UNITY_HOST ||
27
+ null;
28
+
29
+ const envMcpHost =
30
+ process.env.UNITY_MCP_HOST ||
31
+ process.env.UNITY_CLIENT_HOST ||
32
+ process.env.UNITY_HOST ||
33
+ null;
34
+
35
+ const envBindHost = process.env.UNITY_BIND_HOST || null;
36
+
22
37
  const baseConfig = {
23
38
  // Unity connection settings
24
39
  unity: {
25
- host: process.env.UNITY_HOST || 'localhost',
40
+ unityHost: envUnityHost,
41
+ mcpHost: envMcpHost,
42
+ bindHost: envBindHost,
26
43
  port: parseInt(process.env.UNITY_PORT || '', 10) || 6400,
27
44
  reconnectDelay: 1000,
28
45
  maxReconnectDelay: 30000,
@@ -81,20 +98,10 @@ const baseConfig = {
81
98
  function loadExternalConfig() {
82
99
  const explicitPath = process.env.UNITY_MCP_CONFIG;
83
100
 
84
- // Find nearest <workspace>/.unity/config.json by walking up from process.cwd()
85
- const findProjectConfigUp = () => {
86
- let dir = process.cwd();
87
- let prev = '';
88
- for (let i = 0; i < 3 && dir && dir !== prev; i++) {
89
- const p = path.resolve(dir, '.unity', 'config.json');
90
- if (fs.existsSync(p)) return p;
91
- prev = dir;
92
- dir = path.dirname(dir);
93
- }
94
- return null;
95
- };
96
-
97
- const projectPath = findProjectConfigUp();
101
+ const projectPath = findUpSync((directory) => {
102
+ const candidate = path.resolve(directory, '.unity', 'config.json');
103
+ return fs.existsSync(candidate) ? candidate : undefined;
104
+ }, { cwd: process.cwd() });
98
105
  const homeDir = process.env.HOME || process.env.USERPROFILE || '';
99
106
  const userPath = homeDir ? path.resolve(homeDir, '.unity', 'config.json') : null;
100
107
 
@@ -118,6 +125,34 @@ function loadExternalConfig() {
118
125
  const external = loadExternalConfig();
119
126
  export const config = merge(baseConfig, external);
120
127
 
128
+ const normalizeUnityConfig = () => {
129
+ const unityConfig = config.unity || (config.unity = {});
130
+
131
+ // Legacy aliases coming from config files or env vars
132
+ const legacyHost = unityConfig.host;
133
+ const legacyClientHost = unityConfig.clientHost;
134
+ const legacyBindHost = unityConfig.bindHost;
135
+
136
+ if (!unityConfig.unityHost) {
137
+ unityConfig.unityHost = legacyBindHost || legacyHost || envUnityHost || 'localhost';
138
+ }
139
+
140
+ if (!unityConfig.mcpHost) {
141
+ unityConfig.mcpHost = legacyClientHost || envMcpHost || legacyHost || unityConfig.unityHost;
142
+ }
143
+
144
+ // Keep bindHost for backwards compatibility with legacy code paths
145
+ if (!unityConfig.bindHost) {
146
+ unityConfig.bindHost = legacyBindHost || envBindHost || unityConfig.unityHost;
147
+ }
148
+
149
+ // Maintain legacy properties so older handlers keep working
150
+ unityConfig.host = unityConfig.unityHost;
151
+ unityConfig.clientHost = unityConfig.mcpHost;
152
+ };
153
+
154
+ normalizeUnityConfig();
155
+
121
156
  // Workspace root detection: directory that contains .unity/config.json used
122
157
  const initialCwd = process.cwd();
123
158
  let workspaceRoot = initialCwd;
@@ -28,8 +28,8 @@ export class IndexWatcher {
28
28
  if (this.running) return;
29
29
  this.running = true;
30
30
  try {
31
- const { BuildCodeIndexToolHandler } = await import('../handlers/script/BuildCodeIndexToolHandler.js');
32
- const handler = new BuildCodeIndexToolHandler(this.unityConnection);
31
+ const { CodeIndexBuildToolHandler } = await import('../handlers/script/CodeIndexBuildToolHandler.js');
32
+ const handler = new CodeIndexBuildToolHandler(this.unityConnection);
33
33
  const params = {
34
34
  concurrency: config.indexing.concurrency || 8,
35
35
  retry: config.indexing.retry || 2,
@@ -49,4 +49,3 @@ export class IndexWatcher {
49
49
  }
50
50
  }
51
51
  }
52
-
@@ -1,6 +1,13 @@
1
1
  import fs from 'fs';
2
2
  import path from 'path';
3
- import { logger, config } from './config.js';
3
+ import { logger, config, WORKSPACE_ROOT } from './config.js';
4
+
5
+ const normalize = (p) => p.replace(/\\/g, '/');
6
+
7
+ const resolveDefaultCodeIndexRoot = (projectRoot) => {
8
+ const base = WORKSPACE_ROOT || projectRoot || process.cwd();
9
+ return normalize(path.join(base, '.unity', 'cache', 'code-index'));
10
+ };
4
11
 
5
12
  // Lazy project info resolver. Prefers Unity via get_editor_info, otherwise infers by walking up for Assets/Packages.
6
13
  export class ProjectInfoProvider {
@@ -15,13 +22,13 @@ export class ProjectInfoProvider {
15
22
  // Config-driven project root (no env fallback)
16
23
  const cfgRoot = config?.project?.root;
17
24
  if (cfgRoot) {
18
- const projectRoot = cfgRoot.replace(/\\/g, '/');
19
- const codeIndexRoot = (config?.project?.codeIndexRoot
20
- || path.join(projectRoot, 'Library/UnityMCP/CodeIndex')).replace(/\\/g, '/');
25
+ // Resolve relative paths against WORKSPACE_ROOT
26
+ const projectRoot = normalize(path.isAbsolute(cfgRoot) ? cfgRoot : path.resolve(WORKSPACE_ROOT, cfgRoot));
27
+ const codeIndexRoot = normalize(config?.project?.codeIndexRoot || resolveDefaultCodeIndexRoot(projectRoot));
21
28
  this.cached = {
22
29
  projectRoot,
23
- assetsPath: path.join(projectRoot, 'Assets').replace(/\\/g, '/'),
24
- packagesPath: path.join(projectRoot, 'Packages').replace(/\\/g, '/'),
30
+ assetsPath: normalize(path.join(projectRoot, 'Assets')),
31
+ packagesPath: normalize(path.join(projectRoot, 'Packages')),
25
32
  codeIndexRoot,
26
33
  };
27
34
  return this.cached;
@@ -36,8 +43,8 @@ export class ProjectInfoProvider {
36
43
  this.cached = {
37
44
  projectRoot: info.projectRoot,
38
45
  assetsPath: info.assetsPath,
39
- packagesPath: info.packagesPath || path.join(info.projectRoot, 'Packages').replace(/\\/g, '/'),
40
- codeIndexRoot: info.codeIndexRoot || path.join(info.projectRoot, 'Library/UnityMCP/CodeIndex').replace(/\\/g, '/'),
46
+ packagesPath: normalize(info.packagesPath || path.join(info.projectRoot, 'Packages')),
47
+ codeIndexRoot: normalize(info.codeIndexRoot || resolveDefaultCodeIndexRoot(info.projectRoot)),
41
48
  };
42
49
  return this.cached;
43
50
  }
@@ -59,13 +66,13 @@ export class ProjectInfoProvider {
59
66
  const dockerDefaultPath = '/unity-mcp-server/UnityMCPServer';
60
67
  const dockerAssets = path.join(dockerDefaultPath, 'Assets');
61
68
  if (fs.existsSync(dockerAssets)) {
62
- const projectRoot = dockerDefaultPath.replace(/\\/g, '/');
69
+ const projectRoot = normalize(dockerDefaultPath);
63
70
  logger.info(`Found Unity project at Docker default path: ${projectRoot}`);
64
71
  return {
65
72
  projectRoot,
66
- assetsPath: dockerAssets.replace(/\\/g, '/'),
67
- packagesPath: path.join(dockerDefaultPath, 'Packages').replace(/\\/g, '/'),
68
- codeIndexRoot: path.join(dockerDefaultPath, 'Library/UnityMCP/CodeIndex').replace(/\\/g, '/'),
73
+ assetsPath: normalize(dockerAssets),
74
+ packagesPath: normalize(path.join(dockerDefaultPath, 'Packages')),
75
+ codeIndexRoot: resolveDefaultCodeIndexRoot(projectRoot),
69
76
  };
70
77
  }
71
78
 
@@ -74,12 +81,12 @@ export class ProjectInfoProvider {
74
81
  for (let i = 0; i < 5; i++) {
75
82
  const assets = path.join(dir, 'Assets');
76
83
  if (fs.existsSync(assets)) {
77
- const projectRoot = dir.replace(/\\/g, '/');
84
+ const projectRoot = normalize(dir);
78
85
  return {
79
86
  projectRoot,
80
- assetsPath: assets.replace(/\\/g, '/'),
81
- packagesPath: path.join(dir, 'Packages').replace(/\\/g, '/'),
82
- codeIndexRoot: path.join(dir, 'Library/UnityMCP/CodeIndex').replace(/\\/g, '/'),
87
+ assetsPath: normalize(assets),
88
+ packagesPath: normalize(path.join(dir, 'Packages')),
89
+ codeIndexRoot: resolveDefaultCodeIndexRoot(projectRoot),
83
90
  };
84
91
  }
85
92
  dir = path.dirname(dir);
@@ -95,12 +102,12 @@ export class ProjectInfoProvider {
95
102
  const candidate = path.join(root, e.name);
96
103
  const assets = path.join(candidate, 'Assets');
97
104
  if (fs.existsSync(assets)) {
98
- const projectRoot = candidate.replace(/\\/g, '/');
105
+ const projectRoot = normalize(candidate);
99
106
  return {
100
107
  projectRoot,
101
- assetsPath: assets.replace(/\\/g, '/'),
102
- packagesPath: path.join(candidate, 'Packages').replace(/\\/g, '/'),
103
- codeIndexRoot: path.join(candidate, 'Library/UnityMCP/CodeIndex').replace(/\\/g, '/'),
108
+ assetsPath: normalize(assets),
109
+ packagesPath: normalize(path.join(candidate, 'Packages')),
110
+ codeIndexRoot: resolveDefaultCodeIndexRoot(projectRoot),
104
111
  };
105
112
  }
106
113
  }
@@ -40,7 +40,8 @@ export class UnityConnection extends EventEmitter {
40
40
  return;
41
41
  }
42
42
 
43
- logger.info(`Connecting to Unity at ${config.unity.host}:${config.unity.port}...`);
43
+ const targetHost = config.unity.mcpHost || config.unity.unityHost;
44
+ logger.info(`Connecting to Unity at ${targetHost}:${config.unity.port}...`);
44
45
 
45
46
  this.socket = new net.Socket();
46
47
  let connectionTimeout = null;
@@ -118,7 +119,7 @@ export class UnityConnection extends EventEmitter {
118
119
  });
119
120
 
120
121
  // Attempt connection
121
- this.socket.connect(config.unity.port, config.unity.host);
122
+ this.socket.connect(config.unity.port, targetHost);
122
123
 
123
124
  // Set timeout for initial connection
124
125
  connectionTimeout = setTimeout(() => {
@@ -32,4 +32,4 @@ export class AnalyzeSceneContentsToolHandler extends BaseToolHandler {
32
32
  // Return the content
33
33
  return result;
34
34
  }
35
- }
35
+ }
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
2
  import { findByComponentToolDefinition, findByComponentHandler } from '../../tools/analysis/findByComponent.js';
3
3
 
4
4
  /**
5
- * Handler for the find_by_component tool
5
+ * Handler for the analysis_component_find tool
6
6
  */
7
7
  export class FindByComponentToolHandler extends BaseToolHandler {
8
8
  constructor(unityConnection) {
@@ -17,4 +17,4 @@ export class FindByComponentToolHandler extends BaseToolHandler {
17
17
  async execute(args) {
18
18
  return findByComponentHandler(this.unityConnection, args);
19
19
  }
20
- }
20
+ }
@@ -34,4 +34,4 @@ export class GetAnimatorRuntimeInfoToolHandler extends BaseToolHandler {
34
34
  async execute(args) {
35
35
  return getAnimatorRuntimeInfoHandler(this.unityConnection, args);
36
36
  }
37
- }
37
+ }
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
2
  import { getComponentValuesToolDefinition, getComponentValuesHandler } from '../../tools/analysis/getComponentValues.js';
3
3
 
4
4
  /**
5
- * Handler for the get_component_values tool
5
+ * Handler for the analysis_component_values_get tool
6
6
  */
7
7
  export class GetComponentValuesToolHandler extends BaseToolHandler {
8
8
  constructor(unityConnection) {
@@ -17,4 +17,4 @@ export class GetComponentValuesToolHandler extends BaseToolHandler {
17
17
  async execute(args) {
18
18
  return getComponentValuesHandler(this.unityConnection, args);
19
19
  }
20
- }
20
+ }
@@ -32,4 +32,4 @@ export class GetGameObjectDetailsToolHandler extends BaseToolHandler {
32
32
  // Return the content
33
33
  return result;
34
34
  }
35
- }
35
+ }
@@ -34,4 +34,4 @@ export class AnalyzeInputActionsAssetToolHandler extends BaseToolHandler {
34
34
  async execute(args) {
35
35
  return analyzeInputActionsAssetHandler(this.unityConnection, args);
36
36
  }
37
- }
37
+ }
@@ -2,7 +2,7 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
2
  import { getObjectReferencesToolDefinition, getObjectReferencesHandler } from '../../tools/analysis/getObjectReferences.js';
3
3
 
4
4
  /**
5
- * Handler for the get_object_references tool
5
+ * Handler for the analysis_object_references_get tool
6
6
  */
7
7
  export class GetObjectReferencesToolHandler extends BaseToolHandler {
8
8
  constructor(unityConnection) {
@@ -17,4 +17,4 @@ export class GetObjectReferencesToolHandler extends BaseToolHandler {
17
17
  async execute(args) {
18
18
  return getObjectReferencesHandler(this.unityConnection, args);
19
19
  }
20
- }
20
+ }
@@ -3,10 +3,10 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
3
3
  /**
4
4
  * Handler for Unity Asset Database operations
5
5
  */
6
- export class AssetDatabaseToolHandler extends BaseToolHandler {
6
+ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
7
7
  constructor(unityConnection) {
8
8
  super(
9
- 'manage_asset_database',
9
+ 'asset_database_manage',
10
10
  'Manage Unity Asset Database operations (find, info, create folders, move, copy, delete, refresh). NOTE: The "refresh" action may take 5-120+ seconds for large projects as Unity needs to scan all assets, reimport changed files, and compile scripts. Please wait for the operation to complete.',
11
11
  {
12
12
  type: 'object',
@@ -3,10 +3,10 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
3
3
  /**
4
4
  * Handler for Unity asset dependency analysis
5
5
  */
6
- export class AssetDependencyToolHandler extends BaseToolHandler {
6
+ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
7
7
  constructor(unityConnection) {
8
8
  super(
9
- 'analyze_asset_dependencies',
9
+ 'asset_dependency_analyze',
10
10
  'Analyze Unity asset dependencies (get dependencies, dependents, circular deps, unused assets, size impact)',
11
11
  {
12
12
  type: 'object',