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

Remove bounds coordinates from mobile_ui_dump XML output to reduce
token consumption when LLMs process the hierarchy tree.
This commit is contained in:
顾盼 2026-07-09 11:59:00 +08:00 committed by GitHub
parent d8084c63bc
commit befa937375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

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');