Files
tw2/examples/agent/browser_agent/README.md
codex-bot a64378956a
Some checks failed
Pre-commit / run (ubuntu-latest) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_en (ubuntu-latest, 3.10) (push) Has been cancelled
Deploy Sphinx documentation to Pages / build_zh (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (macos-15, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (ubuntu-latest, 3.12) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.10) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.11) (push) Has been cancelled
Python Unittest Coverage / test (windows-latest, 3.12) (push) Has been cancelled
chore: initialize sandbox and overwrite remote content
2026-03-02 22:32:27 +08:00

1.1 KiB

Browser Agent Example

This example demonstrates how to use AgentScope's BrowserAgent for web automation tasks. The BrowserAgent leverages the Model Context Protocol (MCP) to interact with browser tools powered by Playwright, enabling sophisticated web navigation, data extraction, and automation.

Prerequisites

  • Python 3.10 or higher
  • Node.js and npm (for the MCP server)
  • DashScope API key from Alibaba Cloud

Installation

Install AgentScope

# Install from source
cd {PATH_TO_AGENTSCOPE}
pip install -e .

Setup

1. Environment Configuration

Set up your DashScope API key:

export DASHSCOPE_API_KEY="your_dashscope_api_key_here"

You can obtain a DashScope API key from Alibaba Cloud DashScope Console.

2. About PlayWright MCP Server

Before running the browser agent, you can test whether you can start the Playwright MCP server:

npx @playwright/mcp@latest

Usage

Basic Example

You can start running the browser agent in your terminal with the following command

cd examples/agent/browser_agent
python main.py