themindmod selenium mcp server

themindmod selenium mcp server avatar

by themindmod

What is themindmod selenium mcp server

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.

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

  1. Clone the repository:
    git clone <your-repo-url> selenium-mcp-server
    cd selenium-mcp-server
    
  2. Install dependencies:
    npm install
    
  3. Configure 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.
  4. Build the server:
    npm run build
    
  5. Run the server:
    npm start
    
    Alternatively, 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 build
  • Run: npm start (executes node build/index.js)
  • Lint: npm run lint
  • Format: 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

  1. Build your server: npm run build
  2. In Cursor: Settings > Features > MCP: Add a new MCP server.
  3. Register your server:
    • Select stdio as the transport type.
    • Name: Selenium Server (or similar).
    • Command: node /path/to/selenium-mcp-server/build/index.js.
  4. Save.

Claude Desktop Integration

  1. Build your server: npm run build
  2. Modify claude_desktop_config.json:
    {
      "mcpServers": {
        "selenium-mcp-server": {
          "command": "node",
          "args": [
            "/path/to/selenium-mcp-server/build/index.js"
          ]
        }
      }
    }
    
  3. 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:

Leave a Comment

Frequently Asked Questions

What is MCP?

MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. Think of MCP like a USB-C port for AI applications, providing a standardized way to connect AI models to different data sources and tools.

What are MCP Servers?

MCP Servers are lightweight programs that expose specific capabilities through the standardized Model Context Protocol. They act as bridges between LLMs like Claude and various data sources or services, allowing secure access to files, databases, APIs, and other resources.

How do MCP Servers work?

MCP Servers follow a client-server architecture where a host application (like Claude Desktop) connects to multiple servers. Each server provides specific functionality through standardized endpoints and protocols, enabling Claude to access data and perform actions through the standardized protocol.

Are MCP Servers secure?

Yes, MCP Servers are designed with security in mind. They run locally with explicit configuration and permissions, require user approval for actions, and include built-in security features to prevent unauthorized access and ensure data privacy.

Related MCP Servers

chrisdoc hevy mcp avatar

chrisdoc hevy mcp

mcp
sylphlab pdf reader mcp avatar

sylphlab pdf reader mcp

An MCP server built with Node.js/TypeScript that allows AI agents to securely read PDF files (local or URL) and extract text, metadata, or page counts. Uses pdf-parse.

pdf-parsetypescriptnodejs
aashari mcp server atlassian bitbucket avatar

aashari mcp server atlassian bitbucket

Node.js/TypeScript MCP server for Atlassian Bitbucket. Enables AI systems (LLMs) to interact with workspaces, repositories, and pull requests via tools (list, get, comment, search). Connects AI directly to version control workflows through the standard MCP interface.

atlassianrepositorymcp
aashari mcp server atlassian confluence avatar

aashari mcp server atlassian confluence

Node.js/TypeScript MCP server for Atlassian Confluence. Provides tools enabling AI systems (LLMs) to list/get spaces & pages (content formatted as Markdown) and search via CQL. Connects AI seamlessly to Confluence knowledge bases using the standard MCP interface.

atlassianmcpconfluence
prisma prisma avatar

prisma prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB

cockroachdbgomcp
Zzzccs123 mcp sentry avatar

Zzzccs123 mcp sentry

mcp sentry for typescript sdk

mcptypescript
zhuzhoulin dify mcp server avatar

zhuzhoulin dify mcp server

mcp
zhongmingyuan mcp my mac avatar

zhongmingyuan mcp my mac

mcp
zhixiaoqiang desktop image manager mcp avatar

zhixiaoqiang desktop image manager mcp

MCP 服务器,用于管理桌面图片、查看详情、压缩、移动等(完全让Trae实现)

mcp
zhixiaoqiang antd components mcp avatar

zhixiaoqiang antd components mcp

An MCP service for Ant Design components query | 一个减少 Ant Design 组件代码生成幻觉的 MCP 服务,包含系统提示词、组件文档、API 文档、代码示例和更新日志查询

designantdapi

Submit Your MCP Server

Share your MCP server with the community

Submit Now