Skip to content

Commit a7b9c1c

Browse files
authored
Merge pull request #12 from co-browser/9-add-action-to-publish-to-github-packages
feat: 9 add action to publish to GitHub packages & refactor server into library
2 parents f122dc5 + af7120e commit a7b9c1c

File tree

13 files changed

+2039
-174
lines changed

13 files changed

+2039
-174
lines changed

.cursor/mcp.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"mcpServers": {
3-
"browser-use-mcp=server": {
3+
"browser-use-mcp-server": {
44
"url": "http://localhost:8000/sse"
55
}
66
}

.env.example

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
OPENAI_API_KEY=sk
2-
CHROME_PATH=/usr/bin/chromium
1+
# Path to Chrome/Chromium executable leave blank to use default playwright chromium
2+
CHROME_PATH=
3+
4+
# OpenAI API key for OpenAI model access
5+
OPENAI_API_KEY=your-api-key-here

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ on:
77
workflow_dispatch:
88

99
concurrency:
10-
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || github.sha }}
10+
group: ${{ github.workflow }}-${{ github.ref_name }}-${{
11+
github.event.pull_request.number || github.sha }}
1112
cancel-in-progress: true
1213

1314
env:
@@ -70,7 +71,8 @@ jobs:
7071
run: uvx ruff check .
7172

7273
- name: "Validate project metadata"
73-
run: uvx --from 'validate-pyproject[all,store]' validate-pyproject pyproject.toml
74+
run: uvx --from 'validate-pyproject[all,store]' validate-pyproject
75+
pyproject.toml
7476

7577
build-and-publish:
7678
runs-on: ubuntu-latest

Dockerfile

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
FROM ghcr.io/astral-sh/uv:bookworm-slim AS builder
22

3-
ARG VNC_PASSWORD=browser-use
4-
53
ENV UV_COMPILE_BYTECODE=1 \
64
UV_LINK_MODE=copy \
75
UV_PYTHON_INSTALL_DIR=/python \
@@ -26,6 +24,8 @@ RUN --mount=type=cache,target=/root/.cache/uv \
2624

2725
FROM debian:bookworm-slim AS runtime
2826

27+
ARG VNC_PASSWORD="browser-use"
28+
2929
# Install required packages including Chromium and clean up in the same layer
3030
RUN apt-get update && \
3131
apt-get install --no-install-recommends -y \
@@ -56,15 +56,19 @@ COPY --from=builder --chown=app:app /app /app
5656
ENV PATH="/app/.venv/bin:$PATH" \
5757
DISPLAY=:0 \
5858
CHROME_BIN=/usr/bin/chromium \
59-
CHROMIUM_FLAGS="--no-sandbox --headless --disable-gpu --disable-software-rasterizer --disable-dev-shm-usage"
59+
CHROMIUM_FLAGS="--no-sandbox --headless --disable-gpu --disable-software-rasterizer --disable-dev-shm-usage" \
60+
CHROME_PATH="/usr/bin/chromium"
6061

6162
# Combine VNC setup commands to reduce layers
6263
RUN mkdir -p ~/.vnc && \
63-
echo ${VNC_PASSWORD} | vncpasswd -f > /root/.vnc/passwd && \
64+
echo $VNC_PASSWORD | vncpasswd -f > /root/.vnc/passwd && \
6465
chmod 600 /root/.vnc/passwd && \
6566
printf '#!/bin/sh\nunset SESSION_MANAGER\nunset DBUS_SESSION_BUS_ADDRESS\nstartxfce4' > /root/.vnc/xstartup && \
6667
chmod +x /root/.vnc/xstartup && \
67-
printf '#!/bin/bash\nvncserver -depth 24 -geometry 1920x1080 -localhost no -PasswordFile /root/.vnc/passwd :0\nproxy-login-automator\npython /app/server --transport sse --port 8000' > /app/boot.sh && \
68+
printf '#!/bin/bash\nvncserver -depth 24 -geometry 1920x1080 -localhost no -PasswordFile /root/.vnc/passwd :0\nproxy-login-automator\npython /app/server --port 8000' > /app/boot.sh && \
6869
chmod +x /app/boot.sh
6970

