Puppeteer MCP 服务器(Python 实现)
一个模型上下文协议 (MLM) 服务器,使用 Playwright(Python 版 Puppeteer)提供浏览器自动化功能。该服务器使 LLM 能够在真实的浏览器环境中与网页交互、截取屏幕截图并执行 JavaScript。
概述
此 Python 实现提供了 TypeScript 版本的稳定替代方案,在提供相同功能的同时,还改进了错误处理和日志记录功能。它使用了 Playwright(相当于 Puppeteer 的 Python 版本),提供强大的浏览器自动化功能。
主要特点
- 完全浏览器自动化
- 页面导航
- 屏幕截图(整页或元素)
- 表单交互(点击和填写)
- JavaScript 执行
- 控制台日志监控
- 可配置超时
- 详细的错误处理
- 综合日志记录
先决条件
- Python 3.8+
- pip(Python 包安装程序)
安装
- 安装所需的软件包:
- 安装 Playwright 浏览器:
用法
启动服务器
直接运行服务器:
Claude桌面配置
将其添加到您的 Claude 配置文件中:
可用工具
puppeteer_navigate
导航到浏览器中的任意 URL。
puppeteer_screenshot
捕获整个页面或特定元素的屏幕截图。
puppeteer_click
单击页面上的元素。
puppeteer_fill
填写输入字段。
puppeteer_evaluate
在浏览器控制台中执行 JavaScript。
错误处理
服务器提供了常见场景的详细错误信息:
- 导航失败
- 未找到元素
- 超时错误
- JavaScript 执行错误
- 截图失败
日志记录
全面的日志记录以不同的级别实现:
- 信息:标准操作
- 错误:操作失败
- DEBUG:详细的执行信息
笔记
- 浏览器以非无头模式启动,以便更好地调试
- 默认视口尺寸为 1280x720
- 所有超时都是可配置的
- 捕获并存储控制台日志
- 屏幕截图以base64编码存储在内存中
贡献
欢迎贡献!提交拉取请求之前,请阅读代码库的贡献指南。
执照
该项目根据 Apache 2.0 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that provides browser automation capabilities using Playwright. This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.Last updated -139,4573,642TypeScriptMIT License
- AsecurityFlicenseAqualityA server that enables browser automation using Playwright, allowing interaction with web pages, capturing screenshots, and executing JavaScript in a browser environment through LLMs.Last updated -129,4571TypeScript
- -securityFlicense-qualityA Model Context Protocol server that provides browser automation capabilities using BrowserCat's cloud browser service. This server enables LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment without needing to install browsers locally.Last updated -39
- -securityFlicense-qualityA Model Context Protocol server that provides browser automation capabilities using Puppeteer, enabling LLMs to interact with web pages, take screenshots, and execute JavaScript in a real browser environment.Last updated -15,502JavaScript