@akiojin/unity-mcp-server 2.40.2 → 2.40.3

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 (90) hide show
  1. package/README.md +21 -0
  2. package/bin/unity-mcp-server +1 -1
  3. package/package.json +1 -1
  4. package/src/core/codeIndex.js +64 -15
  5. package/src/core/server.js +3 -34
  6. package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +27 -24
  7. package/src/handlers/analysis/FindByComponentToolHandler.js +4 -1
  8. package/src/handlers/analysis/GetAnimatorStateToolHandler.js +5 -5
  9. package/src/handlers/analysis/GetComponentValuesToolHandler.js +4 -1
  10. package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +27 -24
  11. package/src/handlers/analysis/GetInputActionsStateToolHandler.js +5 -5
  12. package/src/handlers/analysis/GetObjectReferencesToolHandler.js +4 -1
  13. package/src/handlers/asset/AssetDatabaseManageToolHandler.js +24 -6
  14. package/src/handlers/asset/AssetDependencyAnalyzeToolHandler.js +21 -11
  15. package/src/handlers/asset/AssetImportSettingsManageToolHandler.js +7 -7
  16. package/src/handlers/asset/AssetMaterialCreateToolHandler.js +78 -81
  17. package/src/handlers/asset/AssetMaterialModifyToolHandler.js +57 -61
  18. package/src/handlers/asset/AssetPrefabCreateToolHandler.js +61 -64
  19. package/src/handlers/asset/AssetPrefabExitModeToolHandler.js +9 -13
  20. package/src/handlers/asset/AssetPrefabInstantiateToolHandler.js +110 -116
  21. package/src/handlers/asset/AssetPrefabModifyToolHandler.js +58 -58
  22. package/src/handlers/asset/AssetPrefabOpenToolHandler.js +7 -5
  23. package/src/handlers/asset/AssetPrefabSaveToolHandler.js +13 -6
  24. package/src/handlers/compilation/CompilationGetStateToolHandler.js +4 -3
  25. package/src/handlers/component/ComponentAddToolHandler.js +2 -2
  26. package/src/handlers/component/ComponentGetTypesToolHandler.js +17 -21
  27. package/src/handlers/component/ComponentListToolHandler.js +5 -3
  28. package/src/handlers/component/ComponentModifyToolHandler.js +3 -3
  29. package/src/handlers/component/ComponentRemoveToolHandler.js +2 -2
  30. package/src/handlers/console/ConsoleClearToolHandler.js +36 -46
  31. package/src/handlers/editor/EditorLayersManageToolHandler.js +7 -6
  32. package/src/handlers/editor/EditorTagsManageToolHandler.js +20 -11
  33. package/src/handlers/editor/EditorToolsManageToolHandler.js +2 -2
  34. package/src/handlers/editor/EditorWindowsManageToolHandler.js +6 -5
  35. package/src/handlers/gameobject/GameObjectCreateToolHandler.js +62 -66
  36. package/src/handlers/gameobject/GameObjectDeleteToolHandler.js +9 -9
  37. package/src/handlers/gameobject/GameObjectFindToolHandler.js +13 -11
  38. package/src/handlers/gameobject/GameObjectGetHierarchyToolHandler.js +22 -16
  39. package/src/handlers/input/InputActionAddToolHandler.js +2 -2
  40. package/src/handlers/input/InputActionMapCreateToolHandler.js +2 -2
  41. package/src/handlers/input/InputActionMapRemoveToolHandler.js +2 -2
  42. package/src/handlers/input/InputActionRemoveToolHandler.js +2 -2
  43. package/src/handlers/input/InputBindingAddToolHandler.js +2 -2
  44. package/src/handlers/input/InputBindingCompositeCreateToolHandler.js +2 -2
  45. package/src/handlers/input/InputBindingRemoveAllToolHandler.js +2 -2
  46. package/src/handlers/input/InputBindingRemoveToolHandler.js +2 -2
  47. package/src/handlers/input/InputControlSchemesManageToolHandler.js +2 -2
  48. package/src/handlers/package/PackageManagerToolHandler.js +41 -44
  49. package/src/handlers/package/RegistryConfigToolHandler.js +28 -7
  50. package/src/handlers/playmode/PlaymodeGetStateToolHandler.js +12 -16
  51. package/src/handlers/playmode/PlaymodePauseToolHandler.js +8 -12
  52. package/src/handlers/playmode/PlaymodeWaitForStateToolHandler.js +6 -3
  53. package/src/handlers/scene/GetSceneInfoToolHandler.js +11 -11
  54. package/src/handlers/scene/SceneCreateToolHandler.js +28 -31
  55. package/src/handlers/scene/SceneListToolHandler.js +21 -24
  56. package/src/handlers/scene/SceneLoadToolHandler.js +27 -29
  57. package/src/handlers/scene/SceneSaveToolHandler.js +19 -22
  58. package/src/handlers/screenshot/ScreenshotCaptureToolHandler.js +88 -66
  59. package/src/handlers/script/CodeIndexStatusToolHandler.js +4 -3
  60. package/src/handlers/script/CodeIndexUpdateToolHandler.js +24 -14
  61. package/src/handlers/script/ScriptCreateClassToolHandler.js +44 -9
  62. package/src/handlers/script/ScriptPackagesListToolHandler.js +91 -91
  63. package/src/handlers/script/ScriptRefactorRenameToolHandler.js +80 -71
  64. package/src/handlers/script/ScriptRemoveSymbolToolHandler.js +21 -7
  65. package/src/handlers/script/ScriptSearchToolHandler.js +299 -266
  66. package/src/handlers/script/ScriptSymbolsGetToolHandler.js +88 -79
  67. package/src/handlers/settings/SettingsGetToolHandler.js +28 -13
  68. package/src/handlers/settings/SettingsUpdateToolHandler.js +20 -6
  69. package/src/handlers/ui/UIClickElementToolHandler.js +87 -96
  70. package/src/handlers/ui/UIFindElementsToolHandler.js +45 -55
  71. package/src/handlers/ui/UIGetElementStateToolHandler.js +35 -43
  72. package/src/handlers/ui/UISetElementValueToolHandler.js +42 -49
  73. package/src/handlers/ui/UISimulateInputToolHandler.js +134 -136
  74. package/src/handlers/video/VideoCaptureForToolHandler.js +24 -7
  75. package/src/lsp/LspRpcClient.js +24 -12
  76. package/src/tools/analysis/analyzeSceneContents.js +85 -85
  77. package/src/tools/analysis/findByComponent.js +73 -73
  78. package/src/tools/analysis/getAnimatorState.js +287 -287
  79. package/src/tools/analysis/getComponentValues.js +161 -161
  80. package/src/tools/analysis/getGameObjectDetails.js +138 -138
  81. package/src/tools/analysis/getInputActionsState.js +291 -291
  82. package/src/tools/analysis/getObjectReferences.js +72 -72
  83. package/src/tools/input/inputActionsEditor.js +522 -474
  84. package/src/tools/scene/createScene.js +98 -97
  85. package/src/tools/scene/getSceneInfo.js +82 -81
  86. package/src/tools/scene/listScenes.js +70 -69
  87. package/src/tools/scene/loadScene.js +108 -106
  88. package/src/tools/scene/saveScene.js +78 -77
  89. package/src/tools/system/ping.js +9 -12
  90. package/src/utils/validators.js +2 -2
