Skip to content

Commit ad471cc

Browse files
authored
Merge pull request #31 from co-browser/dev-rebased
Dev rebased
2 parents 1aeec10 + 52bfa52 commit ad471cc

File tree

8 files changed

+502
-82
lines changed

8 files changed

+502
-82
lines changed

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ CHROME_PATH=
55
OPENAI_API_KEY=your-api-key-here
66

77
# Set to true if you want api calls to wait for tasks to complete (default is false)
8-
PATIENT=false
8+
PATIENT=false
9+
10+
# Set to true if you want to disable anonymous telemetry (default is false)
11+
ANONYMIZED_TELEMETRY=false

README.md

Lines changed: 160 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,71 @@
1-
# ➡️ browser-use mcp server
1+
# browser-use-mcp-server
22

3-
[browser-use](https://github.com/browser-use/browser-use) MCP Server with SSE
4-
transport
3+
<div align="center">
54

6-
### requirements
5+
[![Twitter URL](https://img.shields.io/twitter/url/https/twitter.com/cobrowser.svg?style=social&label=Follow%20%40cobrowser)](https://x.com/cobrowser)
6+
[![PyPI version](https://badge.fury.io/py/browser-use-mcp-server.svg)](https://pypi.org/project/browser-use-mcp-server/)
77

8-
- uv
8+
**An MCP server that enables AI agents to control web browsers using
9+
[browser-use](https://github.com/browser-use/browser-use).**
910

10-
```
11-
curl -LsSf https://astral.sh/uv/install.sh | sh
12-
```
11+
</div>
1312

14-
### quickstart
13+
## Prerequisites
1514

16-
```
17-
uv sync
18-
uv pip install playwright
19-
uv run playwright install --with-deps --no-shell chromium
20-
uv run server --port 8000
21-
```
22-
23-
- the .env requires the following:
15+
- [uv](https://github.com/astral-sh/uv) - Fast Python package manager
16+
- [Playwright](https://playwright.dev/) - Browser automation
17+
- [mcp-proxy](https://github.com/sparfenyuk/mcp-proxy) - Required for stdio mode
2418

25-
```
26-
OPENAI_API_KEY=[your api key]
27-
CHROME_PATH=[only change this if you have a custom chrome build]
28-
PATIENT=false # Set to true if you want api calls to wait for tasks to complete (default is false)
19+
```bash
20+
# Install prerequisites
21+
curl -LsSf https://astral.sh/uv/install.sh | sh
22+
uv tool install mcp-proxy
23+
uv tool update-shell
2924
```
3025

31-
- we will be adding support for other LLM providers to power browser-use
32-
(claude, grok, bedrock, etc)
26+
## Environment
3327

34-
when building the docker image, you can use Docker secrets for VNC password:
28+
Create a `.env` file:
3529

3630
```
37-
# With Docker secrets (recommended for production)
38-
echo "your-secure-password" > vnc_password.txt
39-
docker run -v $(pwd)/vnc_password.txt:/run/secrets/vnc_password your-image-name
40-
41-
# Or during development with the default password
42-
docker build .
31+
OPENAI_API_KEY=your-api-key
32+
CHROME_PATH=optional/path/to/chrome
33+
PATIENT=false # Set to true if API calls should wait for task completion
4334
```
4435

45-
### tools
36+
## Installation
4637

47-
- [x] SSE transport
48-
- [x] browser_use - Initiates browser tasks with URL and action
49-
- [x] browser_get_result - Retrieves results of async browser tasks
50-
- [x] VNC server - stream the dockerized browser to your client
38+
```bash
39+
# Install dependencies
40+
uv sync
41+
uv pip install playwright
42+
uv run playwright install --with-deps --no-shell chromium
43+
```
5144

52-
### VNC
45+
## Usage
5346

54-
the dockerfile has a vnc server with a default password of browser-use. connect
55-
to it:
47+
### SSE Mode
5648

57-
```
58-
docker build -t browser-use-mcp-server .
59-
docker run --rm -p8000:8000 -p5900:5900 browser-use-mcp-server
60-
git clone https://github.com/novnc/noVNC
61-
cd noVNC
62-
./utils/novnc_proxy --vnc localhost:5900
49+
```bash
50+
# Run directly from source
51+
uv run server --port 8000
6352
```
6453

65-
<p align="center">
66-
<img width="428" alt="Screenshot 2025-03-24 at 12 03 15 PM" src="https://github.com/user-attachments/assets/45bc5bee-418d-4182-94f5-db84b4fc0b3a" />
67-
<br>
68-
<img width="428" alt="Screenshot 2025-03-24 at 12 11 42 PM" src="https://github.com/user-attachments/assets/7db53f41-fc00-4e48-8892-f7108096f9c4" />
69-
</p>
54+
### stdio Mode
7055

71-
### supported clients
56+
```bash
57+
# 1. Build and install globally
58+
uv build
59+
uv tool uninstall browser-use-mcp-server 2>/dev/null || true
60+
uv tool install dist/browser_use_mcp_server-*.whl
7261

73-
- cursor.ai
74-
- claude desktop
75-
- claude code
76-
- <s>windsurf</s> ([windsurf](https://codeium.com/windsurf) doesn't support SSE
77-
yet)
62+
# 2. Run with stdio transport
63+
browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000
64+
```
7865

79-
### usage
66+
## Client Configuration
8067

81-
after running the server, add http://localhost:8000/sse to your client UI, or in
82-
a mcp.json file:
68+
### SSE Mode
8369

8470
```json
8571
{
@@ -91,31 +77,130 @@ a mcp.json file:
9177
}
9278
```
9379

94-
#### cursor
80+
### stdio Mode
9581

96-
- `./.cursor/mcp.json`
82+
```json
83+
{
84+
"mcpServers": {
85+
"browser-server": {
86+
"command": "browser-use-mcp-server",
87+
"args": [
88+
"run",
89+
"server",
90+
"--port",
91+
"8000",
92+
"--stdio",
93+
"--proxy-port",
94+
"9000"
95+
],
96+
"env": {
97+
"OPENAI_API_KEY": "your-api-key"
98+
}
99+
}
100+
}
101+
}
102+
```
103+
104+
### Config Locations
105+
106+
| Client | Configuration Path |
107+
| ---------------- | ----------------------------------------------------------------- |
108+
| Cursor | `./.cursor/mcp.json` |
109+
| Windsurf | `~/.codeium/windsurf/mcp_config.json` |
110+
| Claude (Mac) | `~/Library/Application Support/Claude/claude_desktop_config.json` |
111+
| Claude (Windows) | `%APPDATA%\Claude\claude_desktop_config.json` |
112+
113+
## Features
114+
115+
- [x] **Browser Automation**: Control browsers through AI agents
116+
- [x] **Dual Transport**: Support for both SSE and stdio protocols
117+
- [x] **VNC Streaming**: Watch browser automation in real-time
118+
- [x] **Async Tasks**: Execute browser operations asynchronously
119+
120+
## Local Development
121+
122+
To develop and test the package locally:
123+
124+
1. Build a distributable wheel:
125+
126+
```bash
127+
# From the project root directory
128+
uv build
129+
```
130+
131+
2. Install it as a global tool:
132+
133+
```bash
134+
uv tool uninstall browser-use-mcp-server 2>/dev/null || true
135+
uv tool install dist/browser_use_mcp_server-*.whl
136+
```
137+
138+
3. Run from any directory:
139+
140+
```bash
141+
# Set your OpenAI API key for the current session
142+
export OPENAI_API_KEY=your-api-key-here
97143

98-
#### windsurf
144+
# Or provide it inline for a one-time run
145+
OPENAI_API_KEY=your-api-key-here browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000
146+
```
99147

100-
- `~/.codeium/windsurf/mcp_config.json`
148+
4. After making changes, rebuild and reinstall:
149+
```bash
150+
uv build
151+
uv tool uninstall browser-use-mcp-server
152+
uv tool install dist/browser_use_mcp_server-*.whl
153+
```
101154

102-
#### claude
155+
## Docker
103156

104-
- `~/Library/Application Support/Claude/claude_desktop_config.json`
105-
- `%APPDATA%\Claude\claude_desktop_config.json`
157+
```bash
158+
# Run with default VNC password
159+
docker build -t browser-use-mcp-server .
160+
docker run --rm -p8000:8000 -p5900:5900 browser-use-mcp-server
161+
162+
# Use custom VNC password
163+
echo "your-password" > vnc_password.txt
164+
docker run --rm -p8000:8000 -p5900:5900 \
165+
-v $(pwd)/vnc_password.txt:/run/secrets/vnc_password \
166+
browser-use-mcp-server
167+
```
168+
169+
### VNC Viewer
170+
171+
```bash
172+
# Browser-based viewer
173+
git clone https://github.com/novnc/noVNC
174+
cd noVNC
175+
./utils/novnc_proxy --vnc localhost:5900
176+
```
177+
178+
Default password: `browser-use`
179+
180+
<div align="center">
181+
<img width="428" alt="VNC Screenshot" src="https://github.com/user-attachments/assets/45bc5bee-418d-4182-94f5-db84b4fc0b3a" />
182+
<br><br>
183+
<img width="428" alt="VNC Screenshot" src="https://github.com/user-attachments/assets/7db53f41-fc00-4e48-8892-f7108096f9c4" />
184+
</div>
106185

107-
then try asking your LLM the following:
186+
## Example
108187

109-
`open https://news.ycombinator.com and return the top ranked article`
188+
Try asking your AI:
189+
190+
```
191+
open https://news.ycombinator.com and return the top ranked article
192+
```
110193

111-
### help
194+
## Support
112195

113-
for issues or interest reach out @ https://cobrowser.xyz
196+
For issues or inquiries: [cobrowser.xyz](https://cobrowser.xyz)
114197

115-
# stars
198+
## Star History
116199

117-
<picture>
118-
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date&theme=dark" />
119-
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" />
120-
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" />
121-
</picture>
200+
<div align="center">
201+
<picture>
202+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date&theme=dark" />
203+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" />
204+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" />
205+
</picture>
206+
</div>

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies = [
2525
"pydantic>=2.10.6",
2626
"anyio",
2727
"python-dotenv",
28+
"python-json-logger>=2.0.7",
2829
"starlette",
2930
"uvicorn",
3031
"playwright>=1.50.0",
@@ -72,4 +73,8 @@ disallow_incomplete_defs = true
7273
browser-use-mcp-server = "browser_use_mcp_server.cli:cli"
7374

7475
[tool.hatch.build]
75-
packages = ["src/browser_use_mcp_server"]
76+
packages = ["src", "server"]
77+
include = ["server"]
78+
79+
[tool.hatch.build.targets.wheel]
80+
packages = ["src/browser_use_mcp_server", "server"]

0 commit comments

Comments
 (0)