@akiojin/unity-mcp-server 2.14.14

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 (125) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +206 -0
  3. package/bin/unity-mcp-server +2 -0
  4. package/package.json +73 -0
  5. package/src/core/codeIndex.js +163 -0
  6. package/src/core/codeIndexDb.js +96 -0
  7. package/src/core/config.js +165 -0
  8. package/src/core/indexWatcher.js +52 -0
  9. package/src/core/projectInfo.js +111 -0
  10. package/src/core/server.js +294 -0
  11. package/src/core/unityConnection.js +426 -0
  12. package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +35 -0
  13. package/src/handlers/analysis/FindByComponentToolHandler.js +20 -0
  14. package/src/handlers/analysis/GetAnimatorStateToolHandler.js +37 -0
  15. package/src/handlers/analysis/GetComponentValuesToolHandler.js +20 -0
  16. package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +35 -0
  17. package/src/handlers/analysis/GetInputActionsStateToolHandler.js +37 -0
  18. package/src/handlers/analysis/GetObjectReferencesToolHandler.js +20 -0
  19. package/src/handlers/asset/AssetDatabaseToolHandler.js +221 -0
  20. package/src/handlers/asset/AssetDependencyToolHandler.js +201 -0
  21. package/src/handlers/asset/AssetImportSettingsToolHandler.js +170 -0
  22. package/src/handlers/asset/CreateMaterialToolHandler.js +96 -0
  23. package/src/handlers/asset/CreatePrefabToolHandler.js +78 -0
  24. package/src/handlers/asset/ExitPrefabModeToolHandler.js +83 -0
  25. package/src/handlers/asset/InstantiatePrefabToolHandler.js +133 -0
  26. package/src/handlers/asset/ModifyMaterialToolHandler.js +76 -0
  27. package/src/handlers/asset/ModifyPrefabToolHandler.js +72 -0
  28. package/src/handlers/asset/OpenPrefabToolHandler.js +121 -0
  29. package/src/handlers/asset/SavePrefabToolHandler.js +106 -0
  30. package/src/handlers/base/BaseToolHandler.js +133 -0
  31. package/src/handlers/compilation/GetCompilationStateToolHandler.js +90 -0
  32. package/src/handlers/component/AddComponentToolHandler.js +126 -0
  33. package/src/handlers/component/GetComponentTypesToolHandler.js +100 -0
  34. package/src/handlers/component/ListComponentsToolHandler.js +85 -0
  35. package/src/handlers/component/ModifyComponentToolHandler.js +143 -0
  36. package/src/handlers/component/RemoveComponentToolHandler.js +108 -0
  37. package/src/handlers/console/ClearConsoleToolHandler.js +160 -0
  38. package/src/handlers/console/ReadConsoleToolHandler.js +276 -0
  39. package/src/handlers/editor/LayerManagementToolHandler.js +160 -0
  40. package/src/handlers/editor/SelectionToolHandler.js +141 -0
  41. package/src/handlers/editor/TagManagementToolHandler.js +129 -0
  42. package/src/handlers/editor/ToolManagementToolHandler.js +135 -0
  43. package/src/handlers/editor/WindowManagementToolHandler.js +125 -0
  44. package/src/handlers/gameobject/CreateGameObjectToolHandler.js +131 -0
  45. package/src/handlers/gameobject/DeleteGameObjectToolHandler.js +101 -0
  46. package/src/handlers/gameobject/FindGameObjectToolHandler.js +119 -0
  47. package/src/handlers/gameobject/GetHierarchyToolHandler.js +132 -0
  48. package/src/handlers/gameobject/ModifyGameObjectToolHandler.js +128 -0
  49. package/src/handlers/index.js +389 -0
  50. package/src/handlers/input/AddInputActionToolHandler.js +20 -0
  51. package/src/handlers/input/AddInputBindingToolHandler.js +20 -0
  52. package/src/handlers/input/CreateActionMapToolHandler.js +20 -0
  53. package/src/handlers/input/CreateCompositeBindingToolHandler.js +20 -0
  54. package/src/handlers/input/GamepadSimulationHandler.js +116 -0
  55. package/src/handlers/input/InputSystemHandler.js +80 -0
  56. package/src/handlers/input/KeyboardSimulationHandler.js +79 -0
  57. package/src/handlers/input/ManageControlSchemesToolHandler.js +20 -0
  58. package/src/handlers/input/MouseSimulationHandler.js +107 -0
  59. package/src/handlers/input/RemoveActionMapToolHandler.js +20 -0
  60. package/src/handlers/input/RemoveAllBindingsToolHandler.js +20 -0
  61. package/src/handlers/input/RemoveInputActionToolHandler.js +20 -0
  62. package/src/handlers/input/RemoveInputBindingToolHandler.js +20 -0
  63. package/src/handlers/input/TouchSimulationHandler.js +142 -0
  64. package/src/handlers/menu/ExecuteMenuItemToolHandler.js +304 -0
  65. package/src/handlers/package/PackageManagerToolHandler.js +248 -0
  66. package/src/handlers/package/RegistryConfigToolHandler.js +198 -0
  67. package/src/handlers/playmode/GetEditorStateToolHandler.js +81 -0
  68. package/src/handlers/playmode/PauseToolHandler.js +44 -0
  69. package/src/handlers/playmode/PlayToolHandler.js +91 -0
  70. package/src/handlers/playmode/StopToolHandler.js +77 -0
  71. package/src/handlers/playmode/WaitForEditorStateToolHandler.js +45 -0
  72. package/src/handlers/scene/CreateSceneToolHandler.js +91 -0
  73. package/src/handlers/scene/GetSceneInfoToolHandler.js +20 -0
  74. package/src/handlers/scene/ListScenesToolHandler.js +58 -0
  75. package/src/handlers/scene/LoadSceneToolHandler.js +92 -0
  76. package/src/handlers/scene/SaveSceneToolHandler.js +76 -0
  77. package/src/handlers/screenshot/AnalyzeScreenshotToolHandler.js +238 -0
  78. package/src/handlers/screenshot/CaptureScreenshotToolHandler.js +692 -0
  79. package/src/handlers/script/BuildCodeIndexToolHandler.js +163 -0
  80. package/src/handlers/script/ScriptCreateClassFileToolHandler.js +60 -0
  81. package/src/handlers/script/ScriptEditStructuredToolHandler.js +173 -0
  82. package/src/handlers/script/ScriptIndexStatusToolHandler.js +61 -0
  83. package/src/handlers/script/ScriptPackagesListToolHandler.js +103 -0
  84. package/src/handlers/script/ScriptReadToolHandler.js +106 -0
  85. package/src/handlers/script/ScriptRefactorRenameToolHandler.js +83 -0
  86. package/src/handlers/script/ScriptRefsFindToolHandler.js +144 -0
  87. package/src/handlers/script/ScriptRemoveSymbolToolHandler.js +79 -0
  88. package/src/handlers/script/ScriptSearchToolHandler.js +320 -0
  89. package/src/handlers/script/ScriptSymbolFindToolHandler.js +117 -0
  90. package/src/handlers/script/ScriptSymbolsGetToolHandler.js +96 -0
  91. package/src/handlers/settings/GetProjectSettingsToolHandler.js +161 -0
  92. package/src/handlers/settings/UpdateProjectSettingsToolHandler.js +272 -0
  93. package/src/handlers/system/GetCommandStatsToolHandler.js +25 -0
  94. package/src/handlers/system/PingToolHandler.js +53 -0
  95. package/src/handlers/system/RefreshAssetsToolHandler.js +45 -0
  96. package/src/handlers/ui/ClickUIElementToolHandler.js +110 -0
  97. package/src/handlers/ui/FindUIElementsToolHandler.js +63 -0
  98. package/src/handlers/ui/GetUIElementStateToolHandler.js +50 -0
  99. package/src/handlers/ui/SetUIElementValueToolHandler.js +49 -0
  100. package/src/handlers/ui/SimulateUIInputToolHandler.js +156 -0
  101. package/src/handlers/video/CaptureVideoForToolHandler.js +96 -0
  102. package/src/handlers/video/CaptureVideoStartToolHandler.js +38 -0
  103. package/src/handlers/video/CaptureVideoStatusToolHandler.js +30 -0
  104. package/src/handlers/video/CaptureVideoStopToolHandler.js +32 -0
  105. package/src/lsp/CSharpLspUtils.js +134 -0
  106. package/src/lsp/LspProcessManager.js +60 -0
  107. package/src/lsp/LspRpcClient.js +133 -0
  108. package/src/tools/analysis/analyzeSceneContents.js +100 -0
  109. package/src/tools/analysis/findByComponent.js +87 -0
  110. package/src/tools/analysis/getAnimatorState.js +326 -0
  111. package/src/tools/analysis/getComponentValues.js +182 -0
  112. package/src/tools/analysis/getGameObjectDetails.js +159 -0
  113. package/src/tools/analysis/getInputActionsState.js +329 -0
  114. package/src/tools/analysis/getObjectReferences.js +86 -0
  115. package/src/tools/input/inputActionsEditor.js +556 -0
  116. package/src/tools/scene/createScene.js +112 -0
  117. package/src/tools/scene/getSceneInfo.js +95 -0
  118. package/src/tools/scene/listScenes.js +82 -0
  119. package/src/tools/scene/loadScene.js +122 -0
  120. package/src/tools/scene/saveScene.js +91 -0
  121. package/src/tools/system/ping.js +72 -0
  122. package/src/tools/video/recordFor.js +31 -0
  123. package/src/tools/video/recordPlayMode.js +61 -0
  124. package/src/utils/csharpParse.js +88 -0
  125. package/src/utils/validators.js +90 -0
