Skip to main content
Glama
Browser MCP Server

Browser MCP Server

by Akioo77

🌐 Browser MCP Server

用 Playwright + MCP 协议打造的浏览器自动化工具 任何支持 MCP 的 Agent(如 OpenClaw、Claude Desktop)都能直接用它控制浏览器 💎


功能概览

类别

工具

说明

🖥️ 浏览器控制

launch / close / status

启动/关闭浏览器

🧭 页面导航

navigate / back / forward / reload

页面跳转

📝 内容提取

get_text / get_links / get_inputs

提取文本/链接/表单

📸 截图

screenshot

全页/元素截图

🖱️ 交互操作

click / fill / select / check / hover

点击/填表/选择

🔍 搜索等待

search / wait_for_selector / wait_for_url / sleep

搜索/等待

📜 滚动

scroll

按方向/元素滚动


Related MCP server: browser-mcp-server

快速开始

安装

cd ~/workspace/browser-mcp-server
npm install
npx playwright install chromium   # 首次需要安装浏览器

方式一:直接运行测试

node test.js

方式二:启动 MCP Server(供 Agent 使用)

node src/index.js

Server 会以 Stdio 模式运行,等待 JSON-RPC 请求。


工具详细说明

🖥️ launch

启动浏览器。

{ "headless": true, "browserType": "chromium" }
  • headless: true=后台(默认),false=显示 Chrome 窗口

  • browserType: chromium / firefox / webkit


🧭 navigate

导航到 URL。

{ "url": "https://www.google.com", "waitUntil": "domcontentloaded" }
  • waitUntil: domcontentloaded(默认)/ load / networkidle


📝 get_text

提取页面纯文本。

{ "selector": "article", "maxLength": 3000 }
  • selector: CSS 选择器,不填则提取整页

  • maxLength: 最大字符数,防止超长


📸 screenshot

截图。

{ "path": "./screenshot.png", "selector": ".chart", "fullPage": true }
  • path: 保存路径

  • selector: 截取指定元素

  • fullPage: true=整页滚动截图


🖱️ click

点击元素。

{ "selector": "button.submit", "index": 0, "timeout": 5000 }
  • index: 多个匹配时按序号(从 0 开始)


✏️ fill

向输入框填入文本。

{ "selector": "input[name='q']", "text": "Hello World", "pressEnter": true }
  • pressEnter: 填入后自动按回车


📜 scroll

滚动页面。

{ "direction": "down", "amount": 500 }
  • direction: down / up / left / right


在 OpenClaw 中使用

在 OpenClaw 的 skills/ 目录下创建一个 skill:

# Browser Automation MCP Skill

## 启动 MCP Server
command: node
args: ["src/index.js"]
cwd: /Users/sunxiaoxuan/workspace/browser-mcp-server
protocol: stdio

或者在代码中直接调用:

# Python 示例(通过 subprocess 调 MCP Server)
import subprocess, json

proc = subprocess.Popen(
    ['node', 'src/index.js'],
    stdin=subprocess.PIPE,
    stdout=subprocess.PIPE,
    cwd='/Users/sunxiaoxuan/workspace/browser-mcp-server'
)

# 发送 MCP 请求
request = {
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": {
        "name": "launch",
        "arguments": {"headless": True}
    }
}

与 Siri 语音控制集成

配合 macOS 的 osascript 可以实现 Siri 语音控制浏览器!

# 例子:"Hey Siri,打开 GitHub"
osascript -e 'tell application "System Events"
    keystroke "https://github.com" using command to activate
end tell'

配合 MCP Server 可以实现更复杂的语音指令:

"打开 GitHub,搜索 OpenAI 的最新项目,截一张图"


项目结构

browser-mcp-server/
├── package.json
├── README.md
├── test.js              # 快速测试脚本
└── src/
    ├── index.js         # MCP Server 主程序
    └── browser.js       # Playwright 浏览器管理

