fix(mobile-mcp): strip bounds attributes from UI hierarchy dump

Remove bounds coordinates from mobile_ui_dump XML output to reduce
token consumption when LLMs process the hierarchy tree.
This commit is contained in:
LaZzyMan 2026-07-09 11:52:03 +08:00
parent d8084c63bc
commit 3764699a61

View file

@ -1247,7 +1247,8 @@ export const createMcpServer = (): McpServer => {
{ readOnlyHint: true },
async ({ device, compressed, output_path }) => {
const robot = getAndroidRobotFromDevice(device, 'mobile_ui_dump');
const xml = await robot.dumpUiHierarchy(compressed ?? false);
let xml = await robot.dumpUiHierarchy(compressed ?? false);
xml = xml.replace(/ bounds="\[[0-9,]+\]\[[0-9,]+\]"/g, '');
if (output_path) {
validateOutputPath(output_path);
fs.writeFileSync(output_path, xml, 'utf-8');