Give your AI agent a clearer view of the page
Set up release 1.0.1 and explore a Selenium.dev accessibility snapshot with Claude Desktop.
MCP server documentation
Connect an MCP client to Chrome, Firefox, Edge, or Safari. Navigate pages, interact with elements, manage browser context, and inspect results through a familiar set of browser tools.
The server launches the selected browser the first time a browser tool is used.
From the blog
Practical guides to the tools and concepts behind Selenium MCP Server.
Set up release 1.0.1 and explore a Selenium.dev accessibility snapshot with Claude Desktop.
Follow a step-by-step guide to install the server, configure Claude Desktop, and try browser tasks.
Connect to Grid, inspect nodes and sessions, and perform basic session and node administration.
Python 3.10 or later.
Install Chrome/Chromium, Firefox, Edge, or Safari on macOS.
On macOS, enable automation from Safari’s Develop menu.
Selenium Manager may need network access on first use to obtain a compatible driver.
Create a virtual environment, install the pinned dependencies, and start the MCP server:
python -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txt
python -m selenium_mcp_server
The server communicates over standard input/output using MCP stdio.
Configure your MCP client to launch python -m selenium_mcp_server
from the repository directory.
Set environment variables in the MCP client's server configuration.
SELENIUM_BROWSERSelect chrome, firefox, edge, or safari. Defaults to chrome.
SELENIUM_HEADLESSDefaults to true. Set to false to show Chrome, Firefox, or Edge. Safari does not support headless mode.
SELENIUM_REMOTE_URLOptional Selenium Grid WebDriver URL, such as http://localhost:4444. When set, the browser session starts on the Grid; otherwise it starts locally.
For local sessions, Selenium Manager handles driver setup where supported. Safari requires
macOS and Safari’s built-in safaridriver.
Tools are grouped by task. Locator-based tools use one of the supported locator strategies listed below.
navigate(url)Open a URL.navigate_history(direction)Go back, forward, or refresh.get_current_url()Read the current URL.get_page_title()Read the page title.get_page_text()Read visible page text.get_page_source(max_chars=20000)Read page source, capped at 100,000 characters.get_accessibility_tree(interesting_only=true)Read an accessibility snapshot of the current context and reachable child frames.take_screenshot()Capture a PNG screenshot.Selenium computes snapshots from the DOM, not the browser's native accessibility tree. Set interesting_only=false to include all rendered elements. Text output omits element references, descriptions, and URLs and can include sensitive page text and form values.
get_grid_status()Check whether the configured Grid is ready.list_grid_nodes()Inspect Grid nodes, status, browser stereotypes, and slots.get_grid_browser_availability()Count available, busy, and unavailable slots by browser.list_grid_sessions()List active Grid sessions.create_grid_session(browser_name, capabilities={})Create a separate session with optional WebDriver capabilities.delete_grid_session(session_id)End the specified active Grid session.drain_grid_node(node_id)Stop a node from accepting new sessions while current sessions finish.These tools require SELENIUM_REMOTE_URL. A session created with create_grid_session is separate from the browser session controlled by the interaction tools.
find_elements(strategy, selector, limit=50)List matching elements and their state (limit 1–200).get_element_attribute(strategy, selector, attribute)Read an element attribute.get_element_state(strategy, selector)Inspect displayed, enabled, and selected state.get_element_accessibility_tree(strategy, selector, interesting_only=true)Read an accessibility snapshot of the first matching element's subtree.get_element_property(strategy, selector, name)Read a DOM property.get_element_css_value(strategy, selector, property_name)Read a computed CSS value.get_element_rect(strategy, selector)Read an element’s bounding rectangle.take_element_screenshot(strategy, selector)Capture an element screenshot.click_element(strategy, selector)Click an element.submit_element(strategy, selector)Submit a form element.clear_element(strategy, selector)Clear an input.type_text(strategy, selector, text, clear=true)Type into an element, optionally clearing it first.press_key(strategy, selector, key)Send a supported key such as ENTER, TAB, ESCAPE, or an arrow key.select_option(strategy, selector, label|value|index)Select an option by exactly one criterion.hover_element(strategy, selector)Move the pointer over an element.click_action(strategy, selector, action)Double-click or right-click.drag_and_drop(source_strategy, source_selector, target_strategy, target_selector)Drag one element onto another.scroll_to_element(strategy, selector)Scroll an element into view.scroll_page(x=0, y=0)Scroll the current page.wait_for_element(strategy, selector, timeout=10, visible=true)Wait for presence or visibility; timeout is capped at 120 seconds.find_shadow_element(host_strategy, host_selector, strategy, selector)Find an element inside a host’s shadow root.click_shadow_element(...), type_shadow_text(...)Interact with an element inside a shadow root.find_relative_elements(strategy, selector, relation, anchor_strategy, anchor_selector, near_distance=50, limit=50)Find elements positioned relative to an anchor.get_active_element()Get the currently focused element.wait_for_title(title, timeout=10)Wait for a matching page title.wait_for_url(url_fragment, timeout=10)Wait for a URL fragment.execute_javascript(script, arguments)Execute JavaScript; arguments must be JSON-serializable.execute_async_javascript(script, arguments, timeout=10)Execute an async script using Selenium’s final callback; timeout is capped at 120 seconds.get_windows()List browser window handles.open_window(window_type=tab, url)Open a tab or window.switch_window(handle)Switch to a window.close_window()Close the current window.switch_frame(strategy, selector)Switch into a frame.switch_to_parent_frame()Move to the parent frame.switch_to_default_content()Return to the top-level document.get_alert_text()Read the current alert or prompt text.handle_alert(action, text)Accept or dismiss an alert, or enter prompt text.get_cookies()List current cookies.add_cookie(cookie)Add a cookie.delete_cookies(name)Delete cookies by name.set_window_size(width, height)Set the browser viewport size.maximize_window(), fullscreen_window()Maximize or fullscreen the window.get_window_position(), set_window_position(x, y)Read or set the window position.set_timeout(timeout_type, seconds)Set implicit, page-load, or script timeout (0–120 seconds).close_browser()End the current browser session.get_bidi_status()Check whether a BiDi WebSocket is available.get_bidi_context_tree(max_depth=5)Inspect the browsing context tree.bidi_navigate(context, url)Navigate a BiDi browsing context.get_bidi_user_contexts()List BiDi user contexts.create_bidi_user_context()Create a BiDi user context.remove_bidi_user_context(user_context)Remove a BiDi user context.BiDi is requested at session creation. The browser and driver must support the specific BiDi command.
id, name, css, xpath, tag, class, link_text, and partial_link_text.
Run the unit tests from the repository root:
python -m unittest discover -s tests