Reading JSON-LD and __NEXT_DATA__ in 204 tokens instead of scraping the DOM (turbo-browser-mcp v0.7.6)
Most browser agents still scrape product pages and dashboards by dumping a 1,500-token ARIA tree and guessing CSS selectors. On Next.js, Nuxt, and schema.org pages, the structured JSON the page rendered from is already sitting in <script> tags.
In turbo-browser-mcp v0.7.6, I added two things I kept needing during overnight agent runs: format: "structured" on extract_clean_text, and an opt-in --trace JSONL flight recorder.
1. Extracting hydration data without CSS selectors
extract_clean_text now accepts format: "structured". In one call (no selectors required), it pulls:
-
application/ld+jsonblocks -
#__NEXT_DATA__(page,query, andprops.pageProps, strippingbuildIdnoise) -
#__NUXT_DATA__/window.__NUXT__ -
window.__INITIAL_STATE__andwindow.__APOLLO_STATE__ - canonical link plus OpenGraph and Twitter
<meta>tags
{ "name": "extract_clean_text", "arguments": { "format": "structured", "maxChars": 6000 } } It also works inside a batch_actions extract step, so an agent can navigate through several product URLs and pull structured JSON in one turn.
On a local Next.js product fixture (40 nav links, 30 promo cards, JSON-LD Product block, and __NEXT_DATA__ with inventory count and variants), measured with tiktoken (o200k_base) in headless Chromium:
| Representation | Chars | Tokens (o200k_base) | Notes |
|---|---|---|---|
| Raw HTML | 6,839 | 1,925 | Full document |
| Playwright ARIA snapshot | 5,387 | 1,539 | Missing hidden stockCount |
extract_clean_text(format: "structured") | 725 | 204 | 17 ms, includes SKU, stockCount, variants |
That is 89.4% fewer tokens than raw HTML and 86.7% fewer than the ARIA tree, and it picked up stockCount: 14 and variants directly from pageProps without touching a single class name.
Adding "structured" to the enum cost 3 tokens in the 11-tool compact schema (2,443 tokens total; --tools core stays at 1,714 tokens).
2. Opt-in JSONL flight recorder (--trace)
When an agent loops on a real site at 3 AM, you usually want to know which tool call burned 40 seconds or returned 12,000 chars. Passing --trace ./tmp/run.jsonl (or setting TURBO_BROWSER_TRACE_PATH) appends one JSON line per tool call:
{"ts":"2026-12-03T05:35:00.123Z","tool":"inspect_compact","ok":true,"durationMs":42,"responseChars":1120,"args":{"mode":"interactive","onlyChanged":true}} Because it is a CLI flag, it adds 0 tokens to the MCP tool schema. The writer confines paths to TURBO_BROWSER_SAVE_ROOT, logs arguments before $secret:NAME expansion, masks keys matching password/token/secret/api_key/cookie, and scrubs sensitive URL query parameters (access_token, code, api_key, etc.) before writing to disk.
Try it
npx -y turbo-browser-mcp --trace ./tmp/trace.jsonl Repo: https://github.com/Tthanh2k6/turbo-browser-mcp
If a site renders everything client-side via fetch with no JSON-LD or hydration script, format: "structured" returns a short no structured or hydration metadata found note and you fall back to markdown or table_json. I am still debating whether to add an opt-in XHR JSON ring buffer in page_diagnostics for pure-CSR SPAs next.