@@ -11,32 +11,12 @@ const deviceConnections = new Map<string, DeviceConnection>();
1111// Common device_id parameter added to every phone tool
1212const deviceIdParam = z . number ( ) . int ( ) . describe ( 'Device ID number. Use list_devices to see available devices.' ) ;
1313
14- // Default scaling resolution (landscape)
15- const DEFAULT_SCALE_WIDTH = 1456 ;
16- const DEFAULT_SCALE_HEIGHT = 819 ;
17-
18- // Optional coordinate scaling params — pass the same max_width/max_height used for screenshot
14+ // Optional coordinate scaling params — device applies defaults based on its own screen ratio
1915const scalingParams = {
20- max_width : z . number ( ) . int ( ) . optional ( ) . describe ( ` Screenshot width for coordinate auto-scaling (default: ${ DEFAULT_SCALE_WIDTH } , 0 to disable)` ) ,
21- max_height : z . number ( ) . int ( ) . optional ( ) . describe ( ` Screenshot height for coordinate auto-scaling (default: ${ DEFAULT_SCALE_HEIGHT } , 0 to disable)` ) ,
16+ max_width : z . number ( ) . int ( ) . optional ( ) . describe ( ' Screenshot width for coordinate auto-scaling (device applies default if omitted , 0 to disable)' ) ,
17+ max_height : z . number ( ) . int ( ) . optional ( ) . describe ( ' Screenshot height for coordinate auto-scaling (device applies default if omitted , 0 to disable)' ) ,
2218} ;
2319
24- // Tools that need default scaling injected
25- const SCALING_TOOLS = new Set ( [
26- 'screenshot' , 'screenshot_window' , 'click' , 'long_click' , 'double_click' ,
27- 'right_click' , 'middle_click' , 'mouse_move' , 'mouse_scroll' , 'drag' , 'scroll' ,
28- 'ui_tree' , 'list_windows' , 'get_screen_size' , 'active_window' , 'camera' ,
29- ] ) ;
30-
31- /** Inject default max_width/max_height if not specified and tool needs scaling. */
32- function injectScalingDefaults ( toolName : string , params : Record < string , unknown > ) : Record < string , unknown > {
33- if ( ! SCALING_TOOLS . has ( toolName ) ) return params ;
34- const p = { ...params } ;
35- if ( p . max_width === undefined ) p . max_width = DEFAULT_SCALE_WIDTH ;
36- if ( p . max_height === undefined ) p . max_height = DEFAULT_SCALE_HEIGHT ;
37- return p ;
38- }
39-
4020// MCP tools for phone control — descriptions match web/ exactly
4121const phoneTools = [
4222 {
@@ -521,8 +501,7 @@ export function createMcpHandler(
521501
522502 const p = await getPhone ( deviceId ) ;
523503 const { device_id : _ , ...phoneParams } = params ;
524- const scaledParams = injectScalingDefaults ( tool . name , phoneParams ) ;
525- const result = await tool . handler ( p , scaledParams ) ;
504+ const result = await tool . handler ( p , phoneParams ) ;
526505 return {
527506 content : [ { type : 'text' as const , text : JSON . stringify ( result , null , 2 ) } ] ,
528507 } ;
0 commit comments