Skip to main content
Glama
Relax! MCP DOM Intelligence

Relax! MCP DOM Intelligence

by jgauffin

Relax! MCP DOM Intelligence

An MCP server that gives coding agents structured access to HTML and CSS files. Instead of reading raw source text, agents query parsed ASTs and get back only the specific information they need.

Why not just read the files?

When an agent reads an HTML or CSS file with a generic read_file tool, it dumps the entire file into context. This is wasteful and error-prone:

  • Token cost -- A 2000-line HTML file burns thousands of tokens even if the agent only needs to know what classes are on the nav bar.

  • Noise -- Raw markup buries the structural information agents actually need (element hierarchy, which selectors exist, what rules apply to an element) inside a wall of content, attributes, and boilerplate.

  • No cross-file reasoning -- Understanding which CSS rules apply to a given HTML element requires matching selectors across multiple files. A file-read tool can't do that; the agent has to load everything and figure it out manually, which is slow and unreliable.

  • Stale reads -- Files change during development. This server watches loaded files and re-parses automatically, so agents always work with current state.

This server solves these problems by parsing files once, caching the ASTs in memory, and exposing targeted query tools that return compact, structured results.

Related MCP server: webnav-mcp

Tools

Tool

What it does

load_files

Load HTML/CSS files into memory. Must be called first. Watches for changes.

html_outline

Compact tree showing tag names, ids, and classes -- like the DOM inspector sidebar.

html_query

Query elements by CSS selector. Returns structured info (tag, id, classes, attributes, text, children).

css_outline

List all selectors in a CSS file with line numbers and property counts.

css_for_selector

Find CSS rules matching a selector string (substring match).

used_classes

List all CSS classes used in an HTML file with frequency counts.

element_styles

Find all CSS rules that apply to a specific element -- inline styles, <style> blocks, and external CSS files. Like browser DevTools computed styles.

Installation

Prerequisites

  • Node.js 18+

Build

git clone <repo-url>
cd relax-dom-intelligence
npm install
npm run build

Add to Claude Code

For the current project (run from your project directory):

claude mcp add relax-dom -- node /absolute/path/to/relax-dom-intelligence/dist/index.js

For a specific directory (global use -- run multiple instances with distinct names):

claude mcp add relax-dom-mysite -s user -- node /absolute/path/to/relax-dom-intelligence/dist/index.js /path/to/mysite --name relax-dom-mysite

The -s user flag makes the server available across all your projects.

Add to Claude Desktop

Add an entry to your claude_desktop_config.json:

{
  "mcpServers": {
    "relax-dom": {
      "command": "node",
      "args": ["/absolute/path/to/relax-dom-intelligence/dist/index.js", "/path/to/project"]
    }
  }
}

CLI options

node dist/index.js [directory] [--name <name>] [--description <desc>]

Option

Default

Description

directory

Current working directory

Root directory for resolving relative file paths

--name, -n

relax-dom-<dirname>

Server name (use distinct names when running multiple instances)

--description, -d

Relax! MCP DOM Intelligence for <dirname> (<path>)

Server description shown to clients

Examples

Serve current directory (typical local project use):

node dist/index.js

Serve a specific project:

node dist/index.js /home/user/projects/my-website

Multiple instances for global access:

# In Claude Code config, register two servers:
claude mcp add relax-dom-docs -s user -- node /path/to/dist/index.js /sites/docs --name relax-dom-docs
claude mcp add relax-dom-blog -s user -- node /path/to/dist/index.js /sites/blog --name relax-dom-blog

Running and debugging

Run directly

npm start
# or with options:
node dist/index.js /path/to/project --name my-server

The server communicates over stdio (stdin/stdout). Diagnostic messages are written to stderr, so they won't interfere with the MCP protocol.

Watch mode (development)

Rebuild on source changes in one terminal:

npm run dev

Then run/restart the server in another.

Inspect with MCP Inspector

The MCP Inspector lets you interact with the server in a browser UI -- useful for testing tools without a full agent setup:

npx @modelcontextprotocol/inspector node dist/index.js /path/to/project

Debug logging

All log output goes to stderr. You'll see messages like:

[relax-dom-mysite] Server started on stdio (root: /sites/mysite)
[relax-dom-mysite] Re-parsed: /sites/mysite/index.html

To capture logs while running through an MCP client, redirect stderr to a file:

node dist/index.js /path/to/project 2>server.log

Tests

npm test

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      C
      maintenance
      Gives coding agents structured code understanding via tree-sitter with 23 tools and 10 languages, enabling precise queries instead of reading entire files.
      23
      32 PyPI
      30
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI agents to navigate JS/TS/HTML/CSS code through TypeScript, HTML, and CSS language servers, answering hover, definition, references, symbol search, outline, and diagnostics queries. Adds a cross-file index of CSS custom properties and #id/.class selectors that single-file language servers cannot provide.
      10
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to navigate JS/TS, HTML, and CSS code — symbol info, outlines, callers, implementations, definitions, references, hover, and diagnostics — through bundled Node language servers. It also builds a cross-file index answering where CSS custom properties and #id/.class selectors are defined and used across stylesheets, markup, and scripts.
      12
      33 npm
      MIT
    • A
      license
      Not graded
      quality
      B
      maintenance
      Enables coding agents to query a project's living frontend index — components, pages, data flow, global state, API calls, styles, health issues and history — through tools for search, component cards, impact analysis, page trees and incremental rescans.
      16 npm
      2
      Apache 2.0