@akiojin/unity-mcp-server 2.40.1 → 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 +3 -8
  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
package/README.md CHANGED
@@ -332,6 +332,27 @@ npm uninstall -g @akiojin/unity-mcp-server
332
332
  npm install -g @akiojin/unity-mcp-server
333
333
  ```
334
334
 
335
+ ### MCP Client Shows "Capabilities: none"
336
+
337
+ If your MCP client (Claude Code, Cursor, etc.) shows "Capabilities: none" despite successful connection:
338
+
339
+ **Symptom**: Server connects successfully, but no tools are visible to the client.
340
+
341
+ **Root Cause**: Empty capability objects (`resources: {}`, `prompts: {}`) in MCP SDK v0.6.1 cause capability validation to fail silently.
342
+
343
+ **Solution**: Update to latest version with the fix:
344
+
345
+ ```bash
346
+ # Update to latest version (2.41.0+)
347
+ npm update -g @akiojin/unity-mcp-server
348
+
349
+ # Or reinstall
350
+ npm uninstall -g @akiojin/unity-mcp-server
351
+ npm install -g @akiojin/unity-mcp-server
352
+ ```
353
+
354
+ **Verification**: After restart, your MCP client should display 107 available tools.
355
+
335
356
  ## Repository
336
357
 
337
358
  Full source code and documentation: <https://github.com/akiojin/unity-mcp-server>
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { startServer } from '../src/core/server.js';
3
3
 
4
- startServer().catch((error) => {
4
+ startServer().catch(error => {
5
5
  console.error('Fatal error:', error);
6
6
  console.error('Stack trace:', error?.stack);
7
7
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akiojin/unity-mcp-server",
3
- "version": "2.40.1",
3
+ "version": "2.40.3",
4
4
  "description": "MCP server and Unity Editor bridge — enables AI assistants to control Unity for AI-assisted workflows",
5
5
  "type": "module",
6
6
  "main": "src/core/server.js",
@@ -26,11 +26,11 @@
26
26
  "simulate:code-index": "node scripts/simulate-code-index-status.mjs",
27
27
  "test:verbose": "VERBOSE_TEST=true node --test tests/**/*.test.js",
28
28
  "prepare": "cd .. && husky || true",
29
- "prepublishOnly": "pnpm run test:ci",
29
+ "prepublishOnly": "npm run test:ci",
30
30
  "postinstall": "chmod +x bin/unity-mcp-server || true",
31
31
  "test:ci:unity": "timeout 60 node --test tests/unit/core/codeIndex.test.js tests/unit/core/codeIndexDb.test.js tests/unit/core/config.test.js tests/unit/core/indexWatcher.test.js tests/unit/core/projectInfo.test.js tests/unit/core/server.test.js || exit 0",
32
32
  "test:unity": "node tests/run-unity-integration.mjs",
33
- "test:nounity": "pnpm run test:integration",
33
+ "test:nounity": "npm run test:integration",
34
34
  "test:ci:integration": "CI=true NODE_ENV=test node --test tests/integration/code-index-background.test.js"
35
35
  },
36
36
  "keywords": [
@@ -60,11 +60,6 @@
60
60
  "url": "https://github.com/akiojin/unity-mcp-server.git",
61
61
  "directory": "mcp-server"
62
62
  },
63
- "pnpm": {
64
- "onlyBuiltDependencies": [
65
- "better-sqlite3"
66
- ]
67
- },
68
63
  "homepage": "https://github.com/akiojin/unity-mcp-server#readme",
69
64
  "bugs": {
70
65
  "url": "https://github.com/akiojin/unity-mcp-server/issues"
@@ -80,14 +80,27 @@ export class CodeIndex {
80
80
  async clearAndLoad(symbols) {
81
81
  const db = await this.open();
82
82
  if (!db) throw new Error('CodeIndex is unavailable (better-sqlite3 not installed)');
83
- const insert = db.prepare('INSERT INTO symbols(path,name,kind,container,namespace,line,column) VALUES (?,?,?,?,?,?,?)');
84
- const tx = db.transaction((rows) => {
83
+ const insert = db.prepare(
84
+ 'INSERT INTO symbols(path,name,kind,container,namespace,line,column) VALUES (?,?,?,?,?,?,?)'
85
+ );
86
+ const tx = db.transaction(rows => {
85
87
  db.exec('DELETE FROM symbols');
86
88
  db.exec('DELETE FROM files');
87
89
  for (const r of rows) {
88
- insert.run(r.path, r.name, r.kind, r.container || null, r.ns || r.namespace || null, r.line || null, r.column || null);
90
+ insert.run(
91
+ r.path,
92
+ r.name,
93
+ r.kind,
94
+ r.container || null,
95
+ r.ns || r.namespace || null,
96
+ r.line || null,
97
+ r.column || null
98
+ );
89
99
  }
90
- db.prepare('REPLACE INTO meta(key,value) VALUES (?,?)').run('lastIndexedAt', new Date().toISOString());
100
+ db.prepare('REPLACE INTO meta(key,value) VALUES (?,?)').run(
101
+ 'lastIndexedAt',
102
+ new Date().toISOString()
103
+ );
91
104
  });
92
105
  tx(symbols || []);
93
106
  return { total: symbols?.length || 0 };
@@ -106,13 +119,17 @@ export class CodeIndex {
106
119
  async upsertFile(pathStr, sig) {
107
120
  const db = await this.open();
108
121
  if (!db) return;
109
- db.prepare('REPLACE INTO files(path,sig,updatedAt) VALUES (?,?,?)').run(pathStr, sig || '', new Date().toISOString());
122
+ db.prepare('REPLACE INTO files(path,sig,updatedAt) VALUES (?,?,?)').run(
123
+ pathStr,
124
+ sig || '',
125
+ new Date().toISOString()
126
+ );
110
127
  }
111
128
 
112
129
  async removeFile(pathStr) {
113
130
  const db = await this.open();
114
131
  if (!db) return;
115
- const tx = db.transaction((p) => {
132
+ const tx = db.transaction(p => {
116
133
  db.prepare('DELETE FROM symbols WHERE path = ?').run(p);
117
134
  db.prepare('DELETE FROM files WHERE path = ?').run(p);
118
135
  });
@@ -124,9 +141,23 @@ export class CodeIndex {
124
141
  if (!db) return;
125
142
  const tx = db.transaction((p, list) => {
126
143
  db.prepare('DELETE FROM symbols WHERE path = ?').run(p);
127
- const insert = db.prepare('INSERT INTO symbols(path,name,kind,container,namespace,line,column) VALUES (?,?,?,?,?,?,?)');
128
- for (const r of list) insert.run(p, r.name, r.kind, r.container || null, r.ns || r.namespace || null, r.line || null, r.column || null);
129
- db.prepare('REPLACE INTO meta(key,value) VALUES (?,?)').run('lastIndexedAt', new Date().toISOString());
144
+ const insert = db.prepare(
145
+ 'INSERT INTO symbols(path,name,kind,container,namespace,line,column) VALUES (?,?,?,?,?,?,?)'
146
+ );
147
+ for (const r of list)
148
+ insert.run(
149
+ p,
150
+ r.name,
151
+ r.kind,
152
+ r.container || null,
153
+ r.ns || r.namespace || null,
154
+ r.line || null,
155
+ r.column || null
156
+ );
157
+ db.prepare('REPLACE INTO meta(key,value) VALUES (?,?)').run(
158
+ 'lastIndexedAt',
159
+ new Date().toISOString()
160
+ );
130
161
  });
131
162
  tx(pathStr, rows || []);
132
163
  }
@@ -137,27 +168,45 @@ export class CodeIndex {
137
168
  let sql = 'SELECT path,name,kind,container,namespace,line,column FROM symbols WHERE 1=1';
138
169
  const params = {};
139
170
  if (name) {
140
- if (exact) { sql += ' AND name = @name'; params.name = name; }
141
- else { sql += ' AND name LIKE @name'; params.name = `%${name}%`; }
171
+ if (exact) {
172
+ sql += ' AND name = @name';
173
+ params.name = name;
174
+ } else {
175
+ sql += ' AND name LIKE @name';
176
+ params.name = `%${name}%`;
177
+ }
178
+ }
179
+ if (kind) {
180
+ sql += ' AND kind = @kind';
181
+ params.kind = kind;
142
182
  }
143
- if (kind) { sql += ' AND kind = @kind'; params.kind = kind; }
144
183
  const rows = db.prepare(sql).all(params);
145
184
  // Apply path-based scope filter in JS (simpler than CASE in SQL)
146
185
  const filtered = rows.filter(r => {
147
186
  const p = String(r.path || '').replace(/\\\\/g, '/');
148
187
  if (scope === 'assets') return p.startsWith('Assets/');
149
- if (scope === 'packages') return p.startsWith('Packages/') || p.includes('Library/PackageCache/');
188
+ if (scope === 'packages')
189
+ return p.startsWith('Packages/') || p.includes('Library/PackageCache/');
150
190
  if (scope === 'embedded') return p.startsWith('Packages/');
151
191
  return true;
152
192
  });
153
- return filtered.map(r => ({ path: r.path, name: r.name, kind: r.kind, container: r.container, ns: r.namespace, line: r.line, column: r.column }));
193
+ return filtered.map(r => ({
194
+ path: r.path,
195
+ name: r.name,
196
+ kind: r.kind,
197
+ container: r.container,
198
+ ns: r.namespace,
199
+ line: r.line,
200
+ column: r.column
201
+ }));
154
202
  }
155
203
 
156
204
  async getStats() {
157
205
  const db = await this.open();
158
206
  if (!db) return { total: 0, lastIndexedAt: null };
159
207
  const total = db.prepare('SELECT COUNT(*) AS c FROM symbols').get().c || 0;
160
- const last = db.prepare("SELECT value AS v FROM meta WHERE key = 'lastIndexedAt'").get()?.v || null;
208
+ const last =
209
+ db.prepare("SELECT value AS v FROM meta WHERE key = 'lastIndexedAt'").get()?.v || null;
161
210
  return { total, lastIndexedAt: last };
162
211
  }
163
212
  }
@@ -1,11 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Server } from '@modelcontextprotocol/sdk/server/index.js';
3
- import {
4
- ListToolsRequestSchema,
5
- CallToolRequestSchema,
6
- ListResourcesRequestSchema,
7
- ListPromptsRequestSchema
8
- } from '@modelcontextprotocol/sdk/types.js';
3
+ import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
9
4
  // Note: filename is lowercase on disk; use exact casing for POSIX filesystems
10
5
  import { UnityConnection } from './unityConnection.js';
11
6
  import { createHandlers } from '../handlers/index.js';
@@ -29,9 +24,7 @@ const server = new Server(
29
24
  capabilities: {
30
25
  // Explicitly advertise tool support; some MCP clients expect a non-empty object
31
26
  // Setting listChanged enables future push updates if we emit notifications
32
- tools: { listChanged: true },
33
- resources: {},
34
- prompts: {}
27
+ tools: { listChanged: true }
35
28
  }
36
29
  }
37
30
  );
@@ -63,20 +56,6 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
63
56
  return { tools };
64
57
  });
65
58
 
66
- // Handle resources listing
67
- server.setRequestHandler(ListResourcesRequestSchema, async () => {
68
- logger.debug('[MCP] Received resources/list request');
69
- // Unity MCP server doesn't provide resources
70
- return { resources: [] };
71
- });
72
-
73
- // Handle prompts listing
74
- server.setRequestHandler(ListPromptsRequestSchema, async () => {
75
- logger.debug('[MCP] Received prompts/list request');
76
- // Unity MCP server doesn't provide prompts
77
- return { prompts: [] };
78
- });
79
-
80
59
  // Handle tool execution
81
60
  server.setRequestHandler(CallToolRequestSchema, async request => {
82
61
  const { name, arguments: args } = request.params;
@@ -298,9 +277,7 @@ export async function createServer(customConfig = config) {
298
277
  },
299
278
  {
300
279
  capabilities: {
301
- tools: { listChanged: true },
302
- resources: {},
303
- prompts: {}
280
+ tools: { listChanged: true }
304
281
  }
305
282
  }
306
283
  );
@@ -311,14 +288,6 @@ export async function createServer(customConfig = config) {
311
288
  return { tools };
312
289
  });
313
290
 
314
- testServer.setRequestHandler(ListResourcesRequestSchema, async () => {
315
- return { resources: [] };
316
- });
317
-
318
- testServer.setRequestHandler(ListPromptsRequestSchema, async () => {
319
- return { prompts: [] };
320
- });
321
-
322
291
  testServer.setRequestHandler(CallToolRequestSchema, async request => {
323
292
  const { name, arguments: args } = request.params;
324
293
 
@@ -1,35 +1,38 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import { analyzeSceneContentsToolDefinition, analyzeSceneContentsHandler } from '../../tools/analysis/analyzeSceneContents.js';
2
+ import {
3
+ analyzeSceneContentsToolDefinition,
4
+ analyzeSceneContentsHandler
5
+ } from '../../tools/analysis/analyzeSceneContents.js';
3
6
 
4
7
  /**
5
8
  * Handler for analyze_scene_contents tool
6
9
  */
7
10
  export class AnalyzeSceneContentsToolHandler extends BaseToolHandler {
8
- constructor(unityConnection) {
9
- super(
10
- analyzeSceneContentsToolDefinition.name,
11
- analyzeSceneContentsToolDefinition.description,
12
- analyzeSceneContentsToolDefinition.inputSchema
13
- );
14
- this.unityConnection = unityConnection;
15
- this.handler = analyzeSceneContentsHandler;
11
+ constructor(unityConnection) {
12
+ super(
13
+ analyzeSceneContentsToolDefinition.name,
14
+ analyzeSceneContentsToolDefinition.description,
15
+ analyzeSceneContentsToolDefinition.inputSchema
16
+ );
17
+ this.unityConnection = unityConnection;
18
+ this.handler = analyzeSceneContentsHandler;
19
+ }
20
+
21
+ async execute(args) {
22
+ // Check connection
23
+ if (!this.unityConnection.isConnected()) {
24
+ throw new Error('Unity connection not available');
16
25
  }
17
26
 
18
- async execute(args) {
19
- // Check connection
20
- if (!this.unityConnection.isConnected()) {
21
- throw new Error('Unity connection not available');
22
- }
27
+ // Use the handler function
28
+ const result = await this.handler(this.unityConnection, args);
23
29
 
24
- // Use the handler function
25
- const result = await this.handler(this.unityConnection, args);
26
-
27
- // If the handler returns an error response, throw it
28
- if (result.isError) {
29
- throw new Error(result.content[0].text);
30
- }
31
-
32
- // Return the content
33
- return result;
30
+ // If the handler returns an error response, throw it
31
+ if (result.isError) {
32
+ throw new Error(result.content[0].text);
34
33
  }
34
+
35
+ // Return the content
36
+ return result;
37
+ }
35
38
  }
@@ -1,5 +1,8 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import { findByComponentToolDefinition, findByComponentHandler } from '../../tools/analysis/findByComponent.js';
2
+ import {
3
+ findByComponentToolDefinition,
4
+ findByComponentHandler
5
+ } from '../../tools/analysis/findByComponent.js';
3
6
 
4
7
  /**
5
8
  * Handler for the analysis_component_find tool
@@ -1,9 +1,9 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import {
3
- getAnimatorStateToolDefinition,
4
- getAnimatorRuntimeInfoToolDefinition,
5
- getAnimatorStateHandler,
6
- getAnimatorRuntimeInfoHandler
2
+ import {
3
+ getAnimatorStateToolDefinition,
4
+ getAnimatorRuntimeInfoToolDefinition,
5
+ getAnimatorStateHandler,
6
+ getAnimatorRuntimeInfoHandler
7
7
  } from '../../tools/analysis/getAnimatorState.js';
8
8
 
9
9
  export class GetAnimatorStateToolHandler extends BaseToolHandler {
@@ -1,5 +1,8 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import { getComponentValuesToolDefinition, getComponentValuesHandler } from '../../tools/analysis/getComponentValues.js';
2
+ import {
3
+ getComponentValuesToolDefinition,
4
+ getComponentValuesHandler
5
+ } from '../../tools/analysis/getComponentValues.js';
3
6
 
4
7
  /**
5
8
  * Handler for the analysis_component_values_get tool
@@ -1,35 +1,38 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import { getGameObjectDetailsToolDefinition, getGameObjectDetailsHandler } from '../../tools/analysis/getGameObjectDetails.js';
2
+ import {
3
+ getGameObjectDetailsToolDefinition,
4
+ getGameObjectDetailsHandler
5
+ } from '../../tools/analysis/getGameObjectDetails.js';
3
6
 
4
7
  /**
5
8
  * Handler for get_gameobject_details tool
6
9
  */
7
10
  export class GetGameObjectDetailsToolHandler extends BaseToolHandler {
8
- constructor(unityConnection) {
9
- super(
10
- getGameObjectDetailsToolDefinition.name,
11
- getGameObjectDetailsToolDefinition.description,
12
- getGameObjectDetailsToolDefinition.inputSchema
13
- );
14
- this.unityConnection = unityConnection;
15
- this.handler = getGameObjectDetailsHandler;
11
+ constructor(unityConnection) {
12
+ super(
13
+ getGameObjectDetailsToolDefinition.name,
14
+ getGameObjectDetailsToolDefinition.description,
15
+ getGameObjectDetailsToolDefinition.inputSchema
16
+ );
17
+ this.unityConnection = unityConnection;
18
+ this.handler = getGameObjectDetailsHandler;
19
+ }
20
+
21
+ async execute(args) {
22
+ // Check connection
23
+ if (!this.unityConnection.isConnected()) {
24
+ throw new Error('Unity connection not available');
16
25
  }
17
26
 
18
- async execute(args) {
19
- // Check connection
20
- if (!this.unityConnection.isConnected()) {
21
- throw new Error('Unity connection not available');
22
- }
27
+ // Use the handler function
28
+ const result = await this.handler(this.unityConnection, args);
23
29
 
24
- // Use the handler function
25
- const result = await this.handler(this.unityConnection, args);
26
-
27
- // If the handler returns an error response, throw it
28
- if (result.isError) {
29
- throw new Error(result.content[0].text);
30
- }
31
-
32
- // Return the content
33
- return result;
30
+ // If the handler returns an error response, throw it
31
+ if (result.isError) {
32
+ throw new Error(result.content[0].text);
34
33
  }
34
+
35
+ // Return the content
36
+ return result;
37
+ }
35
38
  }
@@ -1,9 +1,9 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import {
3
- getInputActionsStateToolDefinition,
4
- analyzeInputActionsAssetToolDefinition,
5
- getInputActionsStateHandler,
6
- analyzeInputActionsAssetHandler
2
+ import {
3
+ getInputActionsStateToolDefinition,
4
+ analyzeInputActionsAssetToolDefinition,
5
+ getInputActionsStateHandler,
6
+ analyzeInputActionsAssetHandler
7
7
  } from '../../tools/analysis/getInputActionsState.js';
8
8
 
9
9
  export class GetInputActionsStateToolHandler extends BaseToolHandler {
@@ -1,5 +1,8 @@
1
1
  import { BaseToolHandler } from '../base/BaseToolHandler.js';
2
- import { getObjectReferencesToolDefinition, getObjectReferencesHandler } from '../../tools/analysis/getObjectReferences.js';
2
+ import {
3
+ getObjectReferencesToolDefinition,
4
+ getObjectReferencesHandler
5
+ } from '../../tools/analysis/getObjectReferences.js';
3
6
 
4
7
  /**
5
8
  * Handler for the analysis_object_references_get tool
@@ -13,7 +13,16 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
13
13
  properties: {
14
14
  action: {
15
15
  type: 'string',
16
- enum: ['find_assets', 'get_asset_info', 'create_folder', 'delete_asset', 'move_asset', 'copy_asset', 'refresh', 'save'],
16
+ enum: [
17
+ 'find_assets',
18
+ 'get_asset_info',
19
+ 'create_folder',
20
+ 'delete_asset',
21
+ 'move_asset',
22
+ 'copy_asset',
23
+ 'refresh',
24
+ 'save'
25
+ ],
17
26
  description: 'The action to perform'
18
27
  },
19
28
  filter: {
@@ -53,7 +62,16 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
53
62
  throw new Error('action is required');
54
63
  }
55
64
 
56
- const validActions = ['find_assets', 'get_asset_info', 'create_folder', 'delete_asset', 'move_asset', 'copy_asset', 'refresh', 'save'];
65
+ const validActions = [
66
+ 'find_assets',
67
+ 'get_asset_info',
68
+ 'create_folder',
69
+ 'delete_asset',
70
+ 'move_asset',
71
+ 'copy_asset',
72
+ 'refresh',
73
+ 'save'
74
+ ];
57
75
  if (!validActions.includes(params.action)) {
58
76
  throw new Error(`action must be one of: ${validActions.join(', ')}`);
59
77
  }
@@ -123,7 +141,7 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
123
141
 
124
142
  async execute(params) {
125
143
  this.validate(params);
126
-
144
+
127
145
  if (!this.unityConnection.isConnected()) {
128
146
  await this.unityConnection.connect();
129
147
  }
@@ -184,8 +202,8 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
184
202
  }
185
203
  },
186
204
  {
187
- input: {
188
- action: 'move_asset',
205
+ input: {
206
+ action: 'move_asset',
189
207
  fromPath: 'Assets/icon.png',
190
208
  toPath: 'Assets/Textures/icon.png'
191
209
  },
@@ -218,4 +236,4 @@ export class AssetDatabaseManageToolHandler extends BaseToolHandler {
218
236
  }
219
237
  ];
220
238
  }
221
- }
239
+ }
@@ -13,7 +13,14 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
13
13
  properties: {
14
14
  action: {
15
15
  type: 'string',
16
- enum: ['get_dependencies', 'get_dependents', 'analyze_circular', 'find_unused', 'analyze_size_impact', 'validate_references'],
16
+ enum: [
17
+ 'get_dependencies',
18
+ 'get_dependents',
19
+ 'analyze_circular',
20
+ 'find_unused',
21
+ 'analyze_size_impact',
22
+ 'validate_references'
23
+ ],
17
24
  description: 'The analysis action to perform'
18
25
  },
19
26
  assetPath: {
@@ -40,7 +47,14 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
40
47
  throw new Error('action is required');
41
48
  }
42
49
 
43
- const validActions = ['get_dependencies', 'get_dependents', 'analyze_circular', 'find_unused', 'analyze_size_impact', 'validate_references'];
50
+ const validActions = [
51
+ 'get_dependencies',
52
+ 'get_dependents',
53
+ 'analyze_circular',
54
+ 'find_unused',
55
+ 'analyze_size_impact',
56
+ 'validate_references'
57
+ ];
44
58
  if (!validActions.includes(params.action)) {
45
59
  throw new Error(`action must be one of: ${validActions.join(', ')}`);
46
60
  }
@@ -51,11 +65,11 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
51
65
  if (params.assetPath === undefined || params.assetPath === null) {
52
66
  throw new Error(`assetPath is required for ${params.action} action`);
53
67
  }
54
-
68
+
55
69
  if (params.assetPath === '') {
56
70
  throw new Error('assetPath cannot be empty');
57
71
  }
58
-
72
+
59
73
  // Validate assetPath starts with "Assets/"
60
74
  if (!params.assetPath.startsWith('Assets/')) {
61
75
  throw new Error('assetPath must start with "Assets/"');
@@ -65,7 +79,7 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
65
79
 
66
80
  async execute(params) {
67
81
  this.validate(params);
68
-
82
+
69
83
  if (!this.unityConnection.isConnected()) {
70
84
  await this.unityConnection.connect();
71
85
  }
@@ -124,11 +138,7 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
124
138
  action: 'analyze_circular',
125
139
  circularDependencies: [
126
140
  {
127
- cycle: [
128
- 'Assets/Scripts/A.cs',
129
- 'Assets/Scripts/B.cs',
130
- 'Assets/Scripts/A.cs'
131
- ],
141
+ cycle: ['Assets/Scripts/A.cs', 'Assets/Scripts/B.cs', 'Assets/Scripts/A.cs'],
132
142
  length: 3,
133
143
  severity: 'warning'
134
144
  }
@@ -198,4 +208,4 @@ export class AssetDependencyAnalyzeToolHandler extends BaseToolHandler {
198
208
  }
199
209
  ];
200
210
  }
201
- }
211
+ }
@@ -71,7 +71,7 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
71
71
  if (params.preset === undefined || params.preset === null) {
72
72
  throw new Error('preset is required for apply_preset action');
73
73
  }
74
-
74
+
75
75
  if (params.preset === '') {
76
76
  throw new Error('preset cannot be empty');
77
77
  }
@@ -80,7 +80,7 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
80
80
 
81
81
  async execute(params) {
82
82
  this.validate(params);
83
-
83
+
84
84
  if (!this.unityConnection.isConnected()) {
85
85
  await this.unityConnection.connect();
86
86
  }
@@ -112,8 +112,8 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
112
112
  }
113
113
  },
114
114
  {
115
- input: {
116
- action: 'modify',
115
+ input: {
116
+ action: 'modify',
117
117
  assetPath: 'Assets/Textures/icon.png',
118
118
  settings: {
119
119
  maxTextureSize: 1024,
@@ -136,8 +136,8 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
136
136
  }
137
137
  },
138
138
  {
139
- input: {
140
- action: 'apply_preset',
139
+ input: {
140
+ action: 'apply_preset',
141
141
  assetPath: 'Assets/Textures/icon.png',
142
142
  preset: 'UI_Sprite'
143
143
  },
@@ -167,4 +167,4 @@ export class AssetImportSettingsManageToolHandler extends BaseToolHandler {
167
167
  }
168
168
  ];
169
169
  }
170
- }
170
+ }