Skip to main content
Glama

capture_ui_dump

Capture UI hierarchy dumps from Android devices for debugging and testing purposes. Analyze app layouts and identify UI elements through ADB automation.

Instructions

Capture UI hierarchy dump from the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'capture_ui_dump' tool. It calls the captureUIContent helper with raw XML included and returns the formatted content.
    capture_ui_dump: async (args: any) => { const content = await captureUIContent(true); return { content: content, }; },
  • The core helper function that performs the ADB UI dump, parses the XML using parseUIAutomatorXML, formats it, and constructs the response content including optional raw XML.
    const captureUIContent = async (includeRawXML: boolean = true) => { await executeCommand('adb shell uiautomator dump /sdcard/window_dump.xml'); const xmlContent = await executeCommand('adb shell "cat /sdcard/window_dump.xml"'); try { const processedUI = await parseUIAutomatorXML(xmlContent); const formattedOutput = formatElementsForDisplay(processedUI); const result = [ { type: 'text', text: formattedOutput, }, ]; if (includeRawXML) { result.push({ type: 'text', text: `\n=== RAW XML UI Automator ===\n${xmlContent}`, }); } return result; } catch (error) { const result = [ { type: 'text', text: `Error processing UI dump: ${error}`, }, { type: 'text', text: `\n=== RAW XML DATA ===\n${xmlContent}`, } ]; return result; } };
  • The schema definition for the 'capture_ui_dump' tool, specifying no input parameters.
    { name: 'capture_ui_dump', description: 'Capture UI hierarchy dump from the device', inputSchema: { type: 'object', properties: {}, }, },
  • src/index.ts:26-30 (registration)
    Tool list registration that exposes the toolDefinitions array, including the capture_ui_dump schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });
  • src/index.ts:32-46 (registration)
    Tool execution registration that looks up and invokes the handler from toolHandlers based on tool name, enabling capture_ui_dump execution.
    server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; try { const handler = toolHandlers[name as keyof typeof toolHandlers]; if (!handler) { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${name}`); } return await handler(args); } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); throw new McpError(ErrorCode.InternalError, `Tool execution failed: ${errorMessage}`); } });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/TiagoDanin/Android-Debug-Bridge-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server