@akiojin/unity-mcp-server 2.16.0 → 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.
- package/README.md +142 -99
- package/package.json +4 -3
- package/src/core/config.js +5 -14
- package/src/core/indexWatcher.js +2 -3
- package/src/core/projectInfo.js +27 -20
- package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +1 -1
- package/src/handlers/analysis/FindByComponentToolHandler.js +2 -2
- package/src/handlers/analysis/GetAnimatorStateToolHandler.js +1 -1
- package/src/handlers/analysis/GetComponentValuesToolHandler.js +2 -2
- package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +1 -1
- package/src/handlers/analysis/GetInputActionsStateToolHandler.js +1 -1
- package/src/handlers/analysis/GetObjectReferencesToolHandler.js +2 -2
- package/src/handlers/asset/{AssetDatabaseToolHandler.js → AssetDatabaseManageToolHandler.js} +2 -2
- package/src/handlers/asset/{AssetDependencyToolHandler.js → AssetDependencyAnalyzeToolHandler.js} +2 -2
- package/src/handlers/asset/{AssetImportSettingsToolHandler.js → AssetImportSettingsManageToolHandler.js} +2 -2
- package/src/handlers/asset/{CreateMaterialToolHandler.js → AssetMaterialCreateToolHandler.js} +2 -2
- package/src/handlers/asset/{ModifyMaterialToolHandler.js → AssetMaterialModifyToolHandler.js} +2 -2
- package/src/handlers/asset/{CreatePrefabToolHandler.js → AssetPrefabCreateToolHandler.js} +2 -2
- package/src/handlers/asset/{ExitPrefabModeToolHandler.js → AssetPrefabExitModeToolHandler.js} +2 -2
- package/src/handlers/asset/{InstantiatePrefabToolHandler.js → AssetPrefabInstantiateToolHandler.js} +2 -2
- package/src/handlers/asset/{ModifyPrefabToolHandler.js → AssetPrefabModifyToolHandler.js} +2 -2
- package/src/handlers/asset/{OpenPrefabToolHandler.js → AssetPrefabOpenToolHandler.js} +2 -2
- package/src/handlers/asset/{SavePrefabToolHandler.js → AssetPrefabSaveToolHandler.js} +2 -2
- package/src/handlers/compilation/{GetCompilationStateToolHandler.js → CompilationGetStateToolHandler.js} +2 -2
- package/src/handlers/component/{AddComponentToolHandler.js → ComponentAddToolHandler.js} +2 -2
- package/src/handlers/component/{GetComponentTypesToolHandler.js → ComponentGetTypesToolHandler.js} +2 -2
- package/src/handlers/component/{ListComponentsToolHandler.js → ComponentListToolHandler.js} +2 -2
- package/src/handlers/component/{ModifyComponentToolHandler.js → ComponentModifyToolHandler.js} +2 -2
- package/src/handlers/component/{RemoveComponentToolHandler.js → ComponentRemoveToolHandler.js} +2 -2
- package/src/handlers/console/{ClearConsoleToolHandler.js → ConsoleClearToolHandler.js} +2 -2
- package/src/handlers/console/{ReadConsoleToolHandler.js → ConsoleReadToolHandler.js} +2 -2
- package/src/handlers/editor/{LayerManagementToolHandler.js → EditorLayersManageToolHandler.js} +2 -2
- package/src/handlers/editor/{SelectionToolHandler.js → EditorSelectionManageToolHandler.js} +2 -2
- package/src/handlers/editor/{TagManagementToolHandler.js → EditorTagsManageToolHandler.js} +2 -2
- package/src/handlers/editor/{ToolManagementToolHandler.js → EditorToolsManageToolHandler.js} +2 -2
- package/src/handlers/editor/{WindowManagementToolHandler.js → EditorWindowsManageToolHandler.js} +2 -2
- package/src/handlers/gameobject/{CreateGameObjectToolHandler.js → GameObjectCreateToolHandler.js} +3 -3
- package/src/handlers/gameobject/{DeleteGameObjectToolHandler.js → GameObjectDeleteToolHandler.js} +3 -3
- package/src/handlers/gameobject/{FindGameObjectToolHandler.js → GameObjectFindToolHandler.js} +3 -3
- package/src/handlers/gameobject/{GetHierarchyToolHandler.js → GameObjectGetHierarchyToolHandler.js} +3 -3
- package/src/handlers/gameobject/{ModifyGameObjectToolHandler.js → GameObjectModifyToolHandler.js} +3 -3
- package/src/handlers/index.js +225 -218
- package/src/handlers/input/{AddInputActionToolHandler.js → InputActionAddToolHandler.js} +2 -2
- package/src/handlers/input/{CreateActionMapToolHandler.js → InputActionMapCreateToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveActionMapToolHandler.js → InputActionMapRemoveToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveInputActionToolHandler.js → InputActionRemoveToolHandler.js} +2 -2
- package/src/handlers/input/{AddInputBindingToolHandler.js → InputBindingAddToolHandler.js} +2 -2
- package/src/handlers/input/{CreateCompositeBindingToolHandler.js → InputBindingCompositeCreateToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveAllBindingsToolHandler.js → InputBindingRemoveAllToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveInputBindingToolHandler.js → InputBindingRemoveToolHandler.js} +2 -2
- package/src/handlers/input/{ManageControlSchemesToolHandler.js → InputControlSchemesManageToolHandler.js} +2 -2
- package/src/handlers/input/{GamepadSimulationHandler.js → InputGamepadSimulateToolHandler.js} +3 -3
- package/src/handlers/input/{KeyboardSimulationHandler.js → InputKeyboardSimulateToolHandler.js} +3 -3
- package/src/handlers/input/{MouseSimulationHandler.js → InputMouseSimulateToolHandler.js} +3 -3
- package/src/handlers/input/{InputSystemHandler.js → InputSystemControlToolHandler.js} +4 -4
- package/src/handlers/input/{TouchSimulationHandler.js → InputTouchSimulateToolHandler.js} +3 -3
- package/src/handlers/menu/{ExecuteMenuItemToolHandler.js → MenuItemExecuteToolHandler.js} +2 -2
- package/src/handlers/package/PackageManagerToolHandler.js +1 -1
- package/src/handlers/package/RegistryConfigToolHandler.js +1 -1
- package/src/handlers/playmode/{GetEditorStateToolHandler.js → PlaymodeGetStateToolHandler.js} +2 -2
- package/src/handlers/playmode/{PauseToolHandler.js → PlaymodePauseToolHandler.js} +3 -3
- package/src/handlers/playmode/{PlayToolHandler.js → PlaymodePlayToolHandler.js} +4 -4
- package/src/handlers/playmode/{StopToolHandler.js → PlaymodeStopToolHandler.js} +4 -4
- package/src/handlers/playmode/{WaitForEditorStateToolHandler.js → PlaymodeWaitForStateToolHandler.js} +3 -3
- package/src/handlers/scene/GetSceneInfoToolHandler.js +1 -1
- package/src/handlers/scene/{CreateSceneToolHandler.js → SceneCreateToolHandler.js} +2 -2
- package/src/handlers/scene/{ListScenesToolHandler.js → SceneListToolHandler.js} +2 -2
- package/src/handlers/scene/{LoadSceneToolHandler.js → SceneLoadToolHandler.js} +2 -2
- package/src/handlers/scene/{SaveSceneToolHandler.js → SceneSaveToolHandler.js} +2 -2
- package/src/handlers/screenshot/{AnalyzeScreenshotToolHandler.js → ScreenshotAnalyzeToolHandler.js} +2 -2
- package/src/handlers/screenshot/{CaptureScreenshotToolHandler.js → ScreenshotCaptureToolHandler.js} +2 -2
- package/src/handlers/script/{BuildCodeIndexToolHandler.js → CodeIndexBuildToolHandler.js} +4 -4
- package/src/handlers/script/CodeIndexUpdateToolHandler.js +234 -0
- package/src/handlers/script/{ScriptCreateClassFileToolHandler.js → ScriptCreateClassToolHandler.js} +2 -2
- package/src/handlers/script/ScriptEditSnippetToolHandler.js +272 -0
- package/src/handlers/script/ScriptIndexStatusToolHandler.js +2 -2
- package/src/handlers/settings/{GetProjectSettingsToolHandler.js → SettingsGetToolHandler.js} +2 -2
- package/src/handlers/settings/{UpdateProjectSettingsToolHandler.js → SettingsUpdateToolHandler.js} +2 -2
- package/src/handlers/system/{GetCommandStatsToolHandler.js → SystemGetCommandStatsToolHandler.js} +2 -3
- package/src/handlers/system/{PingToolHandler.js → SystemPingToolHandler.js} +3 -3
- package/src/handlers/system/{RefreshAssetsToolHandler.js → SystemRefreshAssetsToolHandler.js} +3 -3
- package/src/handlers/test/{GetTestStatusToolHandler.js → TestGetStatusToolHandler.js} +2 -2
- package/src/handlers/test/{RunTestsToolHandler.js → TestRunToolHandler.js} +2 -2
- package/src/handlers/ui/{ClickUIElementToolHandler.js → UIClickElementToolHandler.js} +2 -2
- package/src/handlers/ui/{FindUIElementsToolHandler.js → UIFindElementsToolHandler.js} +2 -2
- package/src/handlers/ui/{GetUIElementStateToolHandler.js → UIGetElementStateToolHandler.js} +2 -2
- package/src/handlers/ui/{SetUIElementValueToolHandler.js → UISetElementValueToolHandler.js} +2 -2
- package/src/handlers/ui/{SimulateUIInputToolHandler.js → UISimulateInputToolHandler.js} +2 -2
- package/src/handlers/video/{CaptureVideoForToolHandler.js → VideoCaptureForToolHandler.js} +8 -8
- package/src/handlers/video/{CaptureVideoStartToolHandler.js → VideoCaptureStartToolHandler.js} +2 -2
- package/src/handlers/video/{CaptureVideoStatusToolHandler.js → VideoCaptureStatusToolHandler.js} +2 -2
- package/src/handlers/video/{CaptureVideoStopToolHandler.js → VideoCaptureStopToolHandler.js} +3 -3
- package/src/lsp/CSharpLspUtils.js +68 -10
- package/src/lsp/LspRpcClient.js +14 -0
- package/src/tools/analysis/analyzeSceneContents.js +3 -3
- package/src/tools/analysis/findByComponent.js +3 -3
- package/src/tools/analysis/getAnimatorState.js +6 -6
- package/src/tools/analysis/getComponentValues.js +3 -3
- package/src/tools/analysis/getGameObjectDetails.js +3 -3
- package/src/tools/analysis/getInputActionsState.js +4 -4
- package/src/tools/analysis/getObjectReferences.js +3 -3
- package/src/tools/input/inputActionsEditor.js +18 -18
- package/src/tools/scene/createScene.js +3 -3
- package/src/tools/scene/getSceneInfo.js +3 -3
- 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/tools/video/recordFor.js +2 -2
package/README.md
CHANGED
|
@@ -74,105 +74,148 @@ Add to your `claude_desktop_config.json`:
|
|
|
74
74
|
}
|
|
75
75
|
```
|
|
76
76
|
|
|
77
|
-
##
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
- `
|
|
94
|
-
- `
|
|
95
|
-
- `
|
|
96
|
-
|
|
97
|
-
###
|
|
98
|
-
- `
|
|
99
|
-
- `
|
|
100
|
-
- `
|
|
101
|
-
- `
|
|
102
|
-
- `
|
|
103
|
-
|
|
104
|
-
###
|
|
105
|
-
- `
|
|
106
|
-
- `
|
|
107
|
-
- `
|
|
108
|
-
- `
|
|
109
|
-
- `
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
- `
|
|
115
|
-
- `
|
|
116
|
-
- `
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
- `
|
|
120
|
-
- `
|
|
121
|
-
- `
|
|
122
|
-
- `
|
|
123
|
-
- `
|
|
124
|
-
- `
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
- `
|
|
129
|
-
- `
|
|
130
|
-
- `
|
|
131
|
-
- `
|
|
132
|
-
- `
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
- `
|
|
136
|
-
- `
|
|
137
|
-
- `
|
|
138
|
-
- `
|
|
139
|
-
|
|
140
|
-
###
|
|
141
|
-
- `
|
|
142
|
-
- `
|
|
143
|
-
- `
|
|
144
|
-
- `
|
|
145
|
-
- `
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
- `
|
|
149
|
-
- `
|
|
150
|
-
- `
|
|
151
|
-
- `
|
|
152
|
-
- `
|
|
153
|
-
|
|
154
|
-
###
|
|
155
|
-
- `
|
|
156
|
-
- `
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
- `
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
- `
|
|
163
|
-
- `
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
- `
|
|
167
|
-
- `
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
- `
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
- `
|
|
174
|
-
|
|
175
|
-
|
|
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.16.
|
|
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
|
|
49
|
+
"node": ">=18 <21"
|
|
49
50
|
},
|
|
50
51
|
"repository": {
|
|
51
52
|
"type": "git",
|
package/src/core/config.js
CHANGED
|
@@ -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)
|
|
@@ -97,20 +98,10 @@ const baseConfig = {
|
|
|
97
98
|
function loadExternalConfig() {
|
|
98
99
|
const explicitPath = process.env.UNITY_MCP_CONFIG;
|
|
99
100
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
for (let i = 0; i < 3 && dir && dir !== prev; i++) {
|
|
105
|
-
const p = path.resolve(dir, '.unity', 'config.json');
|
|
106
|
-
if (fs.existsSync(p)) return p;
|
|
107
|
-
prev = dir;
|
|
108
|
-
dir = path.dirname(dir);
|
|
109
|
-
}
|
|
110
|
-
return null;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
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() });
|
|
114
105
|
const homeDir = process.env.HOME || process.env.USERPROFILE || '';
|
|
115
106
|
const userPath = homeDir ? path.resolve(homeDir, '.unity', 'config.json') : null;
|
|
116
107
|
|
package/src/core/indexWatcher.js
CHANGED
|
@@ -28,8 +28,8 @@ export class IndexWatcher {
|
|
|
28
28
|
if (this.running) return;
|
|
29
29
|
this.running = true;
|
|
30
30
|
try {
|
|
31
|
-
const {
|
|
32
|
-
const handler = new
|
|
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
|
-
|
package/src/core/projectInfo.js
CHANGED
|
@@ -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
|
-
|
|
19
|
-
const
|
|
20
|
-
|
|
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')
|
|
24
|
-
packagesPath: path.join(projectRoot, 'Packages')
|
|
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')
|
|
40
|
-
codeIndexRoot: info.codeIndexRoot ||
|
|
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
|
|
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
|
|
67
|
-
packagesPath: path.join(dockerDefaultPath, 'Packages')
|
|
68
|
-
codeIndexRoot:
|
|
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
|
|
84
|
+
const projectRoot = normalize(dir);
|
|
78
85
|
return {
|
|
79
86
|
projectRoot,
|
|
80
|
-
assetsPath: assets
|
|
81
|
-
packagesPath: path.join(dir, 'Packages')
|
|
82
|
-
codeIndexRoot:
|
|
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
|
|
105
|
+
const projectRoot = normalize(candidate);
|
|
99
106
|
return {
|
|
100
107
|
projectRoot,
|
|
101
|
-
assetsPath: assets
|
|
102
|
-
packagesPath: path.join(candidate, 'Packages')
|
|
103
|
-
codeIndexRoot:
|
|
108
|
+
assetsPath: normalize(assets),
|
|
109
|
+
packagesPath: normalize(path.join(candidate, 'Packages')),
|
|
110
|
+
codeIndexRoot: resolveDefaultCodeIndexRoot(projectRoot),
|
|
104
111
|
};
|
|
105
112
|
}
|
|
106
113
|
}
|
|
@@ -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
|
|
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
|
+
}
|
|
@@ -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
|
|
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
|
+
}
|
|
@@ -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
|
|
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
|
+
}
|
package/src/handlers/asset/{AssetDatabaseToolHandler.js → AssetDatabaseManageToolHandler.js}
RENAMED
|
@@ -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
|
|
6
|
+
export class AssetDatabaseManageToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
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',
|
package/src/handlers/asset/{AssetDependencyToolHandler.js → AssetDependencyAnalyzeToolHandler.js}
RENAMED
|
@@ -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
|
|
6
|
+
export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
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',
|
|
@@ -3,10 +3,10 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Handler for Unity asset import settings management
|
|
5
5
|
*/
|
|
6
|
-
export class
|
|
6
|
+
export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
9
|
+
'asset_import_settings_manage',
|
|
10
10
|
'Manage Unity asset import settings (get, modify, apply presets, reimport)',
|
|
11
11
|
{
|
|
12
12
|
type: 'object',
|
package/src/handlers/asset/{CreateMaterialToolHandler.js → AssetMaterialCreateToolHandler.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class AssetMaterialCreateToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
5
|
super(
|
|
6
|
-
'
|
|
6
|
+
'asset_material_create',
|
|
7
7
|
'Create a material asset with a shader and property overrides (optional copyFrom).',
|
|
8
8
|
{
|
|
9
9
|
type: 'object',
|
package/src/handlers/asset/{ModifyMaterialToolHandler.js → AssetMaterialModifyToolHandler.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class AssetMaterialModifyToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
5
|
super(
|
|
6
|
-
'
|
|
6
|
+
'asset_material_modify',
|
|
7
7
|
'Modify a material by updating property values and/or changing the shader.',
|
|
8
8
|
{
|
|
9
9
|
type: 'object',
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class AssetPrefabCreateToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
5
|
super(
|
|
6
|
-
'
|
|
6
|
+
'asset_prefab_create',
|
|
7
7
|
'Create a prefab from a GameObject path or create an empty prefab at a target asset path.',
|
|
8
8
|
{
|
|
9
9
|
type: 'object',
|
package/src/handlers/asset/{ExitPrefabModeToolHandler.js → AssetPrefabExitModeToolHandler.js}
RENAMED
|
@@ -3,10 +3,10 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Handler for exiting Unity's prefab mode
|
|
5
5
|
*/
|
|
6
|
-
export class
|
|
6
|
+
export class AssetPrefabExitModeToolHandler extends BaseToolHandler {
|
|
7
7
|
constructor(unityConnection) {
|
|
8
8
|
super(
|
|
9
|
-
'
|
|
9
|
+
'asset_prefab_exit_mode',
|
|
10
10
|
'Exit prefab mode and return to the main scene',
|
|
11
11
|
{
|
|
12
12
|
type: 'object',
|
package/src/handlers/asset/{InstantiatePrefabToolHandler.js → AssetPrefabInstantiateToolHandler.js}
RENAMED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseToolHandler } from '../base/BaseToolHandler.js';
|
|
2
2
|
|
|
3
|
-
export class
|
|
3
|
+
export class AssetPrefabInstantiateToolHandler extends BaseToolHandler {
|
|
4
4
|
constructor(unityConnection) {
|
|
5
5
|
super(
|
|
6
|
-
'
|
|
6
|
+
'asset_prefab_instantiate',
|
|
7
7
|
'Instantiate a prefab in the scene with optional transform, parent, and name override.',
|
|
8
8
|
{
|
|
9
9
|
type: 'object',
|