@@ -2,555 +2,603 @@
2
2
 
3
3
  // Action Map Management
4
4
  export const createActionMapToolDefinition = {
5
- name: 'input_action_map_create',
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
- }
5
+ name: 'input_action_map_create',
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
32
  };
33
33
 
34
34
  export const removeActionMapToolDefinition = {
35
- name: 'input_action_map_remove',
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
- }
35
+ name: 'input_action_map_remove',
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
51
  };
52
52
 
53
53
  // Action Management
54
54
  export const addInputActionToolDefinition = {
55
- name: 'input_action_add',
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
- }
55
+ name: 'input_action_add',
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
81
  };
82
82
 
83
83
  export const removeInputActionToolDefinition = {
84
- name: 'input_action_remove',
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
- }
84
+ name: 'input_action_remove',
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
104
  };
105
105
 
106
106
  // Binding Management
107
107
  export const addInputBindingToolDefinition = {
108
- name: 'input_binding_add',
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
- }
108
+ name: 'input_binding_add',
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
144
  };
145
145
 
146
146
  export const removeInputBindingToolDefinition = {
147
- name: 'input_binding_remove',
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
- }
147
+ name: 'input_binding_remove',
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
175
  };
176
176
 
177
177
  export const removeAllBindingsToolDefinition = {
178
- name: 'input_binding_remove_all',
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
- }
178
+ name: 'input_binding_remove_all',
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
198
  };
