@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
@@ -1,96 +1,93 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
2
 
3
3
  export class AssetMaterialCreateToolHandler extends BaseToolHandler {
4
- constructor(unityConnection) {
5
- super(
6
- 'asset_material_create',
7
- 'Create a material asset with a shader and property overrides (optional copyFrom).',
8
- {
9
- type: 'object',
10
- properties: {
11
- materialPath: {
12
- type: 'string',
13
- description: 'Asset path for the material. Must start with Assets/ and end with .mat.'
14
- },
15
- shader: {
16
- type: 'string',
17
- description: 'Shader to use (e.g., Standard, Unlit/Color, Universal Render Pipeline/Lit).'
18
- },
19
- properties: {
20
- type: 'object',
21
- description: 'Material property overrides (e.g., {"_Color":[1,0,0,1], "_Metallic":0.5}).'
22
- },
23
- copyFrom: {
24
- type: 'string',
25
- description: 'Optional: path to an existing material to clone before applying overrides.'
26
- },
27
- overwrite: {
28
- type: 'boolean',
29
- description: 'If true, overwrite existing material at the path.'
30
- }
31
- },
32
- required: ['materialPath']
33
- }
34
- );
35
- this.unityConnection = unityConnection;
36
- }
4
+ constructor(unityConnection) {
5
+ super(
6
+ 'asset_material_create',
7
+ 'Create a material asset with a shader and property overrides (optional copyFrom).',
8
+ {
9
+ type: 'object',
10
+ properties: {
11
+ materialPath: {
12
+ type: 'string',
13
+ description: 'Asset path for the material. Must start with Assets/ and end with .mat.'
14
+ },
15
+ shader: {
16
+ type: 'string',
17
+ description:
18
+ 'Shader to use (e.g., Standard, Unlit/Color, Universal Render Pipeline/Lit).'
19
+ },
20
+ properties: {
21
+ type: 'object',
22
+ description:
23
+ 'Material property overrides (e.g., {"_Color":[1,0,0,1], "_Metallic":0.5}).'
24
+ },
25
+ copyFrom: {
26
+ type: 'string',
27
+ description:
28
+ 'Optional: path to an existing material to clone before applying overrides.'
29
+ },
30
+ overwrite: {
31
+ type: 'boolean',
32
+ description: 'If true, overwrite existing material at the path.'
33
+ }
34
+ },
35
+ required: ['materialPath']
36
+ }
37
+ );
38
+ this.unityConnection = unityConnection;
39
+ }
37
40
 
38
- validate(params) {
39
- // Call parent validation for required fields
40
- super.validate(params);
41
+ validate(params) {
42
+ // Call parent validation for required fields
43
+ super.validate(params);
41
44
 
42
- const { materialPath, shader, properties, copyFrom } = params;
45
+ const { materialPath, shader, properties, copyFrom } = params;
43
46
 
44
- // Validate materialPath format
45
- if (!materialPath.startsWith('Assets/') || !materialPath.endsWith('.mat')) {
46
- throw new Error('materialPath must start with Assets/ and end with .mat');
47
- }
47
+ // Validate materialPath format
48
+ if (!materialPath.startsWith('Assets/') || !materialPath.endsWith('.mat')) {
49
+ throw new Error('materialPath must start with Assets/ and end with .mat');
50
+ }
48
51
 
49
- // Validate shader when provided
50
- if (shader !== undefined && shader === '') {
51
- throw new Error('shader cannot be empty when provided');
52
- }
52
+ // Validate shader when provided
53
+ if (shader !== undefined && shader === '') {
54
+ throw new Error('shader cannot be empty when provided');
55
+ }
53
56
 
54
- // Validate properties when provided
55
- if (properties !== undefined) {
56
- if (typeof properties !== 'object' || properties === null) {
57
- throw new Error('properties must be an object');
58
- }
59
- }
57
+ // Validate properties when provided
58
+ if (properties !== undefined) {
59
+ if (typeof properties !== 'object' || properties === null) {
60
+ throw new Error('properties must be an object');
61
+ }
62
+ }
60
63
 
61
- // Validate copyFrom when provided
62
- if (copyFrom !== undefined) {
63
- if (copyFrom === '') {
64
- throw new Error('copyFrom cannot be empty when provided');
65
- }
66
- if (!copyFrom.startsWith('Assets/') || !copyFrom.endsWith('.mat')) {
67
- throw new Error('copyFrom must be a valid material path (Assets/.../.mat)');
68
- }
69
- }
64
+ // Validate copyFrom when provided
65
+ if (copyFrom !== undefined) {
66
+ if (copyFrom === '') {
67
+ throw new Error('copyFrom cannot be empty when provided');
68
+ }
69
+ if (!copyFrom.startsWith('Assets/') || !copyFrom.endsWith('.mat')) {
70
+ throw new Error('copyFrom must be a valid material path (Assets/.../.mat)');
71
+ }
70
72
  }
73
+ }
71
74
 
72
- async execute(params) {
73
- const {
74
- materialPath,
75
- shader,
76
- properties,
77
- copyFrom,
78
- overwrite
79
- } = params;
75
+ async execute(params) {
76
+ const { materialPath, shader, properties, copyFrom, overwrite } = params;
80
77
 
81
- // Ensure connected
82
- if (!this.unityConnection.isConnected()) {
83
- await this.unityConnection.connect();
84
- }
78
+ // Ensure connected
79
+ if (!this.unityConnection.isConnected()) {
80
+ await this.unityConnection.connect();
81
+ }
85
82
 
86
- const result = await this.unityConnection.sendCommand('create_material', {
87
- materialPath,
88
- shader,
89
- properties,
90
- copyFrom,
91
- overwrite
92
- });
83
+ const result = await this.unityConnection.sendCommand('create_material', {
84
+ materialPath,
85
+ shader,
86
+ properties,
87
+ copyFrom,
88
+ overwrite
89
+ });
93
90
 
94
- return result;
95
- }
91
+ return result;
92
+ }
96
93
  }
@@ -1,76 +1,72 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
2
 
3
3
  export class AssetMaterialModifyToolHandler extends BaseToolHandler {
4
- constructor(unityConnection) {
5
- super(
6
- 'asset_material_modify',
7
- 'Modify a material by updating property values and/or changing the shader.',
8
- {
9
- type: 'object',
10
- properties: {
11
- materialPath: {
12
- type: 'string',
13
- description: 'Asset path to the material. Must start with Assets/ and end with .mat.'
14
- },
15
- properties: {
16
- type: 'object',
17
- description: 'Property updates (e.g., {"_Color":[1,0,0,1], "_Metallic":0.5}).'
18
- },
19
- shader: {
20
- type: 'string',
21
- description: 'Optional: change the shader (e.g., Standard, Unlit/Color).'
22
- }
23
- },
24
- required: ['materialPath', 'properties']
25
- }
26
- );
27
- this.unityConnection = unityConnection;
28
- }
4
+ constructor(unityConnection) {
5
+ super(
6
+ 'asset_material_modify',
7
+ 'Modify a material by updating property values and/or changing the shader.',
8
+ {
9
+ type: 'object',
10
+ properties: {
11
+ materialPath: {
12
+ type: 'string',
13
+ description: 'Asset path to the material. Must start with Assets/ and end with .mat.'
14
+ },
15
+ properties: {
16
+ type: 'object',
17
+ description: 'Property updates (e.g., {"_Color":[1,0,0,1], "_Metallic":0.5}).'
18
+ },
19
+ shader: {
20
+ type: 'string',
21
+ description: 'Optional: change the shader (e.g., Standard, Unlit/Color).'
22
+ }
23
+ },
24
+ required: ['materialPath', 'properties']
25
+ }
26
+ );
27
+ this.unityConnection = unityConnection;
28
+ }
29
29
 
30
- validate(params) {
31
- // Call parent validation for required fields
32
- super.validate(params);
30
+ validate(params) {
31
+ // Call parent validation for required fields
32
+ super.validate(params);
33
33
 
34
- const { materialPath, properties, shader } = params;
34
+ const { materialPath, properties, shader } = params;
35
35
 
36
- // Validate materialPath format
37
- if (!materialPath.startsWith('Assets/') || !materialPath.endsWith('.mat')) {
38
- throw new Error('materialPath must start with Assets/ and end with .mat');
39
- }
36
+ // Validate materialPath format
37
+ if (!materialPath.startsWith('Assets/') || !materialPath.endsWith('.mat')) {
38
+ throw new Error('materialPath must start with Assets/ and end with .mat');
39
+ }
40
40
 
41
- // Validate properties
42
- if (typeof properties !== 'object' || properties === null || Array.isArray(properties)) {
43
- throw new Error('properties must be an object');
44
- }
41
+ // Validate properties
42
+ if (typeof properties !== 'object' || properties === null || Array.isArray(properties)) {
43
+ throw new Error('properties must be an object');
44
+ }
45
45
 
46
- if (Object.keys(properties).length === 0) {
47
- throw new Error('properties cannot be empty');
48
- }
46
+ if (Object.keys(properties).length === 0) {
47
+ throw new Error('properties cannot be empty');
48
+ }
49
49
 
50
- // Validate shader when provided
51
- if (shader !== undefined && shader === '') {
52
- throw new Error('shader cannot be empty when provided');
53
- }
50
+ // Validate shader when provided
51
+ if (shader !== undefined && shader === '') {
52
+ throw new Error('shader cannot be empty when provided');
54
53
  }
54
+ }
55
55
 
56
- async execute(params) {
57
- const {
58
- materialPath,
59
- properties,
60
- shader
61
- } = params;
56
+ async execute(params) {
57
+ const { materialPath, properties, shader } = params;
62
58
 
63
- // Ensure connected
64
- if (!this.unityConnection.isConnected()) {
65
- await this.unityConnection.connect();
66
- }
59
+ // Ensure connected
60
+ if (!this.unityConnection.isConnected()) {
61
+ await this.unityConnection.connect();
62
+ }
67
63
 
68
- const result = await this.unityConnection.sendCommand('modify_material', {
69
- materialPath,
70
- properties,
71
- shader
72
- });
64
+ const result = await this.unityConnection.sendCommand('modify_material', {
65
+ materialPath,
66
+ properties,
67
+ shader
68
+ });
73
69
 
74
- return result;
75
- }
70
+ return result;
71
+ }
76
72
  }
@@ -1,78 +1,75 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
2
 
3
3
  export class AssetPrefabCreateToolHandler extends BaseToolHandler {
4
- constructor(unityConnection) {
5
- super(
6
- 'asset_prefab_create',
7
- 'Create a prefab from a GameObject path or create an empty prefab at a target asset path.',
8
- {
9
- type: 'object',
10
- properties: {
11
- gameObjectPath: {
12
- type: 'string',
13
- description: 'Scene path to convert (e.g., "/Root/Player"). Mutually exclusive with createFromTemplate.'
14
- },
15
- prefabPath: {
16
- type: 'string',
17
- description: 'Asset path for the prefab. Must start with Assets/ and end with .prefab.'
18
- },
19
- createFromTemplate: {
20
- type: 'boolean',
21
- description: 'If true, create an empty prefab (no source GameObject) (default: false).'
22
- },
23
- overwrite: {
24
- type: 'boolean',
25
- description: 'If true, overwrite existing prefab at the destination path (default: false).'
26
- }
27
- },
28
- required: ['prefabPath']
29
- }
30
- );
31
- this.unityConnection = unityConnection;
32
- }
4
+ constructor(unityConnection) {
5
+ super(
6
+ 'asset_prefab_create',
7
+ 'Create a prefab from a GameObject path or create an empty prefab at a target asset path.',
8
+ {
9
+ type: 'object',
10
+ properties: {
11
+ gameObjectPath: {
12
+ type: 'string',
13
+ description:
14
+ 'Scene path to convert (e.g., "/Root/Player"). Mutually exclusive with createFromTemplate.'
15
+ },
16
+ prefabPath: {
17
+ type: 'string',
18
+ description: 'Asset path for the prefab. Must start with Assets/ and end with .prefab.'
19
+ },
20
+ createFromTemplate: {
21
+ type: 'boolean',
22
+ description: 'If true, create an empty prefab (no source GameObject) (default: false).'
23
+ },
24
+ overwrite: {
25
+ type: 'boolean',
26
+ description:
27
+ 'If true, overwrite existing prefab at the destination path (default: false).'
28
+ }
29
+ },
30
+ required: ['prefabPath']
31
+ }
32
+ );
33
+ this.unityConnection = unityConnection;
34
+ }
33
35
 
34
- validate(params) {
35
- // Call parent validation for required fields
36
- super.validate(params);
36
+ validate(params) {
37
+ // Call parent validation for required fields
38
+ super.validate(params);
37
39
 
38
- const { prefabPath, gameObjectPath, createFromTemplate } = params;
40
+ const { prefabPath, gameObjectPath, createFromTemplate } = params;
39
41
 
40
- // Validate prefabPath format
41
- if (!prefabPath.startsWith('Assets/') || !prefabPath.endsWith('.prefab')) {
42
- throw new Error('prefabPath must start with Assets/ and end with .prefab');
43
- }
42
+ // Validate prefabPath format
43
+ if (!prefabPath.startsWith('Assets/') || !prefabPath.endsWith('.prefab')) {
44
+ throw new Error('prefabPath must start with Assets/ and end with .prefab');
45
+ }
44
46
 
45
- // Validate gameObjectPath when provided
46
- if (gameObjectPath !== undefined && gameObjectPath === '') {
47
- throw new Error('gameObjectPath cannot be empty when provided');
48
- }
47
+ // Validate gameObjectPath when provided
48
+ if (gameObjectPath !== undefined && gameObjectPath === '') {
49
+ throw new Error('gameObjectPath cannot be empty when provided');
50
+ }
49
51
 
50
- // Validate mutually exclusive options
51
- if (gameObjectPath && createFromTemplate) {
52
- throw new Error('Cannot specify both gameObjectPath and createFromTemplate');
53
- }
52
+ // Validate mutually exclusive options
53
+ if (gameObjectPath && createFromTemplate) {
54
+ throw new Error('Cannot specify both gameObjectPath and createFromTemplate');
54
55
  }
56
+ }
55
57
 
56
- async execute(params) {
57
- const {
58
- gameObjectPath,
59
- prefabPath,
60
- createFromTemplate = false,
61
- overwrite = false
62
- } = params;
58
+ async execute(params) {
59
+ const { gameObjectPath, prefabPath, createFromTemplate = false, overwrite = false } = params;
63
60
 
64
- // Ensure connected
65
- if (!this.unityConnection.isConnected()) {
66
- await this.unityConnection.connect();
67
- }
61
+ // Ensure connected
62
+ if (!this.unityConnection.isConnected()) {
63
+ await this.unityConnection.connect();
64
+ }
68
65
 
69
- const result = await this.unityConnection.sendCommand('create_prefab', {
70
- gameObjectPath,
71
- prefabPath,
72
- createFromTemplate,
73
- overwrite
74
- });
66
+ const result = await this.unityConnection.sendCommand('create_prefab', {
67
+ gameObjectPath,
68
+ prefabPath,
69
+ createFromTemplate,
70
+ overwrite
71
+ });
75
72
 
76
- return result;
77
- }
73
+ return result;
74
+ }
78
75
  }
@@ -5,20 +5,16 @@ import { BaseToolHandler } from '../base/BaseToolHandler.js';
5
5
  */
6
6
  export class AssetPrefabExitModeToolHandler extends BaseToolHandler {
7
7
  constructor(unityConnection) {
8
- super(
9
- 'asset_prefab_exit_mode',
10
- 'Exit prefab mode and return to the main scene',
11
- {
12
- type: 'object',
13
- properties: {
14
- saveChanges: {
15
- type: 'boolean',
16
- description: 'Save changes before exiting (default: true)'
17
- }
8
+ super('asset_prefab_exit_mode', 'Exit prefab mode and return to the main scene', {
9
+ type: 'object',
10
+ properties: {
11
+ saveChanges: {
12
+ type: 'boolean',
13
+ description: 'Save changes before exiting (default: true)'
18
14
  }
19
15
  }
20
- );
21
-
16
+ });
17
+
22
18
  this.unityConnection = unityConnection;
23
19
  }
24
20
 
@@ -80,4 +76,4 @@ export class AssetPrefabExitModeToolHandler extends BaseToolHandler {
80
76
  }
81
77
  };
82
78
  }
83
- }
79
+ }