Selenium MCP Server
Supported as a compatible web browser for WebDriver interaction, allowing the MCP server to automate Firefox browser sessions.
Allows AI agents to control web browser sessions through Selenium WebDriver, enabling web scraping, automated testing, and form filling by providing tools for navigation, element finding, clicking, sending keystrokes, and retrieving page content.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Selenium MCP Server navigate to https://github.com and find the search input field"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Selenium MCP Server
smithery badge
An MCP server that uses Selenium to interact with a WebDriver instance. Built using the MCP-Server-Starter template.
Overview
This server allows AI agents to control a web browser session via Selenium WebDriver, enabling tasks like web scraping, automated testing, and form filling through the Model Context Protocol.
Related MCP server: mcp-selenium-python
Core Components
MCP Server: Exposes Selenium WebDriver actions as MCP tools.
Selenium WebDriver: Interacts with the browser.
MCP Clients: AI hosts (like Cursor, Claude Desktop) that can utilize the exposed tools.
Prerequisites
Node.js (v18 or later)
npm (v7 or later)
A WebDriver executable (e.g., ChromeDriver, GeckoDriver) installed and available in your system's PATH.
A compatible web browser (e.g., Chrome, Firefox).
Getting Started
Clone the repository:
git clone <your-repo-url> selenium-mcp-server cd selenium-mcp-serverInstall dependencies:
npm installConfigure WebDriver:
Ensure your WebDriver (e.g.,
chromedriver) is installed and in your PATH.Modify
src/seleniumService.ts(you'll create this file) if needed to specify browser options or WebDriver paths.
Build the server:
npm run buildRun the server:
npm startAlternatively, integrate it with an MCP host like Cursor or Claude Desktop (see Integration sections below).
Tools
This server will provide tools such as:
selenium_navigate: Navigates the browser to a specific URL.selenium_findElement: Finds an element on the page using a CSS selector.selenium_click: Clicks an element.selenium_sendKeys: Sends keystrokes to an element.selenium_getPageSource: Retrieves the current page source HTML.(Add more tools as needed)
TypeScript Implementation
The server uses the @modelcontextprotocol/sdk and selenium-webdriver libraries.
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { Builder, By, Key, until, WebDriver } from 'selenium-webdriver';
// Basic server setup (details in src/index.ts)
const server = new Server({
name: "selenium-mcp-server",
version: "0.1.0",
capabilities: {
tools: {}, // Enable tools capability
}
});
// Selenium WebDriver setup (details in src/seleniumService.ts)
let driver: WebDriver;
async function initializeWebDriver() {
driver = await new Builder().forBrowser('chrome').build(); // Or 'firefox', etc.
}
// Example tool implementation (details in src/tools/)
server.registerTool('selenium_navigate', {
description: 'Navigates the browser to a specific URL.',
inputSchema: { /* ... zod schema ... */ },
outputSchema: { /* ... zod schema ... */ },
handler: async (params) => {
await driver.get(params.url);
return { success: true };
}
});
// Connect transport
async function startServer() {
await initializeWebDriver();
const transport = new StdioServerTransport();
await server.connect(transport);
console.log("Selenium MCP Server connected via stdio.");
// Graceful shutdown
process.on('SIGINT', async () => {
console.log("Shutting down WebDriver...");
if (driver) {
await driver.quit();
}
process.exit(0);
});
}
startServer();Development
Build:
npm run buildRun:
npm start(executesnode build/index.js)Lint:
npm run lintFormat:
npm run format
Debugging
Use the MCP Inspector or standard Node.js debugging techniques.
Integration with MCP Hosts
(Keep relevant sections from the original README for Cursor, Claude Desktop, Smithery, etc., updating paths and commands as necessary)
Cursor Integration
Build your server:
npm run buildIn Cursor:
Settings>Features>MCP: Add a new MCP server.Register your server:
Select
stdioas the transport type.Name:
Selenium Server(or similar).Command:
node /path/to/selenium-mcp-server/build/index.js.
Save.
Claude Desktop Integration
Build your server:
npm run buildModify
claude_desktop_config.json:{ "mcpServers": { "selenium-mcp-server": { "command": "node", "args": [ "/path/to/selenium-mcp-server/build/index.js" ] } } }Restart Claude Desktop.
Best Practices
Use TypeScript and Zod for type safety and validation.
Keep tools modular (e.g., one file per tool in
src/tools/).Handle WebDriver errors gracefully (e.g., element not found, navigation issues).
Ensure proper WebDriver shutdown (e.g.,
driver.quit()on server exit).Follow MCP best practices for schemas, error handling, and content types.
Learn More
Credits
Based on the template created by Seth Rose:
Website: https://www.sethrose.dev
𝕏 (Twitter): https://x.com/TheSethRose
🦋 (Bluesky): https://bsky.app/profile/sethrose.dev
Available Tools
6 toolsbrowser_clickC
Perform click on a web page
Inputs: element (required), ref (required).
browser_snapshotB
Capture accessibility snapshot of the current page
Inputs: no named parameters.
browser_take_screenshotC
Take a screenshot of the current page
Inputs: filename, raw.
browser_typeC
Type text into editable element
Inputs: element (required), ref (required), text (required), submit.
browser_wait_forC
Wait for text to appear or disappear or a specified time to pass
Inputs: text, textGone, time.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Each tool has a clearly distinct purpose with no overlap: clicking, navigating, capturing snapshots, taking screenshots, typing text, and waiting for conditions. The descriptions make it easy to differentiate between them, eliminating any ambiguity in tool selection.
All tools follow a consistent 'browser_' prefix with descriptive action names (e.g., click, navigate, snapshot). This uniform snake_case pattern makes the tool set predictable and easy to understand, enhancing usability for agents.
With 6 tools, the server is well-scoped for web automation tasks. Each tool serves a specific, essential function in the Selenium domain, avoiding bloat while covering core interactions like navigation, input, and monitoring.
The tool set covers key web automation actions (navigation, interaction, monitoring), but lacks some common operations like form submission, element selection, or handling alerts. However, agents can work around these gaps using existing tools, making it mostly complete for basic workflows.
Maintenance
Related MCP Connectors
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Let your AI agent operate any website through a real, logged-in browser session.
Browser sessions for agents: navigate, interact, read and screenshot. Pay in stablecoins.
Related MCP Servers
- AlicenseBqualityDmaintenanceEnables AI assistants to automate web browser interactions through Selenium WebDriver. Supports multi-browser automation, element interaction, navigation, and web testing capabilities.56132 npm6MIT
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to automate browser tasks (navigation, clicks, text input) via Selenium through the Model Context Protocol.1GPL 3.0
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to automate web tasks such as browsing, clicking, typing, and taking screenshots via the Model Context Protocol.1MIT
- AlicenseAqualityBmaintenanceEnables browser automation through the Model Context Protocol, allowing AI agents to control Chrome, Firefox, or Edge for tasks like navigation, clicking, typing, and screenshots.4192 npmMIT