199
199
 
200
200
  export const createCompositeBindingToolDefinition = {
201
- name: 'input_binding_composite_create',
202
- description: 'Create a composite binding (e.g., 2D Vector for WASD movement)',
203
- inputSchema: {
201
+ name: 'input_binding_composite_create',
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: {
204
229
  type: 'object',
230
+ description: 'Binding paths for composite parts',
205
231
  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
- }
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
247
  };
248
248
 
249
249
  // Control Scheme Management
250
250
  export const manageControlSchemesToolDefinition = {
251
- name: 'input_control_schemes_manage',
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
- }
251
+ name: 'input_control_schemes_manage',
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
277
  };
278
278
 
279
279
  // Helper function to format Unity response
280
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
- }
281
+ if (!result || typeof result === 'string') {
282
+ return {
283
+ content: [
284
+ {
285
+ type: 'text',
286
+ text: `Failed: Invalid response format`
287
+ }
288
+ ],
289
+ isError: true
290
+ };
291
+ }
290
292
 
291
- if (result.error) {
292
- return {
293
- content: [{
294
- type: 'text',
295
- text: `Failed: ${result.error}`
296
- }],
297
- isError: true
298
- };
299
- }
293
+ if (result.error) {
294
+ return {
295
+ content: [
296
+ {
297
+ type: 'text',
298
+ text: `Failed: ${result.error}`
299
+ }
300
+ ],
301
+ isError: true
302
+ };
303
+ }
300
304
 
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
- }
305
+ if (result.success) {
306
+ let text = result.message || successMessage;
307
+ // Add any additional info from result
308
+ Object.keys(result).forEach(key => {
309
+ if (key !== 'success' && key !== 'message' && key !== 'error') {
310
+ text += `\n${key}: ${result[key]}`;
311
+ }
312
+ });
318
313
 
319
314
  return {
320
- content: [{
321
- type: 'text',
322
- text: 'Operation completed'
323
- }],
324
- isError: false
315
+ content: [
316
+ {
317
+ type: 'text',
318
+ text: text
319
+ }
320
+ ],
321
+ isError: false
325
322
  };
323
+ }
324
+
325
+ return {
326
+ content: [
327
+ {
328
+ type: 'text',
329
+ text: 'Operation completed'
330
+ }
331
+ ],
332
+ isError: false
333
+ };
326
334
  }
327
335
 
328
336
  // Handlers for Action Map Management
329
337
  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('input_action_map_create', 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
- };
338
+ try {
339
+ if (!unityConnection.isConnected()) {
340
+ return {
341
+ content: [
342
+ {
343
+ type: 'text',
344
+ text: 'Failed to create Action Map: Unity connection not available'
345
+ }
346
+ ],
347
+ isError: true
348
+ };
351
349
  }
352
- }
353
350
 
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
- };
351
+ const result = await unityConnection.sendCommand('input_action_map_create', args);
352
+ return formatUnityResponse(result, `Created Action Map: ${args.mapName}`);
353
+ } catch (error) {
354
+ return {
355
+ content: [
356
+ {
357
+ type: 'text',
358
+ text: `Failed to create Action Map: ${error.message}`
364
359
  }
360
+ ],
361
+ isError: true
362
+ };
363
+ }
364
+ }
365
365
 
