Selenium_MCP_Server

KiranMote/Selenium_MCP_Server

3.1

If you are the rightful owner of Selenium_MCP_Server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.

The Selenium MCP Server is a Model Context Protocol server that provides browser automation capabilities using Selenium WebDriver, allowing programmatic control of web browsers through a standardized interface.

Tools
11
Resources
0
Prompts
0

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
image

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)
  1. Open (or create) the file: C:\Users\<your-username>\AppData\Roaming\Code\User\mcp.json image

  2. Add the following under "servers":

    "selenium-mcp-server": {
      "type": "stdio",
      "command": "node",
      "args": [
        "C:\\Users\\<your-username>\\Selenium_MCP_Server\\dist\\index.js"
      ]
    }
    
    image
  3. Save the file. Now, the server is available in all VS Code workspaces.

You Can open New Folder And Installed MCP server Will be available there:
image

How to use Selenium MCP server.

Check in Github Copilot Chat section Selenium MCP server tools present or not. image image

Give Prompt As per Requirement:

image

It Use exploration, Inspect And more tools from that mcp And Do 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: Initialize a new browser session
  • close_browser: Close the current browser session
  • navigate: Navigate to a specific URL
  • get_current_url: Get the current page URL
  • get_page_title: Get the current page title
Element Interaction
  • click: Click on an element
  • type_text: Type text into input fields
  • get_text: Extract text content from elements
  • wait_for_element: Wait for elements to meet specific conditions
Advanced Features
  • take_screenshot: Capture page screenshots
  • execute_script: Run JavaScript code in the browser

Example Usage

  1. Start a browser session:

    {
      "tool": "start_browser",
      "arguments": {
        "browser": "chrome",
        "headless": false,
        "windowSize": "1920x1080"
      }
    }
    
  2. Navigate to a website:

    {
      "tool": "navigate",
      "arguments": {
        "url": "https://example.com"
      }
    }
    
  3. Click an element:

    {
      "tool": "click",
      "arguments": {
        "selector": "#submit-button",
        "method": "css"
      }
    }
    
  4. Type text:

    {
      "tool": "type_text",
      "arguments": {
        "selector": "input[name='username']",
        "text": "user123",
        "method": "css"
      }
    }
    

Configuration

Browser Options

  • browser: Choose from 'chrome', 'firefox', or 'edge'
  • headless: Run browser without GUI (true/false)
  • windowSize: Set browser window dimensions (e.g., "1920x1080")
  • userAgent: Custom user agent string

Element Selection Methods

  • css: CSS selectors (default)
  • xpath: XPath expressions
  • id: Element ID
  • className: CSS class name
  • tagName: HTML tag name

Wait Conditions

  • visible: Element is visible on the page
  • present: Element exists in the DOM
  • clickable: Element is enabled and 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

The server includes comprehensive error handling:

  • Input validation using Zod schemas
  • Browser session state checking
  • Timeout management for element operations
  • Graceful cleanup on server shutdown

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

Related Projects