diff --git a/internal/version/VERSION b/internal/version/VERSION index cc21ecda..9fd914bc 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2505202258 +v5.0.0-beta-2505202311 diff --git a/mcphost/mcp_server.go b/mcphost/mcp_server.go index a5cad28f..5fe5fed9 100644 --- a/mcphost/mcp_server.go +++ b/mcphost/mcp_server.go @@ -91,6 +91,16 @@ func (ums *MCPServer4XTDriver) addTools() { ums.tools = append(ums.tools, listDevicesTool) ums.handlerMap[listDevicesTool.Name] = ums.handleListAvailableDevices + // SelectDevice Tool + selectDeviceTool := mcp.NewTool("select_device", + mcp.WithDescription("Select a device to use from the list of available devices. Use the list_available_devices tool to get a list of available devices."), + mcp.WithString("platform", mcp.Enum("android", "ios"), mcp.Description("The type of device to select")), + mcp.WithString("serial", mcp.Description("The device serial/udid to select")), + ) + ums.mcpServer.AddTool(selectDeviceTool, ums.handleSelectDevice) + ums.tools = append(ums.tools, selectDeviceTool) + ums.handlerMap[selectDeviceTool.Name] = ums.handleSelectDevice + // TapXY Tool tapParams := append( []mcp.ToolOption{mcp.WithDescription("Taps on the device screen at the given coordinates.")}, @@ -160,6 +170,17 @@ func (ums *MCPServer4XTDriver) handleListAvailableDevices(ctx context.Context, r return mcp.NewToolResultText(string(jsonResult)), nil } +// handleSelectDevice handles the select_device tool call. +func (ums *MCPServer4XTDriver) handleSelectDevice(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { + driverExt, err := ums.setupXTDriver(ctx, request.Params.Arguments) + if err != nil { + return nil, err + } + + uuid := driverExt.IDriver.GetDevice().UUID() + return mcp.NewToolResultText(fmt.Sprintf("Selected device: %s", uuid)), nil +} + // handleTapXY handles the tap_xy tool call. func (ums *MCPServer4XTDriver) handleTapXY(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) { driverExt, err := ums.setupXTDriver(ctx, request.Params.Arguments) @@ -237,8 +258,8 @@ func (ums *MCPServer4XTDriver) handleScreenShot(ctx context.Context, request mcp func (ums *MCPServer4XTDriver) setupXTDriver(_ context.Context, args map[string]interface{}) (*uixt.XTDriver, error) { platform, _ := args["platform"].(string) serial, _ := args["serial"].(string) - if platform == "" || serial == "" { - return nil, fmt.Errorf("platform and serial are required") + if platform == "" { + platform = "android" } // Check if driver exists in cache