Token导航 LogoToken导航

MCP Server · 浏览器工具

Playwright Browser Automation

一个基于FastAPI和Google Gemini AI的生产级服务,用于智能自动化网页搜索和操作,支持导航、搜索、滚动和信息提取。

stdio官方级别未说明来源级核验工具 6
浏览器自动化Python异步处理智能搜索

快速开始

作者 / 组织
snehanshu-raj
提供方
snehanshu-raj
运行时
Python

工具数量

6

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

0

仓库热度

收录来源

1 个

MCP World

选型结论

Playwright Browser Automation 属于浏览器工具类 MCP Server,公开资料标注 6 个工具,通过stdio 本地进程接入,客户端适配情况以官方文档为准,有可以直接复制的安装命令;接入前要先准备 API Key。

分类

浏览器工具

传输方式

stdio

认证方式

API Key

部署方式

公开资料未说明

安装与配置

安装命令

python3 main.py

客户端配置示例

{
  "mcpServers": {
    "playwright-browser-automation": {
      "command": "python3",
      "args": [
        "main.py"
      ]
    }
  }
}

按公开安装命令拼出来的示例,字段名和参数以仓库 README 为准;带 YOUR_API_KEY 这类占位符的位置记得换成自己的值。

上手步骤

  1. 1

    准备运行环境

    stdio 服务在本地起进程,需要先装好 Python,再按安装命令拉取依赖。

  2. 2

    安装服务

    复制下面的安装命令执行;命令里带占位符的位置换成自己的密钥或路径。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 6 个工具,随便调一个只读工具确认能返回结果。

接入前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

详细介绍

人工智能浏览器自动化API

智能网络自动化 -使用Gemini LLM+剧作家MCP

一项生产就绪的FastAPI服务,使用谷歌的Gemini AI智能自动化网络搜索和自动化。代理可以导航、搜索、滚动和提取信息,无需人工干预。

______________________________________________________________________

特性

  • 亚马逊优化:专门为Amazon.com工作流程设计的提示
  • 智能产品搜索:自动搜索和查找产品
  • 价格提取:从搜索结果中提取准确的定价
  • 智能滚动:动态滚动以加载更多产品
  • RESTful API:用于自动化任务的简单HTTP端点
  • 实时跟踪:使用详细的执行日志监控任务进度
  • 异步处理:使用FastAPI执行后台任务

______________________________________________________________________

快速演示

目标: *“去亚马逊找到第五台笔记本电脑的价格”*

结果:代理人自主:

  1. 导航到Amazon.com
  2. 在搜索框中填写“笔记本电脑”
  3. 点击搜索按钮
  4. 向下滚动3次以加载更多结果
  5. 摘录第五台笔记本电脑的价格: $379.99

全力以赴 8次迭代 和 约15秒!

______________________________________________________________________

建筑

playwright-browser-automation/
├── agent.py                    # Core automation engine with error handling
├── main.py                     # FastAPI server with async task management
├── prompt.py                   # Amazon-optimized system prompt
├── install.sh                  # One-click setup script
├── .env                        # Configuration (Gemini API key)
└── requirements.txt            # Python dependencies

关键设计原则

  • 网站特定提示:系统提示 prompt.py 已优化 仅限Amazon.com。这使得代理在亚马逊产品搜索中非常精确,但需要对其他网站进行及时修改。
  • 可配置用于其他站点想让eBay或沃尔玛自动化吗?只需修改 prompt.py 使用特定于站点的选择器和模式。

______________________________________________________________________

安装

先决条件

  • Python 3.12+
  • Node.js 20+(用于Playwright MCP服务器)
  • Gemini API密钥(在这里买一个)

设置命令

  1. 克隆仓库
git clone https://github.com/snehanshu-raj/playwright-browser-automation.git
cd playwright-browser-automation
  1. 运行安装脚本
chmod +x install.sh
./install.sh
  1. 重要提示:将Gemini API密钥添加到.env文件
echo "GEMINI_API_KEY=your_api_key_here" > .env
  1. 启动API服务器
python3 main.py
  • 就是这样!您的API现在正在运行 http://localhost:8000
  • 斯瓦格: http://localhost:8000/docs

______________________________________________________________________

用法

1.提交自动化任务

curl -X POST http://localhost:8000/automate \
-H "Content-Type: application/json" \
-d '{
"goal": "Go to Amazon and find the price of the first laptop",
"max_iterations": 15
}'

答复:

{
"task_id": "abc-123-def-456",
"status": "pending",
"message": "Task submitted successfully. Check status at /task/abc-123-def-456"
}
您将看到浏览器自动打开,然后您的查询将逐步执行。

2.检查任务状态

curl http://localhost:8000/task/abc-123-def-456

答复:

{
"task_id": "abc-123-def-456",
"status": "completed",
"goal": "Go to Amazon and find the price of the first laptop",
"result": "The price is \$899.00",
"iterations_used": 5,
"started_at": "2025-10-19T09:00:01",
"completed_at": "2025-10-19T09:00:15",
"history": [
    "playwright_navigate succeeded",
    "playwright_fill succeeded",
    "playwright_click succeeded",
    "playwright_evaluate returned: \"899.\""
],
"execution_log": [...]
}

3.交互式API文档

也可以通过Swagger尝试:服务器运行时访问的URL:

  • Swagger 用户界面: http://localhost:8000/docs

______________________________________________________________________

重要:使用 每次部署一个网站 为了获得最大的精度。LLM在专注、针对特定地点的指导下表现最佳。

______________________________________________________________________

API终点

方法端点描述
GET/API信息和示例
POST/automate提交自动化任务
GET/task/{task_id}获取任务状态和结果
GET/tasks列出所有任务
DELETE/task/{task_id}删除任务
GET/health健康检查

______________________________________________________________________

项目结构

.
├── agent.py               # Automation engine
│   ├── run_agent()        # Main execution loop
│   ├── Error handling     # Retry logic and failure recovery
│   └── Tool calling       # Playwright tool orchestration
│ 
├── .env                   # Your Gemini API key goes here
│ 
├── main.py                # FastAPI application
│   ├── Background tasks   # Async task processing
│   ├── REST endpoints     # API routes
│   └── Task management    # Status tracking
│
├── prompt.py              # AI System Prompt
│   ├── Tool descriptions  # Available Playwright actions
│   ├── Site selectors     # Amazon-specific patterns
│   ├── Scrolling rules    # Scroll behavior
│   └── Decision logic     # When to stop/continue
│
└── install.sh             # Setup automation script

完整流程(一目了然):

┌─────────────────────────────────────────────────────────────────────────┐
│                            USER REQUEST                                 │
│  curl -X POST /automate -d '{"goal": "Find laptop price on Amazon"}'    │
└────────────────────────────────┬────────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                         FASTAPI SERVER (main.py)                        │
│  • Receives HTTP request                                                │
│  • Generates unique task_id                                             │
│  • Creates task entry in memory store                                   │
│  • Spawns background task                                               │
│  • Returns 200 OK with task_id immediately                              │
└────────────────────────────────┬────────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                    BACKGROUND TASK EXECUTOR                             │
│  • Calls run_agent(goal, max_iterations)                                │
│  • Initializes log_callback for real-time logging                       │
│  • Updates task status: pending → running                               │
└────────────────────────────────┬────────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                      AGENT ENGINE (agent.py)                            │
│  ┌─────────────────────────────────────────────────────────────┐        │
│  │  INITIALIZATION                                             │        │
│  │  • Connect to Playwright MCP Server (via npx)               │        │
│  │  • Load tools (32 Playwright automation tools)              │        │
│  │  • Load SYSTEM_PROMPT_MANUAL from prompt.py                 │        │
│  └─────────────────────────────────────────────────────────────┘        │
│                                 │                                       │
│                                 ▼                                       │
│  ┌─────────────────────────────────────────────────────────────┐        │
│  │  ITERATION LOOP (max 15 iterations be deafult)              │        │
│  │                                                             │        │
│  │  FOR i in range(max_iterations):                            │        │
│  │    1. Build prompt with:                                    │        │
│  │       - System instructions (Amazon-specific)               │        │
│  │       - User goal                                           │        │
│  │       - Previous action history (last 3 steps)              │        │
│  │       - Reminder to return FINAL_ANSWER when done           │        │
│  │                                                             │        │
│  │    2. Call Gemini 2.0 Flash Lite API                        │        │
│  │       → Returns: TOOL_CALL or FINAL_ANSWER                  │        │
│  │                                                             │        │
│  │    3. Parse response:                                       │        │
│  │       - Extract tool_name and parameters                    │        │
│  │       - Split on "|" delimiter (except playwright_evaluate) │        │
│  │                                                             │        │
│  │    4. Execute tool via MCP:                                 │        │
│  │       session.call_tool(tool_name, args)                    │        │
│  │                                                             │        │
│  │    5. Capture result and update history                     │        │
│  │       - Log to callback for API tracking                    │        │
│  │       - Detect failures/success                             │        │
│  │       - Append to action history                            │        │
│  │                                                             │        │
│  │    6. Check termination:                                    │        │
│  │       IF "FINAL_ANSWER:" in response:                       │        │
│  │         → Extract answer and RETURN                         │        │
│  │       ELSE:                                                 │        │
│  │         → Continue to next iteration                        │        │
│  └─────────────────────────────────────────────────────────────┘        │
└────────────────────────────────┬────────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│               PLAYWRIGHT MCP SERVER (Node.js)                           │
│  • Running as child process via npx                                     │
│  • Manages Chromium browser instance (headless in Docker via xvfb)      │
│  • Provides 32 tools:                                                   │
│    - playwright_navigate                                                │
│    - playwright_fill                                                    │
│    - playwright_click                                                   │
│    - playwright_evaluate (JavaScript execution)                         │
│    - playwright_screenshot                                              │
│    - etc.                                                               │
└────────────────────────────────┬────────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                      CHROMIUM BROWSER                                   │
│  • Launches via Playwright                                              │
│  • Navigates to Amazon.com                                              │
│  • Executes DOM interactions:                                           │
│    - Fill search box: input[id="twotabsearchtextbox"]                   │
│    - Click search: input[id="nav-search-submit-button"]                 │
│    - Scroll: window.scrollBy(0, 800)                                    │
│    - Extract price: document.querySelector('.a-price-whole')            │
└────────────────────────────────┬────────────────────────────────────────┘
                                 │
                                 ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                       GEMINI AI (LLM)                                   │
│  Model: gemini-2.0-flash-lite                                           │
│  • Receives prompt with:                                                │
│    - Goal: "Find laptop price on Amazon"                                │
│    - Available tools                                                    │
│    - Action history                                                     │
│  • Reasons about next action                                            │
│  • Returns structured response:                                         │
│    TOOL_CALL: playwright_navigate | https://amazon.com                  │
│    TOOL_CALL: playwright_fill | input[id="..."] | laptop                │
│    TOOL_CALL: playwright_evaluate | document.querySelector(...)         │
│    FINAL_ANSWER: The price is $899.00                                   │
└─────────────────────────────────────────────────────────────────────────┘
                                 │
                    ┌────────────┴────────────┐
                    ▼                         ▼
        ┌───────────────────────┐  ┌──────────────────────┐
        │   SUCCESS PATH        │  │   FAILURE PATH       │
        │                       │  │                      │
        │ • Extract result      │  │ • Retry with alt     │
        │ • Update task status  │  │   approach           │
        │ • Return to user      │  │ • Log failure        │
        │                       │  │ • Continue loop      │
        └───────────────────────┘  └──────────────────────┘
                    │
                    ▼
┌─────────────────────────────────────────────────────────────────────────┐
│                           API RESPONSE                                  │
│  GET /task/{task_id}                                                    │
│  {                                                                      │
│    "task_id": "abc-123",                                                │
│    "status": "completed",                                               │
│    "result": "The price is $899.00",                                    │
│    "iterations_used": 5,                                                │
│    "history": ["Navigate", "Fill", "Click", "Extract"],                 │
│    "execution_log": [...]                                               │
│  }                                                                      │
└─────────────────────────────────────────────────────────────────────────┘

______________________________________________________________________

工具与能力

工具数量

6

资源数量

0

提示词数量

0

能力标签

网页自动化Python本地部署智能搜索价格提取RESTfulAPI异步处理

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

自动操作网页

打开页面、点击、填表,把浏览器动作交给模型执行。

抓结构化数据

把页面内容整理成表格或 JSON,省掉手工复制粘贴。

走一遍关键流程

按步骤检查页面是否正常,回归时少漏环节。

选择建议

值得选的地方

  • 只提供 6 个工具,职责集中,接入后不容易误操作。
  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • stdio 方式要求本地装好 Python,换机器要重新装一遍。
  • 需要自备API Key,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在浏览器工具场景里让模型直接调用外部能力的人。
  • 想先快速试一下、能接受在本地跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 暂时拿不到API Key的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Playwright Browser Automation

MCP World · 本页

6stdio有1 个2026-05-17
Fetch 9a2682de

MCP.so

1SSE有3 个2026-05-17
Browser 738d52bc

MCP World

0stdio有1 个2026-05-17
Playwright MCP Server

MCP.so

21stdio有4 个2026-05-17
Skyvern MCP

MCP World

0stdio有2 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Playwright Browser Automation 怎么安装?

公开资料给出的安装命令是 python3 main.py,运行环境为 Python。装完后按客户端要求写进 MCP 配置,重启客户端生效。

Playwright Browser Automation 怎么在 Claude Desktop、Cursor 里配置?

它是stdio 本地进程,客户端配置里要写启动命令和参数,运行环境是 Python;保存后完全退出客户端再打开,配置才会生效。

Playwright Browser Automation 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Playwright Browser Automation 需要 API Key 吗?

公开资料标注的认证方式是API Key,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

Playwright Browser Automation 支持哪些客户端?

公开资料没有标注具体客户端;能配置本地 MCP 命令的客户端都能接,配置方式参照官方文档。

来源信息

继续浏览同类 MCP