website/docs/mcp/tools.md
The following tools are available through the WebdriverIO MCP server. These tools enable AI assistants to automate browsers and mobile applications.
start_browserLaunches a Chrome browser session.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
headless | boolean | No | false | Run Chrome in headless mode |
windowWidth | number | No | 1920 | Browser window width (400-3840) |
windowHeight | number | No | 1080 | Browser window height (400-2160) |
navigationUrl | string | No | - | URL to navigate to after starting the browser |
Start a browser with 1920x1080 resolution and navigate to webdriver.io
start_app_sessionLaunches a mobile app session on iOS or Android via Appium.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
platform | string | Yes | - | Platform to automate: iOS or Android |
deviceName | string | Yes | - | Name of the device or simulator/emulator |
appPath | string | No* | - | Path to the app file (.app, .ipa, or .apk) |
platformVersion | string | No | - | OS version (e.g., 17.0, 14) |
automationName | string | No | Auto | XCUITest (iOS), UiAutomator2 or Espresso (Android) |
udid | string | No | - | Unique device identifier (required for real iOS devices) |
noReset | boolean | No | false | Preserve app state between sessions |
fullReset | boolean | No | true | Uninstall and reinstall app before session |
autoGrantPermissions | boolean | No | true | Automatically grant app permissions |
autoAcceptAlerts | boolean | No | true | Automatically accept system alerts |
autoDismissAlerts | boolean | No | false | Dismiss (instead of accept) alerts |
appWaitActivity | string | No | - | Activity to wait for on launch (Android only) |
newCommandTimeout | number | No | 60 | Seconds before session times out due to inactivity |
appiumHost | string | No | 127.0.0.1 | Appium server hostname |
appiumPort | number | No | 4723 | Appium server port |
appiumPath | string | No | / | Appium server path |
*Either appPath must be provided, or noReset: true to connect to an already-running app.
Start an iOS app session on iPhone 15 simulator with my app at /path/to/app.app
close_sessionCloses the current browser or app session.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
detach | boolean | No | false | Detach from session instead of closing (keeps browser/app running) |
Sessions with noReset: true or without appPath automatically detach on close to preserve state.
navigateNavigates to a URL.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
url | string | Yes | The URL to navigate to |
Navigate to https://webdriver.io
click_elementClicks an element identified by a selector.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
selector | string | Yes | - | CSS selector, XPath, or mobile selector |
scrollToView | boolean | No | true | Scroll element into view before clicking |
timeout | number | No | 3000 | Max time to wait for element (ms) |
button=Exact text or a*=Contains textClick the element with selector "#submit-button"
set_valueTypes text into an input field.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
selector | string | Yes | - | Selector for the input element |
value | string | Yes | - | Text to type |
scrollToView | boolean | No | true | Scroll element into view before typing |
timeout | number | No | 3000 | Max time to wait for element (ms) |
Clears existing value before typing new text.
Set the value "[email protected]" in the element with selector "#email"
get_visible_elementsGets visible and interactable elements on the current page or screen. This is the primary tool for discovering what elements are available for interaction.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
elementType | string | No | interactable | Type of elements: interactable (buttons/links/inputs), visual (images/SVGs), or all |
inViewportOnly | boolean | No | true | Only return elements visible in the viewport |
includeContainers | boolean | No | false | Include layout containers (ViewGroup, ScrollView, etc.) |
includeBounds | boolean | No | false | Include element coordinates (x, y, width, height) |
limit | number | No | 0 | Maximum elements to return (0 = unlimited) |
offset | number | No | 0 | Number of elements to skip (for pagination) |
{
"total": 42,
"showing": 20,
"hasMore": true,
"elements": [...]
}
Web elements include: tagName, type, id, className, textContent, value, placeholder, href, ariaLabel, role, cssSelector, isInViewport
Mobile elements include: Multiple locator strategies (accessibility ID, resource ID, XPath, UiAutomator/predicates), element type, text, and optionally bounds
limit and offset) for large pages to reduce token usageGet all visible elements on the page with their coordinates
get_accessibilityGets the accessibility tree of the current page with semantic information about roles, names, and states.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
limit | number | No | 100 | Maximum nodes to return (0 = unlimited) |
offset | number | No | 0 | Number of nodes to skip (for pagination) |
roles | string[] | No | All | Filter to specific roles (e.g., ["button", "link", "textbox"]) |
namedOnly | boolean | No | true | Only return nodes with a name/label |
{
"total": 85,
"showing": 100,
"hasMore": false,
"nodes": [
{ "role": "button", "name": "Submit" },
{ "role": "link", "name": "Home" }
]
}
get_visible_elements insteadget_visible_elements doesn't return expected elementsnamedOnly: true filters out anonymous containers and reduces noisetake_screenshotCaptures a screenshot of the current viewport.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
outputPath | string | No | Path to save screenshot file. If omitted, returns base64 data |
Base64-encoded image data (PNG or JPEG) with size information.
Screenshots are automatically optimized:
scrollScrolls the page up or down by a specified number of pixels.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
direction | string | Yes | - | Scroll direction: up or down |
pixels | number | No | 500 | Number of pixels to scroll |
Browser-only. For mobile scrolling, use the swipe tool instead.
get_cookiesGets cookies from the current session.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
name | string | No | Specific cookie name to retrieve (omit for all cookies) |
Cookie objects with name, value, domain, path, expiry, secure, and httpOnly properties.
set_cookieSets a cookie in the current session.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
name | string | Yes | - | Cookie name |
value | string | Yes | - | Cookie value |
domain | string | No | Current | Cookie domain |
path | string | No | / | Cookie path |
expiry | number | No | - | Expiration as Unix timestamp (seconds) |
secure | boolean | No | - | Secure flag |
httpOnly | boolean | No | - | HttpOnly flag |
sameSite | string | No | - | SameSite attribute: strict, lax, or none |
delete_cookiesDeletes cookies from the current session.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
name | string | No | Specific cookie name to delete (omit to delete all) |
tap_elementTaps on an element or screen coordinates.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
selector | string | No* | Selector for the element to tap |
x | number | No* | X coordinate for tap |
y | number | No* | Y coordinate for tap |
*Either selector or both x and y are required.
swipePerforms a swipe gesture in the specified direction.
| Parameter | Type | Mandatory | Default | Description |
|---|---|---|---|---|
direction | string | Yes | - | Swipe direction: up, down, left, right |
duration | number | No | 500 | Swipe duration in milliseconds (100-5000) |
percent | number | No | 0.5/0.95 | Percentage of screen to swipe (0-1) |
Swipe up to scroll down the screen
drag_and_dropDrags an element to another element or coordinates.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
sourceSelector | string | Yes | Source element selector to drag |
targetSelector | string | No* | Target element selector to drop onto |
x | number | No* | Target X offset (if no targetSelector) |
y | number | No* | Target Y offset (if no targetSelector) |
duration | number | No | Default |
*Either targetSelector or both x and y are required.
get_app_stateGets the current state of an app.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
bundleId | string | Yes | App identifier (bundle ID for iOS, package name for Android) |
App state: not installed, not running, running in background (suspended), running in background, or running in foreground.
get_contextsLists all available contexts (native and webviews).
None
Array of context names (e.g., ["NATIVE_APP", "WEBVIEW_com.example.app"]).
get_current_contextGets the currently active context.
None
Current context name (e.g., NATIVE_APP or WEBVIEW_*).
switch_contextSwitches between native and webview contexts.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
context | string | Yes | Context name or index (1-based) from get_contexts |
Switch to the WEBVIEW_com.example.app context
rotate_deviceRotates the device to a specific orientation.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
orientation | string | Yes | PORTRAIT or LANDSCAPE |
hide_keyboardHides the on-screen keyboard.
None
get_geolocationGets the current GPS coordinates.
None
Object with latitude, longitude, and altitude.
set_geolocationSets the device GPS coordinates.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
latitude | number | Yes | Latitude coordinate (-90 to 90) |
longitude | number | Yes | Longitude coordinate (-180 to 180) |
altitude | number | No | Altitude in meters |
Set geolocation to San Francisco (37.7749, -122.4194)
execute_scriptExecutes JavaScript in the browser or mobile commands via Appium.
| Parameter | Type | Mandatory | Description |
|---|---|---|---|
script | string | Yes | JavaScript code (browser) or mobile command (e.g., mobile: pressKey) |
args | array | No | Arguments for the script |
// Get page title
execute_script({ script: "return document.title" })
// Get scroll position
execute_script({ script: "return window.scrollY" })
// Click element by selector
execute_script({ script: "arguments[0].click()", args: ["#myButton"] })
// Press back key (Android)
execute_script({ script: "mobile: pressKey", args: [{ keycode: 4 }] })
// Activate app
execute_script({ script: "mobile: activateApp", args: [{ appId: "com.example" }] })
// Terminate app
execute_script({ script: "mobile: terminateApp", args: [{ appId: "com.example" }] })
// Deep link
execute_script({ script: "mobile: deepLink", args: [{ url: "myapp://screen", package: "com.example" }] })
// Shell command (Android)
execute_script({ script: "mobile: shell", args: [{ command: "dumpsys", args: ["battery"] }] })
| Key | Code |
|---|---|
| BACK | 4 |
| HOME | 3 |
| ENTER | 66 |
| MENU | 82 |
| SEARCH | 84 |
For a complete list of available Appium mobile commands, see: