Skip to main content
Glama
Selenium MCP Server

Selenium MCP Server

Selenium MCP Server πŸš€

Node.js TypeScript Model Context Protocol Selenium WebDriver License: MIT

A production-grade Model Context Protocol (MCP) server providing comprehensive browser automation capabilities powered by Selenium WebDriver communicating over standard I/O (stdio).

Designed for seamless integration with LLMs, AI agents, and IDEs including Antigravity IDE, Claude Desktop, Cursor, Windsurf, and any MCP-compliant client.


🌟 Key Highlights

  • ⚑ Multi-Browser Support: Chrome, Firefox, Microsoft Edge (headless or visible window).

  • 🎯 Intelligent Locators: CSS Selectors, XPath, ID, Name, Tag, Class, Exact Text, and Partial Text matching.

  • πŸ–±οΈ Full Interaction Suite: Click, type/fill, clear, hover, dropdown selection, keyboard shortcuts, and form submissions.

  • πŸ“Έ Visual Intelligence: Full viewport screenshots or element-level screenshots returned directly as PNG images.

  • 🧠 Smart Content Extraction: Clean text, full HTML source, or interactive semantic DOM structures tailored for LLM reasoning.

  • πŸ›‘οΈ Advanced Automation: Explicit wait conditions, JavaScript execution in page context, multi-tab switching, frame switching, and cookie session management.

  • πŸ€– Auto Driver Management: Utilizes Selenium 4+ built-in driver management (no manual driver installation required).


Related MCP server: Selenium MCP Server

🎬 Demo

https://github.com/AbyvargheseMandapathel/Selenium-MCP-Server/raw/main/demo.mp4


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 AI Agent / MCP Client                       β”‚
β”‚      (Claude Desktop / Antigravity IDE / Cursor)            β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ stdio (JSON-RPC 2.0)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Selenium MCP Server (Node.js/TS)               β”‚
β”‚                                                             β”‚
β”‚  β”œβ”€β”€ WebDriverManager (Session lifecycle, locators, auto-exit)
β”‚  β”œβ”€β”€ Browser Tools    (launch, navigate, history, resize)   β”‚
β”‚  β”œβ”€β”€ Interaction Tools(click, fill, hover, select, keys)    β”‚
β”‚  β”œβ”€β”€ Content Tools    (extract, inspect, screenshot)        β”‚
β”‚  └── Advanced Tools   (scripting, waits, tabs, cookies)     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ WebDriver Wire Protocol / CDP
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Browser (Chrome / Edge / Firefox)              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“‹ Prerequisites

  • Node.js: v18.0.0 or higher (Download Node.js)

  • Web Browser: At least one supported browser installed (Google Chrome, Firefox, or Microsoft Edge).


πŸ“¦ Installation & Build

  1. Clone or navigate to the project directory:

    cd "c:/Users/ABY/Desktop/project/selenium - mcp"
  2. Install dependencies:

    npm install
  3. Build the TypeScript source to JavaScript (dist/):

    npm run build
  4. (Optional) Run the automated smoke test to verify stdio communication:

    npm run test:smoke

βš™οΈ MCP Client Configuration

1. Antigravity IDE / Gemini IDE

Add the server to your .agents/mcp_config.json or global config:

{
  "mcpServers": {
    "selenium": {
      "command": "node",
      "args": ["c:/Users/ABY/Desktop/project/selenium - mcp/dist/index.js"],
      "env": {
        "SELENIUM_HEADLESS": "false",
        "SELENIUM_BROWSER": "chrome"
      }
    }
  }
}

2. Claude Desktop

Add to %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "selenium": {
      "command": "node",
      "args": ["c:/Users/ABY/Desktop/project/selenium - mcp/dist/index.js"],
      "env": {
        "SELENIUM_HEADLESS": "false"
      }
    }
  }
}

πŸ‘οΈ Headless vs. Visible (Headful) Mode

You can control whether the browser runs in the background (headless) or opens as a visible window on your screen:

Option A: Via AI Prompt / Tool Call

Simply ask your AI agent to run in visible or headless mode:

  • Visible mode: The agent calls launch_browser({ headless: false }) β€” Chrome/Edge/Firefox will pop up on your desktop so you can watch live clicks and typing.

  • Headless mode: The agent calls launch_browser({ headless: true }) β€” Runs silently in the background with zero desktop interruption.

Option B: Server-Wide Default (via env)

Set the environment variable SELENIUM_HEADLESS in your MCP client config:

  • "SELENIUM_HEADLESS": "false": All browser sessions open as visible windows by default.

  • "SELENIUM_HEADLESS": "true" (default): All sessions run silently in headless mode.

3. Cursor

In Cursor Settings -> Features -> MCP Servers -> Add New MCP Server:

  • Name: selenium

  • Type: command

  • Command: node "c:/Users/ABY/Desktop/project/selenium - mcp/dist/index.js"


πŸ› οΈ Complete Tools Reference

🌐 1. Browser Lifecycle & Navigation

Tool

Parameters

Description

launch_browser

browser ("chrome" | "firefox" | "edge")headless (boolean, default: true)width, height (integers)userAgent (string)proxy (string)args (string array)

Launch a new browser session with custom viewport, flags, and configuration.

close_browser

(none)

Closes the active browser session and frees system resources.

navigate

url (string, required)

Navigates the browser to the specified URL.

get_current_url

(none)

Returns current page URL and document title.

navigate_history

action ("back" | "forward" | "refresh")

Navigates backward/forward in history or reloads the page.

set_window_size

width (int), height (int)

Resizes the active browser window dimensions.


πŸ–±οΈ 2. User Interactions

Tool

Parameters

Description

click_element

selector (string, req)strategy (locator strategy)timeoutMs (number)

Scrolls element into view, waits until clickable, and clicks it.

fill_element

selector (string, req)text (string, req)strategy (locator strategy)clearBefore (bool, def: true)pressEnter (bool, def: false)

Types text into an input field or textarea.

clear_element

selector (string, req)strategy (locator strategy)

Clears all text from an input or textarea element.

hover_element

selector (string, req)strategy (locator strategy)

Moves the mouse cursor over the target element.

select_dropdown

selector (string, req)selectBy ("value" | "text" | "index")optionValue (string, req)

Selects an option inside a standard HTML <select> element.

press_key

key ("ENTER" | "TAB" | "ESCAPE" | "BACK_SPACE" | "ARROWS" | ...)selector (optional)

Sends special keyboard keys to the page or target element.


πŸ” 3. Content Inspection & Visuals

Tool

Parameters

Description

get_page_content

format ("text" | "html" | "structure")maxLength (number)

Extracts text, raw HTML, or interactive semantic DOM hierarchy.

find_elements

selector (string, req)strategy (locator strategy)limit (int, def: 20)

Inspects matching elements and returns tag, text, classes, IDs, hrefs, and visibility.

get_element_attribute

selector (string, req)attributeName (string, req)strategy (locator strategy)

Reads an HTML attribute (e.g. href, src, value, placeholder, aria-label).

take_screenshot

selector (optional string)strategy (optional)

Captures a high-resolution PNG screenshot of the full viewport or a specific element.


⚑ 4. Advanced Execution & Flow

Tool

Parameters

Description

execute_script

script (string, req)args (array of any)

Runs custom JavaScript in the browser context with arguments and returns output.

wait_for_element

selector (string, req)strategy (locator strategy)condition ("present" | "visible" | "clickable" | "invisible")timeoutMs (int)

Explicitly waits for an element to satisfy a condition.

manage_tabs

action ("list" | "switch" | "new" | "close")tabIndex (number)url (optional string)

Tab management: list open tabs, switch by index, create tab, or close current tab.

manage_cookies

action ("get_all" | "get" | "set" | "delete" | "delete_all")name, value, domain, path, secure, httpOnly

Full cookie session manipulation.

switch_frame

target ("default" | "parent" | "element" | "index")frameIndex (int)selector (string)

Changes driver execution context between iframes and parent documents.


🎯 Locator Strategies Guide

When targeting elements, specify the strategy parameter:

Strategy

Example Selector

Notes

css (default)

#login-btn, .item:nth-child(2), input[name='email']

Standard CSS selector

xpath

//div[@class='card'][contains(., 'Premium')]

Full XPath 1.0 support

id

username

Matches id="username"

name

password

Matches name="password"

text

Sign In

Matches exact visible text

partialText

Welcome back

Matches substring of text

class

btn-primary

Matches class name

tag

h1

Matches HTML tag name


πŸ’‘ Example AI Automation Prompt

Once configured in your MCP client, you can give high-level automation instructions like:

"Launch Chrome in visible mode, go to https://news.ycombinator.com, find the top 5 articles, extract their titles and URLs, and take a screenshot of the top story."

The LLM will automatically chain:

  1. launch_browser({ browser: "chrome", headless: false })

  2. navigate({ url: "https://news.ycombinator.com" })

  3. find_elements({ selector: ".titleline > a", strategy: "css", limit: 5 })

  4. take_screenshot({ selector: ".athing:first-child", strategy: "css" })


πŸ“‚ Project Structure

