How to run adb commands using appium / webdriver?

An error occurred: unknown error: An unknown server-side error occurred while processing the command. Original error: Potentially insecure feature ‘adb_shell’ has not been enabled. If you want to enable this feature and accept the security ramifications, please do so by following the documented instructions at

I get the above error after running this code

await mobileDriver.executeScript('mobile: shell', [{ command: "input keyevent KEYCODE_APP_SWITCH" }])

Full code:

const mobileDriver: WebdriverIO.Browser = await remote({
    port: 4723,
    capabilities: {
        "appium:platformName": "Android",
        "appium:platformVersion": "11",
        "appium:automationName": "UiAutomator2",
        "appium:appPackage": "xxx",
        "appium:appActivity": "xxx.MainActivity",
        "appium:noReset": true,
        "appium:autoGrantPermissions": true,
            "appium:forceAppLaunch": true,
            "appium:newCommandTimeout": 60000
        },
        logLevel: 'silent',
    });

    await Utils.waitFor(40000)
    await mobileDriver.executeScript('mobile: shell', [{ command: "input keyevent KEYCODE_APP_SWITCH" }])

try add --relaxed-security to appium server