@mcp-b/smart-dom-reader extracts DOM structure optimized for AI/LLM consumption. It provides stable CSS selectors, interactive element maps, and semantic page structure while minimizing token usage. Zero runtime dependencies.
Installation
Minimal example
Two extraction approaches
Full extraction (SmartDOMReader)
Single-pass extraction of all elements. Use when you need everything upfront.
Progressive extraction (ProgressiveExtractor)
Step-by-step extraction for token-sensitive AI workflows.
extractStructure accepts a Document or an Element to scope the extraction.
Extraction modes
Options
Output structure
SmartDOMResult
ExtractedElement
true, saving tokens.
Selector ranking
Selectors are ranked by stability (higher score = more reliable):Exported modules
Bundle string export
A self-contained IIFE bundle is available for injection into pages (e.g. viachrome.userScripts.execute):
MCP server
An optional MCP server returns XML-wrapped Markdown. Output format:
Golden path sequence:
dom_extract_structureto get the page outlinedom_extract_regionto get selectors for a target area- Write a script using those selectors
- Optionally
dom_extract_contentfor readable text
Related
- @mcp-b/extension-tools (uses
smart-dom-readerfor DOM extraction tools) - Chrome DevTools MCP (upstream DevTools-based browser automation)
