|
|
| MseeP.ai Security Assessment | 特别感谢Warp,开发者的AI终端 |
Playwright MCP Server 🎭
一个使用Playwright提供浏览器自动化功能的模型上下文协议服务器。该服务器使LLM能够与网页交互、截图、生成测试代码、抓取网页内容并在真实浏览器环境中执行JavaScript。
截图

文档 | API参考
安装
您可以使用npm、mcp-get或Smithery来安装此包:
使用npm:
npm install -g @executeautomation/playwright-mcp-server
使用mcp-get:
npx @michaellatman/mcp-get@latest install @executeautomation/playwright-mcp-server
使用Smithery
通过Smithery自动安装Claude桌面版的Playwright MCP:
npx @smithery/cli install @executeautomation/playwright-mcp-server --client claude
VS Code中的安装
使用以下按钮之一在VS Code中安装Playwright MCP服务器:
或者,您可以使用VS Code CLI安装Playwright MCP服务器:
# 对于VS Code
code --add-mcp '{"name":"playwright","command":"npx","args":["@executeautomation/playwright-mcp-server"]}'
# 对于VS Code Insiders
code-insiders --add-mcp '{"name":"playwright","command":"npx","args":["@executeautomation/playwright-mcp-server"]}'
安装后,ExecuteAutomation Playwright MCP服务器将在VS Code中可用于您的GitHub Copilot代理。
使用Playwright服务器的配置
以下是Claude桌面版使用Playwright服务器的配置:
{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@executeautomation/playwright-mcp-server"]
}
}
}
测试
该项目使用Jest进行测试。测试位于src/__tests__目录中。
运行测试
您可以使用以下命令运行测试:
# 使用自定义脚本运行测试(带覆盖率)
node run-tests.cjs
# 使用npm脚本运行测试
npm test # 不带覆盖率的测试
npm run test:coverage # 带覆盖率的测试
npm run test:custom # 使用自定义脚本运行测试(与node run-tests.cjs相同)
测试覆盖率报告将生成在coverage目录中。
运行evals
evals包加载一个mcp客户端,然后运行index.ts文件,因此测试之间无需重新构建。您可以通过在npx命令前缀环境变量来加载环境变量。完整文档可参考此处。
OPENAI_API_KEY=your-key npx mcp-eval src/evals/evals.ts src/tools/codegen/index.ts
贡献
添加新工具时,请留意工具名称的长度。某些客户端(如Cursor)对服务器和工具名称的合并长度有60个字符的限制(server_name:tool_name)。
我们的服务器名称是playwright-mcp。请确保您的工具名称足够简短,以免超过此限制。
