
playwright-server MCP server

2025.03.15
0
Python浏览器自动化网页测试数据抓取浏览器自动化
playwright-plus-python-mcp 是一个基于 Playwright 的 MCP 服务器,提供了一系列浏览器自动化工具,用于网页导航、截图、点击、填写表单等操作。该服务器还包含一个简单的笔记存储系统和笔记摘要生成功能。
View on GitHub
Overview
基本能力
产品定位
playwright-plus-python-mcp 是一个浏览器自动化工具服务器,旨在通过 Playwright 提供高效的网页操作和自动化测试能力。
核心功能
- 浏览器自动化工具:
playwright_navigate
: 导航到指定 URLplaywright_screenshot
: 截取页面或特定元素的截图playwright_click
: 通过 CSS 选择器点击元素playwright_fill
: 填写输入字段playwright_evaluate
: 在浏览器控制台执行 JavaScript 代码playwright_click_text
: 通过文本内容点击元素playwright_get_text_content
: 获取所有可见元素的文本内容-
playwright_get_html_content
: 获取页面的 HTML 内容 -
笔记系统:
- 自定义 note:// URI 方案访问单个笔记
-
每个笔记资源包含名称、描述和文本/纯文本 MIME 类型
-
提示功能:
summarize-notes
: 生成所有存储笔记的摘要
适用场景
- 网页自动化测试
- 网页数据抓取
- 网页内容监控
- 自动化表单填写
- 网页截图生成
使用教程
使用依赖
需要安装 Playwright 和 Python 环境。
安装教程
- Claude Desktop 配置
- MacOS:
~/Library/Application\ Support/Claude/claude_desktop_config.json
-
Windows:
%APPDATA%/Claude/claude_desktop_config.json
-
开发/未发布服务器配置
"mcpServers": {
"playwright-server": {
"command": "uv",
"args": [
"--directory",
"C:\\Users\\xxxxx\\Documents\\project\\python\\mcp\\playwright-server",
"run",
"playwright-server"
]
}
}
- 已发布服务器配置
"mcpServers": {
"playwright-server": {
"command": "uvx",
"args": [
"playwright-server"
]
}
}
调试方式
推荐使用 MCP Inspector 进行调试:
npx @modelcontextprotocol/inspector uv --directory C:\Users\YUNYING\Documents\project\python\mcp\playwright-server run playwright-server
开发
构建和发布
- 同步依赖并更新锁文件:
uv sync
- 构建包分发:
uv build
- 发布到 PyPI:
uv publish
需要设置 PyPI 凭据:
- Token: --token
或 UV_PUBLISH_TOKEN
- 或用户名/密码: --username
/UV_PUBLISH_USERNAME
和 --password
/UV_PUBLISH_PASSWORD