@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,111 +2,112 @@
2
2
  * Tool definition for scene_create
3
3
  */
4
4
  export const createSceneToolDefinition = {
5
- name: 'scene_create',
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
- }
5
+ name: 'scene_create',
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:
17
+ 'Path where the scene should be saved (e.g., "Assets/Scenes/"). If not specified, defaults to "Assets/Scenes/"'
18
+ },
19
+ loadScene: {
20
+ type: 'boolean',
21
+ description: 'Whether to load the scene after creation (default: true)'
22
+ },
23
+ addToBuildSettings: {
24
+ type: 'boolean',
25
+ description: 'Whether to add the scene to build settings (default: false)'
26
+ }
27
+ },
28
+ required: ['sceneName']
29
+ }
29
30
  };
30
31
 
31
32
  /**
32
33
  * Handler for create_scene tool
33
34
  */
34
35
  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
- }
36
+ try {
37
+ // Check connection
38
+ if (!unityConnection.isConnected()) {
39
+ return {
40
+ content: [
41
+ {
42
+ type: 'text',
43
+ text: 'Failed to create scene: Unity connection not available'
44
+ }
45
+ ],
46
+ isError: true
47
+ };
48
+ }
61
49
 
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
- }
50
+ // Validate scene name
51
+ if (!args.sceneName || args.sceneName.trim() === '') {
52
+ return {
53
+ content: [
54
+ {
55
+ type: 'text',
56
+ text: 'Failed to create scene: Scene name cannot be empty'
57
+ }
58
+ ],
59
+ isError: true
60
+ };
61
+ }
74
62
 
75
- // Send command to Unity
76
- const result = await unityConnection.sendCommand('scene_create', args);
63
+ // Check for invalid characters in scene name
64
+ if (args.sceneName.includes('/') || args.sceneName.includes('\\')) {
65
+ return {
66
+ content: [
67
+ {
68
+ type: 'text',
69
+ text: 'Failed to create scene: Scene name contains invalid characters'
70
+ }
71
+ ],
72
+ isError: true
73
+ };
74
+ }
77
75
 
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
- }
76
+ // Send command to Unity
77
+ const result = await unityConnection.sendCommand('scene_create', args);
90
78
 
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
- };
79
+ // Handle Unity response
80
+ if (result.status === 'error') {
81
+ return {
82
+ content: [
83
+ {
84
+ type: 'text',
85
+ text: `Failed to create scene: ${result.error}`
86
+ }
87
+ ],
88
+ isError: true
89
+ };
111
90
  }
112
- }
91
+
92
+ // Success response
93
+ return {
94
+ content: [
95
+ {
96
+ type: 'text',
97
+ text: result.result.summary || `Scene created successfully`
98
+ }
99
+ ],
100
+ isError: false
101
+ };
102
+ } catch (error) {
103
+ return {
104
+ content: [
105
+ {
106
+ type: 'text',
107
+ text: `Failed to create scene: ${error.message}`
108
+ }
109
+ ],
110
+ isError: true
111
+ };
112
+ }
113
+ }
@@ -2,94 +2,95 @@
2
2
  * Tool definition for scene_info_get
3
3
  */
4
4
  export const getSceneInfoToolDefinition = {
5
- name: 'scene_info_get',
6
- description: 'Get detailed information about a scene',
7
- inputSchema: {
8
- type: 'object',
9
- properties: {
10
- scenePath: {
11
- type: 'string',
12
- description: 'Full path to the scene file. If not provided, gets info about current scene.'
13
- },
14
- sceneName: {
15
- type: 'string',
16
- description: 'Name of the scene. Use either scenePath or sceneName, not both.'
17
- },
18
- includeGameObjects: {
19
- type: 'boolean',
20
- description: 'Include list of root GameObjects in the scene (only for loaded scenes). Default: false'
21
- }
22
- },
23
- required: []
24
- }
5
+ name: 'scene_info_get',
6
+ description: 'Get detailed information about a scene',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ scenePath: {
11
+ type: 'string',
12
+ description: 'Full path to the scene file. If not provided, gets info about current scene.'
13
+ },
14
+ sceneName: {
15
+ type: 'string',
16
+ description: 'Name of the scene. Use either scenePath or sceneName, not both.'
17
+ },
18
+ includeGameObjects: {
19
+ type: 'boolean',
20
+ description:
21
+ 'Include list of root GameObjects in the scene (only for loaded scenes). Default: false'
22
+ }
23
+ },
24
+ required: []
25
+ }
25
26
  };
