Skip to content

Commit f19eb9c

Browse files
committed
docs: update CLAUDE.md and README with session recording and code export details
- Added documentation for session step recording, MCP resources, and generated WebdriverIO JS scripts. - Updated file structure and descriptions to include recording, code generation, and MCP resource components. - Highlighted session recording as a feature in the README.
1 parent f18a945 commit f19eb9c

2 files changed

Lines changed: 30 additions & 3 deletions

File tree

CLAUDE.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ npm start # Run built server from lib/server.js
1515

1616
```
1717
src/
18-
├── server.ts # MCP server entry, registers all tools
18+
├── server.ts # MCP server entry, registers all tools + MCP resources
1919
├── tools/
2020
│ ├── browser.tool.ts # Session state + start_browser + getBrowser()
2121
│ ├── app-session.tool.ts # start_app_session (iOS/Android via Appium)
2222
│ ├── navigate.tool.ts # URL navigation
2323
│ ├── get-visible-elements.tool.ts # Element detection (web + mobile)
24-
│ ├── click-element.tool.ts # Click/tap actions
24+
│ ├── click.tool.ts # Click/tap actions
2525
│ └── ... # Other tools follow same pattern
26+
├── recording/
27+
│ ├── step-recorder.ts # withRecording HOF, appendStep, session history access
28+
│ ├── code-generator.ts # SessionHistory → WebdriverIO JS code
29+
│ └── resources.ts # MCP resource builders (sessions index, step log)
2630
├── scripts/
2731
│ └── get-interactable-browser-elements.ts # Browser-context script
2832
├── locators/
@@ -32,7 +36,8 @@ src/
3236
├── config/
3337
│ └── appium.config.ts # iOS/Android capability builders
3438
└── types/
35-
└── tool.ts # ToolDefinition interface
39+
├── tool.ts # ToolDefinition interface
40+
└── recording.ts # RecordedStep, SessionHistory interfaces
3641
```
3742

3843
### Session State
@@ -80,6 +85,14 @@ export const myTool: ToolCallback = async ({ param }: { param: string }) => {
8085
server.tool(myToolDefinition.name, myToolDefinition.description, myToolDefinition.inputSchema, myTool);
8186
```
8287

88+
### Recording
89+
90+
All tools are wrapped with `withRecording()` in `server.ts`. Steps accumulate in `state.sessionHistory` (keyed by sessionId).
91+
MCP resources expose history without tool calls:
92+
- `wdio://sessions` — index of all sessions (fixed URI, discoverable via ListResources)
93+
- `wdio://session/current/steps` — current session step log + generated JS (fixed URI)
94+
- `wdio://session/{sessionId}/steps` — any session by ID (URI template, NOT listed by ListResources — see `docs/architecture/mcp-resources-notes.md`)
95+
8396
### Build
8497

8598
- **tsup** bundles `src/server.ts``lib/server.js` (ESM)
@@ -95,6 +108,9 @@ server.tool(myToolDefinition.name, myToolDefinition.description, myToolDefinitio
95108
| `src/tools/app-session.tool.ts` | Appium session creation |
96109
| `src/scripts/get-interactable-browser-elements.ts` | Browser-context element detection |
97110
| `src/locators/` | Mobile element detection + locator generation |
111+
| `src/recording/step-recorder.ts` | `withRecording(toolName, cb)` HOF — wraps every tool for step logging |
112+
| `src/recording/code-generator.ts` | Generates runnable WebdriverIO JS from `SessionHistory` |
113+
| `src/recording/resources.ts` | Builds text for `wdio://sessions` and `wdio://session/*/steps` resources |
98114
| `tsup.config.ts` | Build configuration |
99115

100116
## Gotchas

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ appium
8585
- **Scrolling**: Smooth scrolling with configurable distances
8686
- **Attach to running Chrome**: Connect to an existing Chrome window via `--remote-debugging-port` — ideal for testing authenticated or pre-configured sessions
8787
- **Device emulation**: Apply mobile/tablet presets (iPhone 15, Pixel 7, etc.) to simulate responsive layouts without a physical device
88+
- **Session Recording**: All tool calls are automatically recorded and exportable as runnable WebdriverIO JS
8889

8990
### Mobile App Automation (iOS/Android)
9091

@@ -458,6 +459,16 @@ This eliminates the need to manually handle permission popups during automated t
458459
- **Data Format:** TOON (Token-Oriented Object Notation) for efficient LLM communication
459460
- **Element Detection:** XML-based page source parsing with intelligent filtering and multi-strategy locator generation
460461

462+
### Session Recording & Code Export
463+
464+
Every tool call is automatically recorded to a session history. You can inspect sessions and export runnable code via MCP resources — no extra tool calls needed:
465+
466+
- `wdio://sessions` — lists all recorded sessions with type, timestamps, and step count
467+
- `wdio://session/current/steps` — step log for the active session, plus a generated WebdriverIO JS script ready to run with `webdriverio`
468+
- `wdio://session/{sessionId}/steps` — same for any past session by ID
469+
470+
The generated script reconstructs the full session — including capabilities, navigation, clicks, and inputs — as a standalone `import { remote } from 'webdriverio'` file.
471+
461472
## Troubleshooting
462473

463474
**Browser automation not working?**

0 commit comments

Comments
 (0)