366
- const result = await unityConnection.sendCommand('input_action_map_remove', 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
- };
366
+ export async function removeActionMapHandler(unityConnection, args) {
367
+ try {
368
+ if (!unityConnection.isConnected()) {
369
+ return {
370
+ content: [
371
+ {
372
+ type: 'text',
373
+ text: 'Failed to remove Action Map: Unity connection not available'
374
+ }
375
+ ],
376
+ isError: true
377
+ };
376
378
  }
379
+
380
+ const result = await unityConnection.sendCommand('input_action_map_remove', args);
381
+ return formatUnityResponse(result, `Removed Action Map: ${args.mapName}`);
382
+ } catch (error) {
383
+ return {
384
+ content: [
385
+ {
386
+ type: 'text',
387
+ text: `Failed to remove Action Map: ${error.message}`
388
+ }
389
+ ],
390
+ isError: true
391
+ };
392
+ }
377
393
  }
378
394
 
379
395
  // Handlers for Action Management
380
396
  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('input_action_add', 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
- };
397
+ try {
398
+ if (!unityConnection.isConnected()) {
399
+ return {
400
+ content: [
401
+ {
402
+ type: 'text',
403
+ text: 'Failed to add Input Action: Unity connection not available'
404
+ }
405
+ ],
406
+ isError: true
407
+ };
402
408
  }
403
- }
404
409
 
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
- };
410
+ const result = await unityConnection.sendCommand('input_action_add', args);
411
+ return formatUnityResponse(result, `Added Action: ${args.actionName}`);
412
+ } catch (error) {
413
+ return {
414
+ content: [
415
+ {
416
+ type: 'text',
417
+ text: `Failed to add Input Action: ${error.message}`
415
418
  }
419
+ ],
420
+ isError: true
421
+ };
422
+ }
423
+ }
416
424
 
417
- const result = await unityConnection.sendCommand('input_action_remove', 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
- };
425
+ export async function removeInputActionHandler(unityConnection, args) {
426
+ try {
427
+ if (!unityConnection.isConnected()) {
428
+ return {
429
+ content: [
430
+ {
431
+ type: 'text',
432
+ text: 'Failed to remove Input Action: Unity connection not available'
433
+ }
434
+ ],
435
+ isError: true
436
+ };
427
437
  }
438
+
439
+ const result = await unityConnection.sendCommand('input_action_remove', args);
440
+ return formatUnityResponse(result, `Removed Action: ${args.actionName}`);
441
+ } catch (error) {
442
+ return {
443
+ content: [
444
+ {
445
+ type: 'text',
446
+ text: `Failed to remove Input Action: ${error.message}`
447
+ }
448
+ ],
449
+ isError: true
450
+ };
451
+ }
428
452
  }
429
453
 
430
454
  // Handlers for Binding Management
431
455
  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('input_binding_add', 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
- };
456
+ try {
457
+ if (!unityConnection.isConnected()) {
458
+ return {
459
+ content: [
460
+ {
461
+ type: 'text',
462
+ text: 'Failed to add Input Binding: Unity connection not available'
463
+ }
464
+ ],
465
+ isError: true
466
+ };
453
467
  }
454
- }
455
468
 
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
- };
469
+ const result = await unityConnection.sendCommand('input_binding_add', args);
470
+ return formatUnityResponse(result, `Added Binding: ${args.path}`);
471
+ } catch (error) {
472
+ return {
473
+ content: [
474
+ {
475
+ type: 'text',
476
+ text: `Failed to add Input Binding: ${error.message}`
466
477
  }
478
+ ],
479
+ isError: true
480
+ };
481
+ }
482
+ }
467
483
 