26
27
 
27
28
  /**
28
29
  * Handler for get_scene_info tool
29
30
  */
30
31
  export async function getSceneInfoHandler(unityConnection, args) {
31
- try {
32
- // Check connection
33
- if (!unityConnection.isConnected()) {
34
- return {
35
- content: [
36
- {
37
- type: 'text',
38
- text: 'Failed to get scene info: Unity connection not available'
39
- }
40
- ],
41
- isError: true
42
- };
43
- }
44
-
45
- // Validate that only one identifier is provided if any
46
- if (args.scenePath && args.sceneName) {
47
- return {
48
- content: [
49
- {
50
- type: 'text',
51
- text: 'Failed to get scene info: Provide either scenePath or sceneName, not both'
52
- }
53
- ],
54
- isError: true
55
- };
56
- }
32
+ try {
33
+ // Check connection
34
+ if (!unityConnection.isConnected()) {
35
+ return {
36
+ content: [
37
+ {
38
+ type: 'text',
39
+ text: 'Failed to get scene info: Unity connection not available'
40
+ }
41
+ ],
42
+ isError: true
43
+ };
44
+ }
57
45
 
58
- // Send command to Unity
59
- const result = await unityConnection.sendCommand('scene_info_get', args);
46
+ // Validate that only one identifier is provided if any
47
+ if (args.scenePath && args.sceneName) {
48
+ return {
49
+ content: [
50
+ {
51
+ type: 'text',
52
+ text: 'Failed to get scene info: Provide either scenePath or sceneName, not both'
53
+ }
54
+ ],
55
+ isError: true
56
+ };
57
+ }
60
58
 
61
- // Handle Unity response
62
- if (result.status === 'error') {
63
- return {
64
- content: [
65
- {
66
- type: 'text',
67
- text: `Failed to get scene info: ${result.error}`
68
- }
69
- ],
70
- isError: true
71
- };
72
- }
59
+ // Send command to Unity
60
+ const result = await unityConnection.sendCommand('scene_info_get', args);
73
61
 
74
- // Success response
75
- return {
76
- content: [
77
- {
78
- type: 'text',
79
- text: result.result.summary || `Scene information retrieved`
80
- }
81
- ],
82
- isError: false
83
- };
84
- } catch (error) {
85
- return {
86
- content: [
87
- {
88
- type: 'text',
89
- text: `Failed to get scene info: ${error.message}`
90
- }
91
- ],
92
- isError: true
93
- };
62
+ // Handle Unity response
63
+ if (result.status === 'error') {
64
+ return {
65
+ content: [
66
+ {
67
+ type: 'text',
68
+ text: `Failed to get scene info: ${result.error}`
69
+ }
70
+ ],
71
+ isError: true
72
+ };
94
73
  }
95
- }
74
+
75
+ // Success response
76
+ return {
77
+ content: [
78
+ {
79
+ type: 'text',
80
+ text: result.result.summary || `Scene information retrieved`
81
+ }
82
+ ],
83
+ isError: false
84
+ };
85
+ } catch (error) {
86
+ return {
87
+ content: [
88
+ {
89
+ type: 'text',
90
+ text: `Failed to get scene info: ${error.message}`
91
+ }
92
+ ],
93
+ isError: true
94
+ };
95
+ }
96
+ }
@@ -2,81 +2,82 @@
2
2
  * Tool definition for scene_list
3
3
  */
