@akiojin/unity-mcp-server 2.16.0 → 2.25.0
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.
- package/LICENSE +0 -0
- package/README.md +153 -100
- package/bin/unity-mcp-server +7 -1
- package/package.json +30 -7
- package/src/core/codeIndex.js +0 -0
- package/src/core/codeIndexDb.js +0 -0
- package/src/core/config.js +47 -14
- package/src/core/indexWatcher.js +84 -15
- package/src/core/jobManager.js +178 -0
- package/src/core/projectInfo.js +21 -67
- package/src/core/server.js +15 -2
- package/src/core/unityConnection.js +0 -0
- package/src/handlers/addressables/AddressablesAnalyzeToolHandler.js +170 -0
- package/src/handlers/addressables/AddressablesBuildToolHandler.js +145 -0
- package/src/handlers/addressables/AddressablesManageToolHandler.js +266 -0
- package/src/handlers/analysis/AnalyzeSceneContentsToolHandler.js +1 -1
- package/src/handlers/analysis/FindByComponentToolHandler.js +2 -2
- package/src/handlers/analysis/GetAnimatorStateToolHandler.js +1 -1
- package/src/handlers/analysis/GetComponentValuesToolHandler.js +2 -2
- package/src/handlers/analysis/GetGameObjectDetailsToolHandler.js +1 -1
- package/src/handlers/analysis/GetInputActionsStateToolHandler.js +1 -1
- package/src/handlers/analysis/GetObjectReferencesToolHandler.js +2 -2
- package/src/handlers/asset/{AssetDatabaseToolHandler.js → AssetDatabaseManageToolHandler.js} +2 -2
- package/src/handlers/asset/{AssetDependencyToolHandler.js → AssetDependencyAnalyzeToolHandler.js} +2 -2
- package/src/handlers/asset/{AssetImportSettingsToolHandler.js → AssetImportSettingsManageToolHandler.js} +2 -2
- package/src/handlers/asset/{CreateMaterialToolHandler.js → AssetMaterialCreateToolHandler.js} +2 -2
- package/src/handlers/asset/{ModifyMaterialToolHandler.js → AssetMaterialModifyToolHandler.js} +2 -2
- package/src/handlers/asset/{CreatePrefabToolHandler.js → AssetPrefabCreateToolHandler.js} +2 -2
- package/src/handlers/asset/{ExitPrefabModeToolHandler.js → AssetPrefabExitModeToolHandler.js} +2 -2
- package/src/handlers/asset/{InstantiatePrefabToolHandler.js → AssetPrefabInstantiateToolHandler.js} +2 -2
- package/src/handlers/asset/{ModifyPrefabToolHandler.js → AssetPrefabModifyToolHandler.js} +2 -2
- package/src/handlers/asset/{OpenPrefabToolHandler.js → AssetPrefabOpenToolHandler.js} +2 -2
- package/src/handlers/asset/{SavePrefabToolHandler.js → AssetPrefabSaveToolHandler.js} +2 -2
- package/src/handlers/base/BaseToolHandler.js +0 -0
- package/src/handlers/compilation/{GetCompilationStateToolHandler.js → CompilationGetStateToolHandler.js} +2 -2
- package/src/handlers/component/{AddComponentToolHandler.js → ComponentAddToolHandler.js} +2 -2
- package/src/handlers/component/ComponentFieldSetToolHandler.js +419 -0
- package/src/handlers/component/{GetComponentTypesToolHandler.js → ComponentGetTypesToolHandler.js} +2 -2
- package/src/handlers/component/{ListComponentsToolHandler.js → ComponentListToolHandler.js} +2 -2
- package/src/handlers/component/{ModifyComponentToolHandler.js → ComponentModifyToolHandler.js} +2 -2
- package/src/handlers/component/{RemoveComponentToolHandler.js → ComponentRemoveToolHandler.js} +2 -2
- package/src/handlers/console/{ClearConsoleToolHandler.js → ConsoleClearToolHandler.js} +2 -2
- package/src/handlers/console/{ReadConsoleToolHandler.js → ConsoleReadToolHandler.js} +83 -64
- package/src/handlers/editor/{LayerManagementToolHandler.js → EditorLayersManageToolHandler.js} +2 -2
- package/src/handlers/editor/{SelectionToolHandler.js → EditorSelectionManageToolHandler.js} +2 -2
- package/src/handlers/editor/{TagManagementToolHandler.js → EditorTagsManageToolHandler.js} +2 -2
- package/src/handlers/editor/{ToolManagementToolHandler.js → EditorToolsManageToolHandler.js} +2 -2
- package/src/handlers/editor/{WindowManagementToolHandler.js → EditorWindowsManageToolHandler.js} +2 -2
- package/src/handlers/gameobject/{CreateGameObjectToolHandler.js → GameObjectCreateToolHandler.js} +3 -3
- package/src/handlers/gameobject/{DeleteGameObjectToolHandler.js → GameObjectDeleteToolHandler.js} +3 -3
- package/src/handlers/gameobject/{FindGameObjectToolHandler.js → GameObjectFindToolHandler.js} +3 -3
- package/src/handlers/gameobject/{GetHierarchyToolHandler.js → GameObjectGetHierarchyToolHandler.js} +3 -3
- package/src/handlers/gameobject/{ModifyGameObjectToolHandler.js → GameObjectModifyToolHandler.js} +3 -3
- package/src/handlers/index.js +331 -293
- package/src/handlers/input/{AddInputActionToolHandler.js → InputActionAddToolHandler.js} +2 -2
- package/src/handlers/input/{CreateActionMapToolHandler.js → InputActionMapCreateToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveActionMapToolHandler.js → InputActionMapRemoveToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveInputActionToolHandler.js → InputActionRemoveToolHandler.js} +2 -2
- package/src/handlers/input/{AddInputBindingToolHandler.js → InputBindingAddToolHandler.js} +2 -2
- package/src/handlers/input/{CreateCompositeBindingToolHandler.js → InputBindingCompositeCreateToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveAllBindingsToolHandler.js → InputBindingRemoveAllToolHandler.js} +2 -2
- package/src/handlers/input/{RemoveInputBindingToolHandler.js → InputBindingRemoveToolHandler.js} +2 -2
- package/src/handlers/input/{ManageControlSchemesToolHandler.js → InputControlSchemesManageToolHandler.js} +2 -2
- package/src/handlers/input/{GamepadSimulationHandler.js → InputGamepadSimulateToolHandler.js} +3 -3
- package/src/handlers/input/{KeyboardSimulationHandler.js → InputKeyboardSimulateToolHandler.js} +3 -3
- package/src/handlers/input/{MouseSimulationHandler.js → InputMouseSimulateToolHandler.js} +3 -3
- package/src/handlers/input/{InputSystemHandler.js → InputSystemControlToolHandler.js} +4 -4
- package/src/handlers/input/{TouchSimulationHandler.js → InputTouchSimulateToolHandler.js} +3 -3
- package/src/handlers/menu/{ExecuteMenuItemToolHandler.js → MenuItemExecuteToolHandler.js} +2 -2
- package/src/handlers/package/PackageManagerToolHandler.js +1 -1
- package/src/handlers/package/RegistryConfigToolHandler.js +1 -1
- package/src/handlers/playmode/{GetEditorStateToolHandler.js → PlaymodeGetStateToolHandler.js} +3 -3
- package/src/handlers/playmode/{PauseToolHandler.js → PlaymodePauseToolHandler.js} +4 -4
- package/src/handlers/playmode/{PlayToolHandler.js → PlaymodePlayToolHandler.js} +4 -4
- package/src/handlers/playmode/{StopToolHandler.js → PlaymodeStopToolHandler.js} +4 -4
- package/src/handlers/playmode/{WaitForEditorStateToolHandler.js → PlaymodeWaitForStateToolHandler.js} +3 -3
- package/src/handlers/scene/GetSceneInfoToolHandler.js +1 -1
- package/src/handlers/scene/{CreateSceneToolHandler.js → SceneCreateToolHandler.js} +2 -2
- package/src/handlers/scene/{ListScenesToolHandler.js → SceneListToolHandler.js} +2 -2
- package/src/handlers/scene/{LoadSceneToolHandler.js → SceneLoadToolHandler.js} +2 -2
- package/src/handlers/scene/{SaveSceneToolHandler.js → SceneSaveToolHandler.js} +2 -2
- package/src/handlers/screenshot/{AnalyzeScreenshotToolHandler.js → ScreenshotAnalyzeToolHandler.js} +2 -2
- package/src/handlers/screenshot/{CaptureScreenshotToolHandler.js → ScreenshotCaptureToolHandler.js} +2 -2
- package/src/handlers/script/{BuildCodeIndexToolHandler.js → CodeIndexBuildToolHandler.js} +127 -17
- package/src/handlers/script/CodeIndexStatusToolHandler.js +129 -0
- package/src/handlers/script/CodeIndexUpdateToolHandler.js +234 -0
- package/src/handlers/script/{ScriptCreateClassFileToolHandler.js → ScriptCreateClassToolHandler.js} +2 -2
- package/src/handlers/script/ScriptEditSnippetToolHandler.js +272 -0
- package/src/handlers/script/ScriptEditStructuredToolHandler.js +1 -1
- package/src/handlers/script/ScriptPackagesListToolHandler.js +0 -0
- package/src/handlers/script/ScriptReadToolHandler.js +0 -0
- package/src/handlers/script/ScriptRefactorRenameToolHandler.js +0 -0
- package/src/handlers/script/ScriptRefsFindToolHandler.js +0 -0
- package/src/handlers/script/ScriptRemoveSymbolToolHandler.js +0 -0
- package/src/handlers/script/ScriptSearchToolHandler.js +0 -0
- package/src/handlers/script/ScriptSymbolFindToolHandler.js +0 -0
- package/src/handlers/script/ScriptSymbolsGetToolHandler.js +0 -0
- package/src/handlers/settings/{GetProjectSettingsToolHandler.js → SettingsGetToolHandler.js} +2 -2
- package/src/handlers/settings/{UpdateProjectSettingsToolHandler.js → SettingsUpdateToolHandler.js} +2 -2
- package/src/handlers/system/{GetCommandStatsToolHandler.js → SystemGetCommandStatsToolHandler.js} +2 -3
- package/src/handlers/system/{PingToolHandler.js → SystemPingToolHandler.js} +3 -3
- package/src/handlers/system/{RefreshAssetsToolHandler.js → SystemRefreshAssetsToolHandler.js} +3 -3
- package/src/handlers/test/{GetTestStatusToolHandler.js → TestGetStatusToolHandler.js} +2 -2
- package/src/handlers/test/{RunTestsToolHandler.js → TestRunToolHandler.js} +2 -2
- package/src/handlers/ui/{ClickUIElementToolHandler.js → UIClickElementToolHandler.js} +2 -2
- package/src/handlers/ui/{FindUIElementsToolHandler.js → UIFindElementsToolHandler.js} +2 -2
- package/src/handlers/ui/{GetUIElementStateToolHandler.js → UIGetElementStateToolHandler.js} +2 -2
- package/src/handlers/ui/{SetUIElementValueToolHandler.js → UISetElementValueToolHandler.js} +2 -2
- package/src/handlers/ui/{SimulateUIInputToolHandler.js → UISimulateInputToolHandler.js} +2 -2
- package/src/handlers/video/{CaptureVideoForToolHandler.js → VideoCaptureForToolHandler.js} +8 -8
- package/src/handlers/video/{CaptureVideoStartToolHandler.js → VideoCaptureStartToolHandler.js} +2 -2
- package/src/handlers/video/{CaptureVideoStatusToolHandler.js → VideoCaptureStatusToolHandler.js} +2 -2
- package/src/handlers/video/{CaptureVideoStopToolHandler.js → VideoCaptureStopToolHandler.js} +3 -3
- package/src/lsp/CSharpLspUtils.js +95 -14
- package/src/lsp/LspProcessManager.js +0 -0
- package/src/lsp/LspRpcClient.js +14 -0
- package/src/tools/analysis/analyzeSceneContents.js +3 -3
- package/src/tools/analysis/findByComponent.js +3 -3
- package/src/tools/analysis/getAnimatorState.js +6 -6
- package/src/tools/analysis/getComponentValues.js +3 -3
- package/src/tools/analysis/getGameObjectDetails.js +3 -3
- package/src/tools/analysis/getInputActionsState.js +4 -4
- package/src/tools/analysis/getObjectReferences.js +3 -3
- package/src/tools/input/inputActionsEditor.js +18 -18
- package/src/tools/scene/createScene.js +3 -3
- package/src/tools/scene/getSceneInfo.js +3 -3
- package/src/tools/scene/listScenes.js +3 -3
- package/src/tools/scene/loadScene.js +3 -3
- package/src/tools/scene/saveScene.js +3 -3
- package/src/tools/system/ping.js +5 -5
- package/src/tools/video/recordFor.js +2 -2
- package/src/tools/video/recordPlayMode.js +0 -0
- package/src/utils/csharpParse.js +0 -0
- package/src/utils/validators.js +0 -0
- package/src/handlers/script/ScriptIndexStatusToolHandler.js +0 -61
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
3
5
|
import { logger } from '../core/config.js';
|
|
4
6
|
import { WORKSPACE_ROOT } from '../core/config.js';
|
|
5
7
|
|
|
@@ -13,37 +15,116 @@ export class CSharpLspUtils {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
getDesiredVersion() {
|
|
18
|
+
const candidates = [];
|
|
19
|
+
|
|
20
|
+
// When launched from workspace root: mcp-server/package.json
|
|
21
|
+
candidates.push(path.resolve('mcp-server/package.json'));
|
|
22
|
+
// When launched within mcp-server directory
|
|
23
|
+
candidates.push(path.resolve('package.json'));
|
|
24
|
+
|
|
25
|
+
// Resolve relative to this module (always inside mcp-server/src/lsp)
|
|
16
26
|
try {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
} catch {
|
|
20
|
-
|
|
27
|
+
const moduleDir = path.dirname(fileURLToPath(import.meta.url));
|
|
28
|
+
candidates.push(path.resolve(moduleDir, '../../package.json'));
|
|
29
|
+
} catch {}
|
|
30
|
+
|
|
31
|
+
// Resolve relative to WORKSPACE_ROOT if provided
|
|
32
|
+
if (WORKSPACE_ROOT) {
|
|
33
|
+
candidates.push(path.resolve(WORKSPACE_ROOT, 'mcp-server', 'package.json'));
|
|
34
|
+
candidates.push(path.resolve(WORKSPACE_ROOT, 'package.json'));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const candidate of candidates) {
|
|
38
|
+
try {
|
|
39
|
+
if (!fs.existsSync(candidate)) continue;
|
|
40
|
+
const pkg = JSON.parse(fs.readFileSync(candidate, 'utf8'));
|
|
41
|
+
if (pkg?.version) return pkg.version;
|
|
42
|
+
} catch {}
|
|
21
43
|
}
|
|
44
|
+
|
|
45
|
+
return null;
|
|
22
46
|
}
|
|
23
47
|
|
|
24
|
-
|
|
48
|
+
getExecutableName() {
|
|
49
|
+
return process.platform === 'win32' ? 'server.exe' : 'server';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getPrimaryToolRoot() {
|
|
53
|
+
const envRoot = process.env.UNITY_MCP_TOOLS_ROOT;
|
|
54
|
+
if (envRoot && envRoot.trim().length > 0) {
|
|
55
|
+
return path.resolve(envRoot.trim());
|
|
56
|
+
}
|
|
57
|
+
return path.join(os.homedir(), '.unity', 'tools');
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
getLegacyToolRoot() {
|
|
25
61
|
const root = WORKSPACE_ROOT || process.cwd();
|
|
26
|
-
|
|
27
|
-
|
|
62
|
+
return path.resolve(root, '.unity', 'tools');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
resolveToolPaths(rid) {
|
|
66
|
+
const exe = this.getExecutableName();
|
|
67
|
+
const primary = path.resolve(this.getPrimaryToolRoot(), 'csharp-lsp', rid, exe);
|
|
68
|
+
const legacy = path.resolve(this.getLegacyToolRoot(), 'csharp-lsp', rid, exe);
|
|
69
|
+
return { primary, legacy };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
resolveVersionPaths(rid) {
|
|
73
|
+
const { primary, legacy } = this.resolveToolPaths(rid);
|
|
74
|
+
return {
|
|
75
|
+
primary: path.resolve(path.dirname(primary), 'VERSION'),
|
|
76
|
+
legacy: path.resolve(path.dirname(legacy), 'VERSION')
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
migrateLegacyIfNeeded(rid) {
|
|
81
|
+
const { primary, legacy } = this.resolveToolPaths(rid);
|
|
82
|
+
if (!fs.existsSync(legacy)) return;
|
|
83
|
+
if (fs.existsSync(primary)) return;
|
|
84
|
+
try {
|
|
85
|
+
fs.mkdirSync(path.dirname(primary), { recursive: true });
|
|
86
|
+
fs.copyFileSync(legacy, primary);
|
|
87
|
+
const { primary: primaryVersion, legacy: legacyVersion } = this.resolveVersionPaths(rid);
|
|
88
|
+
if (fs.existsSync(legacyVersion) && !fs.existsSync(primaryVersion)) {
|
|
89
|
+
try {
|
|
90
|
+
fs.copyFileSync(legacyVersion, primaryVersion);
|
|
91
|
+
} catch {}
|
|
92
|
+
}
|
|
93
|
+
logger.info(`[csharp-lsp] migrated legacy binary to ${path.dirname(primary)}`);
|
|
94
|
+
} catch (e) {
|
|
95
|
+
logger.warn(`[csharp-lsp] legacy migration failed: ${e.message}`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
getLocalPath(rid) {
|
|
100
|
+
const { primary, legacy } = this.resolveToolPaths(rid);
|
|
101
|
+
this.migrateLegacyIfNeeded(rid);
|
|
102
|
+
if (fs.existsSync(primary)) return primary;
|
|
103
|
+
if (fs.existsSync(legacy)) return legacy;
|
|
104
|
+
return primary;
|
|
28
105
|
}
|
|
29
106
|
|
|
30
107
|
getVersionMarkerPath(rid) {
|
|
31
|
-
const
|
|
32
|
-
|
|
108
|
+
const { primary, legacy } = this.resolveVersionPaths(rid);
|
|
109
|
+
if (fs.existsSync(primary)) return primary;
|
|
110
|
+
if (fs.existsSync(legacy)) return legacy;
|
|
111
|
+
return primary;
|
|
33
112
|
}
|
|
34
113
|
|
|
35
114
|
readLocalVersion(rid) {
|
|
36
115
|
try {
|
|
37
|
-
const
|
|
38
|
-
if (fs.existsSync(
|
|
116
|
+
const { primary, legacy } = this.resolveVersionPaths(rid);
|
|
117
|
+
if (fs.existsSync(primary)) return fs.readFileSync(primary, 'utf8').trim();
|
|
118
|
+
if (fs.existsSync(legacy)) return fs.readFileSync(legacy, 'utf8').trim();
|
|
39
119
|
} catch {}
|
|
40
120
|
return null;
|
|
41
121
|
}
|
|
42
122
|
|
|
43
123
|
writeLocalVersion(rid, version) {
|
|
44
124
|
try {
|
|
45
|
-
const
|
|
46
|
-
fs.
|
|
125
|
+
const marker = this.getVersionMarkerPath(rid);
|
|
126
|
+
fs.mkdirSync(path.dirname(marker), { recursive: true });
|
|
127
|
+
fs.writeFileSync(marker, String(version || '').trim() + '\n', 'utf8');
|
|
47
128
|
} catch {}
|
|
48
129
|
}
|
|
49
130
|
|
|
@@ -67,7 +148,7 @@ export class CSharpLspUtils {
|
|
|
67
148
|
const entry = manifest?.assets?.[rid];
|
|
68
149
|
if (!entry?.url || !entry?.sha256) throw new Error(`manifest missing entry for ${rid}`);
|
|
69
150
|
|
|
70
|
-
const dest = this.
|
|
151
|
+
const { primary: dest } = this.resolveToolPaths(rid);
|
|
71
152
|
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
72
153
|
const tmp = dest + '.download';
|
|
73
154
|
await this.downloadTo(entry.url, tmp);
|
|
File without changes
|
package/src/lsp/LspRpcClient.js
CHANGED
|
@@ -99,6 +99,20 @@ export class LspRpcClient {
|
|
|
99
99
|
return await this.#requestWithRetry(method, params, 1);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
+
async validateText(relative, newText) {
|
|
103
|
+
const resp = await this.request('mcp/validateTextEdits', { relative, newText });
|
|
104
|
+
if (!resp) return [];
|
|
105
|
+
const payload = resp.result ?? resp;
|
|
106
|
+
const diagnostics = Array.isArray(payload?.diagnostics) ? payload.diagnostics : [];
|
|
107
|
+
return diagnostics.map((d) => ({
|
|
108
|
+
severity: d?.severity,
|
|
109
|
+
message: d?.message,
|
|
110
|
+
id: d?.id,
|
|
111
|
+
line: d?.line,
|
|
112
|
+
column: d?.column,
|
|
113
|
+
}));
|
|
114
|
+
}
|
|
115
|
+
|
|
102
116
|
async #requestWithRetry(method, params, attempt) {
|
|
103
117
|
await this.ensure();
|
|
104
118
|
const id = this.seq++;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for analysis_scene_contents_analyze
|
|
3
3
|
*/
|
|
4
4
|
export const analyzeSceneContentsToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'analysis_scene_contents_analyze',
|
|
6
6
|
description: 'Analyze current scene: object counts, types, prefabs, and memory stats.',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -47,7 +47,7 @@ export async function analyzeSceneContentsHandler(unityConnection, args) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Send command to Unity with provided parameters
|
|
50
|
-
const result = await unityConnection.sendCommand('
|
|
50
|
+
const result = await unityConnection.sendCommand('analysis_scene_contents_analyze', args);
|
|
51
51
|
|
|
52
52
|
// The unityConnection.sendCommand already extracts the result field
|
|
53
53
|
// from the response, so we access properties directly on result
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for analysis_component_find
|
|
3
3
|
*/
|
|
4
4
|
export const findByComponentToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'analysis_component_find',
|
|
6
6
|
description: 'Find GameObjects that have a specific component type (scene/prefabs/all).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -48,7 +48,7 @@ export async function findByComponentHandler(unityConnection, args) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
// Send command to Unity
|
|
51
|
-
const result = await unityConnection.sendCommand('
|
|
51
|
+
const result = await unityConnection.sendCommand('analysis_component_find', args);
|
|
52
52
|
|
|
53
53
|
// Handle Unity response
|
|
54
54
|
if (result.status === 'error') {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// Tool definition for
|
|
1
|
+
// Tool definition for analysis_animator_state_get
|
|
2
2
|
export const getAnimatorStateToolDefinition = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'analysis_animator_state_get',
|
|
4
4
|
description: 'Get Animator state: layers, transitions, and parameter values for a GameObject.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -39,9 +39,9 @@ export const getAnimatorStateToolDefinition = {
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
// Tool definition for
|
|
42
|
+
// Tool definition for analysis_animator_runtime_info_get
|
|
43
43
|
export const getAnimatorRuntimeInfoToolDefinition = {
|
|
44
|
-
name: '
|
|
44
|
+
name: 'analysis_animator_runtime_info_get',
|
|
45
45
|
description: 'Get Animator runtime info (IK, root motion, performance) — Play mode only.',
|
|
46
46
|
inputSchema: {
|
|
47
47
|
type: 'object',
|
|
@@ -100,7 +100,7 @@ export async function getAnimatorStateHandler(unityConnection, args) {
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// Send command to Unity
|
|
103
|
-
const result = await unityConnection.sendCommand('
|
|
103
|
+
const result = await unityConnection.sendCommand('analysis_animator_state_get', args);
|
|
104
104
|
|
|
105
105
|
// Check for errors
|
|
106
106
|
if (!result || typeof result === 'string') {
|
|
@@ -222,7 +222,7 @@ export async function getAnimatorRuntimeInfoHandler(unityConnection, args) {
|
|
|
222
222
|
}
|
|
223
223
|
|
|
224
224
|
// Send command to Unity
|
|
225
|
-
const result = await unityConnection.sendCommand('
|
|
225
|
+
const result = await unityConnection.sendCommand('analysis_animator_runtime_info_get', args);
|
|
226
226
|
|
|
227
227
|
// Check for errors
|
|
228
228
|
if (!result || typeof result === 'string') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for analysis_component_values_get
|
|
3
3
|
*/
|
|
4
4
|
export const getComponentValuesToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'analysis_component_values_get',
|
|
6
6
|
description: 'Get properties/values from a component on a GameObject (scene or prefab mode).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -77,7 +77,7 @@ export async function getComponentValuesHandler(unityConnection, args) {
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
// Send command to Unity
|
|
80
|
-
const result = await unityConnection.sendCommand('
|
|
80
|
+
const result = await unityConnection.sendCommand('analysis_component_values_get', args);
|
|
81
81
|
|
|
82
82
|
// The unityConnection.sendCommand already extracts the result field
|
|
83
83
|
// from the response, so we access properties directly on result
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for analysis_gameobject_details_get
|
|
3
3
|
*/
|
|
4
4
|
export const getGameObjectDetailsToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'analysis_gameobject_details_get',
|
|
6
6
|
description: 'Get details for a GameObject by name or path (children/components/materials).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -106,7 +106,7 @@ export async function getGameObjectDetailsHandler(unityConnection, args) {
|
|
|
106
106
|
if (args.maxDepth !== undefined) params.maxDepth = args.maxDepth;
|
|
107
107
|
|
|
108
108
|
// Send command to Unity
|
|
109
|
-
const result = await unityConnection.sendCommand('
|
|
109
|
+
const result = await unityConnection.sendCommand('analysis_gameobject_details_get', args);
|
|
110
110
|
|
|
111
111
|
// The unityConnection.sendCommand already extracts the result field
|
|
112
112
|
// from the response, so we access properties directly on result
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Tool definitions for Input Actions analysis
|
|
2
2
|
export const getInputActionsStateToolDefinition = {
|
|
3
|
-
name: '
|
|
3
|
+
name: 'input_actions_state_get',
|
|
4
4
|
description: 'Get Input Actions state: maps, actions, bindings, devices, JSON structure.',
|
|
5
5
|
inputSchema: {
|
|
6
6
|
type: 'object',
|
|
@@ -34,7 +34,7 @@ export const getInputActionsStateToolDefinition = {
|
|
|
34
34
|
};
|
|
35
35
|
|
|
36
36
|
export const analyzeInputActionsAssetToolDefinition = {
|
|
37
|
-
name: '
|
|
37
|
+
name: 'input_actions_asset_analyze',
|
|
38
38
|
description: 'Analyze an Input Actions asset in detail (statistics + device usage).',
|
|
39
39
|
inputSchema: {
|
|
40
40
|
type: 'object',
|
|
@@ -75,7 +75,7 @@ export async function getInputActionsStateHandler(unityConnection, args) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
// Send command to Unity
|
|
78
|
-
const result = await unityConnection.sendCommand('
|
|
78
|
+
const result = await unityConnection.sendCommand('input_actions_state_get', args);
|
|
79
79
|
|
|
80
80
|
// Check for errors
|
|
81
81
|
if (!result || typeof result === 'string') {
|
|
@@ -216,7 +216,7 @@ export async function analyzeInputActionsAssetHandler(unityConnection, args) {
|
|
|
216
216
|
}
|
|
217
217
|
|
|
218
218
|
// Send command to Unity
|
|
219
|
-
const result = await unityConnection.sendCommand('
|
|
219
|
+
const result = await unityConnection.sendCommand('input_actions_asset_analyze', args);
|
|
220
220
|
|
|
221
221
|
// Check for errors
|
|
222
222
|
if (!result || typeof result === 'string') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for analysis_object_references_get
|
|
3
3
|
*/
|
|
4
4
|
export const getObjectReferencesToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'analysis_object_references_get',
|
|
6
6
|
description: 'Find references to and from a GameObject (hierarchy/assets/prefabs).',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -47,7 +47,7 @@ export async function getObjectReferencesHandler(unityConnection, args) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Send command to Unity
|
|
50
|
-
const result = await unityConnection.sendCommand('
|
|
50
|
+
const result = await unityConnection.sendCommand('analysis_object_references_get', args);
|
|
51
51
|
|
|
52
52
|
// Handle Unity response
|
|
53
53
|
if (result.status === 'error') {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// Action Map Management
|
|
4
4
|
export const createActionMapToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'input_action_map_create',
|
|
6
6
|
description: 'Create a new Action Map in an Input Actions asset',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -32,7 +32,7 @@ export const createActionMapToolDefinition = {
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
export const removeActionMapToolDefinition = {
|
|
35
|
-
name: '
|
|
35
|
+
name: 'input_action_map_remove',
|
|
36
36
|
description: 'Remove an Action Map from an Input Actions asset',
|
|
37
37
|
inputSchema: {
|
|
38
38
|
type: 'object',
|
|
@@ -52,7 +52,7 @@ export const removeActionMapToolDefinition = {
|
|
|
52
52
|
|
|
53
53
|
// Action Management
|
|
54
54
|
export const addInputActionToolDefinition = {
|
|
55
|
-
name: '
|
|
55
|
+
name: 'input_action_add',
|
|
56
56
|
description: 'Add a new Action to an Action Map',
|
|
57
57
|
inputSchema: {
|
|
58
58
|
type: 'object',
|
|
@@ -81,7 +81,7 @@ export const addInputActionToolDefinition = {
|
|
|
81
81
|
};
|
|
82
82
|
|
|
83
83
|
export const removeInputActionToolDefinition = {
|
|
84
|
-
name: '
|
|
84
|
+
name: 'input_action_remove',
|
|
85
85
|
description: 'Remove an Action from an Action Map',
|
|
86
86
|
inputSchema: {
|
|
87
87
|
type: 'object',
|
|
@@ -105,7 +105,7 @@ export const removeInputActionToolDefinition = {
|
|
|
105
105
|
|
|
106
106
|
// Binding Management
|
|
107
107
|
export const addInputBindingToolDefinition = {
|
|
108
|
-
name: '
|
|
108
|
+
name: 'input_binding_add',
|
|
109
109
|
description: 'Add a new Binding to an Action',
|
|
110
110
|
inputSchema: {
|
|
111
111
|
type: 'object',
|
|
@@ -144,7 +144,7 @@ export const addInputBindingToolDefinition = {
|
|
|
144
144
|
};
|
|
145
145
|
|
|
146
146
|
export const removeInputBindingToolDefinition = {
|
|
147
|
-
name: '
|
|
147
|
+
name: 'input_binding_remove',
|
|
148
148
|
description: 'Remove a Binding from an Action',
|
|
149
149
|
inputSchema: {
|
|
150
150
|
type: 'object',
|
|
@@ -175,7 +175,7 @@ export const removeInputBindingToolDefinition = {
|
|
|
175
175
|
};
|
|
176
176
|
|
|
177
177
|
export const removeAllBindingsToolDefinition = {
|
|
178
|
-
name: '
|
|
178
|
+
name: 'input_binding_remove_all',
|
|
179
179
|
description: 'Remove all Bindings from an Action',
|
|
180
180
|
inputSchema: {
|
|
181
181
|
type: 'object',
|
|
@@ -198,7 +198,7 @@ export const removeAllBindingsToolDefinition = {
|
|
|
198
198
|
};
|
|
199
199
|
|
|
200
200
|
export const createCompositeBindingToolDefinition = {
|
|
201
|
-
name: '
|
|
201
|
+
name: 'input_binding_composite_create',
|
|
202
202
|
description: 'Create a composite binding (e.g., 2D Vector for WASD movement)',
|
|
203
203
|
inputSchema: {
|
|
204
204
|
type: 'object',
|
|
@@ -248,7 +248,7 @@ export const createCompositeBindingToolDefinition = {
|
|
|
248
248
|
|
|
249
249
|
// Control Scheme Management
|
|
250
250
|
export const manageControlSchemesToolDefinition = {
|
|
251
|
-
name: '
|
|
251
|
+
name: 'input_control_schemes_manage',
|
|
252
252
|
description: 'Manage Control Schemes in an Input Actions asset',
|
|
253
253
|
inputSchema: {
|
|
254
254
|
type: 'object',
|
|
@@ -338,7 +338,7 @@ export async function createActionMapHandler(unityConnection, args) {
|
|
|
338
338
|
};
|
|
339
339
|
}
|
|
340
340
|
|
|
341
|
-
const result = await unityConnection.sendCommand('
|
|
341
|
+
const result = await unityConnection.sendCommand('input_action_map_create', args);
|
|
342
342
|
return formatUnityResponse(result, `Created Action Map: ${args.mapName}`);
|
|
343
343
|
} catch (error) {
|
|
344
344
|
return {
|
|
@@ -363,7 +363,7 @@ export async function removeActionMapHandler(unityConnection, args) {
|
|
|
363
363
|
};
|
|
364
364
|
}
|
|
365
365
|
|
|
366
|
-
const result = await unityConnection.sendCommand('
|
|
366
|
+
const result = await unityConnection.sendCommand('input_action_map_remove', args);
|
|
367
367
|
return formatUnityResponse(result, `Removed Action Map: ${args.mapName}`);
|
|
368
368
|
} catch (error) {
|
|
369
369
|
return {
|
|
@@ -389,7 +389,7 @@ export async function addInputActionHandler(unityConnection, args) {
|
|
|
389
389
|
};
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
const result = await unityConnection.sendCommand('
|
|
392
|
+
const result = await unityConnection.sendCommand('input_action_add', args);
|
|
393
393
|
return formatUnityResponse(result, `Added Action: ${args.actionName}`);
|
|
394
394
|
} catch (error) {
|
|
395
395
|
return {
|
|
@@ -414,7 +414,7 @@ export async function removeInputActionHandler(unityConnection, args) {
|
|
|
414
414
|
};
|
|
415
415
|
}
|
|
416
416
|
|
|
417
|
-
const result = await unityConnection.sendCommand('
|
|
417
|
+
const result = await unityConnection.sendCommand('input_action_remove', args);
|
|
418
418
|
return formatUnityResponse(result, `Removed Action: ${args.actionName}`);
|
|
419
419
|
} catch (error) {
|
|
420
420
|
return {
|
|
@@ -440,7 +440,7 @@ export async function addInputBindingHandler(unityConnection, args) {
|
|
|
440
440
|
};
|
|
441
441
|
}
|
|
442
442
|
|
|
443
|
-
const result = await unityConnection.sendCommand('
|
|
443
|
+
const result = await unityConnection.sendCommand('input_binding_add', args);
|
|
444
444
|
return formatUnityResponse(result, `Added Binding: ${args.path}`);
|
|
445
445
|
} catch (error) {
|
|
446
446
|
return {
|
|
@@ -465,7 +465,7 @@ export async function removeInputBindingHandler(unityConnection, args) {
|
|
|
465
465
|
};
|
|
466
466
|
}
|
|
467
467
|
|
|
468
|
-
const result = await unityConnection.sendCommand('
|
|
468
|
+
const result = await unityConnection.sendCommand('input_binding_remove', args);
|
|
469
469
|
return formatUnityResponse(result, 'Removed Binding');
|
|
470
470
|
} catch (error) {
|
|
471
471
|
return {
|
|
@@ -490,7 +490,7 @@ export async function removeAllBindingsHandler(unityConnection, args) {
|
|
|
490
490
|
};
|
|
491
491
|
}
|
|
492
492
|
|
|
493
|
-
const result = await unityConnection.sendCommand('
|
|
493
|
+
const result = await unityConnection.sendCommand('input_binding_remove_all', args);
|
|
494
494
|
return formatUnityResponse(result, `Removed all bindings from ${args.actionName}`);
|
|
495
495
|
} catch (error) {
|
|
496
496
|
return {
|
|
@@ -515,7 +515,7 @@ export async function createCompositeBindingHandler(unityConnection, args) {
|
|
|
515
515
|
};
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
-
const result = await unityConnection.sendCommand('
|
|
518
|
+
const result = await unityConnection.sendCommand('input_binding_composite_create', args);
|
|
519
519
|
return formatUnityResponse(result, `Created composite binding: ${args.name || args.compositeType}`);
|
|
520
520
|
} catch (error) {
|
|
521
521
|
return {
|
|
@@ -541,7 +541,7 @@ export async function manageControlSchemesHandler(unityConnection, args) {
|
|
|
541
541
|
};
|
|
542
542
|
}
|
|
543
543
|
|
|
544
|
-
const result = await unityConnection.sendCommand('
|
|
544
|
+
const result = await unityConnection.sendCommand('input_control_schemes_manage', args);
|
|
545
545
|
const operationText = args.operation === 'add' ? 'Added' : args.operation === 'remove' ? 'Removed' : 'Modified';
|
|
546
546
|
return formatUnityResponse(result, `${operationText} control scheme: ${args.schemeName}`);
|
|
547
547
|
} catch (error) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for scene_create
|
|
3
3
|
*/
|
|
4
4
|
export const createSceneToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'scene_create',
|
|
6
6
|
description: 'Create a new scene in Unity',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -73,7 +73,7 @@ export async function createSceneHandler(unityConnection, args) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// Send command to Unity
|
|
76
|
-
const result = await unityConnection.sendCommand('
|
|
76
|
+
const result = await unityConnection.sendCommand('scene_create', args);
|
|
77
77
|
|
|
78
78
|
// Handle Unity response
|
|
79
79
|
if (result.status === 'error') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for scene_info_get
|
|
3
3
|
*/
|
|
4
4
|
export const getSceneInfoToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'scene_info_get',
|
|
6
6
|
description: 'Get detailed information about a scene',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -56,7 +56,7 @@ export async function getSceneInfoHandler(unityConnection, args) {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
// Send command to Unity
|
|
59
|
-
const result = await unityConnection.sendCommand('
|
|
59
|
+
const result = await unityConnection.sendCommand('scene_info_get', args);
|
|
60
60
|
|
|
61
61
|
// Handle Unity response
|
|
62
62
|
if (result.status === 'error') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for scene_list
|
|
3
3
|
*/
|
|
4
4
|
export const listScenesToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'scene_list',
|
|
6
6
|
description: 'List all scenes in the Unity project',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -43,7 +43,7 @@ export async function listScenesHandler(unityConnection, args) {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// Send command to Unity
|
|
46
|
-
const result = await unityConnection.sendCommand('
|
|
46
|
+
const result = await unityConnection.sendCommand('scene_list', args);
|
|
47
47
|
|
|
48
48
|
// Handle Unity response
|
|
49
49
|
if (result.status === 'error') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for scene_load
|
|
3
3
|
*/
|
|
4
4
|
export const loadSceneToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'scene_load',
|
|
6
6
|
description: 'Load a scene in Unity',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -83,7 +83,7 @@ export async function loadSceneHandler(unityConnection, args) {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// Send command to Unity
|
|
86
|
-
const result = await unityConnection.sendCommand('
|
|
86
|
+
const result = await unityConnection.sendCommand('scene_load', args);
|
|
87
87
|
|
|
88
88
|
// Handle Unity response
|
|
89
89
|
if (result.status === 'error') {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tool definition for
|
|
2
|
+
* Tool definition for scene_save
|
|
3
3
|
*/
|
|
4
4
|
export const saveSceneToolDefinition = {
|
|
5
|
-
name: '
|
|
5
|
+
name: 'scene_save',
|
|
6
6
|
description: 'Save the current scene in Unity',
|
|
7
7
|
inputSchema: {
|
|
8
8
|
type: 'object',
|
|
@@ -52,7 +52,7 @@ export async function saveSceneHandler(unityConnection, args) {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
// Send command to Unity
|
|
55
|
-
const result = await unityConnection.sendCommand('
|
|
55
|
+
const result = await unityConnection.sendCommand('scene_save', args);
|
|
56
56
|
|
|
57
57
|
// Handle Unity response
|
|
58
58
|
if (result.status === 'error') {
|
package/src/tools/system/ping.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
export function registerPingTool(server, unityConnection) {
|
|
10
10
|
// Tool definition
|
|
11
11
|
const pingTool = {
|
|
12
|
-
name: '
|
|
12
|
+
name: 'system_ping',
|
|
13
13
|
description: 'Test connection to Unity Editor',
|
|
14
14
|
inputSchema: {
|
|
15
15
|
type: 'object',
|
|
@@ -34,7 +34,7 @@ export function registerPingTool(server, unityConnection) {
|
|
|
34
34
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
35
35
|
const { name, arguments: args } = request.params;
|
|
36
36
|
|
|
37
|
-
if (name === '
|
|
37
|
+
if (name === 'system_ping') {
|
|
38
38
|
try {
|
|
39
39
|
// Ensure connected
|
|
40
40
|
if (!unityConnection.isConnected()) {
|
|
@@ -42,15 +42,15 @@ export function registerPingTool(server, unityConnection) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
// Send ping with optional message
|
|
45
|
-
const result = await unityConnection.sendCommand('
|
|
46
|
-
message: args?.message || '
|
|
45
|
+
const result = await unityConnection.sendCommand('system_ping', {
|
|
46
|
+
message: args?.message || 'system_ping'
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
return {
|
|
50
50
|
content: [
|
|
51
51
|
{
|
|
52
52
|
type: 'text',
|
|
53
|
-
text: `Unity responded: ${result.message} (echo: ${result.echo || args?.message || '
|
|
53
|
+
text: `Unity responded: ${result.message} (echo: ${result.echo || args?.message || 'system_ping'})`
|
|
54
54
|
}
|
|
55
55
|
]
|
|
56
56
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnityConnection } from '../../core/unityConnection.js';
|
|
2
|
-
import {
|
|
2
|
+
import { VideoCaptureForToolHandler } from '../../handlers/video/VideoCaptureForToolHandler.js';
|
|
3
3
|
|
|
4
4
|
async function main() {
|
|
5
5
|
const unity = new UnityConnection();
|
|
@@ -7,7 +7,7 @@ async function main() {
|
|
|
7
7
|
try {
|
|
8
8
|
const ts = new Date().toISOString().replace(/[:.]/g, '').slice(0, 15);
|
|
9
9
|
const outputPath = `Assets/Screenshots/recordings/mcp_for_${ts}.mp4`;
|
|
10
|
-
const handler = new
|
|
10
|
+
const handler = new VideoCaptureForToolHandler(unity);
|
|
11
11
|
const result = await handler.execute({
|
|
12
12
|
captureMode: 'game',
|
|
13
13
|
width: 1280,
|
|
File without changes
|
package/src/utils/csharpParse.js
CHANGED
|
File without changes
|