常见问题

Q: 报错 "Executable doesn't exist"

npx playwright install chromium

Q: 截图不完整(只截到可见区域) 设置 fullPage: true 截取整页

Q: 点击报错"元素不可见" 用 wait_for_selector 先等元素出现再操作

Q: 需要登录怎么办 先用 navigate 打开登录页,fill 填入账号密码,click 点击登录


庄英琪 💎 制作 | 基于 Playwright + MCP SDK

Available Tools

21 tools
backB

浏览器后退一页

Inputs: no named parameters.

checkA

勾选或取消勾选复选框/单选框

Inputs: checked (required), selector (required).

clickB

点击页面上指定元素(按钮、链接、任意可点击元素)。支持 CSS 选择器或元素索引。

Inputs: index, timeout, selector.

closeA

关闭浏览器,释放资源。

Inputs: no named parameters.

fillA

向输入框填入文本(会先清空现有内容)。

Inputs: text (required), selector (required), pressEnter.

forwardA

浏览器前进一页

Inputs: no named parameters.

get_inputsA

获取页面上所有可输入的表单元素(input、textarea、select),返回元素引用和名称。

Inputs: no named parameters.

get_textA

提取页面的文本内容(纯文本,去除 HTML 标签)。支持全文或 CSS 选择器指定范围。

Inputs: selector, maxLength.

hoverA

鼠标悬停在指定元素上(可触发 hover 效果,如显示下拉菜单)

Inputs: selector (required).

launchB

启动浏览器。可以选择无头模式(后台,不显示窗口)或有窗口模式。

Inputs: headless, browserType.

reloadB

刷新当前页面

Inputs: no named parameters.

screenshotB

对当前页面截图。可截全屏、指定元素,或页面可见区域。

Inputs: path, fullPage, selector.

scrollC

滚动页面。可以按像素、元素或比例滚动。

Inputs: amount, selector, direction.

selectB

在下拉框()中选择选项

Inputs: value (required), selector (required).

sleepA

等待一段时间(毫秒),等待浏览器 JS 执行或页面渲染

Inputs: ms.

statusA

查看浏览器当前状态(是否启动、当前 URL 等)。

Inputs: no named parameters.

wait_for_selectorB

等待指定元素出现在页面中(可用于等待页面加载、弹窗等)

Inputs: selector (required), state, timeout.

wait_for_urlA

等待页面跳转到指定 URL(支持通配符 *)

Inputs: url (required), timeout.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.6/5.0

    Scored across 21 tools

    Disambiguation5/5

    Each tool targets a distinct browser action (e.g., click vs. check for different element types, fill vs. select for form fields). No two tools have overlapping purposes; descriptions clearly differentiate them.

    Naming Consistency5/5

    All tool names follow a consistent verb-based pattern, using lowercase snake_case for compound names (e.g., get_inputs, wait_for_selector). Single verbs like click, fill, navigate are uniform.

    Tool Count5/5

    With 21 tools, the server covers a broad range of browser automation tasks (navigation, interaction, data extraction, state management) without being excessive. Each tool serves a clear purpose within the domain.

    Completeness4/5

    The set covers core browser actions—launch, navigate, click, fill, select, scroll, screenshot, text extraction, and waiting. Minor gaps exist (e.g., handling alerts, cookies, or frame access), but the surface is largely complete for typical automation scenarios.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      A browser automation agent that enables Claude to interact with web browsers through the Model Context Protocol, allowing for actions like navigating websites, manipulating elements, and managing browser state.
      2
      9
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A universal browser automation MCP server using Playwright, enabling programmatic control of Chrome with 63 tools for navigation, interaction, media control, and CDP-based diagnostics.
      63
      13 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A browser automation MCP server with stealth mode, profile management, and multi-browser support, enabling LLMs to control browsers for tasks like navigation, data extraction, and form filling.
      1
      MIT