4
4
  export const listScenesToolDefinition = {
5
- name: 'scene_list',
6
- description: 'List all scenes in the Unity project',
7
- inputSchema: {
8
- type: 'object',
9
- properties: {
10
- includeLoadedOnly: {
11
- type: 'boolean',
12
- description: 'Only include currently loaded scenes (default: false)'
13
- },
14
- includeBuildScenesOnly: {
15
- type: 'boolean',
16
- description: 'Only include scenes in build settings (default: false)'
17
- },
18
- includePath: {
19
- type: 'string',
20
- description: 'Filter scenes by path pattern (e.g., "Levels" to find scenes in Levels folder)'
21
- }
22
- },
23
- required: []
24
- }
5
+ name: 'scene_list',
6
+ description: 'List all scenes in the Unity project',
7
+ inputSchema: {
8
+ type: 'object',
9
+ properties: {
10
+ includeLoadedOnly: {
11
+ type: 'boolean',
12
+ description: 'Only include currently loaded scenes (default: false)'
13
+ },
14
+ includeBuildScenesOnly: {
15
+ type: 'boolean',
16
+ description: 'Only include scenes in build settings (default: false)'
17
+ },
18
+ includePath: {
19
+ type: 'string',
20
+ description:
21
+ 'Filter scenes by path pattern (e.g., "Levels" to find scenes in Levels folder)'
22
+ }
23
+ },
24
+ required: []
25
+ }
25
26
  };
26
27
 
27
28
  /**
28
29
  * Handler for list_scenes tool
29
30
  */
30
31
  export async function listScenesHandler(unityConnection, args) {
31
- try {
32
- // Check connection
33
- if (!unityConnection.isConnected()) {
34
- return {
35
- content: [
36
- {
37
- type: 'text',
38
- text: 'Failed to list scenes: Unity connection not available'
39
- }
40
- ],
41
- isError: true
42
- };
43
- }
44
-
45
- // Send command to Unity
46
- const result = await unityConnection.sendCommand('scene_list', args);
32
+ try {
33
+ // Check connection
34
+ if (!unityConnection.isConnected()) {
35
+ return {
36
+ content: [
37
+ {
38
+ type: 'text',
39
+ text: 'Failed to list scenes: Unity connection not available'
40
+ }
41
+ ],
42
+ isError: true
43
+ };
44
+ }
47
45
 
48
- // Handle Unity response
49
- if (result.status === 'error') {
50
- return {
51
- content: [
52
- {
53
- type: 'text',
54
- text: `Failed to list scenes: ${result.error}`
55
- }
56
- ],
57
- isError: true
58
- };
59
- }
46
+ // Send command to Unity
47
+ const result = await unityConnection.sendCommand('scene_list', args);
60
48
 
61
- // Success response
62
- return {
63
- content: [
64
- {
65
- type: 'text',
66
- text: result.result.summary || `Found ${result.result.totalCount} scenes`
67
- }
68
- ],
69
- isError: false
70
- };
71
- } catch (error) {
72
- return {
73
- content: [
74
- {
75
- type: 'text',
76
- text: `Failed to list scenes: ${error.message}`
77
- }
78
- ],
79
- isError: true
80
- };
49
+ // Handle Unity response
50
+ if (result.status === 'error') {
51
+ return {
52
+ content: [
53
+ {
54
+ type: 'text',
55
+ text: `Failed to list scenes: ${result.error}`
56
+ }
57
+ ],
58
+ isError: true
59
+ };
81
60
  }
82
- }
61
+
62
+ // Success response
63
+ return {
64
+ content: [
65
+ {
66
+ type: 'text',
67
+ text: result.result.summary || `Found ${result.result.totalCount} scenes`
68
+ }
69
+ ],
70
+ isError: false
71
+ };
72
+ } catch (error) {
73
+ return {
74
+ content: [
75
+ {
76
+ type: 'text',
77
+ text: `Failed to list scenes: ${error.message}`
78
+ }
79
+ ],
80
+ isError: true
81
+ };
82
+ }
83
+ }