71+
72+
EXPOSE 8000
73+
7074
ENTRYPOINT ["/bin/bash", "/app/boot.sh"]

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ curl -LsSf https://astral.sh/uv/install.sh | sh
1717
uv sync
1818
uv pip install playwright
1919
uv run playwright install --with-deps --no-shell chromium
20-
uv run server --transport sse --port 8000
20+
uv run server --port 8000
2121
```
2222

2323
- the .env requires the following:
@@ -36,6 +36,12 @@ when building the dockerfile you can add in your own VNC server password:
3636
docker build --build-arg VNC_PASSWORD=klaatubaradanikto .
3737
```
3838

39+
### tools
40+
41+
- [x] SSE transport
42+
- [x] browser_use - Initiates browser tasks with URL and action
43+
- [x] browser_get_result - Retrieves results of async browser tasks
44+
3945
### supported clients
4046

4147
- cursor.ai
@@ -79,3 +85,11 @@ then try asking your LLM the following:
7985
### help
8086

8187
for issues or interest reach out @ https://cobrowser.xyz
88+
89+
# stars
90+
91+
<picture>
92+
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date&theme=dark" />
93+
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" />
94+
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=co-browser/browser-use-mcp-server&type=Date" />
95+
</picture>

pyproject.toml

Lines changed: 63 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
15
[project]
26
name = "browser-use-mcp-server"
3-
version = "0.1.2"
4-
description = "MCP browser-use server"
7+
version = "0.1.3"
8+
description = "MCP browser-use server library"
59
readme = "README.md"
6-
requires-python = ">=3.13"
10+
requires-python = ">=3.11,<4.0"
11+
authors = [
12+
{name = "Cobrowser Team"}
13+
]
14+
classifiers = [
15+
"Programming Language :: Python :: 3",
16+
"Operating System :: OS Independent",
17+
]
718
dependencies = [
819
"asyncio>=3.4.3",
920
"browser-use>=0.1.40",
@@ -12,4 +23,53 @@ dependencies = [
1223
"langchain-openai>=0.3.1",
1324
"mcp>=1.3.0",
1425
"pydantic>=2.10.6",
26+
"anyio",
27+
"python-dotenv",
28+
"starlette",
29+
"uvicorn",
30+
"playwright>=1.50.0",
31+
]
32+
33+
[project.optional-dependencies]
34+
dev = [
35+
"pytest>=7.0.0",
36+
"pytest-asyncio>=0.21.0",
37+
"black>=23.0.0",
38+
"isort>=5.12.0",
39+
"mypy>=1.0.0",
40+
]
41+
test = [
42+
"pytest>=7.0.0",
43+
"pytest-asyncio>=0.21.0",
44+
"pytest-cov>=4.1.0",
1545
]
46+
47+
[project.urls]
48+
"Homepage" = "https://github.com/cobrowser/browser-use-mcp-server"
49+
"Bug Tracker" = "https://github.com/cobrowser/browser-use-mcp-server/issues"
50+
51+
[tool.pytest.ini_options]
52+
testpaths = ["tests"]
53+
python_files = "test_*.py"
54+
asyncio_mode = "auto"
55+
56+
[tool.black]
57+
line-length = 88
58+
target-version = ["py311"]
59+
60+
[tool.isort]
61+
profile = "black"
62+
line_length = 88
63+
64+
[tool.mypy]
65+
python_version = "3.11"
66+
warn_return_any = true
67+
warn_unused_configs = true
68+
disallow_untyped_defs = true
69+
disallow_incomplete_defs = true
70+
71+
[project.scripts]
72+
browser-use-mcp-server = "browser_use_mcp_server.cli:cli"
73+
74+
[tool.hatch.build]
75+
packages = ["src/browser_use_mcp_server"]

server/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .server import main
2+
3+
__all__ = ["main"]

0 commit comments

Comments
 (0)