| name | inspect |
| description | Connect to the md-diff browser view via playwright-cli for inspection and interaction. Requires md-diff to be running with --inspect flag. |
Connect to the md-diff Chrome instance via remote debugging and interact with the page.
Steps
-
ALWAYS use ./browse.sh to run playwright-cli commands. Never call playwright-cli directly or set PLAYWRIGHT_MCP_CDP_ENDPOINT manually. browse.sh handles CDP endpoint configuration automatically and attaches to the existing Chrome page.
./browse.sh snapshot
./browse.sh tab-list
./browse.sh click e5
./browse.sh hover e5
./browse.sh screenshot
./browse.sh screenshot e5
./browse.sh scroll-to e5
./browse.sh block-html e5
./browse.sh selection
./browse.sh pick
./browse.sh inspect-el
./browse.sh eval "document.title"
./browse.sh eval "el => el.className" e5
-
First run: If the daemon has stale state from a previous session, run playwright-cli close-all first, then ./browse.sh snapshot to get a fresh connection.
-
NEVER read the entire snapshot YAML file — it can be very large. Instead, use Grep to search for specific text content, element refs, or class names within the YAML file.
Debugging workflow
To inspect a specific diff block:
./browse.sh snapshot — get element refs
- Find the ref near the problem area (search the YAML for text content)
./browse.sh screenshot <ref> — zoomed-in screenshot of just that element
./browse.sh block-diff <ref> — structured diff parts (type, value, absorb, minor flags)
./browse.sh block-html <ref> — raw HTML with CSS classes (for CSS debugging)
Always prefer screenshot <ref> over screenshot — full-page screenshots are too small to read text. Element screenshots zoom into exactly the content you need. Use resize 1920 1080 first if you need a wider full-page view.
eval syntax
Two modes depending on whether a ref is passed:
Page-level (no ref) — single expression returning a value:
./browse.sh eval "document.title"
./browse.sh eval "document.querySelectorAll('.diff-part').length"
Element-level (with ref) — arrow function receiving the element:
./browse.sh eval "el => el.outerHTML" e5
./browse.sh eval "el => el.className" e5
./browse.sh eval "el => el.children.length" e5
Gotchas:
- Page-level: no arrow functions (
=>) anywhere in the expression — playwright interprets them as function definitions and breaks. Use function() for callbacks:
./browse.sh eval "Array.from(els).map(el => el.className)"
./browse.sh eval "JSON.stringify(Array.from(document.querySelectorAll('.x')).map(function(el){return el.className}))"
- No
var/let/const, no multi-statement blocks, no forEach
- Use
run-code for anything complex:
./browse.sh run-code "const els = await page.locator('.diff-block').all(); console.log(els.length)"
Notes
- The user must first launch md-diff with
--inspect to open Chrome with remote debugging.
- If connection fails or lands on
about:blank, run playwright-cli close-all and retry.
- The left header shows the project root path (
data-path attribute) for identification.