浏览器使用 mcp 服务器
一个 MCP 服务器,使 AI 代理能够使用
**🔗 管理多个 MCP 服务器?**使用agent-browser简化您的开发工作流程
先决条件
uv——快速 Python 包管理器
Playwright - 浏览器自动化
mcp-proxy - stdio 模式所需
# Install prerequisites
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install mcp-proxy
uv tool update-shellRelated MCP server: browser-mcp
环境
创建.env文件:
OPENAI_API_KEY=your-api-key
CHROME_PATH=optional/path/to/chrome
PATIENT=false # Set to true if API calls should wait for task completion安装
# Install dependencies
uv sync
uv pip install playwright
uv run playwright install --with-deps --no-shell chromium用法
SSE模式
# Run directly from source
uv run server --port 8000stdio模式
# 1. Build and install globally
uv build
uv tool uninstall browser-use-mcp-server 2>/dev/null || true
uv tool install dist/browser_use_mcp_server-*.whl
# 2. Run with stdio transport
browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000客户端配置
SSE 模式客户端配置
{
"mcpServers": {
"browser-use-mcp-server": {
"url": "http://localhost:8000/sse"
}
}
}stdio 模式客户端配置
{
"mcpServers": {
"browser-server": {
"command": "browser-use-mcp-server",
"args": [
"run",
"server",
"--port",
"8000",
"--stdio",
"--proxy-port",
"9000"
],
"env": {
"OPENAI_API_KEY": "your-api-key"
}
}
}
}配置位置
客户 | 配置路径 |
光标 |
|
风帆冲浪 |
|
克劳德(麦克) |
|
克劳德(Windows) |
|
特征
[x]浏览器自动化:通过 AI 代理控制浏览器
[x]双传输:支持 SSE 和 stdio 协议
[x] VNC Streaming :实时观看浏览器自动化
[x]异步任务:异步执行浏览器操作
本地开发
要在本地开发和测试包:
构建可分发的轮子:
# From the project root directory uv build将其安装为全局工具:
uv tool uninstall browser-use-mcp-server 2>/dev/null || true uv tool install dist/browser_use_mcp_server-*.whl从任意目录运行:
# Set your OpenAI API key for the current session export OPENAI_API_KEY=your-api-key-here # Or provide it inline for a one-time run OPENAI_API_KEY=your-api-key-here browser-use-mcp-server run server --port 8000 --stdio --proxy-port 9000进行更改后,重建并重新安装:
uv build uv tool uninstall browser-use-mcp-server uv tool install dist/browser_use_mcp_server-*.whl
Docker
使用 Docker 为运行服务器提供了一致且隔离的环境。
# Build the Docker image
docker build -t browser-use-mcp-server .
# Run the container with the default VNC password ("browser-use")
# --rm ensures the container is automatically removed when it stops
# -p 8000:8000 maps the server port
# -p 5900:5900 maps the VNC port
docker run --rm -p8000:8000 -p5900:5900 browser-use-mcp-server
# Run with a custom VNC password read from a file
# Create a file (e.g., vnc_password.txt) containing only your desired password
echo "your-secure-password" > vnc_password.txt
# Mount the password file as a secret inside the container
docker run --rm -p8000:8000 -p5900:5900 \
-v $(pwd)/vnc_password.txt:/run/secrets/vnc_password:ro \
browser-use-mcp-server注意:卷挂载(
VNC 查看器
# Browser-based viewer
git clone https://github.com/novnc/noVNC
cd noVNC
./utils/novnc_proxy --vnc localhost:5900默认密码: browser-use (除非使用自定义密码方法覆盖)
例子
尝试询问你的人工智能:
open https://news.ycombinator.com and return the top ranked article支持
如有疑问或咨询,请访问: cobrowser.xyz