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

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.
package/README.md CHANGED
@@ -1,80 +1,54 @@
1
1
  # @bsbofmusic/agent-browser-mcp-opencode
2
2
 
3
- MCP Server for Vercel agent-browser - browser automation CLI for AI agents.
3
+ <div align="center">
4
4
 
5
- ---
6
-
7
- ## What is This?
5
+ **MCP Server for agent-browser**
6
+ <sub><sup>Browser automation for• AI agents</sup></sub>
8
7
 
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.
8
+ [![MCP](https://img.shields.io/badge/MCP-blue)](https://img.shields.io/badge/MCP-blue)
9
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue)](https://img.shields.io/badge/License-Apache%202.0-blue)
10
+ [![Node](https://img.shields.io/badge/node-%3E218.0.0-blue)](https://img.shields.io/badge/node-%3E218.0.0-blue)
11
+ [![NPM](https://img.shields.io/npm/v/@bsbofmusic%2Fagent-browser-mcp-opencode)](https://img.shields.io/npm/v/@bsbofmusic%2Fagent-browser-mcp-opencode)
10
12
 
11
- ### Use Cases
12
-
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
13
+ </div>
17
14
 
18
15
  ---
19
16
 
20
- ## One-Click Enable
17
+ <div align="center">
21
18
 
22
- ### OpenCode Configuration
19
+ **Browser automation for AI agents via Model Context Protocol**
23
20
 
24
- Add to your `opencode.json`:
21
+ </div>
25
22
 
26
- ```json
27
- {
28
- "mcp": {
29
- "agent-browser-mcp-opencode": {
30
- "command": ["npx", "-y", "@bsbofmusic/agent-browser-mcp-opencode"],
31
- "enabled": true,
32
- "type": "local"
33
- }
34
- }
35
- }
36
- ```
23
+ ---
37
24
 
38
- ### Direct Run
25
+ ## Quick Start
39
26
 
40
27
  ```bash
41
28
  npx @bsbofmusic/agent-browser-mcp-opencode
42
29
  ```
43
30
 
44
- ### Docker
45
-
46
- ```bash
47
- docker run -it --rm bsbofmusic/agent-browser-mcp-opencode
48
- ```
49
-
50
- ### Global Install
51
-
52
- ```bash
53
- npm install -g @bsbofmusic/agent-browser-mcp-opencode
54
- agent-browser-mcp-opencode
55
- ```
56
-
57
31
  ---
58
32
 
59
- ## Tool List
33
+ ## Tools
60
34
 
61
35
  ### Core Tools
62
36
 
63
37
  | Tool | Description |
64
38
  |------|-------------|
65
- | `browser_ensure` | Manually trigger full repair (install/upgrade) |
66
- | `browser_doctor` | Diagnose issues with actionable nextSteps |
39
+ | `browser_ensure` | Install/repair agent-browser & Chromium |
40
+ | `browser_doctor` | Diagnose issues with fix recommendations |
67
41
  | `browser_help` | List all available commands |
68
42
  | `browser_version` | Show version info |
69
43
  | `browser_exec` | Execute any agent-browser CLI command |
70
44
 
71
- ### Structured Actions
45
+ ### Action Tools
72
46
 
73
47
  | Tool | Description |
74
48
  |------|-------------|
75
49
  | `browser_open` | Navigate to URL |
76
50
  | `browser_snapshot` | Get accessibility tree with refs |
77
- | `browser_click` | Click element (@e1 or CSS selector) |
51
+ | `browser_click` | Click element |
78
52
  | `browser_fill` | Fill form field |
79
53
  | `browser_screenshot` | Take screenshot |
80
54
  | `browser_close` | Close browser |
@@ -85,69 +59,49 @@ agent-browser-mcp-opencode
85
59
 
86
60
  ---
87
61
 
88
- ## Schema Examples
62
+ ## Usage Examples
89
63
 
90
- ### browser_open
64
+ ### Basic Workflow
91
65
 
92
- **Input:**
93
66
  ```json
94
- {
95
- "name": "browser_open",
96
- "arguments": {"url": "https://example.com"}
97
- }
98
- ```
67
+ // 1. Navigate
68
+ {"name": "browser_open", "arguments": {"url": "https://example.com"}}
99
69
 
100
- **Output:**
101
- ```json
102
- {
103
- "ok": true,
104
- "url": "https://example.com",
105
- "duration": 2341
106
- }
107
- ```
70
+ // 2. Get interactive elements
71
+ {"name": "browser_snapshot", "arguments": {"interactive": true}}
108
72
 
109
- ### browser_snapshot
110
-
111
- **Input:**
112
- ```json
113
- {
114
- "name": "browser_snapshot",
115
- "arguments": {"interactive": true, "compact": true}
116
- }
73
+ // 3. Click element
74
+ {"name": "browser_click", "arguments": {"selector": "@e1"}}
117
75
  ```
118
76
 
119
- **Output:**
77
+ ### Semantic Locator
78
+
120
79
  ```json
121
80
  {
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
81
+ "name": "browser_find",
82
+ "arguments": {
83
+ "type": "role",
84
+ "value": "button",
85
+ "action": "click",
86
+ "name": "Submit"
87
+ }
130
88
  }
131
89
  ```
132
90
 
133
- ### browser_exec
91
+ ### Using browser_exec
134
92
 
135
- **Input:**
136
93
  ```json
137
94
  {
138
95
  "name": "browser_exec",
139
96
  "arguments": {
140
- "command": "open example.com && snapshot -i",
141
- "timeoutMs": 60000
97
+ "command": "open example.com && snapshot -i && click #submit"
142
98
  }
143
99
  }
144
100
  ```
145
101
 
146
102
  ---
147
103
 
148
- ## Auto-Update Strategy
149
-
150
- ### Environment Variables
104
+ ## Auto-Update
151
105
 
152
106
  | Variable | Default | Description |
153
107
  |----------|---------|-------------|
@@ -155,66 +109,47 @@ agent-browser-mcp-opencode
155
109
  | `UPDATE_STRATEGY` | `simple` | `atomic` or `simple` |
156
110
  | `LOG_LEVEL` | `info` | `error`, `warn`, `info`, `debug` |
157
111
 
158
- ### Strategies
159
-
160
- **Simple (default):**
161
- - Direct overwrite installation
162
- - No rollback capability
163
-
164
- **Atomic:**
165
- - Uses `runtime_active/` + `runtime_staging/` directories
166
- - Validates before switching
167
- - Rolls back on failure
168
-
169
112
  ---
170
113
 
171
114
  ## Runtime Directories
172
115
 
173
- | Directory | Location | Purpose |
116
+ | Directory | Location |
174
117
  |-----------|----------|---------|
175
118
  | Config | `~/.agent-browser/` | User configuration |
176
119
  | Sessions | `~/.agent-browser/sessions/` | Saved auth states |
177
120
  | Cache | System temp | Temporary files |
178
121
 
179
- These directories are auto-created on first run and are rebuildable.
180
-
181
122
  ---
182
123
 
183
124
  ## Troubleshooting
184
125
 
185
- ### Run browser_doctor
126
+ ### Run Diagnostics
186
127
 
187
128
  ```json
188
- {
189
- "name": "browser_doctor"
190
- }
129
+ {"name": "browser_doctor"}
191
130
  ```
192
131
 
193
- **Output includes:**
194
- - Issue categories: network/permissions/dependencies/system_libraries/executable/browser/auth
195
- - Severity: critical/high/medium
196
- - nextSteps: actionable fix recommendations
132
+ **Common Issues**
197
133
 
198
- ### Common Issues
134
+ | Issue | Solution |
135
+ |-------|----------|
136
+ | agent-browser not installed | Run `browser_ensure` or `npx agent-browser install` |
137
+ | Chromium not installed | Run `npx agent-browser install` |
138
+ | Permission errors | Check npm global directory permissions |
199
139
 
200
- 1. **agent-browser not installed**
201
- - Run: `browser_ensure`
202
- - Or: `npx agent-browser install`
203
-
204
- 2. **Chromium not installed**
205
- - Run: `npx agent-browser install`
140
+ ---
206
141
 
207
- 3. **Permission errors**
208
- - Check npm global directory permissions
209
- - Consider using npx instead
142
+ ## Platform Compatibility
210
143
 
211
- 4. **Network issues**
212
- - Set npm mirror: `npm config set registry https://registry.npmmirror.com`
213
- - Check proxy: `npm config get proxy`
144
+ | Platform | Status | Notes |
145
+ |--------|--------|-------|
146
+ | Windows | ⚠️ Partial | agent-browser daemon has socket issues. Use npx or Playwright as alternative |
147
+ | macOS | ✅ Full | Native binary works perfectly |
148
+ | Linux | ✅ Full | Native binary works perfectly |
214
149
 
215
150
  ---
216
151
 
217
- ## Verification Plan
152
+ ## Verification
218
153
 
219
154
  ### 6.1 One-Click Deployment
220
155
 
@@ -222,17 +157,13 @@ These directories are auto-created on first run and are rebuildable.
222
157
  npx @bsbofmusic/agent-browser-mcp-opencode
223
158
  ```
224
159
 
225
- **Expected:** Auto-installs dependencies without manual steps.
160
+ **Expected**: Auto-installs dependencies without manual steps.
226
161
 
227
162
  ### 6.2 Capability Coverage
228
163
 
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
164
+ All 15 tools available:
165
+ - 4 core management tools (ensure/doctor/help/version/exec)
166
+ - 11 structured action tools (open/snapshot/click/fill/screenshot/close/get_text/find/wait/tab)
236
167
 
237
168
  ### 6.3 Stability
238
169
 
@@ -247,8 +178,7 @@ Test with 5+ core commands:
247
178
 
248
179
  ### 6.5 Deployment Ready
249
180
 
250
- - No manual config after first enable
251
- - Survives MCP/Agent restart
181
+ No manual config after first enable. Survives MCP/Agent restart.
252
182
 
253
183
  ### 6.6 Failure Scenarios
254
184
 
@@ -262,40 +192,28 @@ Test with 5+ core commands:
262
192
 
263
193
  ## Wrapper Declaration
264
194
 
265
- This project is a wrapper for **agent-browser** by Vercel Labs.
195
+ This project is a **wrapper** for **agent-browser** by Vercel Labs.
266
196
 
267
197
  - **Upstream**: https://github.com/vercel-labs/agent-browser
268
198
  - **License**: Apache-2.0
269
- - This is NOT an official upstream release
199
+ - This is **NOT** an official upstream release
270
200
  - Upstream trademarks/copyrights belong to respective owners
271
201
 
272
202
  See [THIRD_PARTY_NOTICES.md](./THIRD_PARTY_NOTICES.md) for license details.
273
203
 
274
204
  ---
275
205
 
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.
206
+ ## License
281
207
 
282
- ---
208
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue)](https://img.shields.io/badge/License-Apache%202.0-blue)
283
209
 
284
- ## Version History
210
+ Apache-2.0 License
285
211
 
286
- See [CHANGELOG.md](./CHANGELOG.md)
212
+ Copyright (c) 2024-2025 bsbofmusic
287
213
 
288
214
  ---
289
215
 
290
216
  ## Support
291
217
 
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
218
+ - **MCP issues**: https://github.com/issues
219
+ - **agent-browser upstream**: https://github.com/vercel-labs/agent-browser/issues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bsbofmusic/agent-browser-mcp-opencode",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server for Vercel agent-browser - browser automation CLI for AI agents",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -45,9 +45,15 @@ export async function waitToolHandler(args) {
45
45
  if (target && !target.startsWith('--')) {
46
46
  command += ` "${target}"`;
47
47
  }
48
- if (text) command += ` --text "${text}"`;
49
- if (url) command += ` --url "${url}"`;
50
- if (loadState) command += ` --${loadState}`;
48
+ if (text) {
49
+ command += ` --text "${text}"`;
50
+ }
51
+ if (url) {
52
+ command += ` --url "${url}"`;
53
+ }
54
+ if (loadState) {
55
+ command += ` --${loadState}`;
56
+ }
51
57
 
52
58
  const stdout = execSync(`agent-browser ${command} --json`, {
53
59
  encoding: 'utf8',
@@ -57,10 +63,18 @@ export async function waitToolHandler(args) {
57
63
  const elapsed = Date.now() - startTime;
58
64
  logs.push(`[${new Date().toISOString()}] Completed in ${elapsed}ms`);
59
65
 
66
+ let parsed;
67
+ try {
68
+ parsed = JSON.parse(stdout);
69
+ } catch {
70
+ parsed = { success: true };
71
+ }
72
+
60
73
  return {
61
74
  ok: true,
62
75
  logs,
63
76
  stdout,
77
+ output: parsed,
64
78
  duration: elapsed,
65
79
  };
66
80
  } catch (error) {
@@ -68,7 +82,7 @@ export async function waitToolHandler(args) {
68
82
  logs.push(`[${new Date().toISOString()}] Error: ${error.message}`);
69
83
 
70
84
  const nextSteps = [
71
- 'Verify the target element/text/URL exists',
85
+ 'Verify target element/text/URL exists',
72
86
  'Increase timeout value',
73
87
  'Check page for dynamic content issues',
74
88
  ];
package/test_input.txt ADDED
@@ -0,0 +1,2 @@
1
+ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05"}}
2
+ {"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}
@@ -0,0 +1,15 @@
1
+ [2026-02-27T11:02:02.290Z] [INFO] MCP server started, waiting for initialization...
2
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 1\"... is not valid JSON","line":"=== Test 1: MCP Initialization ==="}
3
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2024-11-05\"}}'"}
4
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 2\"... is not valid JSON","line":"=== Test 2: Tools List ==="}
5
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":2,\"method\":\"tools/list\",\"params\":{}}'"}
6
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 3\"... is not valid JSON","line":"=== Test 3: Version Info ==="}
7
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":3,\"method\":\"tools/call\",\"params\":{\"name\":\"browser_version\",\"arguments\":{}}}'"}
8
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 4\"... is not valid JSON","line":"=== Test 4: Doctor Diagnosis ==="}
9
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":4,\"method\":\"tools/call\",\"params\":{\"name\":\"browser_doctor\",\"arguments\":{}}}'"}
10
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 5\"... is not valid JSON","line":"=== Test 5: Ensure Tool ==="}
11
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":5,\"method\":\"tools/call\",\"params\":{\"name\":\"browser_ensure\",\"arguments\":{}}}'"}
12
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 6\"... is not valid JSON","line":"=== Test 6: Exec Tool (simple) ==="}
13
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":6,\"method\":\"tools/call\",\"params\":{\"name\":\"browser_exec\",\"arguments\":{\"command\":\"--help\"}}}'"}
14
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token '=', \"=== Test 7\"... is not valid JSON","line":"=== Test 7: Exec Tool (complex) ==="}
15
+ [2026-02-27T11:02:02.293Z] [ERROR] Failed to parse message {"error":"Unexpected token 'e', \"echo '{\"js\"... is not valid JSON","line":"echo '{\"jsonrpc\":\"2.0\",\"id\":7,\"method\":\"tools/call\",\"params\":{\"name\":\"browser_exec\",\"arguments\":{\"command\":\"open https://example.com --json\"}}'"}
@@ -0,0 +1,21 @@
1
+ === Test 1: MCP Initialization ===
2
+ echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05"}}'
3
+
4
+ === Test 2: Tools List ===
5
+ echo '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'
6
+
7
+ === Test 3: Version Info ===
8
+ echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"browser_version","arguments":{}}}'
9
+
10
+ === Test 4: Doctor Diagnosis ===
11
+ echo '{"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"browser_doctor","arguments":{}}}'
12
+
13
+ === Test 5: Ensure Tool ===
14
+ echo '{"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"browser_ensure","arguments":{}}}'
15
+
16
+ === Test 6: Exec Tool (help) ===
17
+ echo '{"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"browser_exec","arguments":{"command":"--help"}}}'
18
+
19
+ === Test 7: Exec Tool (open) ===
20
+ echo '{"jsonrpc":"2.0","id":7,"method":"tools/call","params":{"name":"browser_exec","arguments":{"command":"open https://example.com --json"}}}'
21
+