Files
spellforge/Tools/godot-mcp-pro/server/build/tools/android-tools.js
T
joywayerandClaude Opus 4.8 e65066a8fb chore: 重命名 Tools/godot-mcp-pro-v1.15.1 → Tools/godot-mcp-pro,更新 .mcp.json
- 去掉版本号后缀,路径更稳定(后续更新工具不必再改 .mcp.json)
- .mcp.json 指向新路径 server/build/index.js
- server 依赖已 npm install 就绪;node_modules 由 .gitignore 忽略,未入库

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-20 15:37:18 +08:00

42 lines
2.8 KiB
JavaScript

import { z } from "zod";
import { formatErrorForMcp } from "../utils/errors.js";
export function registerAndroidTools(server, godot) {
server.tool("list_android_devices", "List Android devices visible to adb (parses 'adb devices -l'). Uses the path configured in Editor Settings > Export > Android > Adb, falls back to 'adb' on PATH.", {}, async () => {
try {
const result = await godot.sendCommand("list_android_devices");
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("get_android_preset_info", "Read metadata (package name, export path, runnable flag) from an Android export preset in export_presets.cfg. If no preset is specified, returns the first Android preset.", {
preset_name: z.string().optional().describe("Preset name as shown in Project > Export"),
preset_index: z.number().optional().describe("Preset index (alternative to name)"),
}, async (params) => {
try {
const result = await godot.sendCommand("get_android_preset_info", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
server.tool("deploy_to_android", "Export APK via Godot CLI, install it on a connected Android device via adb, and optionally launch the main activity. Equivalent to Godot's Remote Deploy button. Requires a configured Android export preset and adb on PATH (or set in Editor Settings). This call is synchronous and may take tens of seconds to complete.", {
preset_name: z.string().optional().describe("Android export preset name (defaults to first Android preset)"),
preset_index: z.number().optional().describe("Preset index (alternative to name)"),
device_serial: z.string().optional().describe("adb device serial (omit to use default device)"),
debug: z.boolean().optional().describe("Debug export (default: true)"),
launch: z.boolean().optional().describe("Launch the app after install (default: true)"),
skip_export: z.boolean().optional().describe("Skip the export step and install the existing APK at the preset's export_path (default: false)"),
}, async (params) => {
try {
const result = await godot.sendCommand("deploy_to_android", params);
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
}
catch (e) {
return { content: [{ type: "text", text: formatErrorForMcp(e) }], isError: true };
}
});
}
//# sourceMappingURL=android-tools.js.map