@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,556 @@
1
+ // Tool definitions for Input Actions editing
2
+
3
+ // Action Map Management
4
+ export const createActionMapToolDefinition = {
5
+ name: 'create_action_map',
6
+ description: 'Create a new Action Map in an Input Actions asset',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ assetPath: {
11
+ type: 'string',
12
+ description: 'Path to the Input Actions asset file'
13
+ },
14
+ mapName: {
15
+ type: 'string',
16
+ description: 'Name for the new Action Map'
17
+ },
18
+ actions: {
19
+ type: 'array',
20
+ description: 'Optional array of actions to add',
21
+ items: {
22
+ type: 'object',
23
+ properties: {
24
+ name: { type: 'string' },
25
+ type: { type: 'string', enum: ['Button', 'Value', 'PassThrough'] }
26
+ }
27
+ }
28
+ }
29
+ },
30
+ required: ['assetPath', 'mapName']
31
+ }
32
+ };
33
+
34
+ export const removeActionMapToolDefinition = {
35
+ name: 'remove_action_map',
36
+ description: 'Remove an Action Map from an Input Actions asset',
37
+ inputSchema: {
38
+ type: 'object',
39
+ properties: {
40
+ assetPath: {
41
+ type: 'string',
42
+ description: 'Path to the Input Actions asset file'
43
+ },
44
+ mapName: {
45
+ type: 'string',
46
+ description: 'Name of the Action Map to remove'
47
+ }
48
+ },
49
+ required: ['assetPath', 'mapName']
50
+ }
51
+ };
52
+
53
+ // Action Management
54
+ export const addInputActionToolDefinition = {
55
+ name: 'add_input_action',
56
+ description: 'Add a new Action to an Action Map',
57
+ inputSchema: {
58
+ type: 'object',
59
+ properties: {
60
+ assetPath: {
61
+ type: 'string',
62
+ description: 'Path to the Input Actions asset file'
63
+ },
64
+ mapName: {
65
+ type: 'string',
66
+ description: 'Name of the Action Map'
67
+ },
68
+ actionName: {
69
+ type: 'string',
70
+ description: 'Name for the new Action'
71
+ },
72
+ actionType: {
73
+ type: 'string',
74
+ description: 'Type of the action',
75
+ enum: ['Button', 'Value', 'PassThrough'],
76
+ default: 'Button'
77
+ }
78
+ },
79
+ required: ['assetPath', 'mapName', 'actionName']
80
+ }
81
+ };
82
+
83
+ export const removeInputActionToolDefinition = {
84
+ name: 'remove_input_action',
85
+ description: 'Remove an Action from an Action Map',
86
+ inputSchema: {
87
+ type: 'object',
88
+ properties: {
89
+ assetPath: {
90
+ type: 'string',
91
+ description: 'Path to the Input Actions asset file'
92
+ },
93
+ mapName: {
94
+ type: 'string',
95
+ description: 'Name of the Action Map'
96
+ },
97
+ actionName: {
98
+ type: 'string',
99
+ description: 'Name of the Action to remove'
100
+ }
101
+ },
102
+ required: ['assetPath', 'mapName', 'actionName']
103
+ }
104
+ };
105
+
106
+ // Binding Management
107
+ export const addInputBindingToolDefinition = {
108
+ name: 'add_input_binding',
109
+ description: 'Add a new Binding to an Action',
110
+ inputSchema: {
111
+ type: 'object',
112
+ properties: {
113
+ assetPath: {
114
+ type: 'string',
115
+ description: 'Path to the Input Actions asset file'
116
+ },
117
+ mapName: {
118
+ type: 'string',
119
+ description: 'Name of the Action Map'
120
+ },
121
+ actionName: {
122
+ type: 'string',
123
+ description: 'Name of the Action'
124
+ },
125
+ path: {
126
+ type: 'string',
127
+ description: 'Binding path (e.g., "<Keyboard>/space", "<Gamepad>/buttonSouth")'
128
+ },
129
+ groups: {
130
+ type: 'string',
131
+ description: 'Control scheme groups (e.g., "Keyboard&Mouse")'
132
+ },
133
+ interactions: {
134
+ type: 'string',
135
+ description: 'Interactions (e.g., "press", "hold")'
136
+ },
137
+ processors: {
138
+ type: 'string',
139
+ description: 'Processors (e.g., "scale", "invert")'
140
+ }
141
+ },
142
+ required: ['assetPath', 'mapName', 'actionName', 'path']
143
+ }
144
+ };
145
+
146
+ export const removeInputBindingToolDefinition = {
147
+ name: 'remove_input_binding',
148
+ description: 'Remove a Binding from an Action',
149
+ inputSchema: {
150
+ type: 'object',
151
+ properties: {
152
+ assetPath: {
153
+ type: 'string',
154
+ description: 'Path to the Input Actions asset file'
155
+ },
156
+ mapName: {
157
+ type: 'string',
158
+ description: 'Name of the Action Map'
159
+ },
160
+ actionName: {
161
+ type: 'string',
162
+ description: 'Name of the Action'
163
+ },
164
+ bindingIndex: {
165
+ type: 'number',
166
+ description: 'Index of the binding to remove'
167
+ },
168
+ bindingPath: {
169
+ type: 'string',
170
+ description: 'Path of the binding to remove (alternative to bindingIndex)'
171
+ }
172
+ },
173
+ required: ['assetPath', 'mapName', 'actionName']
174
+ }
175
+ };
176
+
177
+ export const removeAllBindingsToolDefinition = {
178
+ name: 'remove_all_bindings',
179
+ description: 'Remove all Bindings from an Action',
180
+ inputSchema: {
181
+ type: 'object',
182
+ properties: {
183
+ assetPath: {
184
+ type: 'string',
185
+ description: 'Path to the Input Actions asset file'
186
+ },
187
+ mapName: {
188
+ type: 'string',
189
+ description: 'Name of the Action Map'
190
+ },
191
+ actionName: {
192
+ type: 'string',
193
+ description: 'Name of the Action'
194
+ }
195
+ },
196
+ required: ['assetPath', 'mapName', 'actionName']
197
+ }
198
+ };
199
+
200
+ export const createCompositeBindingToolDefinition = {
201
+ name: 'create_composite_binding',
202
+ description: 'Create a composite binding (e.g., 2D Vector for WASD movement)',
203
+ inputSchema: {
204
+ type: 'object',
205
+ properties: {
206
+ assetPath: {
207
+ type: 'string',
208
+ description: 'Path to the Input Actions asset file'
209
+ },
210
+ mapName: {
211
+ type: 'string',
212
+ description: 'Name of the Action Map'
213
+ },
214
+ actionName: {
215
+ type: 'string',
216
+ description: 'Name of the Action'
217
+ },
218
+ compositeType: {
219
+ type: 'string',
220
+ description: 'Type of composite',
221
+ enum: ['2DVector', '1DAxis'],
222
+ default: '2DVector'
223
+ },
224
+ name: {
225
+ type: 'string',
226
+ description: 'Name for the composite binding'
227
+ },
228
+ bindings: {
229
+ type: 'object',
230
+ description: 'Binding paths for composite parts',
231
+ properties: {
232
+ up: { type: 'string' },
233
+ down: { type: 'string' },
234
+ left: { type: 'string' },
235
+ right: { type: 'string' },
236
+ negative: { type: 'string' },
237
+ positive: { type: 'string' }
238
+ }
239
+ },
240
+ groups: {
241
+ type: 'string',
242
+ description: 'Control scheme groups'
243
+ }
244
+ },
245
+ required: ['assetPath', 'mapName', 'actionName', 'bindings']
246
+ }
247
+ };
248
+
249
+ // Control Scheme Management
250
+ export const manageControlSchemesToolDefinition = {
251
+ name: 'manage_control_schemes',
252
+ description: 'Manage Control Schemes in an Input Actions asset',
253
+ inputSchema: {
254
+ type: 'object',
255
+ properties: {
256
+ assetPath: {
257
+ type: 'string',
258
+ description: 'Path to the Input Actions asset file'
259
+ },
260
+ operation: {
261
+ type: 'string',
262
+ description: 'Operation to perform',
263
+ enum: ['add', 'remove', 'modify']
264
+ },
265
+ schemeName: {
266
+ type: 'string',
267
+ description: 'Name of the control scheme'
268
+ },
269
+ devices: {
270
+ type: 'array',
271
+ description: 'List of device types (e.g., ["Keyboard", "Mouse", "Gamepad"])',
272
+ items: { type: 'string' }
273
+ }
274
+ },
275
+ required: ['assetPath', 'operation']
276
+ }
277
+ };
278
+
279
+ // Helper function to format Unity response
280
+ function formatUnityResponse(result, successMessage) {
281
+ if (!result || typeof result === 'string') {
282
+ return {
283
+ content: [{
284
+ type: 'text',
285
+ text: `Failed: Invalid response format`
286
+ }],
287
+ isError: true
288
+ };
289
+ }
290
+
291
+ if (result.error) {
292
+ return {
293
+ content: [{
294
+ type: 'text',
295
+ text: `Failed: ${result.error}`
296
+ }],
297
+ isError: true
298
+ };
299
+ }
300
+
301
+ if (result.success) {
302
+ let text = result.message || successMessage;
303
+ // Add any additional info from result
304
+ Object.keys(result).forEach(key => {
305
+ if (key !== 'success' && key !== 'message' && key !== 'error') {
306
+ text += `\n${key}: ${result[key]}`;
307
+ }
308
+ });
309
+
310
+ return {
311
+ content: [{
312
+ type: 'text',
313
+ text: text
314
+ }],
315
+ isError: false
316
+ };
317
+ }
318
+
319
+ return {
320
+ content: [{
321
+ type: 'text',
322
+ text: 'Operation completed'
323
+ }],
324
+ isError: false
325
+ };
326
+ }
327
+
328
+ // Handlers for Action Map Management
329
+ export async function createActionMapHandler(unityConnection, args) {
330
+ try {
331
+ if (!unityConnection.isConnected()) {
332
+ return {
333
+ content: [{
334
+ type: 'text',
335
+ text: 'Failed to create Action Map: Unity connection not available'
336
+ }],
337
+ isError: true
338
+ };
339
+ }
340
+
341
+ const result = await unityConnection.sendCommand('create_action_map', args);
342
+ return formatUnityResponse(result, `Created Action Map: ${args.mapName}`);
343
+ } catch (error) {
344
+ return {
345
+ content: [{
346
+ type: 'text',
347
+ text: `Failed to create Action Map: ${error.message}`
348
+ }],
349
+ isError: true
350
+ };
351
+ }
352
+ }
353
+
354
+ export async function removeActionMapHandler(unityConnection, args) {
355
+ try {
356
+ if (!unityConnection.isConnected()) {
357
+ return {
358
+ content: [{
359
+ type: 'text',
360
+ text: 'Failed to remove Action Map: Unity connection not available'
361
+ }],
362
+ isError: true
363
+ };
364
+ }
365
+
366
+ const result = await unityConnection.sendCommand('remove_action_map', args);
367
+ return formatUnityResponse(result, `Removed Action Map: ${args.mapName}`);
368
+ } catch (error) {
369
+ return {
370
+ content: [{
371
+ type: 'text',
372
+ text: `Failed to remove Action Map: ${error.message}`
373
+ }],
374
+ isError: true
375
+ };
376
+ }
377
+ }
378
+
379
+ // Handlers for Action Management
380
+ export async function addInputActionHandler(unityConnection, args) {
381
+ try {
382
+ if (!unityConnection.isConnected()) {
383
+ return {
384
+ content: [{
385
+ type: 'text',
386
+ text: 'Failed to add Input Action: Unity connection not available'
387
+ }],
388
+ isError: true
389
+ };
390
+ }
391
+
392
+ const result = await unityConnection.sendCommand('add_input_action', args);
393
+ return formatUnityResponse(result, `Added Action: ${args.actionName}`);
394
+ } catch (error) {
395
+ return {
396
+ content: [{
397
+ type: 'text',
398
+ text: `Failed to add Input Action: ${error.message}`
399
+ }],
400
+ isError: true
401
+ };
402
+ }
403
+ }
404
+
405
+ export async function removeInputActionHandler(unityConnection, args) {
406
+ try {
407
+ if (!unityConnection.isConnected()) {
408
+ return {
409
+ content: [{
410
+ type: 'text',
411
+ text: 'Failed to remove Input Action: Unity connection not available'
412
+ }],
413
+ isError: true
414
+ };
415
+ }
416
+
417
+ const result = await unityConnection.sendCommand('remove_input_action', args);
418
+ return formatUnityResponse(result, `Removed Action: ${args.actionName}`);
419
+ } catch (error) {
420
+ return {
421
+ content: [{
422
+ type: 'text',
423
+ text: `Failed to remove Input Action: ${error.message}`
424
+ }],
425
+ isError: true
426
+ };
427
+ }
428
+ }
429
+
430
+ // Handlers for Binding Management
431
+ export async function addInputBindingHandler(unityConnection, args) {
432
+ try {
433
+ if (!unityConnection.isConnected()) {
434
+ return {
435
+ content: [{
436
+ type: 'text',
437
+ text: 'Failed to add Input Binding: Unity connection not available'
438
+ }],
439
+ isError: true
440
+ };
441
+ }
442
+
443
+ const result = await unityConnection.sendCommand('add_input_binding', args);
444
+ return formatUnityResponse(result, `Added Binding: ${args.path}`);
445
+ } catch (error) {
446
+ return {
447
+ content: [{
448
+ type: 'text',
449
+ text: `Failed to add Input Binding: ${error.message}`
450
+ }],
451
+ isError: true
452
+ };
453
+ }
454
+ }
455
+
456
+ export async function removeInputBindingHandler(unityConnection, args) {
457
+ try {
458
+ if (!unityConnection.isConnected()) {
459
+ return {
460
+ content: [{
461
+ type: 'text',
462
+ text: 'Failed to remove Input Binding: Unity connection not available'
463
+ }],
464
+ isError: true
465
+ };
466
+ }
467
+
468
+ const result = await unityConnection.sendCommand('remove_input_binding', args);
469
+ return formatUnityResponse(result, 'Removed Binding');
470
+ } catch (error) {
471
+ return {
472
+ content: [{
473
+ type: 'text',
474
+ text: `Failed to remove Input Binding: ${error.message}`
475
+ }],
476
+ isError: true
477
+ };
478
+ }
479
+ }
480
+
481
+ export async function removeAllBindingsHandler(unityConnection, args) {
482
+ try {
483
+ if (!unityConnection.isConnected()) {
484
+ return {
485
+ content: [{
486
+ type: 'text',
487
+ text: 'Failed to remove all bindings: Unity connection not available'
488
+ }],
489
+ isError: true
490
+ };
491
+ }
492
+
493
+ const result = await unityConnection.sendCommand('remove_all_bindings', args);
494
+ return formatUnityResponse(result, `Removed all bindings from ${args.actionName}`);
495
+ } catch (error) {
496
+ return {
497
+ content: [{
498
+ type: 'text',
499
+ text: `Failed to remove all bindings: ${error.message}`
500
+ }],
501
+ isError: true
502
+ };
503
+ }
504
+ }
505
+
506
+ export async function createCompositeBindingHandler(unityConnection, args) {
507
+ try {
508
+ if (!unityConnection.isConnected()) {
509
+ return {
510
+ content: [{
511
+ type: 'text',
512
+ text: 'Failed to create composite binding: Unity connection not available'
513
+ }],
514
+ isError: true
515
+ };
516
+ }
517
+
518
+ const result = await unityConnection.sendCommand('create_composite_binding', args);
519
+ return formatUnityResponse(result, `Created composite binding: ${args.name || args.compositeType}`);
520
+ } catch (error) {
521
+ return {
522
+ content: [{
523
+ type: 'text',
524
+ text: `Failed to create composite binding: ${error.message}`
525
+ }],
526
+ isError: true
527
+ };
528
+ }
529
+ }
530
+
531
+ // Handler for Control Scheme Management
532
+ export async function manageControlSchemesHandler(unityConnection, args) {
533
+ try {
534
+ if (!unityConnection.isConnected()) {
535
+ return {
536
+ content: [{
537
+ type: 'text',
538
+ text: 'Failed to manage control schemes: Unity connection not available'
539
+ }],
540
+ isError: true
541
+ };
542
+ }
543
+
544
+ const result = await unityConnection.sendCommand('manage_control_schemes', args);
545
+ const operationText = args.operation === 'add' ? 'Added' : args.operation === 'remove' ? 'Removed' : 'Modified';
546
+ return formatUnityResponse(result, `${operationText} control scheme: ${args.schemeName}`);
547
+ } catch (error) {
548
+ return {
549
+ content: [{
550
+ type: 'text',
551
+ text: `Failed to manage control schemes: ${error.message}`
552
+ }],
553
+ isError: true
554
+ };
555
+ }
556
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Tool definition for create_scene
3
+ */
4
+ export const createSceneToolDefinition = {
5
+ name: 'create_scene',
6
+ description: 'Create a new scene in Unity',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ sceneName: {
11
+ type: 'string',
12
+ description: 'Name of the scene to create'
13
+ },
14
+ path: {
15
+ type: 'string',
16
+ description: 'Path where the scene should be saved (e.g., "Assets/Scenes/"). If not specified, defaults to "Assets/Scenes/"'
17
+ },
18
+ loadScene: {
19
+ type: 'boolean',
20
+ description: 'Whether to load the scene after creation (default: true)'
21
+ },
22
+ addToBuildSettings: {
23
+ type: 'boolean',
24
+ description: 'Whether to add the scene to build settings (default: false)'
25
+ }
26
+ },
27
+ required: ['sceneName']
28
+ }
29
+ };
30
+
31
+ /**
32
+ * Handler for create_scene tool
33
+ */
34
+ export async function createSceneHandler(unityConnection, args) {
35
+ try {
36
+ // Check connection
37
+ if (!unityConnection.isConnected()) {
38
+ return {
39
+ content: [
40
+ {
41
+ type: 'text',
42
+ text: 'Failed to create scene: Unity connection not available'
43
+ }
44
+ ],
45
+ isError: true
46
+ };
47
+ }
48
+
49
+ // Validate scene name
50
+ if (!args.sceneName || args.sceneName.trim() === '') {
51
+ return {
52
+ content: [
53
+ {
54
+ type: 'text',
55
+ text: 'Failed to create scene: Scene name cannot be empty'
56
+ }
57
+ ],
58
+ isError: true
59
+ };
60
+ }
61
+
62
+ // Check for invalid characters in scene name
63
+ if (args.sceneName.includes('/') || args.sceneName.includes('\\')) {
64
+ return {
65
+ content: [
66
+ {
67
+ type: 'text',
68
+ text: 'Failed to create scene: Scene name contains invalid characters'
69
+ }
70
+ ],
71
+ isError: true
72
+ };
73
+ }
74
+
75
+ // Send command to Unity
76
+ const result = await unityConnection.sendCommand('create_scene', args);
77
+
78
+ // Handle Unity response
79
+ if (result.status === 'error') {
80
+ return {
81
+ content: [
82
+ {
83
+ type: 'text',
84
+ text: `Failed to create scene: ${result.error}`
85
+ }
86
+ ],
87
+ isError: true
88
+ };
89
+ }
90
+
91
+ // Success response
92
+ return {
93
+ content: [
94
+ {
95
+ type: 'text',
96
+ text: result.result.summary || `Scene created successfully`
97
+ }
98
+ ],
99
+ isError: false
100
+ };
101
+ } catch (error) {
102
+ return {
103
+ content: [
104
+ {
105
+ type: 'text',
106
+ text: `Failed to create scene: ${error.message}`
107
+ }
108
+ ],
109
+ isError: true
110
+ };
111
+ }
112
+ }