Skip to content

Commit b93ceb9

Browse files
committed
Refactor server into a library for distribution as a PyPI package
1 parent f93d8e0 commit b93ceb9

File tree

11 files changed

+1912
-492
lines changed

11 files changed

+1912
-492
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
2+
/usr/bin/chromium
3+
4+
# OpenAI API key for OpenAI model access
5+
OPENAI_API_KEY=your-api-key-here
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Python Package
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
tags:
7+
- 'v*'
8+
pull_request:
9+
branches: [ main ]
10+
11+
jobs:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version: ["3.10", "3.11", "3.12"]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
python -m pip install pytest pytest-asyncio pytest-cov
28+
pip install -e ".[dev]"
29+
- name: Test with pytest
30+
run: |
31+
pytest --cov=browser_use_mcp_server
32+
33+
build-and-publish:
34+
needs: test
35+
runs-on: ubuntu-latest
36+
if: startsWith(github.ref, 'refs/tags/v')
37+
38+
steps:
39+
- uses: actions/checkout@v4
40+
- name: Set up Python
41+
uses: actions/setup-python@v5
42+
with:
43+
python-version: "3.12"
44+
- name: Install dependencies
45+
run: |
46+
python -m pip install --upgrade pip
47+
python -m pip install build twine
48+
- name: Build package
49+
run: |
50+
python -m build
51+
- name: Publish to GitHub Packages
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
with:
54+
user: __token__
55+
password: ${{ secrets.GITHUB_TOKEN }}
56+
repository-url: https://pypi.pkg.github.com/${{ github.repository_owner }}

pyproject.toml

Lines changed: 61 additions & 2 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"
37
version = "0.1.2"
4-
description = "MCP browser-use server"
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,52 @@ 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+
]
31+
32+
[project.optional-dependencies]
33+
dev = [
34+
"pytest>=7.0.0",
35+
"pytest-asyncio>=0.21.0",
36+
"black>=23.0.0",
37+
"isort>=5.12.0",
38+
"mypy>=1.0.0",
39+
]
40+
test = [
41+
"pytest>=7.0.0",
42+
"pytest-asyncio>=0.21.0",
43+
"pytest-cov>=4.1.0",
1544
]
45+
46+
[project.urls]
47+
"Homepage" = "https://github.com/cobrowser/browser-use-mcp-server"
48+
"Bug Tracker" = "https://github.com/cobrowser/browser-use-mcp-server/issues"
49+
50+
[tool.pytest.ini_options]
51+
testpaths = ["tests"]
52+
python_files = "test_*.py"
53+
asyncio_mode = "auto"
54+
55+
[tool.black]
56+
line-length = 88
57+
target-version = ["py311"]
58+
59+
[tool.isort]
60+
profile = "black"
61+
line_length = 88
62+
63+
[tool.mypy]
64+
python_version = "3.11"
65+
warn_return_any = true
66+
warn_unused_configs = true
67+
disallow_untyped_defs = true
68+
disallow_incomplete_defs = true
69+
70+
[project.scripts]
71+
browser-use-mcp-server = "browser_use_mcp_server.cli:cli"
72+
73+
[tool.hatch.build]
74+
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)