input_tap
Simulate touch interactions on Android devices by tapping at precise screen coordinates using X and Y values. Ideal for automation, testing, and UI manipulation via ADB commands.
Instructions
Tap at specific coordinates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | Yes | X coordinate for tap | |
| y | Yes | Y coordinate for tap |
Implementation Reference
- src/tools/handlers.ts:168-184 (handler)The main handler function for the 'input_tap' tool. It takes x and y coordinates, executes an ADB tap command, captures the updated UI content, and returns a response including a confirmation message and the UI dump.input_tap: async (args: any) => { const { x, y } = args as { x: number; y: number }; await executeCommand(`adb shell input tap ${x} ${y}`); const uiContent = await captureUIContent(false); return { content: [ { type: 'text', text: `Tap executed at coordinates: (${x}, ${y})`, }, ...uiContent, ], }; },
- src/tools/definitions.ts:85-102 (schema)The schema definition for the 'input_tap' tool, specifying the input parameters x and y as required numbers, along with description.{ name: 'input_tap', description: 'Tap at specific coordinates', inputSchema: { type: 'object', properties: { x: { type: 'number', description: 'X coordinate for tap', }, y: { type: 'number', description: 'Y coordinate for tap', }, }, required: ['x', 'y'], }, },
- src/index.ts:32-46 (registration)The MCP server request handler for calling tools, which dynamically looks up and executes the handler from toolHandlers object by tool name 'input_tap'.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}`); } });
- src/index.ts:26-30 (registration)The MCP server request handler for listing tools, which returns the toolDefinitions array including the 'input_tap' schema.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });
- src/tools/handlers.ts:8-46 (helper)Helper function captureUIContent used by input_tap handler to dump and format the UI hierarchy after the tap action.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; } };