关于 Browser Use MCP
Browser Use MCP 是面向 AI Agent 的浏览器自动化服务端与客户端,旨在通过 Ollama 使用本地模型。它结合 Playwright 浏览器控制与页面检查、数据提取和截图工具。
主要功能
- 01使用 Playwright 自动化控制 Chrome、Firefox 和 Safari
- 02通过 Ollama 用自然语言控制浏览器
- 03检查页面文本和 DOM 结构
- 04提取结构化数据并截取屏幕
- 05管理多个浏览器会话
适用场景
- 01搜索网页并总结结果
- 02比较多个页面中的商品信息
- 03跨多个来源研究主题
- 04执行文件中描述的浏览任务
MCP 相关
MCP 服务提供 10 种浏览器自动化工具,包括导航、点击、滚动、页面检查、数据提取、截图和关闭会话。它通过 stdio 与客户端通信。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
暂未收录安装方式
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
使用 Ollama 进行 MCP 浏览器自动化
强大的浏览器自动化系统,让 AI Agent 能够通过模型上下文协议(MCP)控制 Web 浏览器。本实现专为 Ollama 本地模型打造,可通过本地托管的 AI 模型安全、高效地自动执行浏览器交互。
功能特性
- MCP 集成:全面支持模型上下文协议,实现结构化的 AI 与浏览器通信
- Ollama 模型支持:针对通过 Ollama 运行的本地 AI 模型进行了优化
- 浏览器控制:使用 Playwright 实现完整的浏览器自动化(Chrome、Firefox、Safari)
- AI 驱动的自动化:通过本地大模型使用自然语言控制浏览器
- 截图功能:支持视觉反馈和调试
- 会话管理:支持多个浏览器会话,并自动清理
- 交互模式:实现 AI 与浏览器状态之间的持续反馈循环
- 优化显示:浏览器以最大化窗口(1920x1080)启动,尽量减少滚动
快速开始
前提条件
安装
# Clone the repository
git clone https://github.com/Cam10001110101/mcp-server-browser-use-ollama
cd mcp-server-browser-use-ollama
# Install with uv (recommended)
uv pip install -e .
playwright install
# Start Ollama and pull a model
ollama serve # In one terminal
ollama pull qwen3 # In another terminal
用法
系统支持两种使用模式:
选项 1:直接集成 MCP(搭配 Claude Desktop)
在 claude_desktop_config.json 中配置:
{
"mcpServers": {
"browser-use-ollama": {
"command": "/path/to/.venv/bin/python",
"args": ["/path/to/src/server.py"]
}
}
}
选项 2:由 Ollama 驱动的自动化
# Interactive automation with conversation history
python src/client.py src/server.py
# Custom task via command line
python src/client.py src/server.py "Navigate to Google and search for 'Ollama models'"
# Complex task from file
python src/client.py src/server.py task_description.txt --file
# With custom model
python src/client.py src/server.py "Your task" --model llama3.2:latest
可用工具
MCP 服务提供 10 个浏览器自动化工具:
launch_browser(url)- 启动浏览器并导航至 URLclick_element(session_id, x, y)- 点击指定坐标click_selector(session_id, selector)- 根据 CSS 选择器点击元素type_text(session_id, text)- 在当前位置输入文本scroll_page(session_id, direction)- 向上或向下滚动页面get_page_content(session_id)- 提取页面文本内容get_dom_structure(session_id, max_depth)- 获取 DOM 树extract_data(session_id, pattern)- 提取结构化数据take_screenshot(session_id)- 截取屏幕截图close_browser(session_id)- 关闭浏览器会话
示例
基本网页搜索
python src/client.py src/server.py "Search for 'Ollama models' on Google and summarize the top 3 results"
电商分析
python src/client.py src/server.py "Compare wireless headphones on Amazon - create a table with prices, ratings, and features"
研究工作流
python src/client.py src/server.py "Research transformer architecture improvements in 2024, visit 5 sources, and compile a summary"
基于文件的复杂任务
# Create a task file
echo "Navigate to GitHub, search for MCP repositories, and analyze the top 5 results" > my_task.txt
# Run the task
python src/client.py src/server.py my_task.txt --file
环境变量
OLLAMA_MODEL:指定 Ollama 模型(默认值:qwen3)OLLAMA_HOST:Ollama API 端点(默认值:http://localhost:11434)
测试
# Run pure MCP tests (recommended)
pytest tests/test_server_mcp.py -v
# Run all tests
pytest
# Run specific test categories
pytest tests/test_server_mcp.py # Pure MCP implementation tests
pytest tests/test_integration.py # Integration tests
项目结构
mcp-server-browser-use-ollama/
├── src/ # Core source code
│ ├── server.py # MCP server implementation
│ └── client.py # Interactive client with full automation capabilities
├── tests/ # Test suite
├── docs/ # Additional documentation
├── pyproject.toml # Project configuration
└── README.md # This file
架构
系统采用基于 MCP 协议的客户端-服务端架构:
User → Client → MCP Protocol → Server → Playwright Browser
- 服务端:纯 MCP SDK 服务,提供浏览器自动化工具
- 客户端:用于自然语言处理的 Langchain-Ollama 集成
- 传输方式:基于 stdio 的 MCP 通信
- 浏览器:使用 Playwright 自动化,支持跨浏览器操作
主要功能
交互式反馈循环
客户端与 Ollama 保持持续对话,实现动态自动化:
- 每次操作后,Ollama 都会收到结果
- 可根据浏览器状态调整策略
- 保留完整对话历史作为上下文
- 支持通过命令行或文件输入任务
高级功能
- 对话历史:32k token 上下文窗口,支持复杂的多步骤任务
- 操作解析:对大模型响应进行 JSON 和启发式解析
- 文件输入:支持从文件读取复杂任务描述
- 模型选择:可轻松切换 Ollama 模型
- 调试模式:提供全面的日志记录,便于排查问题
灵活的模型支持
- 适用于任何兼容 Ollama 的模型
- 针对编码模型(qwen3、qwen2.5-coder:7b)进行了优化
- 可配置上下文窗口和参数
- Temperature=0,确保输出具有确定性
稳健的错误处理
- 自动清理浏览器会话
- 从解析错误中平稳恢复
- 提供全面的日志记录,便于调试
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。