@bsbofmusic/agent-browser-mcp-opencode 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +184 -129
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,28 +1,27 @@
1
1
  # @bsbofmusic/agent-browser-mcp-opencode
2
2
 
3
- MCP server for Vercel agent-browser - browser automation CLI for AI agents.
3
+ MCP Server for Vercel agent-browser - browser automation CLI for AI agents.
4
4
 
5
- ## 什么是 MCP Server
5
+ ---
6
6
 
7
- MCP (Model Context Protocol) Server 是一个中间层,允许 AI 助手(如 OpenCode、Claude Code 等)通过标准化接口调用外部工具。
7
+ ## What is This?
8
8
 
9
- ## 这是什么
9
+ This is an MCP (Model Context Protocol) wrapper for [agent-browser](https://github.com/vercel-labs/agent-browser), providing browser automation capabilities for AI assistants like OpenCode, Claude Code, and others.
10
10
 
11
- 本项目是对 [vercel-labs/agent-browser](https://github.com/vercel-labs/agent-browser) 的 MCP 封装(Wrapper),通过 MCP 接口提供浏览器自动化能力。
11
+ ### Use Cases
12
12
 
13
- ## 功能特性
13
+ - **AI Testing**: Automate web testing workflows with AI agents
14
+ - **Web Scraping**: Extract data from dynamic web pages
15
+ - **Form Automation**: Fill forms, click buttons, navigate pages
16
+ - **Visual Testing**: Take screenshots, compare snapshots
14
17
 
15
- - **一键部署**: 启用 MCP 后自动安装 agent-browser 和 Chromium
16
- - **自检自愈**: 内置 `browser_ensure` 和 `browser_doctor` 工具,自动检测和修复问题
17
- - **自动更新**: 支持 `always-latest` 模式,每次调用前检查更新
18
- - **结构化工具**: 提供常用动作的封装(open、snapshot、click、fill 等)
19
- - **通用透传**: 通过 `browser_exec` 执行任意 agent-browser 命令
18
+ ---
20
19
 
21
- ## 一键启用
20
+ ## One-Click Enable
22
21
 
23
- ### OpenCode 配置
22
+ ### OpenCode Configuration
24
23
 
25
- `opencode.json` 中添加:
24
+ Add to your `opencode.json`:
26
25
 
27
26
  ```json
28
27
  {
@@ -36,50 +35,61 @@ MCP (Model Context Protocol) Server 是一个中间层,允许 AI 助手(如
36
35
  }
37
36
  ```
38
37
 
39
- ### 直接运行
38
+ ### Direct Run
40
39
 
41
40
  ```bash
42
41
  npx @bsbofmusic/agent-browser-mcp-opencode
43
42
  ```
44
43
 
45
- ### 全局安装
44
+ ### Docker
45
+
46
+ ```bash
47
+ docker run -it --rm bsbofmusic/agent-browser-mcp-opencode
48
+ ```
49
+
50
+ ### Global Install
46
51
 
47
52
  ```bash
48
53
  npm install -g @bsbofmusic/agent-browser-mcp-opencode
49
54
  agent-browser-mcp-opencode
50
55
  ```
51
56
 
52
- ## 工具列表
57
+ ---
53
58
 
54
- ### 核心工具
59
+ ## Tool List
55
60
 
56
- | 工具名 | 描述 |
57
- |--------|------|
58
- | `browser_ensure` | 手动触发全量自愈(安装/修复/升级) |
59
- | `browser_doctor` | 诊断环境问题并输出修复建议 |
60
- | `browser_help` | 列出所有可用命令 |
61
- | `browser_version` | 显示版本信息 |
62
- | `browser_exec` | 执行任意 agent-browser CLI 命令 |
61
+ ### Core Tools
63
62
 
64
- ### 结构化动作
63
+ | Tool | Description |
64
+ |------|-------------|
65
+ | `browser_ensure` | Manually trigger full repair (install/upgrade) |
66
+ | `browser_doctor` | Diagnose issues with actionable nextSteps |
67
+ | `browser_help` | List all available commands |
68
+ | `browser_version` | Show version info |
69
+ | `browser_exec` | Execute any agent-browser CLI command |
65
70
 
66
- | 工具名 | 描述 |
67
- |--------|------|
68
- | `browser_open` | 导航到 URL |
69
- | `browser_snapshot` | 获取页面可访问性树(带 refs) |
70
- | `browser_click` | 点击元素 |
71
- | `browser_fill` | 填写表单字段 |
72
- | `browser_screenshot` | 截图 |
73
- | `browser_close` | 关闭浏览器 |
74
- | `browser_get_text` | 获取元素文本 |
75
- | `browser_find` | 语义定位查找元素 |
76
- | `browser_wait` | 等待元素/文本/URL/时间 |
77
- | `browser_tab` | 管理浏览器标签页 |
71
+ ### Structured Actions
78
72
 
79
- ## 使用示例
73
+ | Tool | Description |
74
+ |------|-------------|
75
+ | `browser_open` | Navigate to URL |
76
+ | `browser_snapshot` | Get accessibility tree with refs |
77
+ | `browser_click` | Click element (@e1 or CSS selector) |
78
+ | `browser_fill` | Fill form field |
79
+ | `browser_screenshot` | Take screenshot |
80
+ | `browser_close` | Close browser |
81
+ | `browser_get_text` | Get element text |
82
+ | `browser_find` | Semantic locator (role/text/label) |
83
+ | `browser_wait` | Wait for element/text/URL/time |
84
+ | `browser_tab` | Manage tabs |
80
85
 
81
- ### 基本流程
86
+ ---
82
87
 
88
+ ## Schema Examples
89
+
90
+ ### browser_open
91
+
92
+ **Input:**
83
93
  ```json
84
94
  {
85
95
  "name": "browser_open",
@@ -87,65 +97,92 @@ agent-browser-mcp-opencode
87
97
  }
88
98
  ```
89
99
 
100
+ **Output:**
101
+ ```json
102
+ {
103
+ "ok": true,
104
+ "url": "https://example.com",
105
+ "duration": 2341
106
+ }
107
+ ```
108
+
109
+ ### browser_snapshot
110
+
111
+ **Input:**
90
112
  ```json
91
113
  {
92
114
  "name": "browser_snapshot",
93
- "arguments": {"interactive": true}
115
+ "arguments": {"interactive": true, "compact": true}
94
116
  }
95
117
  ```
96
118
 
119
+ **Output:**
97
120
  ```json
98
121
  {
99
- "name": "browser_click",
100
- "arguments": {"selector": "@e1"}
122
+ "ok": true,
123
+ "output": {
124
+ "success": true,
125
+ "data": {
126
+ "snapshot": "- heading \"Example\" [ref=e1]\n - button \"Submit\" [ref=e2]"
127
+ }
128
+ },
129
+ "duration": 1234
101
130
  }
102
131
  ```
103
132
 
104
- ### 使用透传
133
+ ### browser_exec
105
134
 
135
+ **Input:**
106
136
  ```json
107
137
  {
108
138
  "name": "browser_exec",
109
139
  "arguments": {
110
- "command": "open example.com && agent-browser find role button click --name Submit"
140
+ "command": "open example.com && snapshot -i",
141
+ "timeoutMs": 60000
111
142
  }
112
143
  }
113
144
  ```
114
145
 
115
- ## 自动更新策略
146
+ ---
147
+
148
+ ## Auto-Update Strategy
116
149
 
117
- ### 环境变量
150
+ ### Environment Variables
118
151
 
119
- | 变量 | 默认值 | 描述 |
120
- |------|--------|------|
121
- | `ALWAYS_LATEST` | `1` | 每次调用前检查更新 |
122
- | `UPDATE_STRATEGY` | `simple` | 更新策略: `atomic` `simple` |
123
- | `LOG_LEVEL` | `info` | 日志级别: `error`, `warn`, `info`, `debug` |
124
- | `CACHE_DIR` | 系统 temp | 缓存目录 |
125
- | `RUNTIME_DIR` | `~/.agent-browser` | 运行时目录 |
152
+ | Variable | Default | Description |
153
+ |----------|---------|-------------|
154
+ | `ALWAYS_LATEST` | `1` | Check for updates before each call |
155
+ | `UPDATE_STRATEGY` | `simple` | `atomic` or `simple` |
156
+ | `LOG_LEVEL` | `info` | `error`, `warn`, `info`, `debug` |
126
157
 
127
- ### Atomic 更新策略
158
+ ### Strategies
128
159
 
129
- 使用双目录(`runtime_active/` + `runtime_staging/`)实现原子更新:
130
- 1. staging 目录执行更新
131
- 2. 验证成功后切换到新版本
132
- 3. 失败则回滚到原版本
160
+ **Simple (default):**
161
+ - Direct overwrite installation
162
+ - No rollback capability
133
163
 
134
- ### Simple 更新策略
164
+ **Atomic:**
165
+ - Uses `runtime_active/` + `runtime_staging/` directories
166
+ - Validates before switching
167
+ - Rolls back on failure
135
168
 
136
- 直接覆盖安装,不支持回滚。
169
+ ---
137
170
 
138
- ## 运行目录
171
+ ## Runtime Directories
139
172
 
140
- - **配置目录**: `~/.agent-browser/`
141
- - **状态文件**: `~/.agent-browser/sessions/`
142
- - **加密密钥**: `~/.agent-browser/.encryption-key`
173
+ | Directory | Location | Purpose |
174
+ |-----------|----------|---------|
175
+ | Config | `~/.agent-browser/` | User configuration |
176
+ | Sessions | `~/.agent-browser/sessions/` | Saved auth states |
177
+ | Cache | System temp | Temporary files |
143
178
 
144
- 这些目录会在首次运行时自动创建。
179
+ These directories are auto-created on first run and are rebuildable.
145
180
 
146
- ## 常见错误与排障
181
+ ---
147
182
 
148
- ### 运行 `browser_doctor` 获取诊断信息
183
+ ## Troubleshooting
184
+
185
+ ### Run browser_doctor
149
186
 
150
187
  ```json
151
188
  {
@@ -153,94 +190,112 @@ agent-browser-mcp-opencode
153
190
  }
154
191
  ```
155
192
 
156
- 输出包含:
157
- - 问题分类(网络/权限/依赖/系统库/可执行文件/浏览器)
158
- - 严重程度(critical/high/medium
159
- - 修复建议(nextSteps
193
+ **Output includes:**
194
+ - Issue categories: network/permissions/dependencies/system_libraries/executable/browser/auth
195
+ - Severity: critical/high/medium
196
+ - nextSteps: actionable fix recommendations
197
+
198
+ ### Common Issues
160
199
 
161
- ### 常见问题
200
+ 1. **agent-browser not installed**
201
+ - Run: `browser_ensure`
202
+ - Or: `npx agent-browser install`
162
203
 
163
- 1. **agent-browser 未安装**
164
- - 运行: `browser_ensure`
165
- - 或: `npx agent-browser install`
204
+ 2. **Chromium not installed**
205
+ - Run: `npx agent-browser install`
166
206
 
167
- 2. **Chromium 未安装**
168
- - 运行: `npx agent-browser install`
207
+ 3. **Permission errors**
208
+ - Check npm global directory permissions
209
+ - Consider using npx instead
169
210
 
170
- 3. **权限错误**
171
- - 检查 npm 全局目录权限
172
- - 考虑使用 npx 而非全局安装
211
+ 4. **Network issues**
212
+ - Set npm mirror: `npm config set registry https://registry.npmmirror.com`
213
+ - Check proxy: `npm config get proxy`
173
214
 
174
- 4. **网络问题**
175
- - 配置 npm 镜像: `npm config set registry https://registry.npmmirror.com`
176
- - 检查代理设置: `npm config get proxy`
215
+ ---
177
216
 
178
- ## 验证计划
217
+ ## Verification Plan
218
+
219
+ ### 6.1 One-Click Deployment
179
220
 
180
- ### 6.1 一键部署
181
221
  ```bash
182
222
  npx @bsbofmusic/agent-browser-mcp-opencode
183
223
  ```
184
- 预期: 自动完成依赖安装,无需手动操作
185
224
 
186
- ### 6.2 完美复刻
187
- 使用 5+ 核心命令验证:
188
- - `browser_open` - 导航
189
- - `browser_snapshot` - 获取树
190
- - `browser_click` - 点击
191
- - `browser_fill` - 填写
192
- - `browser_screenshot` - 截图
193
- - `browser_exec` - 透传
225
+ **Expected:** Auto-installs dependencies without manual steps.
194
226
 
195
- ### 6.3 稳定健全
196
- - `browser_doctor` 输出 7 类问题分类
197
- - `browser_ensure` 幂等可重复执行
198
- - 失败时返回结构化错误+nextSteps
227
+ ### 6.2 Capability Coverage
199
228
 
200
- ### 6.4 自动更新
201
- - `browser_version` 显示版本信息
202
- - `ALWAYS_LATEST=1` 时每次调用前检查更新
229
+ Test with 5+ core commands:
230
+ - `browser_open` → navigates to URL
231
+ - `browser_snapshot` → returns accessibility tree with refs
232
+ - `browser_click @e1` → clicks element
233
+ - `browser_fill @e2 "test"` → fills form
234
+ - `browser_screenshot` → captures image
235
+ - `browser_exec` → passes through all CLI commands
203
236
 
204
- ### 6.5 部署即用
205
- - MCP 启动后无需额外配置
206
- - 重启后自动恢复可用状态
237
+ ### 6.3 Stability
207
238
 
208
- ### 6.6 失败场景
209
- - 断网: 返回网络错误+nextSteps
210
- - 无权限: 返回权限错误+nextSteps
211
- - 缺依赖: 返回依赖错误+nextSteps
239
+ - `browser_doctor` outputs 7 issue categories
240
+ - `browser_ensure` is idempotent
241
+ - Errors include logs + nextSteps
212
242
 
213
- ## 合规与封装声明
243
+ ### 6.4 Auto-Update
214
244
 
215
- ### 封装声明 / Wrapper Notice
245
+ - `browser_version` shows current/latest
246
+ - `ALWAYS_LATEST=1` checks on each call
216
247
 
217
- 本项目是对上游项目 **agent-browser** MCP 封装(wrapper),用于通过 MCP 接口调用其功能。
248
+ ### 6.5 Deployment Ready
218
249
 
219
- - 上游项目地址: https://github.com/vercel-labs/agent-browser
220
- - 本项目不是上游项目的官方发布
221
- - 上游项目的名称、商标与版权归其各自权利人所有
222
- - 上游项目按其许可证条款授权使用;本项目已在 THIRD_PARTY_NOTICES.md 中包含上游许可证与必要声明
250
+ - No manual config after first enable
251
+ - Survives MCP/Agent restart
223
252
 
224
- ### 上游许可证
253
+ ### 6.6 Failure Scenarios
225
254
 
226
- agent-browser 使用 **Apache-2.0** 许可证。
255
+ | Scenario | Expected Output |
256
+ |----------|-----------------|
257
+ | No network | Network error + nextSteps |
258
+ | No permission | Permission error + nextSteps |
259
+ | Missing deps | Dep error + nextSteps |
227
260
 
228
- 详见 [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md)
261
+ ---
229
262
 
230
- ## 版本历史
263
+ ## Wrapper Declaration
231
264
 
232
- 详见 [CHANGELOG.md](./CHANGELOG.md)
265
+ This project is a wrapper for **agent-browser** by Vercel Labs.
233
266
 
234
- ## 许可证
267
+ - **Upstream**: https://github.com/vercel-labs/agent-browser
268
+ - **License**: Apache-2.0
269
+ - This is NOT an official upstream release
270
+ - Upstream trademarks/copyrights belong to respective owners
235
271
 
236
- Apache-2.0 License
272
+ See [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md) for license details.
237
273
 
238
- Copyright (c) 2024-2025 bsbofmusic
274
+ ---
275
+
276
+ ## Upstream License
277
+
278
+ agent-browser is licensed under **Apache-2.0**.
279
+
280
+ This project includes upstream code per Apache-2.0 requirements.
281
+
282
+ ---
283
+
284
+ ## Version History
239
285
 
240
- This project includes code from the upstream project agent-browser which is licensed under Apache-2.0.
286
+ See [CHANGELOG.md](./CHANGELOG.md)
241
287
 
242
- ## 支持
288
+ ---
243
289
 
244
- 如有问题,请提交 Issue:
245
- - MCP 问题: https://github.com/issues
246
- - agent-browser 问题: https://github.com/vercel-labs/agent-browser/issues
290
+ ## Support
291
+
292
+ - MCP issues: https://github.com/issues
293
+ - agent-browser upstream: https://github.com/vercel-labs/agent-browser/issues
294
+
295
+ ---
296
+
297
+ ## License
298
+
299
+ Apache-2.0 License
300
+
301
+ Copyright (c) 2024-2025 bsbofmusic
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsbofmusic/agent-browser-mcp-opencode",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MCP server for Vercel agent-browser - browser automation CLI for AI agents",
5
5
  "main": "index.js",
6
6
  "type": "module",