网页自动化控制工具

一个基于FastMCP的网页自动化控制系统,提供导航、表单填写、点击交互、数据提取、截图、PDF生成和多标签管理等功能,适用于社交媒体自动化、电子商务流程、表单提交和数据抓取等工作流。

  • by unnikrishnan077
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 unnikrishnan077/mcp-web-automation-server

使用说明

mcp网络自动化服务器

使用FastMCP的基于MCP的web控制综合自动化系统。它提供了用于导航、表单填写、点击/交互、数据提取、屏幕截图、PDF生成和多标签管理的工具。包括社交媒体自动化、电子商务流程、表单提交、数据抓取工作流和报告生成的配置预设。

特性

  • 基于FastMCP的Python MCP服务器
  • 浏览器控件抽象(可插拔后端;TabManager内存中的占位符)
  • 工具:navigate_page、fill_form、click_element、extract_data、capture_screenshot、generate_pdf、new_tab、close_tab、list_tabs、go_back、run_workflow
  • 强大的日志记录和结构化错误处理
  • 具有中间结果的多步工作流运行器

项目结构

.
├── server.py
├── configs/
│   ├── social_media.yaml
│   ├── ecommerce.yaml
│   ├── form_submission.yaml
│   ├── scraping.yaml
│   └── reporting.yaml
├── examples/
│   └── sample_workflows.md
├── requirements.txt
├── claude_desktop_config.json
└── README.md

快速启动

  1. Python 3.10+
  2. 创建并激活venv
    • macOS/Linux: python3 -m venv .venv && source .venv/bin/activate
    • Windows(PowerShell): py -3 -m venv .venv; .venv\Scripts\Activate.ps1
  3. 安装deps: pip install -r requirements.txt
  4. 运行服务器: python server.py

通过MCP客户端使用

  • 配置您的MCP客户端(例如,Claude Desktop)以指向此服务器脚本。
  • 示例工具调用(YAML风格):
- tool: new_tab
  params: {url: https://example.com}
- tool: navigate_page
  params: {url: https://news.ycombinator.com, tab_id: tab-1}
- tool: fill_form
  params: {tab_id: tab-1, selectors_to_values: {input[name=q]: "fastmcp"}}
- tool: click_element
  params: {tab_id: tab-1, selector: "button[type=submit]"}
- tool: extract_data
  params: {tab_id: tab-1, selectors: [".result a.title", ".result .snippet"]}
- tool: capture_screenshot
  params: {tab_id: tab-1, full_page: true}
- tool: generate_pdf
  params: {tab_id: tab-1, landscape: false}
- tool: run_workflow
  params:
    steps:
      - {tool: new_tab, params: {url: https://example.com}}
      - {tool: navigate_page, params: {tab_id: tab-1, url: https://github.com}}
      - {tool: extract_data, params: {tab_id: tab-1, selectors: ["a"]}}

配置文件

有关种子工作流的特定任务预设,请参阅configs/目录。

日志记录

结构化日志打印到stdout。通过以下方式调整水平 LOGLEVEL env或编辑 logging.basicConfig 在server.py中。

路线图

  • 在Playwright自动化后端进行交换,以实现真正的浏览器控制
  • 添加身份验证助手和cookie jar支持
  • 为易受攻击的站点添加重试/回退策略和断路器
  • 工件的持久存储(屏幕截图、PDF、提取的数据)

许可证

在未来的提交中选择许可证(MIT/Apache-2.0)。