mcp-playwright介绍

mcp-playwright是一个使用 Playwright 提供浏览器自动化能力的模型上下文协议服务器。该服务器使 LLMs 能够与网页交互、截屏,并在真实的浏览器环境中执行 JavaScript。

GitHub地址:https://github.com/executeautomation/mcp-playwright。

image-20250319164041666
image-20250319164041666

安装

npm install -g @executeautomation/playwright-mcp-server

Claude Desktop 配置:

{
  "mcpServers": {
    "playwright": {
      "command": "npx",
      "args": ["-y", "@executeautomation/playwright-mcp-server"]
    }
  }
}

但是这样配置在Cline中会报错,如下所示:

image-20250319164907655
image-20250319164907655

修改为如下所示即可:

"playwright": {
      "command": "cmd",
      "args": [
        "/c",
        "npx",
        "-y",
        "@executeautomation/playwright-mcp-server"
      ]
    }

现在看一下mcp-playwright提供的所有功能。

image-20250319165049167
image-20250319165049167
image-20250319165127083
image-20250319165127083
image-20250319165147734
image-20250319165147734

实践

现在开始测试一下mcp-playwright提供的几个工具。

模型使用的是Qwen/Qwen2.5-72B-Instruct。

playwright_navigate

页面导航功能。

任务:“使用mcp服务器导航至https://github.com/executeautomation/mcp-playwright”

效果:

image-20250319165602152
image-20250319165602152
image-20250319165630774
image-20250319165630774

playwright_screenshot

屏幕截图功能。

效果:

image-20250319165854797
image-20250319165854797
image-20250319165942580
image-20250319165942580

playwright_click

点击元素功能。

比如点击Issues 按钮。

image-20250319170731784
image-20250319170731784
image-20250319170753941
image-20250319170753941

playwright_fill

填写输入字段功能。

Task:“使用MCP服务器导航至https://www.google.com.hk/index.html 并在搜索框输入你好。”

image-20250319181613849
image-20250319181613849

playwright_evaluate

执行js代码。

Task:“使用MCP服务器导航至https://www.google.com.hk/index.html 并在控制台输出你好世界。”

image-20250319182114795
image-20250319182114795

剩下的工具我就不一个个试了。

具体使用场景我也还不了解,但是毕竟是个新项目,看看这个项目的发展吧!!

Logo

欢迎加入 MCP 技术社区!与志同道合者携手前行,一同解锁 MCP 技术的无限可能!

更多推荐