selenium - mcp/
β”œβ”€β”€ package.json              # Package metadata and scripts
β”œβ”€β”€ tsconfig.json             # TypeScript configuration
β”œβ”€β”€ mcp_config.example.json   # Ready-to-use client config
β”œβ”€β”€ LICENSE                   # MIT License
β”œβ”€β”€ README.md                 # Complete documentation
β”œβ”€β”€ scripts/
β”‚   └── smoke-test.js         # Automated stdio JSON-RPC smoke test
└── src/
    β”œβ”€β”€ index.ts              # Stdio server entry point
    β”œβ”€β”€ driver/
    β”‚   └── manager.ts        # WebDriverManager lifecycle & locators
    └── tools/
        β”œβ”€β”€ index.ts          # Central MCP tool registration
        β”œβ”€β”€ browser.ts        # Browser launch, navigation & history
        β”œβ”€β”€ interaction.ts    # Click, type, hover, select, keys
        β”œβ”€β”€ content.ts        # Text, HTML, elements & screenshots
        └── advanced.ts       # JavaScript, waits, tabs, cookies, frames

πŸ“„ License

This project is licensed under the MIT License.

Available Tools

21 tools
clear_elementA

Clear text from an input or textarea element.

Inputs: selector (required), strategy, timeoutMs.

click_elementC

Click an element matching selector strategy (css, xpath, id, name, text, partialText).

Inputs: selector (required), strategy, timeoutMs.

close_browserA

Close the active Selenium browser session and free resources.

Inputs: no named parameters.

execute_scriptA

Execute arbitrary JavaScript code in the browser page context and return the result.

Inputs: script (required), args.

fill_elementA

Type text into an input or textarea element.

Inputs: text (required), selector (required), strategy, timeoutMs, +2 more.

find_elementsA

Find and inspect elements matching a selector, returning tag, text, attributes, and visibility.

Inputs: selector (required), limit, strategy.

get_current_urlA

Get current page URL and page title.

Inputs: no named parameters.

get_element_attributeA

Retrieve specific attribute or property (e.g. href, src, value, class) from an element.

Inputs: selector (required), attributeName (required), strategy, timeoutMs.

get_page_contentA

Retrieve text, full HTML source, or interactive structure outline of current page.

Inputs: format, maxLength.

hover_elementB

Hover mouse over a target element.

Inputs: selector (required), strategy, timeoutMs.

launch_browserA

Launch a browser instance (Chrome, Firefox, Edge) with optional headless mode, viewport dimensions, proxy, and custom arguments.

Inputs: args, proxy, width, height, +3 more.

manage_cookiesC

Manage browser cookies: get_all, get, set, delete, or delete_all.

Inputs: action (required), name, path, value, +3 more.

manage_tabsA

Manage browser tabs: list active tabs, switch tab, open new tab, or close tab.

Inputs: action (required), url, tabIndex.

press_keyA

Send special keyboard keys (ENTER, TAB, ESCAPE, BACK_SPACE, ARROWS, etc.) to page or element.

Inputs: key (required), selector, strategy.

select_dropdownB

Select an option in a HTML dropdown by value, visible text, or index.

Inputs: selectBy (required), selector (required), optionValue (required), strategy, +1 more.

set_window_sizeA

Set browser window width and height in pixels.

Inputs: width (required), height (required).

switch_frameB

Switch execution context to an iframe, parent frame, or default document.

Inputs: target (required), selector, strategy, frameIndex.

take_screenshotA

Take a screenshot of the current page viewport or a specific element and return PNG image data.

Inputs: selector, strategy.

wait_for_elementB

Wait until an element satisfies condition (present, visible, clickable, invisible).

Inputs: selector (required), strategy, condition, timeoutMs.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 21 tools

    Disambiguation5/5

    Each tool targets a distinct browser automation action: lifecycle, navigation, element interaction, query, and context management. Even similar tools like get_page_content, find_elements, and get_element_attribute are clearly separated by page-level, element-level, and attribute-level scope.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern, such as launch_browser, click_elament, manage_tabs, and switch_frame. The single deviation, navigate_istory, still preserves the verb-object structure.

    Tool Count3/5

    With 21 tools, the set falls into the 16-25 heavy range. While each tool represents a real Selenium operation, some could be consolidated (e.g., clear_element into fill_element), making the collection feel slightly over-scoped for an MCP server.

    Completeness4/5

    The tool surface covers the full browser lifecycle: launch, navigate, interact, query, and close, plus tabs, cookies, frames, wait conditions, and script execution. Missing advanced features like alert handling or drag-and-drop are workable via execute_cript or represent edge cases, but they are notable omissions.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers