# AgentScope Browser > A browser MCP server purpose-built for AI agents — reliable observation, safe element interaction, session persistence, and graceful failure recovery. [日本語](README.ja.md) ## Why Most browser automation tools were designed for humans writing deterministic scripts. AI agents need something different: - They shouldn't have to reason about CSS selectors or XPath - They need structured, semantic output — not raw HTML - They need to recover from failures rather than hard-crash - They need persistent sessions across runs without leaking credentials AgentScope Browser solves all of these. ## Features - **element_id-based interaction** — every observable element gets a stable `element_id`; the AI never sees a selector - **Semantic observation** — `observe_page` returns structured JSON describing what's on the page and what actions are possible - **Failure recovery** — `diagnose_failure` analyzes what went wrong and returns actionable next steps - **Session persistence** — login state (cookies, localStorage) saved and reloaded across sessions; credentials never returned to the model - **Safety flags** — destructive actions (submit, purchase, delete) return `requires_confirmation: true` before executing - **SSRF protection** — localhost and private IP ranges blocked by default ## Installation ```bash npm install npm run install-browsers # installs Chromium via Playwright npm run build ``` ## Claude Code / Claude Desktop Setup Add to `~/.claude/claude_desktop_config.json`: ```json { "mcpServers": { "agent-scope-browser": { "command": "node", "args": ["/path/to/agent-scope-browser/dist/server.js"] } } } ``` ## Tools | Tool | Description | |------|-------------| | `open_page` | Open a URL and get a `page_id` | | `observe_page` | Observe elements and content as structured JSON with `element_id`s | | `act_on_element` | Click, hover, or interact using an `element_id` | | `fill_form` | Fill form fields by `element_id` and optionally submit | | `extract_structured_data` | Extract data from a page according to a given schema | | `manage_session` | Save and restore login sessions | | `diagnose_failure` | Analyze a failure and return next-action suggestions | ## Usage ### Basic flow ``` 1. open_page → get page_id 2. observe_page → get element_id list 3. act_on_element → click a button 4. observe_page → confirm state change 5. fill_form → submit a form ``` ### Open a page and observe ```json // open_page { "url": "https://example.com", "session_id": "research-001" } // observe_page { "page_id": "page_abc123" } ``` ### Fill and submit a form ```json { "page_id": "page_abc123", "fields": [ { "element_id": "inp_email_0", "value": "test@example.com" }, { "element_id": "inp_password_0", "value": "mypassword" } ], "submit": true, "submit_element_id": "btn_login_0" } ``` ### Extract structured data ```json { "page_id": "page_abc123", "schema": { "company_name": "string", "email": "string", "phone": "string" } } ``` ## Session Management Login state persists across sessions. Credentials are never returned to the model. ```json // Open with session { "url": "https://example.com", "session_id": "my-login", "persist": true } // Save after login { "action": "save", "session_id": "my-login" } // Resume next time — already logged in { "url": "https://example.com/dashboard", "session_id": "my-login", "persist": true } ``` ## Environment Variables | Variable | Default | Description | |----------|---------|-------------| | `LOG_LEVEL` | `info` | Log level (debug/info/warn/error) | | `MAX_PAGES` | `20` | Max concurrent open pages | | `DEFAULT_TIMEOUT` | `30000` | Timeout in ms | ## Security - `localhost` and private IPs blocked (SSRF protection) - `file://` protocol disallowed - Cookies and tokens never included in AI responses - Destructive operations guarded by `requires_confirmation: true` - No CAPTCHA bypass ## License MIT