分步实施指南
针对服务器无GUI环境,可采用客户端-服务器架构:
- preparatory phase::
- 在有显示器的机器运行npx playwright run-server
- 记录输出的WebSocket地址(如ws://localhost:8080/)
- Configuring the MCP Client::
{
"mcpServers": {
"playwright": {
"env": {"PLAYWRIGHT_WS_ENDPOINT": "ws://YOUR_IP:PORT/"}
}
}
} - Verify Connection::
- utilizationbrowser_navigateTesting Basic Functionality
- pass (a bill or inspection etc)–headless参数确保后台运行
caveat::
• 防火墙需开放对应端口
• 建议使用screen/tmux保持会话持久化
• 网页渲染依赖Xvfb等虚拟帧缓冲区时,需预先安装
This answer comes from the articlePlaywright MCP: Browser Automation MCP Service from MicrosoftThe