MCP Selenium

by angiejones
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Supports launching and controlling Firefox browser sessions with customizable options through Selenium WebDriver.

  • Allows AI agents to control web browsers through the Selenium WebDriver. Supports starting browser sessions, navigating to URLs, finding elements, clicking, typing, and performing various mouse and keyboard actions.

MCP Selenium 服务器

Selenium WebDriver 的模型上下文协议 (MCP) 服务器实现,通过标准化 MCP 客户端实现浏览器自动化。

特征

  • 使用可自定义的选项启动浏览器会话
  • 导航至 URL
  • 使用各种定位器策略查找元素
  • 单击、键入并与元素交互
  • 执行鼠标操作(悬停、拖放)
  • 处理键盘输入
  • 截取屏幕截图
  • 上传文件
  • 支持无头模式

支持的浏览器

  • 铬合金
  • 火狐

与 Goose 一起使用

选项 1:一键安装

将以下链接复制并粘贴到浏览器地址栏中,以将此扩展程序添加到 goose 桌面:

goose://extension?cmd=npx&arg=-y&arg=%40angiejones%2Fmcp-selenium&id=selenium-mcp&name=Selenium%20MCP&description=automates%20browser%20interactions

选项 2:手动添加到桌面或 CLI

  • 名称: Selenium MCP
  • 描述: automates browser interactions
  • 命令: npx -y @angiejones/mcp-selenium

与其他 MCP 客户端一起使用(例如 Claude Desktop 等)

{ "mcpServers": { "selenium": { "command": "npx", "args": ["-y", "@angiejones/mcp-selenium"] } } }

发展

从事此项目:

  1. 克隆存储库
  2. 安装依赖项: npm install
  3. 运行服务器: npm start

安装

通过 Smithery 安装

要通过Smithery自动为 Claude Desktop 安装 MCP Selenium:

npx -y @smithery/cli install @angiejones/mcp-selenium --client claude

手动安装

npm install -g @angiejones/mcp-selenium

用法

通过运行以下命令启动服务器:

mcp-selenium

或者在您的 MCP 配置中与 NPX 一起使用:

{ "mcpServers": { "selenium": { "command": "npx", "args": [ "-y", "@angiejones/mcp-selenium" ] } } }

工具

启动浏览器

启动浏览器会话。

参数:

  • browser (必需):要启动的浏览器
    • 类型:字符串
    • 枚举:[“chrome”,“firefox”]
  • options :浏览器配置选项
    • 类型:对象
    • 特性:
      • headless :以无头模式运行浏览器
        • 类型:布尔值
      • arguments :附加浏览器参数
        • 类型:字符串数组

例子:

{ "tool": "start_browser", "parameters": { "browser": "chrome", "options": { "headless": true, "arguments": ["--no-sandbox"] } } }

导航

导航至某个 URL。

参数:

  • url (必填):导航到的 URL
    • 类型:字符串

例子:

{ "tool": "navigate", "parameters": { "url": "https://www.example.com" } }

查找元素

在页面上查找元素。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "find_element", "parameters": { "by": "id", "value": "search-input", "timeout": 5000 } }

click_element

单击一个元素。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "click_element", "parameters": { "by": "css", "value": ".submit-button" } }

发送密钥

将键发送到元素(键入)。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • text (必需):输入到元素中的文本
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "send_keys", "parameters": { "by": "name", "value": "username", "text": "testuser" } }

获取元素文本

获取元素的文本()。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "get_element_text", "parameters": { "by": "css", "value": ".message" } }

徘徊

移动鼠标悬停在元素上。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "hover", "parameters": { "by": "css", "value": ".dropdown-menu" } }

拖放

将一个元素拖放到另一个元素上。

参数:

  • by (必需):源元素的定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):源定位器策略的值
    • 类型:字符串
  • targetBy (必需):目标元素的定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • targetValue (必需):目标定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "drag_and_drop", "parameters": { "by": "id", "value": "draggable", "targetBy": "id", "targetValue": "droppable" } }

双击

对元素执行双击。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "double_click", "parameters": { "by": "css", "value": ".editable-text" } }

右键单击

对元素执行右键单击(上下文单击)。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "right_click", "parameters": { "by": "css", "value": ".context-menu-trigger" } }

按键

模拟按下键盘键。

参数:

  • key (必需):要按下的键(例如,“Enter”,“Tab”,“a”等)
    • 类型:字符串

例子:

{ "tool": "press_key", "parameters": { "key": "Enter" } }

upload_file

使用文件输入元素上传文件。

参数:

  • by (必需):定位器策略
    • 类型:字符串
    • 枚举:[“id”,“css”,“xpath”,“name”,“tag”,“class”]
  • value (必需):定位器策略的值
    • 类型:字符串
  • filePath (必需):要上传的文件的绝对路径
    • 类型:字符串
  • timeout :等待元素的最长时间(以毫秒为单位)
    • 类型:数字
    • 默认值:10000

例子:

{ "tool": "upload_file", "parameters": { "by": "id", "value": "file-input", "filePath": "/path/to/file.pdf" } }

截屏

捕获当前页面的屏幕截图。

参数:

  • outputPath (可选):屏幕截图的保存路径。若未提供,则返回 base64 数据。
    • 类型:字符串

例子:

{ "tool": "take_screenshot", "parameters": { "outputPath": "/path/to/screenshot.png" } }

关闭会话

关闭当前浏览器会话并清理资源。

**参数:**无必填

例子:

{ "tool": "close_session", "parameters": {} }

执照

麻省理工学院

ID: s2em7b2kwf