feat: add CDP discovery endpoints (/json/version, /json/list)

Standard Chrome DevTools Protocol HTTP discovery endpoints that allow
tools like Playwright to connect using just the HTTP URL without needing
to call getCdpUrl() first.

- /json/version returns browser info and webSocketDebuggerUrl
- /json/list returns array of connected targets
- Supports GET/PUT methods and trailing slashes for compatibility
This commit is contained in:
Tommy D. Rossi
2026-01-12 17:08:35 +01:00
parent 9c323c5940
commit 481cb4ddc8
4 changed files with 239 additions and 0 deletions
+19
View File
@@ -90,6 +90,25 @@ await browser.close()
server.close()
```
### Standard CDP Connection
Start the relay server, then connect with just the HTTP URL:
```bash
npx -y playwriter serve --host 127.0.0.1
```
Or programmatically:
```typescript
import { startPlayWriterCDPRelayServer } from 'playwriter'
await startPlayWriterCDPRelayServer()
const browser = await chromium.connectOverCDP('http://127.0.0.1:19988')
```
This works with any CDP-compatible tool - no special configuration needed.
### Visual Aria Ref Labels
Playwriter includes Vimium-style visual labels that overlay interactive elements, making it easy for AI agents to identify and click elements from screenshots. The `screenshotWithAccessibilityLabels` function is available in the MCP context.