@@ -0,0 +1,329 @@
1
+ // Tool definitions for Input Actions analysis
2
+ export const getInputActionsStateToolDefinition = {
3
+ name: 'get_input_actions_state',
4
+ description: 'Get Input Actions state: maps, actions, bindings, devices, JSON structure.',
5
+ inputSchema: {
6
+ type: 'object',
7
+ properties: {
8
+ assetName: {
9
+ type: 'string',
10
+ description: 'Name of the Input Actions asset'
11
+ },
12
+ assetPath: {
13
+ type: 'string',
14
+ description: 'Path to the Input Actions asset file'
15
+ },
16
+ includeBindings: {
17
+ type: 'boolean',
18
+ description: 'Include binding information. Default: true',
19
+ default: true
20
+ },
21
+ includeControlSchemes: {
22
+ type: 'boolean',
23
+ description: 'Include control schemes information. Default: true',
24
+ default: true
25
+ },
26
+ includeJsonStructure: {
27
+ type: 'boolean',
28
+ description: 'Include raw JSON structure. Default: false',
29
+ default: false
30
+ }
31
+ },
32
+ required: []
33
+ }
34
+ };
35
+
36
+ export const analyzeInputActionsAssetToolDefinition = {
37
+ name: 'analyze_input_actions_asset',
38
+ description: 'Analyze an Input Actions asset in detail (statistics + device usage).',
39
+ inputSchema: {
40
+ type: 'object',
41
+ properties: {
42
+ assetPath: {
43
+ type: 'string',
44
+ description: 'Path to the Input Actions asset file'
45
+ },
46
+ includeJsonStructure: {
47
+ type: 'boolean',
48
+ description: 'Include raw JSON structure. Default: true',
49
+ default: true
50
+ },
51
+ includeStatistics: {
52
+ type: 'boolean',
53
+ description: 'Include usage statistics. Default: true',
54
+ default: true
55
+ }
56
+ },
57
+ required: ['assetPath']
58
+ }
59
+ };
60
+
61
+ // Handler for get_input_actions_state
62
+ export async function getInputActionsStateHandler(unityConnection, args) {
63
+ try {
64
+ // Check connection
65
+ if (!unityConnection.isConnected()) {
66
+ return {
67
+ content: [
68
+ {
69
+ type: 'text',
70
+ text: 'Failed to get Input Actions state: Unity connection not available'
71
+ }
72
+ ],
73
+ isError: true
74
+ };
75
+ }
76
+
77
+ // Send command to Unity
78
+ const result = await unityConnection.sendCommand('get_input_actions_state', args);
79
+
80
+ // Check for errors
81
+ if (!result || typeof result === 'string') {
82
+ return {
83
+ content: [
84
+ {
85
+ type: 'text',
86
+ text: `Failed to get Input Actions state: Invalid response format`
87
+ }
88
+ ],
89
+ isError: true
90
+ };
91
+ }
92
+
93
+ if (result.error) {
94
+ return {
95
+ content: [
96
+ {
97
+ type: 'text',
98
+ text: `Failed to get Input Actions state: ${result.error}`
99
+ }
100
+ ],
101
+ isError: true
102
+ };
103
+ }
104
+
105
+ // Format the response
106
+ let text = `Input Actions Asset: ${result.assetName}`;
107
+ text += `\nPath: ${result.assetPath}`;
108
+
109
+ if (result.actionMaps && Array.isArray(result.actionMaps)) {
110
+ text += `\n\n## Action Maps (${result.actionMaps.length}):`;
111
+
112
+ result.actionMaps.forEach(map => {
113
+ text += `\n\n### ${map.name}`;
114
+ text += `\n- ID: ${map.id}`;
115
+
116
+ if (map.actions && Array.isArray(map.actions)) {
117
+ text += `\n- Actions (${map.actions.length}):`;
118
+ map.actions.forEach(action => {
119
+ text += `\n • ${action.name} (${action.type})`;
120
+ if (action.expectedControlType) {
121
+ text += ` - Expected: ${action.expectedControlType}`;
122
+ }
123
+
124
+ if (action.bindings && Array.isArray(action.bindings)) {
125
+ text += `\n Bindings (${action.bindings.length}):`;
126
+ action.bindings.forEach(binding => {
127
+ if (binding.isComposite) {
128
+ text += `\n - Composite: ${binding.name || 'Unnamed'}`;
129
+ } else if (binding.isPartOfComposite) {
130
+ text += `\n • ${binding.path}`;
131
+ } else {
132
+ text += `\n - ${binding.path}`;
133
+ }
134
+ if (binding.groups) {
135
+ text += ` [${binding.groups}]`;
136
+ }
137
+ });
138
+ }
139
+ });
140
+ }
141
+ });
142
+ }
143
+
144
+ if (result.controlSchemes && Array.isArray(result.controlSchemes)) {
145
+ text += `\n\n## Control Schemes (${result.controlSchemes.length}):`;
146
+ result.controlSchemes.forEach(scheme => {
147
+ text += `\n- ${scheme.name}`;
148
+ if (scheme.bindingGroup) {
149
+ text += ` (Group: ${scheme.bindingGroup})`;
150
+ }
151
+ if (scheme.devices && Array.isArray(scheme.devices)) {
152
+ text += `\n Devices:`;
153
+ scheme.devices.forEach(device => {
154
+ text += `\n • ${device.controlPath}`;
155
+ if (device.isOptional) {
156
+ text += ' (optional)';
157
+ }
158
+ });
159
+ }
160
+ });
161
+ }
162
+
163
+ if (result.jsonStructure) {
164
+ text += `\n\n## JSON Structure:\n\`\`\`json\n${JSON.stringify(result.jsonStructure, null, 2)}\n\`\`\``;
165
+ }
166
+
167
+ return {
168
+ content: [
169
+ {
170
+ type: 'text',
171
+ text: text
172
+ }
173
+ ],
174
+ isError: false
175
+ };
176
+ } catch (error) {
177
+ return {
178
+ content: [
179
+ {
180
+ type: 'text',
181
+ text: `Failed to get Input Actions state: ${error.message}`
182
+ }
183
+ ],
184
+ isError: true
185
+ };
186
+ }
187
+ }
188
+
189
+ // Handler for analyze_input_actions_asset
190
+ export async function analyzeInputActionsAssetHandler(unityConnection, args) {
191
+ try {
192
+ // Check connection
193
+ if (!unityConnection.isConnected()) {
194
+ return {
195
+ content: [
196
+ {
197
+ type: 'text',
198
+ text: 'Failed to analyze Input Actions asset: Unity connection not available'
199
+ }
200
+ ],
201
+ isError: true
202
+ };
203
+ }
204
+
205
+ // Validate required parameters
206
+ if (!args.assetPath) {
207
+ return {
208
+ content: [
209
+ {
210
+ type: 'text',
211
+ text: 'Failed to analyze Input Actions asset: assetPath is required'
212
+ }
213
+ ],
214
+ isError: true
215
+ };
216
+ }
217
+
218
+ // Send command to Unity
219
+ const result = await unityConnection.sendCommand('analyze_input_actions_asset', args);
220
+
221
+ // Check for errors
222
+ if (!result || typeof result === 'string') {
223
+ return {
224
+ content: [
225
+ {
226
+ type: 'text',
227
+ text: `Failed to analyze Input Actions asset: Invalid response format`
228
+ }
229
+ ],
230
+ isError: true
231
+ };
232
+ }
233
+
234
+ if (result.error) {
235
+ return {
236
+ content: [
237
+ {
238
+ type: 'text',
239
+ text: `Failed to analyze Input Actions asset: ${result.error}`
240
+ }
241
+ ],
242
+ isError: true
243
+ };
244
+ }
245
+
246
+ // Format the response
247
+ let text = `# Input Actions Analysis: ${result.assetName}`;
248
+ text += `\n\nPath: ${result.assetPath}`;
249
+ text += `\nAction Maps: ${result.actionMapCount}`;
250
+
251
+ if (result.statistics) {
252
+ text += `\n\n## Statistics:`;
253
+ text += `\n- Total Actions: ${result.statistics.totalActions}`;
254
+ text += `\n- Total Bindings: ${result.statistics.totalBindings}`;
255
+ text += `\n- Total Control Schemes: ${result.statistics.totalControlSchemes}`;
256
+
257
+ if (result.statistics.devicesUsed && Array.isArray(result.statistics.devicesUsed)) {
258
+ text += `\n- Devices Used: ${result.statistics.devicesUsed.join(', ')}`;
259
+ }
260
+ }
261
+
262
+ if (result.actionMaps && Array.isArray(result.actionMaps)) {
263
+ text += `\n\n## Detailed Action Maps:`;
264
+
265
+ result.actionMaps.forEach(map => {
266
+ text += `\n\n### ${map.name}`;
267
+ text += `\n- Actions: ${map.actionCount}`;
268
+ text += `\n- Bindings: ${map.bindingCount}`;
269
+
270
+ if (map.actions && Array.isArray(map.actions)) {
271
+ text += `\n\n#### Actions:`;
272
+ map.actions.forEach(action => {
273
+ text += `\n\n**${action.name}** (${action.type})`;
274
+ text += `\n- ID: ${action.id}`;
275
+ text += `\n- Expected Control: ${action.expectedControlType || 'Any'}`;
276
+ text += `\n- Bindings: ${action.bindingCount}`;
277
+
278
+ if (action.bindings && Array.isArray(action.bindings)) {
279
+ text += `\n\n Bindings:`;
280
+ action.bindings.forEach((binding, index) => {
281
+ if (binding.isComposite) {
282
+ text += `\n ${index + 1}. **Composite**: ${binding.name || 'Unnamed'}`;
283
+ } else if (binding.isPartOfComposite) {
284
+ text += `\n - ${binding.name}: ${binding.path}`;
285
+ } else {
286
+ text += `\n ${index + 1}. ${binding.path}`;
287
+ }
288
+
289
+ if (binding.groups) {
290
+ text += ` [${binding.groups}]`;
291
+ }
292
+ if (binding.interactions) {
293
+ text += `\n Interactions: ${binding.interactions}`;
294
+ }
295
+ if (binding.processors) {
296
+ text += `\n Processors: ${binding.processors}`;
297
+ }
298
+ });
299
+ }
300
+ });
301
+ }
302
+ });
303
+ }
304
+
305
+ if (result.jsonStructure) {
306
+ text += `\n\n## Raw JSON Structure:\n\`\`\`json\n${JSON.stringify(result.jsonStructure, null, 2)}\n\`\`\``;
307
+ }
308
+
309
+ return {
310
+ content: [
311
+ {
312
+ type: 'text',
313
+ text: text
314
+ }
315
+ ],
316
+ isError: false
317
+ };
318
+ } catch (error) {
319
+ return {
320
+ content: [
321
+ {
322
+ type: 'text',
323
+ text: `Failed to analyze Input Actions asset: ${error.message}`
324
+ }
325
+ ],
326
+ isError: true
327
+ };
328
+ }
329
+ }
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Tool definition for get_object_references
3
+ */
4
+ export const getObjectReferencesToolDefinition = {
5
+ name: 'get_object_references',
6
+ description: 'Find references to and from a GameObject (hierarchy/assets/prefabs).',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ gameObjectName: {
11
+ type: 'string',
12
+ description: 'Name of the GameObject to analyze references for'
13
+ },
14
+ includeAssetReferences: {
15
+ type: 'boolean',
16
+ description: 'Include references to assets (materials, meshes, etc). Default: true'
17
+ },
18
+ includeHierarchyReferences: {
19
+ type: 'boolean',
20
+ description: 'Include parent/child hierarchy references. Default: true'
21
+ },
22
+ searchInPrefabs: {
23
+ type: 'boolean',
24
+ description: 'Also search for references in prefab assets. Default: false'
25
+ }
26
+ },
27
+ required: ['gameObjectName']
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Handler for get_object_references tool
33
+ */
34
+ export async function getObjectReferencesHandler(unityConnection, args) {
35
+ try {
36
+ // Check connection
37
+ if (!unityConnection.isConnected()) {
38
+ return {
39
+ content: [
40
+ {
41
+ type: 'text',
42
+ text: 'Failed to get object references: Unity connection not available'
43
+ }
44
+ ],
45
+ isError: true
46
+ };
47
+ }
48
+
49
+ // Send command to Unity
50
+ const result = await unityConnection.sendCommand('get_object_references', args);
51
+
52
+ // Handle Unity response
53
+ if (result.status === 'error') {
54
+ return {
55
+ content: [
56
+ {
57
+ type: 'text',
58
+ text: `Failed to get object references: ${result.error}`
59
+ }
60
+ ],
61
+ isError: true
62
+ };
63
+ }
64
+
65
+ // Success response
66
+ return {
67
+ content: [
68
+ {
69
+ type: 'text',
70
+ text: result.result.summary || `References analyzed for ${args.gameObjectName}`
71
+ }
72
+ ],
73
+ isError: false
74
+ };
75
+ } catch (error) {
76
+ return {
77
+ content: [
78
+ {
79
+ type: 'text',
80
+ text: `Failed to get object references: ${error.message}`
81
+ }
82
+ ],
83
+ isError: true
84
+ };
85
+ }
86
+ }