468
- const result = await unityConnection.sendCommand('input_binding_remove', 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
- };
484
+ export async function removeInputBindingHandler(unityConnection, args) {
485
+ try {
486
+ if (!unityConnection.isConnected()) {
487
+ return {
488
+ content: [
489
+ {
490
+ type: 'text',
491
+ text: 'Failed to remove Input Binding: Unity connection not available'
492
+ }
493
+ ],
494
+ isError: true
495
+ };
478
496
  }
479
- }
480
497
 
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
- };
498
+ const result = await unityConnection.sendCommand('input_binding_remove', args);
499
+ return formatUnityResponse(result, 'Removed Binding');
500
+ } catch (error) {
501
+ return {
502
+ content: [
503
+ {
504
+ type: 'text',
505
+ text: `Failed to remove Input Binding: ${error.message}`
491
506
  }
507
+ ],
508
+ isError: true
509
+ };
510
+ }
511
+ }
492
512
 
493
- const result = await unityConnection.sendCommand('input_binding_remove_all', 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
- };
513
+ export async function removeAllBindingsHandler(unityConnection, args) {
514
+ try {
515
+ if (!unityConnection.isConnected()) {
516
+ return {
517
+ content: [
518
+ {
519
+ type: 'text',
520
+ text: 'Failed to remove all bindings: Unity connection not available'
521
+ }
522
+ ],
523
+ isError: true
524
+ };
503
525
  }
504
- }
505
526
 
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
- };
527
+ const result = await unityConnection.sendCommand('input_binding_remove_all', args);
528
+ return formatUnityResponse(result, `Removed all bindings from ${args.actionName}`);
529
+ } catch (error) {
530
+ return {
531
+ content: [
532
+ {
533
+ type: 'text',
534
+ text: `Failed to remove all bindings: ${error.message}`
516
535
  }
536
+ ],
537
+ isError: true
538
+ };
539
+ }
540
+ }
517
541
 
518
- const result = await unityConnection.sendCommand('input_binding_composite_create', 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
- };
542
+ export async function createCompositeBindingHandler(unityConnection, args) {
543
+ try {
544
+ if (!unityConnection.isConnected()) {
545
+ return {
546
+ content: [
547
+ {
548
+ type: 'text',
549
+ text: 'Failed to create composite binding: Unity connection not available'
550
+ }
551
+ ],
552
+ isError: true
553
+ };
528
554
  }
555
+
556
+ const result = await unityConnection.sendCommand('input_binding_composite_create', args);
557
+ return formatUnityResponse(
558
+ result,
559
+ `Created composite binding: ${args.name || args.compositeType}`
560
+ );
561
+ } catch (error) {
562
+ return {
563
+ content: [
564
+ {
565
+ type: 'text',
566
+ text: `Failed to create composite binding: ${error.message}`
567
+ }
568
+ ],
569
+ isError: true
570
+ };
571
+ }
529
572
  }
530
573
 
531
574
  // Handler for Control Scheme Management
532
575
  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('input_control_schemes_manage', 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
- };
576
+ try {
577
+ if (!unityConnection.isConnected()) {
578
+ return {
579
+ content: [
580
+ {
581
+ type: 'text',
582
+ text: 'Failed to manage control schemes: Unity connection not available'
583
+ }
584
+ ],
585
+ isError: true
586
+ };
555
587
  }
556
- }
588
+
589
+ const result = await unityConnection.sendCommand('input_control_schemes_manage', args);
590
+ const operationText =
591
+ args.operation === 'add' ? 'Added' : args.operation === 'remove' ? 'Removed' : 'Modified';
592
+ return formatUnityResponse(result, `${operationText} control scheme: ${args.schemeName}`);
593
+ } catch (error) {
594
+ return {
595
+ content: [
596
+ {
597
+ type: 'text',
598
+ text: `Failed to manage control schemes: ${error.message}`
599
+ }
600
+ ],
601
+ isError: true
602
+ };
603
+ }
604
+ }