Selenium MCP Server
Quick Start: Install & Use in VS Code
Prerequisites
- Node.js 18+
- TypeScript
- Selenium WebDriver browser drivers
1. Clone the Repository
git clone https://github.com/KiranMote/Selenium_MCP_Server.git
cd Selenium_MCP_Server
2. Install Dependencies
npm install
3. Build the Project
npm run build
4. (Optional) Test the Server
Add and run tests as needed.
5. Register the MCP Server in VS Code
Global Registration (Recommended):
- Open (or create) the file:
C:\Users\
\AppData\Roaming\Code\User\mcp.json
Add the following under "servers"
:
{
"selenium-mcp-server": {
"type": "stdio",
"command": "node",
"args": [
"C:\\Users\\\\Selenium_MCP_Server\\dist\\index.js"
]
}
}
Save the file. Now, the server is available in all VS Code workspaces.
How to use Selenium MCP server
Check in Github Copilot Chat section Selenium MCP server tools present or not.
Give Prompt As per Requirement:
It uses exploration, inspect, and more tools from that MCP and does work for us.
Features
- Multi-Browser Support: Chrome, Firefox, and Edge browsers
- Comprehensive Element Interaction: Click, type, get text, wait for elements
- Advanced Capabilities: Screenshot capture, JavaScript execution, page navigation
- Flexible Element Selection: CSS selectors, XPath, ID, class name, and tag name
- Robust Error Handling: Proper validation and user-friendly error messages
- TypeScript: Full type safety and modern JavaScript features
Available Tools
- Browser Management: start_browser, close_browser, navigate, get_current_url, get_page_title
- Element Interaction: click, type_text, get_text, wait_for_element
- Advanced Features: take_screenshot, execute_script
Example Usage
{
"tool": "start_browser",
"arguments": {
"browser": "chrome",
"headless": false,
"windowSize": "1920x1080"
}
}
{
"tool": "navigate",
"arguments": {
"url": "https://example.com"
}
}
{
"tool": "click",
"arguments": {
"selector": "#submit-button",
"method": "css"
}
}
{
"tool": "type_text",
"arguments": {
"selector": "input[name='username']",
"text": "user123",
"method": "css"
}
}
Configuration
- Browser Options: browser, headless, windowSize, userAgent
- Element Selection Methods: css, xpath, id, className, tagName
- Wait Conditions: visible, present, clickable
Development
Building
npm run build
Running in Development
npm run dev
Project Structure
src/
index.ts # Main server implementation
dist/ # Compiled JavaScript output
.vscode/
mcp.json # MCP server configuration
.github/
copilot-instructions.md # Copilot development guidelines
Browser Driver Setup
Make sure you have the appropriate browser drivers installed:
- Chrome: ChromeDriver
- Firefox: GeckoDriver
- Edge: EdgeDriver
Most drivers can be automatically managed by Selenium WebDriver 4+.
Error Handling
- Input validation using Zod schemas
- Browser session state checking
- Timeout management for element operations
- Graceful cleanup on server shutdown
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
License
MIT License - see LICENSE file for details.