Skip to content

Commit ae2ea19

Browse files
authored
Merge pull request #64 from angiejones/feature/page-context-resources
feat: accessibility tree
2 parents 7c690d0 + c502f62 commit ae2ea19

File tree

11 files changed

+705
-341
lines changed

11 files changed

+705
-341
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ dist/
1010
downloads/
1111
eggs/
1212
.eggs/
13-
lib/
13+
/lib/
1414
lib64/
1515
parts/
1616
sdist/

AGENTS.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@ MCP server for Selenium WebDriver browser automation. JavaScript (ES Modules), N
55
## File Map
66

77
```text
8-
src/lib/server.js ← ALL server logic: tool definitions, state, helpers, cleanup
9-
src/index.js ← Thin CLI wrapper, spawns server.js as child process
10-
test/mcp-client.mjs ← Reusable MCP test client (JSON-RPC over stdio)
11-
test/*.test.mjs ← Tests grouped by feature
12-
test/fixtures/*.html ← HTML files loaded via file:// URLs in tests
8+
src/lib/server.js ← ALL server logic: tool definitions, state, helpers, cleanup
9+
src/lib/accessibility-snapshot.js ← Browser-side JS injected via executeScript to build accessibility tree
10+
bin/mcp-selenium.js ← CLI entry point, spawns server.js as child process
11+
test/mcp-client.mjs ← Reusable MCP test client (JSON-RPC over stdio)
12+
test/*.test.mjs ← Tests grouped by feature
13+
test/fixtures/*.html ← HTML files loaded via file:// URLs in tests
1314
```
1415

1516
## Architecture
1617

17-
**Single-file server** — everything is in `server.js`. 18 tools, 1 resource.
18+
Server logic lives in `server.js`, with browser-injected scripts in separate files. 18 tools, 2 resources.
1819

1920
State is a module-level object:
2021
```js
@@ -80,3 +81,4 @@ Tests talk to the real MCP server over stdio. No mocking. Each test file uses **
8081
| `tools.test.mjs` | get_element_attribute, execute_script, window, frame, alert |
8182
| `cookies.test.mjs` | add_cookie, get_cookies, delete_cookie |
8283
| `bidi.test.mjs` | diagnostics (console/errors/network), session isolation |
84+
| `resources.test.mjs` | accessibility-snapshot resource (tree structure, filtering, no-session error) |

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,29 @@ Gets browser diagnostics captured via WebDriver BiDi (auto-enabled when supporte
224224

225225
</details>
226226

227+
<details>
228+
<summary><strong>Resources</strong></summary>
229+
230+
MCP resources provide read-only data that clients can access without calling a tool.
231+
232+
### browser-status://current
233+
Returns the current browser session status (active session ID or "no active session").
234+
235+
| Property | Value |
236+
|----------|-------|
237+
| MIME type | `text/plain` |
238+
| Requires browser | No |
239+
240+
### accessibility://current
241+
Returns an accessibility tree snapshot of the current page — a compact, structured JSON representation of interactive elements and text content. Much smaller than full HTML. Useful for understanding page layout and finding elements to interact with.
242+
243+
| Property | Value |
244+
|----------|-------|
245+
| MIME type | `application/json` |
246+
| Requires browser | Yes |
247+
248+
</details>
249+
227250
---
228251

229252
<details>

0 commit comments

Comments
 (0)