使用说明
浏览器使用mcp服务器
一个MCP服务器,使AI代理能够使用 浏览器使用.
先决条件
# Install prerequisites
curl -LsSf https://astral.sh/uv/install.sh | sh
uv tool install mcp-proxy
uv tool update-shell
环境
创建一个 .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 8000
stdio模式
# 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"
}
}
}
}
配置位置
| 客户端 | 配置路径 |
|---|---|
| 光标 | ./.cursor/mcp.json |
| 风帆冲浪 | ~/.codeium/windsurf/mcp_config.json |
| 克劳德(Mac) | ~/Library/Application Support/Claude/claude_desktop_config.json |
| 克劳德(Windows) | %APPDATA%\Claude\claude_desktop_config.json |
特性
- [x] 浏览器自动化:通过AI代理控制浏览器
- [x] 双重运输:支持SSE和stdio协议
- [x] VNC流媒体:实时观察浏览器自动化
- [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
码头工人
# Run with default VNC password
docker build -t browser-use-mcp-server .
docker run --rm -p8000:8000 -p5900:5900 browser-use-mcp-server
# Use custom VNC password
echo "your-password" > vnc_password.txt
docker run --rm -p8000:8000 -p5900:5900 \
-v $(pwd)/vnc_password.txt:/run/secrets/vnc_password \
browser-use-mcp-server
客户端
# Browser-based viewer
git clone https://github.com/novnc/noVNC
cd noVNC
./utils/novnc_proxy --vnc localhost:5900
默认密码: browser-use
示例
试着问你的AI:
open https://news.ycombinator.com and return the top ranked article
支持
对于问题或询问: cobrowser.xyz