fetch-ui-dom
Connects to a live Chrome browser via the Chrome DevTools Protocol to capture and prune the active tab’s DOM, including shadow roots and iframes, and provides tools for finding elements with resilient selectors and diagnosing broken selectors.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
fetch-ui-dom: MCP Browser Bridge
fetch-ui-dom is a powerful bridge that connects LLMs (like Claude) to your live browser instance. It exposes your browser's DOM as a set of tools through the Model Context Protocol (MCP), allowing AI agents to "see" and "reason" about the UI you are currently developing or using.
🚀 Why use this?
Zero Copy-Paste: Stop manually inspecting and copying HTML into prompts.
Token Efficient: Uses DOM Tree Pruning Programming (DTPP) to reduce DOM size by 25x+ while keeping it fully interactive for the AI.
Resilient Selectors: Automatically identifies the best, most stable selectors (like
data-cyoraria-label) so the AI suggests reliable automation code.Self-Healing: If a selector breaks, the tool can diagnose the failure and suggest the most likely replacement.
Related MCP server: chrome-devtools-mcp
🛠 How it Works
CDP Connection: The tool connects to Chrome via the Chrome DevTools Protocol (CDP) on port
9222.DOM Capture: It identifies the active tab and captures the full DOM, including content inside Shadow Roots and iframes.
Pruning: It recursively traverses the DOM, stripping away non-essential tags (
<script>,<style>, etc.) and non-functional attributes to minimize token usage.MCP Interface: It runs as a local server that your AI client (Claude Desktop, etc.) can talk to.
📋 Prerequisites
Node.js: v20.x or higher.
Chrome: Must be launched with remote debugging enabled.
⚙️ Implementation & Setup
1. Enable Remote Debugging in Chrome (Reliable Method)
Chrome only allows the debugging port on the very first process started for a given profile. If "background apps" are running or a ghost process exists, the flag will be silently ignored.
1.1 The "Clean Start" Method (Command-line)
Close all Chrome windows.
Run this command in your terminal (Windows PowerShell):
# Kill ghost processes and start a fresh instance with a dedicated profile Get-Process chrome -ErrorAction SilentlyContinue | Stop-Process -Force; ` start chrome "--remote-debugging-port=9222 --user-data-dir=$env:TEMP\chrome-debug"
1.2 Create a Dedicated "Dev Shortcut"
Instead of using your main profile (which has all your extensions and history), create a shortcut specifically for debugging.
Right-click on your Desktop > New > Shortcut.
In the "location" box, paste this (adjusting the path if Chrome is installed elsewhere):
"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --user-data-dir="C:\chrome-dev-profile"Name it "Chrome Debug".
Using a dedicated
--user-data-dirensures this instance always starts fresh and never conflicts with your main browser window.
1.3 Create a "Reset" Script
If things still get stuck, keep this one-liner handy as a .ps1 (PowerShell) file on your desktop (or use the provided scripts/kill-chrome.ps1 in this repo):
# kill-chrome.ps1
Get-Process chrome -ErrorAction SilentlyContinue | Stop-Process -Force
Write-Host "All Chrome instances killed. You can now start with the debug flag." -ForegroundColor GreenSummary of the Process: The Remote Debugging Port is a security-sensitive feature. Chrome only allows it to be enabled on the very first process that starts for a given user-data-dir. By using a dedicated profile folder, you guarantee that your debugging instance is always the "first" process, making the connection 100% reliable.
Verification: Run this to ensure Chrome is actually listening on the port:
Get-NetTCPConnection -LocalPort 9222 -ErrorAction SilentlyContinueIf you see a row with state Listen, the connection is active.
2. Install the Bridge
Clone this repository and install the dependencies:
npm install
npm run build3. Connect to your AI Client (e.g., Claude Desktop)
Add the following to your claude_desktop_config.json. Note: Use the absolute path to the dist folder.
{
"mcpServers": {
"browser-bridge": {
"command": "node",
"args": ["C:/Users/91897/Desktop/AI/AI Projects/fetch-ui-dom/dist/server/index.js"],
"env": {
"CYPRESS_DEBUG_PORT": "9222"
}
}
}
}⚠️ Reliability & Troubleshooting
Why is my connection refused?
Chrome is a "single-instance" application. If any hidden background process (like an extension, updater, or "zombie" tab) is running, any new command with the --remote-debugging-port flag is ignored because the existing instance "hijacks" the request.
How to fix it permanently:
Disable Background Apps: Go to Chrome
Settings > Systemand turn OFF "Continue running background apps when Google Chrome is closed". This ensures that closing the window actually kills the process.Use Dedicated Profiles: Always use the
--user-data-dirflag when debugging to separate your "Dev" browser from your main browser profile. This avoids conflicts and makes the connection 100% reliable.
🧰 Tools Provided
Tool | Description |
| Captures the pruned, token-optimized DOM of the active tab. |
| Locates specific elements using the resilient selector hierarchy. |
| Analyzes a broken selector and suggests the correct one based on similarity. |
🧪 Testing with CLI
Before using it with an AI client, you can test the logic directly:
Fetch active DOM:
npx tsx src/cli/fetch-cli.tsPrune local file:
npx tsx src/cli/prune-cli.ts input.htmlAnalyze selector:
npx tsx src/cli/select-cli.ts input.html ".my-button"
📄 License
ISC
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Give AI agents a real cloud Chrome: open sessions, navigate, read pages, click, type and screenshot.
Control a real browser from AI agents: navigate, click, type, screenshot, read the page.
Cloud browser, web extraction, screenshots, and remote CDP tools for AI agents.
Let AI agents use your real, signed-in Chrome: tabs, clicks, forms, screenshots and video.
Related MCP Servers
- AlicenseCqualityBmaintenanceEnables AI agents to automate real Chrome via a structured Semantic Action Graph, without screenshots, CDP, or bot detection. It supports clicks, form filling, navigation, and state diffs on strict-CSP sites and modern SPAs.75MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI coding agents to control and inspect a live Chrome browser, providing reliable automation, in-depth debugging, and performance analysis through Chrome DevTools.2,158,323 npmApache 2.0
- AlicenseNot gradedqualityBmaintenanceEnables LLM agents to automate a live Chrome browser with compact DOM serialization, authenticated session continuity, and human-like input trajectories.MIT
- AlicenseBqualityBmaintenanceEnables AI agents and developers to automate real Chrome/Chromium browsers through the Chrome DevTools Protocol, with token-efficient snapshots, multi-action batching, shadow DOM traversal, system-page control, extension management, and network/WebSocket inspection.951MIT