MCP网页浏览器服务器
一个为模型上下文协议(MCP)设计的高级网页浏览服务器,基于Playwright实现无头浏览器交互。
快速入门
前置条件
- Python 3.10+
- 安装 MCP SDK 和 Playwright
安装步骤
- 安装依赖: pip install mcp playwright
- 安装浏览器支持: playwright install
配置示例
在 claude_desktop_config.json
文件中添加以下内容:
{
"mcpServers": {
"web-browser": {
"command": "python",
"args": ["/path/to/your/server.py"]
}
}
}
示例用法
网页导航
page_content = browse_to("https://example.com")
提取文本
text_content = extract_text_content()
截图
get_page_screenshots(full_page=True)
多标签管理
tab_id = create_new_tab("https://example.com") switch_tab(tab_id) close_tab(tab_id)
更多功能请参考文档。