Skip to main content
Glama

capture_ui_dump

Capture the UI hierarchy dump from an Android device for detailed analysis, enabling efficient debugging and testing through the Android Debug Bridge MCP.

Instructions

Capture UI hierarchy dump from the device

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The handler function for the 'capture_ui_dump' MCP tool. It calls the captureUIContent helper to perform the UI dump.
    capture_ui_dump: async (args: any) => { const content = await captureUIContent(true); return { content: content, }; },
  • Core helper function implementing the UI dump logic: dumps via uiautomator, parses XML, formats output, handles errors.
    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; } };
  • Tool schema definition including name, description, and empty input schema (no parameters required).
    { name: 'capture_ui_dump', description: 'Capture UI hierarchy dump from the device', inputSchema: { type: 'object', properties: {}, }, },
  • src/index.ts:26-30 (registration)
    MCP server registration for listing tools, which includes the capture_ui_dump schema.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });
  • src/index.ts:32-46 (registration)
    MCP server registration for calling tools, dispatching to toolHandlers[name] including capture_ui_dump.
    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}`); } });

Other Tools

Related Tools

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