Playwright Python MCP 服务器
一个集成了Playwright工具的MCP服务器,用于自动化浏览器操作和网页交互
Playwright Python MCP 服务器快速入门
安装配置
Claude桌面应用配置
MacOS路径: ~/Library/Application\ Support/Claude/claude_desktop_config.json
Windows路径: %APPDATA%/Claude/claude_desktop_config.json
对于已发布服务器,配置如下:
"mcpServers": {
"playwright-server": {
"command": "uvx",
"args": [
"playwright-server"
]
}
}
主要功能
工具
playwright_navigate
: 导航到指定URL,需要url
参数playwright_screenshot
: 截取当前页面,需要name
参数,可选selector
参数playwright_click
: 点击页面元素,需要selector
参数playwright_fill
: 填充表单字段,需要selector
和value
参数playwright_evaluate
: 执行JavaScript代码,需要script
参数playwright_click_text
: 通过文本内容点击元素,需要text
参数playwright_get_text_content
: 获取所有可见元素的文本内容playwright_get_html_content
: 获取页面HTML内容,需要selector
参数
资源
系统实现了简单的笔记存储功能,使用note://URI方案访问各个笔记。
调试
使用MCP Inspector进行调试:
npx @modelcontextprotocol/inspector uv --directory 项目路径 run playwright-server