1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! # browser-use
//!
//! A Rust library for browser automation via Chrome DevTools Protocol (CDP), designed for AI agent integration.
//!
//! ## Features
//!
//! - **MCP Server**: Model Context Protocol server for AI-driven browser automation
//! - **Browser Session Management**: Launch or connect to Chrome/Chromium instances
//! - **Tool System**: High-level browser operations (navigate, click, input, extract, screenshot, etc.)
//! - **DOM Extraction**: Extract page structure with indexed interactive elements for AI-friendly targeting
//!
//! ## MCP Server
//!
//! The recommended way to use this library is via the Model Context Protocol (MCP) server,
//! which exposes browser automation tools to AI agents like Claude:
//!
//! ### Running the MCP Server
//!
//! ```bash
//! # Run headless browser
//! cargo run --bin mcp-server
//!
//! # Run with visible browser (useful for debugging)
//! cargo run --bin mcp-server -- --headed
//! ```
//!
//! ## Library Usage (Advanced)
//!
//! For direct integration in Rust applications:
//!
//! ### Basic Browser Automation
//!
//! ```rust,no_run
//! use browser_use::{BrowserSession, LaunchOptions};
//!
//! # fn main() -> browser_use::Result<()> {
//! // Launch a browser
//! let session = BrowserSession::launch(LaunchOptions::default())?;
//!
//! // Navigate to a page
//! session.navigate("https://example.com")?;
//!
//! // Extract DOM with indexed elements
//! let dom = session.extract_dom()?;
//! println!("Found {} interactive elements", dom.count_interactive());
//! # Ok(())
//! # }
//! ```
//!
//! ### Using the Tool System
//!
//! ```rust,no_run
//! use browser_use::{BrowserSession, LaunchOptions};
//! use browser_use::tools::{ToolRegistry, ToolContext};
//! use serde_json::json;
//!
//! # fn main() -> browser_use::Result<()> {
//! let session = BrowserSession::launch(LaunchOptions::default())?;
//! let registry = ToolRegistry::with_defaults();
//! let mut context = ToolContext::new(&session);
//!
//! // Navigate using the tool system
//! registry.execute("navigate", json!({"url": "https://example.com"}), &mut context)?;
//!
//! // Click an element by index
//! registry.execute("click", json!({"index": 5}), &mut context)?;
//! # Ok(())
//! # }
//! ```
//!
//! ### DOM Indexing for AI Agents
//!
//! The library automatically indexes interactive elements (buttons, links, inputs) with numeric IDs,
//! making it easier for AI agents to target elements without complex CSS selectors:
//!
//! ```rust,no_run
//! # use browser_use::{BrowserSession, LaunchOptions};
//! # fn main() -> browser_use::Result<()> {
//! # let session = BrowserSession::launch(LaunchOptions::default())?;
//! # session.navigate("https://example.com")?;
//! let dom = session.extract_dom()?;
//!
//! // Interactive elements are indexed and can be accessed via tools
//! println!("Found {} interactive elements", dom.count_interactive());
//! # Ok(())
//! # }
//! ```
//!
//! ## Module Overview
//!
//! - [`browser`]: Browser session management and configuration
//! - [`dom`]: DOM extraction, element indexing, and tree representation
//! - [`tools`]: Browser automation tools (navigate, click, input, extract, etc.)
//! - [`error`]: Error types and result aliases
//! - [`mcp`]: **Model Context Protocol server** (requires `mcp-handler` feature) - **Start here for AI integration**
pub use ;
pub use ;
pub use ;
pub use ;
pub use BrowserServer;
pub use ServiceExt;