Selenium MCP Server
Provides 66 tools for browser automation using Selenium WebDriver, enabling AI agents to navigate, interact, capture screenshots, assert conditions, manage cookies, handle tabs, execute HTTP requests, record sessions, and more.
README
π Selenium MCP Server
Model Context Protocol server for browser automation using Selenium WebDriver.
66 tools for navigation, interaction, screenshots, assertions, cookies, tabs, HTTP API, recording, batch execution, iframes, and raw WebDriver access β all with strict hexagonal architecture.
Why this MCP?
Most Selenium MCPs expose basic WebDriver commands. This one adds the layers that make AI agents truly reliable:
| Feature | Status |
|---|---|
Page snapshot with stable element refs (capture_page β e1, e2, ...) |
β |
| Persistent per-domain selector hints | β |
| HTTP API tools (GET/POST/PUT/PATCH/DELETE) | β |
| Batch multi-step execution (up to 20 steps in 1 call) | β |
| Built-in test assertions | β |
Raw WebDriver API access (run_selenium) |
β |
| Recording for test generation | β |
| Dialog handling (alert/confirm/prompt) | β |
| Cookie management | β |
| Stealth mode | β |
| Strict hexagonal architecture (Domain/Ports/Adapters) | β |
| Session tracing (NDJSON) | β |
| Selenium Manager auto-provisioning | β |
Quick Start
One-click install
From npm
npm install -g mcp-selenium-webdriver
Or run directly:
npx mcp-selenium-webdriver
Prerequisites
- Node.js 18+
- Chrome, Firefox, or Edge installed
- Selenium Manager provisions the matching driver automatically β no manual setup needed.
# Verify everything is ready
npx mcp-selenium-webdriver doctor
MCP Client Configuration
VS Code Copilot (.vscode/mcp.json):
{
"servers": {
"selenium-mcp": {
"command": "npx",
"args": ["mcp-selenium-webdriver"],
"type": "stdio"
}
}
}
Claude Desktop:
{
"mcpServers": {
"selenium-mcp": {
"command": "npx",
"args": ["mcp-selenium-webdriver"]
}
}
}
Cursor (.cursor/mcp.json):
{
"mcpServers": {
"selenium-mcp": {
"command": "npx",
"args": ["mcp-selenium-webdriver"]
}
}
}
Environment Variables
| Variable | Default | Description |
|---|---|---|
SELENIUM_BROWSER |
chrome |
Browser: chrome, firefox, edge |
SELENIUM_HEADLESS |
false |
Run browser in headless mode |
SELENIUM_STEALTH |
false |
Hide automation indicators |
SELENIUM_GRID_URL |
β | Selenium Grid hub URL |
SELENIUM_MCP_OUTPUT_MODE |
stdout |
Output: stdout or file |
SELENIUM_MCP_OUTPUT_DIR |
auto | Custom output directory |
SELENIUM_MCP_SAVE_TRACE |
false |
Save session trace as NDJSON |
SELENIUM_MCP_UNRESTRICTED_FILES |
false |
Bypass workspace sandbox |
HTTPS_PROXY / HTTP_PROXY |
β | Corporate proxy |
Pass them in your MCP config:
{
"mcpServers": {
"selenium-mcp": {
"command": "npx",
"args": ["mcp-selenium-webdriver"],
"env": {
"SELENIUM_HEADLESS": "true",
"SELENIUM_STEALTH": "true"
}
}
}
}
CLI Flags
npx mcp-selenium-webdriver [flags]
npx mcp-selenium-webdriver doctor # preflight diagnostics
| Flag | Description |
|---|---|
doctor |
Run diagnostics (Chrome, driver, proxy, cache) and exit |
--headless |
Run browser headless |
--stealth |
Enable stealth mode |
--save-trace |
Save session trace JSON |
--output-mode=stdout|file |
Set output mode |
--output-dir=<path> |
Custom output directory |
--grid-url=<url> |
Selenium Grid hub URL |
--allow-unrestricted-file-access |
Bypass workspace sandbox |
Tools (66)
π§ Navigation (7)
| Tool | Description |
|---|---|
navigate_to |
Navigate to a URL. Starts browser automatically. |
go_back |
Navigate back in history. |
go_forward |
Navigate forward in history. |
refresh_page |
Refresh the current page. |
scroll_page |
Scroll the page or element into view. |
get_current_url |
Get the current URL. Read-only. |
get_title |
Get the page title. Read-only. |
πΈ Page Analysis (5)
| Tool | Description |
|---|---|
capture_page |
Capture page state as element list with stable refs (e1-e300). Read-only. |
get_page_source |
Get the full HTML DOM. Read-only. |
get_visible_text |
Get visible text, optionally scoped to a CSS selector. Read-only. |
get_visible_html |
Get visible HTML (scripts removed by default). Read-only. |
take_screenshot |
Take a screenshot (viewport, full-page, or element). |
π±οΈ Elements (9)
| Tool | Description |
|---|---|
click_element |
Click an element by CSS selector or ref. |
hover_element |
Hover over an element. |
double_click |
Double-click an element. |
right_click |
Right-click (context menu) an element. |
select_option |
Select a dropdown option by value, text, or index. |
drag_drop |
Drag one element to another. |
teach_selector |
Teach a preferred CSS selector for a domain. |
iframe_click |
Click an element inside an iframe. |
iframe_fill |
Fill an input inside an iframe. |
β¨οΈ Input (3)
| Tool | Description |
|---|---|
input_text |
Type text into an input field. |
key_press |
Press a keyboard key, optionally with modifiers (ctrl, alt, shift, meta). |
file_upload |
Upload a file through a file input. |
π²οΈ Mouse (3)
| Tool | Description |
|---|---|
mouse_move |
Move mouse to coordinates. |
mouse_click |
Click at coordinates (left, right, middle). |
mouse_drag |
Drag from one position to another. |
π Tabs (4)
| Tool | Description |
|---|---|
tab_list |
List all open tabs. Read-only. |
tab_select |
Switch to a specific tab. |
tab_new |
Open a new tab. |
tab_close |
Close a tab. |
β Verification (4)
| Tool | Description |
|---|---|
verify_element_visible |
Verify an element is visible. Read-only. |
verify_text_visible |
Verify text is visible. Read-only. |
verify_value |
Verify an input has the expected value. Read-only. |
verify_list_visible |
Verify multiple texts are visible. Read-only. |
π Browser Control (7)
| Tool | Description |
|---|---|
wait_for |
Wait for a condition (element visible, URL, title...). |
execute_javascript |
Run JavaScript in the browser context. |
resize_window |
Resize the browser window. |
dialog_handle |
Handle dialogs (alert, confirm, prompt). |
console_logs |
Get browser console logs with filtering. Read-only. |
network_monitor |
Monitor network requests / toggle offline mode. |
pdf_generate |
Generate a PDF from the current page. Read-only. |
π Browser Lifecycle (5)
| Tool | Description |
|---|---|
start_browser |
Start the browser explicitly with options. |
close_browser |
Close the browser and end the session. |
reset_session |
Reset the session (close + restart). |
set_stealth_mode |
Enable/disable stealth mode. |
browser_status |
Get session status (URL, title, state). Read-only. |
πͺ Cookies (3)
| Tool | Description |
|---|---|
get_cookies |
Get all cookies. Read-only. |
add_cookie |
Add a cookie. |
delete_cookie |
Delete a cookie by name. |
βΊοΈ Recording (4)
| Tool | Description |
|---|---|
start_recording |
Start recording actions for test generation. |
stop_recording |
Stop recording and return the action log. |
recording_status |
Check recording status. Read-only. |
clear_recording |
Clear all recorded actions. |
πΎ Selector Hints (4)
| Tool | Description |
|---|---|
selector_hint_save |
Save a preferred CSS selector for a domain. |
selector_hint_get |
Get saved hints for a domain. Read-only. |
selector_hint_list |
List domains with hints. Read-only. |
selector_hint_delete |
Delete a hint. |
π HTTP API (5)
| Tool | Description |
|---|---|
http_get |
HTTP GET request. Read-only. |
http_post |
HTTP POST request with body. |
http_put |
HTTP PUT request. |
http_patch |
HTTP PATCH request. |
http_delete |
HTTP DELETE request. |
β‘ Power Tools (3)
| Tool | Description |
|---|---|
batch_execute |
Execute up to 20 tool steps in a single call. |
run_selenium |
Execute raw Selenium WebDriver API code (access to driver, By, until, Key). |
browser_generate_locator |
Generate a robust locator for an element by description. Read-only. |
Architecture
Hexagonal architecture (Ports & Adapters):
src/
βββ domain/
β βββ models/ Pure types & value objects
β βββ ports/ 18 interfaces (IBrowserPort, INavigationPort...)
β βββ services/ 16 use cases
βββ adapters/
β βββ selenium/ 14 Selenium WebDriver implementations
β βββ mcp/ MCP SDK server & tool registry
β βββ persistence/ File system & selector hints storage
β βββ logging/ Console & trace (NDJSON) loggers
βββ infrastructure/ DI container (tsyringe), bootstrap, config
βββ index.ts Entry point
βββ cli.ts CLI (doctor, flags)
Key design decisions:
- Dependency Injection via
tsyringewithSymboltokens β every port is swappable - Zod would be used for runtime validation (planned)
- Selenium Manager auto-provisions chromedriver matching your installed Chrome version
- 16-phase selector engine for
capture_page(ID β testId β role β label β ... β positional index) - Stealth mode injects scripts to hide
navigator.webdriverand automation indicators
Example Usage
Ask your AI agent:
Navigate to https://example.com, capture the page, click the first link, take a screenshot, verify "Example Domain" is visible.
The agent chains the tools automatically:
navigate_to β capture_page β click_element β take_screenshot β verify_text_visible
Or use raw WebDriver API:
run_selenium with:
const el = await driver.findElement(By.css('h1'));
const text = await el.getText();
return text;
Batch execution:
batch_execute with:
steps: [
{ tool: "navigate_to", args: { url: "https://example.com" } },
{ tool: "take_screenshot", args: { name: "before" } },
{ tool: "click_element", args: { selector: "a" } },
{ tool: "take_screenshot", args: { name: "after" } }
]
Development
git clone <this-repo>
cd mcp-selenium-webdriver
npm install
npm run build
npm run doctor
Scripts
npm run build # Compile TypeScript
npm run dev # Run with tsx (hot reload)
npm run typecheck # Type-check without emitting
npm test # Run all tests
npm run test:coverage # Run tests with coverage
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.