input_scroll
Simulate scrolling on Android devices for automation and testing. Specify direction (up, down, left, right) to navigate app interfaces.
Instructions
Perform scroll action
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| direction | Yes | Direction to scroll |
Implementation Reference
- src/tools/handlers.ts:207-235 (handler)The handler function for the 'input_scroll' tool. It destructures the direction from args, maps it to an ADB swipe command, executes the command, captures the updated UI content, and returns a response with a confirmation message and the UI dump.input_scroll: async (args: any) => { const { direction } = args as { direction: string }; const scrollCommands = { up: 'adb shell input swipe 500 800 500 400', down: 'adb shell input swipe 500 400 500 800', left: 'adb shell input swipe 800 500 400 500', right: 'adb shell input swipe 400 500 800 500', }; const command = scrollCommands[direction as keyof typeof scrollCommands]; if (!command) { throw new McpError(ErrorCode.InvalidParams, `Invalid direction: ${direction}`); } await executeCommand(command); const uiContent = await captureUIContent(false); return { content: [ { type: 'text', text: `Scroll executed: ${direction}`, }, ...uiContent, ], }; },
- src/tools/definitions.ts:118-131 (schema)The schema definition for the 'input_scroll' tool, including name, description, and inputSchema specifying the required 'direction' parameter with allowed values.name: 'input_scroll', description: 'Perform scroll action', inputSchema: { type: 'object', properties: { direction: { type: 'string', enum: ['up', 'down', 'left', 'right'], description: 'Direction to scroll', }, }, required: ['direction'], }, },
- src/index.ts:32-46 (registration)The MCP server request handler for CallToolRequestSchema that dynamically dispatches to the appropriate tool handler (including input_scroll) from the toolHandlers object based on the tool name.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 ListToolsRequestSchema that returns the list of tool definitions, including the schema for input_scroll.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: toolDefinitions, }; });